@mcp-use/inspector 20.3.14 → 20.3.15-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/inspector.css.gz +0 -0
- package/dist/app/inspector.js.gz +0 -0
- package/dist/cli.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/package.json +4 -4
|
Binary file
|
package/dist/app/inspector.js.gz
CHANGED
|
Binary file
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ ${n.join(`\r
|
|
|
5
5
|
\r
|
|
6
6
|
`)},Go=e=>{let t=e.socket.encrypted?"https":"http",r=new URL(e.url??"/",`${t}://${e.headers.host??"localhost"}`),n=new Headers;for(let o in e.headers){let s=e.headers[o];s&&n.append(o,Array.isArray(s)?s[0]:s)}return new Request(r,{headers:n})},Yo=e=>{let{server:t,fetchCallback:r,wss:n}=e,o=new Map;n.on("connection",(a,c)=>{let l=o.get(c);l&&(l.resolve(a),o.delete(c))});let s=a=>{let c=o.get(a);c&&(o.delete(a),c.reject(new Error("WebSocket handshake aborted")))},i=(a,c)=>new Promise((l,u)=>{o.set(a,{resolve:l,reject:u,connectionSymbol:c})});t.on("upgrade",async(a,c,l)=>{if(a.headers.upgrade?.toLowerCase()!=="websocket")return;let u={incoming:a,outgoing:void 0,wss:n,[yr]:i},d=400,f;try{let b=await r(Go(a),u);b instanceof Response&&(d=b.status,f=b.headers)}catch{t.listenerCount("upgrade")===1&&or(c,500);return}let h=o.get(a);if(!h||h.connectionSymbol!==u[gr]){s(a),t.listenerCount("upgrade")===1&&or(c,d,f);return}let y=b=>{wr(b,f)},m=()=>s(a);c.once("close",m),n.on("headers",y);try{n.handleUpgrade(a,c,l,b=>{c.off("close",m),n.emit("connection",b,a)})}finally{n.off("headers",y)}}),t.on("close",()=>{n.close()})},Vi=Xt(async(e,t,r)=>{if(e.req.header("upgrade")?.toLowerCase()!=="websocket")return;let n=e.env,o=n[yr];if(!o||!n.incoming)return new Response(null,{status:500});let s=Ko();return n[gr]=s,(async()=>{let i;try{i=await o(n.incoming,s)}catch{return}let a=[],c=(d,f)=>{a.push([d,f])};i.on("message",c);let l={binaryType:"arraybuffer",close(d,f){i.close(d,f)},protocol:i.protocol,raw:i,get readyState(){return i.readyState},send(d,f){i.send(d,{compress:f?.compress})},url:new URL(e.req.url)};try{t?.onOpen?.(new Event("open"),l)}catch(d){(r?.onError??console.error)(d)}let u=(d,f)=>{let h=Array.isArray(d)?d:[d];for(let y of h)try{t?.onMessage?.(new MessageEvent("message",{data:f?y instanceof ArrayBuffer?y:y.buffer.slice(y.byteOffset,y.byteOffset+y.byteLength):typeof y=="string"?y:Buffer.from(y).toString("utf-8")}),l)}catch(m){(r?.onError??console.error)(m)}};i.off("message",c);for(let d of a)u(...d);i.on("message",(d,f)=>{u(d,f)}),i.on("close",(d,f)=>{try{t?.onClose?.(new zo("close",{code:d,reason:f.toString()}),l)}catch(h){(r?.onError??console.error)(h)}}),i.on("error",d=>{try{t?.onError?.(new qo("error",{error:d}),l)}catch(f){(r?.onError??console.error)(f)}})})(),new Response}),Xo=e=>{let t=e.fetch,r=Wo(t,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming}),n=(e.createServer||fo)(e.serverOptions||{},r);if(e.websocket&&e.websocket.server){if(e.websocket.server.options.noServer!==!0)throw new Error("WebSocket server must be created with { noServer: true } option");Yo({server:n,fetchCallback:t,wss:e.websocket.server})}return n},br=(e,t)=>{let r=Xo(e);return r.listen(e?.port??3e3,e.hostname,()=>{let n=r.address();t&&t(n)}),r};var it=(e,t,r)=>(n,o)=>{let s=-1;return i(0);async function i(a){if(a<=s)throw new Error("next() called multiple times");s=a;let c,l=!1,u;if(e[a]?(u=e[a][0][0],n.req.routeIndex=a):u=a===e.length&&o||void 0,u)try{c=await u(n,()=>i(a+1))}catch(d){if(d instanceof Error&&t)n.error=d,c=await t(d,n),l=!0;else throw d}else n.finalized===!1&&r&&(c=await r(n));return c&&(n.finalized===!1||l)&&(n.res=c),n}};var vr=Symbol();var xr=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,n=>n.toLowerCase())}}).formData();var Er=32,Jo=1e4,Le=e=>"headers"in e,Pr=async(e,t=Object.create(null))=>{let{all:r=!1,dot:n=!1}=t,i=(Le(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return i==="multipart/form-data"||i==="application/x-www-form-urlencoded"?Qo(e,{all:r,dot:n}):{}};async function Qo(e,t){if(!Le(e)&&e.bodyCache.formData)return Sr(await e.bodyCache.formData,t);let r=Le(e)?e.headers:e.raw.headers,n=await e.arrayBuffer(),o=xr(n,r.get("Content-Type")||"");Le(e)||(e.bodyCache.formData=o);let s=await o;return s?Sr(s,t):{}}function Sr(e,t){let r=Object.create(null),n={count:0};return e.forEach((o,s)=>{t.all||s.endsWith("[]")?Zo(r,s,o):r[s]=o}),t.dot&&Object.entries(r).forEach(([o,s])=>{o.includes(".")&&(es(r,o,s,n),delete r[o])}),r}var Zo=(e,t,r)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r},es=(e,t,r,n)=>{if(/(?:^|\.)__proto__\./.test(t))return;let o=e,s=t.split(".",Er+2);s.length>Er+1&&Rr(),s.forEach((i,a)=>{a===s.length-1?o[i]=r:((!o[i]||typeof o[i]!="object"||Array.isArray(o[i])||o[i]instanceof File)&&(n.count++>=Jo&&Rr(),o[i]=Object.create(null)),o=o[i])})},Rr=()=>{throw new Error("Nesting limit exceeded")};var ct=e=>{let t=e.split("/");return t[0]===""&&t.shift(),t},Ar=e=>{let{groups:t,path:r}=ts(e),n=ct(r);return rs(n,t)},ts=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(r,n)=>{let o=`@${n}`;return t.push([o,r]),o}),{groups:t,path:e}},rs=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[n]=t[r];for(let o=e.length-1;o>=0;o--)if(e[o].includes(n)){e[o]=e[o].replace(n,t[r][1]);break}}return e},Ie={},Cr=(e,t)=>{if(e==="*")return"*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${e}#${t}`;return Ie[n]||(r[2]?Ie[n]=t&&t[0]!==":"&&t[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],new RegExp(`^${r[2]}$`)]:Ie[n]=[e,r[1],!0]),Ie[n]}return null},_r=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return t(r)}catch{return r}})}},ns=e=>_r(e,decodeURI),lt=e=>{let t=e.url,r=t.indexOf("/",t.indexOf(":")+4),n=r;for(;n<t.length;n++){let o=t.charCodeAt(n);if(o===37){let s=t.indexOf("?",n),i=t.indexOf("#",n),a=s===-1?i===-1?void 0:i:i===-1?s:Math.min(s,i),c=t.slice(r,a);return ns(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(o===63||o===35)break}return t.slice(r,n)};var Tr=e=>{let t=lt(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},G=(e,t,...r)=>(r.length&&(t=G(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),Me=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;let t=e.split("/"),r=[],n="";return t.forEach(o=>{if(o!==""&&!/\:/.test(o))n+="/"+o;else if(/\:/.test(o))if(o.charCodeAt(o.length-1)===63){r.length===0&&n===""?r.push("/"):r.push(n);let s=o.slice(0,-1);n+="/"+s,r.push(n)}else n+="/"+o}),r.filter((o,s,i)=>i.indexOf(o)===s)},De=e=>e.indexOf("%")!==-1?_r(e,os):e,at=e=>(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),De(e)),Or=(e,t,r)=>{let n=e.indexOf("#",8);n!==-1&&(e=e.slice(0,n));let o;if(!r&&t&&t.indexOf("%")===-1&&t.indexOf("+")===-1){let a=e.indexOf("?",8);if(a===-1)return;for(e.startsWith(t,a+1)||(a=e.indexOf(`&${t}`,a+1));a!==-1;){let c=e.charCodeAt(a+t.length+1);if(c===61){let l=a+t.length+2,u=e.indexOf("&",l);return at(e.slice(l,u===-1?void 0:u))}else if(c==38||isNaN(c))return"";a=e.indexOf(`&${t}`,a+1)}if(o=/[%+]/.test(e),!o)return}let s=Object.create(null);o??=/[%+]/.test(e);let i=e.indexOf("?",8);for(;i!==-1;){let a=e.indexOf("&",i+1),c=e.indexOf("=",i);c>a&&a!==-1&&(c=-1);let l=e.slice(i+1,c===-1?a===-1?void 0:a:c);if(o&&(l=at(l)),i=a,l==="")continue;let u;c===-1?u="":(u=e.slice(c+1,a===-1?void 0:a),o&&(u=at(u))),r?(s[l]&&Array.isArray(s[l])||(s[l]=[]),s[l].push(u)):s[l]??=u}return t?s[t]:s},Lr=Or,Ir=(e,t)=>Or(e,t,!0),os=decodeURIComponent;var Mr=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#t=r}param(e){return e?this.#r(e):this.#s()}#r(e){let t=this.#t[0][this.routeIndex]?.[1][e],r=this.#n(t);return r&&De(r)}#s(){let e={},t=Object.keys(this.#t[0][this.routeIndex]?.[1]??{});for(let r of t){let n=this.#n(this.#t[0][this.routeIndex][1][r]);n!==void 0&&(e[r]=De(n))}return e}#n(e){return this.#t[1]?this.#t[1][e]:e}query(e){return Lr(this.url,e)}queries(e){return Ir(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t=Object.create(null);return this.raw.headers.forEach((r,n)=>{t[n]=r}),t}async parseBody(e){return Pr(this,e)}#o=e=>{let{bodyCache:t,raw:r}=this,n=t[e];if(n)return n;for(let o in t)return t[o].then(s=>(o==="json"&&(s=JSON.stringify(s)),new Response(s)[e]()));return t[e]=r[e]()};json(){return this.#o("text").then(e=>JSON.parse(e))}text(){return this.#o("text")}arrayBuffer(){return this.#o("arrayBuffer")}bytes(){return this.#o("arrayBuffer").then(e=>new Uint8Array(e))}blob(){return this.#o("blob")}formData(){return this.#o("formData")}addValidatedData(e,t){(this.#e??={})[e]=t}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[vr](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}};var Dr={Stringify:1,BeforeStream:2,Stream:3},ss=(e,t)=>{let r=new String(e);return r.isEscaped=!0,r.callbacks=t,r};var ut=async(e,t,r,n,o)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let s=e.callbacks;if(!s?.length)return Promise.resolve(e);o?o[0]+=e:o=[e];let i=Promise.all(s.map(a=>a({phase:t,buffer:o,context:n}))).then(a=>Promise.all(a.filter(Boolean).map(c=>ut(c,t,!1,n,o))).then(()=>o[0]));return r?ss(await i,s):i};var is="text/plain; charset=UTF-8",dt=(e,t)=>({"Content-Type":e,...t}),ve=(e,t)=>new Response(e,t),ft=class{#e;#t;env={};#r;finalized=!1;error;#s;#n;#o;#u;#c;#l;#a;#d;#f;constructor(e,t){this.#e=e,t&&(this.#n=t.executionCtx,this.env=t.env,this.#l=t.notFoundHandler,this.#f=t.path,this.#d=t.matchResult)}get req(){return this.#t??=new Mr(this.#e,this.#f,this.#d),this.#t}get event(){if(this.#n&&"respondWith"in this.#n)return this.#n;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#n)return this.#n;throw Error("This context has no ExecutionContext")}get res(){return this.#o||=ve(null,{headers:this.#a??=new Headers})}set res(e){if(this.#o&&e){e=ve(e.body,e);for(let[t,r]of this.#o.headers.entries())if(t!=="content-type")if(t==="set-cookie"){let n=this.#o.headers.getSetCookie();e.headers.delete("set-cookie");for(let o of n)e.headers.append("set-cookie",o)}else e.headers.set(t,r)}this.#o=e,this.finalized=!0}render=(...e)=>(this.#c??=t=>this.html(t),this.#c(...e));setLayout=e=>this.#u=e;getLayout=()=>this.#u;setRenderer=e=>{this.#c=e};header=(e,t,r)=>{this.finalized&&(this.#o=ve(this.#o.body,this.#o));let n=this.#o?this.#o.headers:this.#a??=new Headers;t===void 0?n.delete(e):r?.append?n.append(e,t):n.set(e,t)};status=e=>{this.#s=e};set=(e,t)=>{this.#r??=new Map,this.#r.set(e,t)};get=e=>this.#r?this.#r.get(e):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(e,t,r){let n=this.#o?new Headers(this.#o.headers):this.#a;if(typeof t=="object"&&t.headers){n??=new Headers;for(let[s,i]of new Headers(t.headers))s==="set-cookie"?n.append(s,i):n.set(s,i)}if(r){if(!n){let s=0;for(let i in r)if(++s>1||typeof r[i]!="string"){n=new Headers;break}}if(n)for(let s in r){let i=r[s];if(typeof i=="string")n.set(s,i);else{n.delete(s);for(let a of i)n.append(s,a)}}}let o=typeof t=="number"?t:t?.status??this.#s;return ve(e,{status:o,headers:n??r})}newResponse=(...e)=>this.#i(...e);body=(e,t,r)=>this.#i(e,t,r);text=(e,t,r)=>!this.#a&&!this.#s&&!t&&!r&&!this.finalized?new Response(e):this.#i(e,t,dt(is,r));json=(e,t,r)=>this.#i(JSON.stringify(e),t,dt("application/json",r));html=(e,t,r)=>{let n=o=>this.#i(o,t,dt("text/html; charset=UTF-8",r));return typeof e=="object"?ut(e,Dr.Stringify,!1,{}).then(n):n(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#l??=()=>ve(),this.#l(this))};var P="ALL",kr="all",Nr=["get","post","put","delete","options","patch","query"],ke="Can not add a route since the matcher is already built.",Ne=class extends Error{};var Ur="__COMPOSED_HANDLER";var as=e=>e.text("404 Not Found",404),Br=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},Hr=class jr{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[...Nr,kr].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?this.#e=i:this.#s(s,this.#e,i),a.forEach(c=>{this.#s(s,this.#e,c)}),this)}),this.on=(s,i,...a)=>{for(let c of[i].flat()){this.#e=c;for(let l of[s].flat())a.map(u=>{this.#s(l.toUpperCase(),this.#e,u)})}return this},this.use=(s,...i)=>(typeof s=="string"?this.#e=s:(this.#e="*",i.unshift(s)),i.forEach(a=>{this.#s(P,this.#e,a)}),this);let{strict:n,...o}=t;Object.assign(this,o),this.getPath=n??!0?t.getPath??lt:Tr}#t(){let t=new jr({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#r=this.#r,t.routes=this.routes,t}#r=as;errorHandler=Br;route(t,r){let n=this.basePath(t);return r.routes.map(o=>{let s;r.errorHandler===Br?s=o.handler:(s=async(i,a)=>(await it([],r.errorHandler)(i,()=>o.handler(i,a))).res,s[Ur]=o.handler),n.#s(o.method,o.path,s,o.basePath)}),this}basePath(t){let r=this.#t();return r._basePath=G(this._basePath,t),r}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#r=t,this);mount(t,r,n){let o,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,n.replaceRequest===!1?o=c=>c:o=n.replaceRequest));let i=s?c=>{let l=s(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};o||=(()=>{let c=G(this._basePath,t),l=c==="/"?0:c.length;return u=>{let d=new URL(u.url);return d.pathname=this.getPath(u).slice(l)||"/",new Request(d,u)}})();let a=async(c,l)=>{let u=await r(o(c.req.raw),...i(c));if(u)return u;await l()};return this.#s(P,G(t,"*"),a),this}#s(t,r,n,o){t=t.toUpperCase(),r=G(this._basePath,r);let s={basePath:o!==void 0?G(this._basePath,o):this._basePath,path:r,method:t,handler:n};this.router.add(t,r,[n,s]),this.routes.push(s)}#n(t,r){if(t instanceof Error)return this.errorHandler(t,r);throw t}#o(t,r,n,o){if(o==="HEAD")return(async()=>new Response(null,await this.#o(t,r,n,"GET")))();let s=this.getPath(t,{env:n}),i=this.router.match(o,s),a=new ft(t,{path:s,matchResult:i,env:n,executionCtx:r,notFoundHandler:this.#r});if(i[0].length===1){let l;try{l=i[0][0][0][0](a,async()=>{a.res=await this.#r(a)})}catch(u){return this.#n(u,a)}return l instanceof Promise?l.then(u=>u||(a.finalized?a.res:this.#r(a))).catch(u=>this.#n(u,a)):l??this.#r(a)}let c=it(i[0],this.errorHandler,this.#r);return(async()=>{try{let l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#n(l,a)}})()}fetch=(t,...r)=>this.#o(t,r[1],r[0],t.method);request=(t,r,n,o)=>t instanceof Request?this.fetch(r?new Request(t,r):t,n,o):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${G("/",t)}`,r),n,o));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#o(t.request,t,void 0,t.request.method))})}};var E=()=>Object.create(null);var Ue=[];function pt(e,t){let r=this.buildAllMatchers(),n=((o,s)=>{let i=r[o]||r[P],a=i[2][s];if(a)return a;let c=s.match(i[0]);if(!c)return[[],Ue];let l=c.indexOf("",1);return[i[1][l],c]});return this.match=n,n(e,t)}var ue="[^/]+",X=".*",$="(?:|/.*)",Y=Symbol(),$r=new Set(".\\+*[^]$()");function cs(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1?1:e===X||e===$?t===$?-1:1:t===X||t===$?-1:e===ue?1:t===ue?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var Fr=class ht{#e;#t;#r=E();insert(t,r,n,o,s){let i=this;for(let a=0,c=t.length;a<c;a++){let l=t[a],u=l.length===1?l==="*"?a===c-1?["","",X]:["","",ue]:null:l==="/*"?["","",$]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),d;if(u){let f=u[1],h=u[2]||ue;if(f&&u[2]&&(h===".*"||(h=h.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(h))||h.length===1&&$r.has(h)))throw Y;if(d=i.#r[h],!d){if(h!==X&&h!==$){for(let y in i.#r)if((h.length>1||y.length>1)&&y!==X&&y!==$)throw Y}d=i.#r[h]=new ht}f!==""&&(d.#t??=o.varIndex++,n.push([f,d.#t]))}else if(d=i.#r[l],!d){for(let f in i.#r)if(f.length>1&&f!==X&&f!==$)throw Y;d=i.#r[l]=new ht}i=d}if(i.#e!==void 0)throw Y;i.#e=s?-1:r}buildRegExpStr(){let r=Object.keys(this.#r).sort(cs).map(n=>{let o=this.#r[n],s=o.buildRegExpStr();return s===""?"":(typeof o.#t=="number"?`(${n})@${o.#t}`:$r.has(n)?`\\${n}`:n)+s}).filter(Boolean);return typeof this.#e=="number"&&this.#e!==-1&&r.unshift(`#${this.#e}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}};var mt=class{#e={varIndex:0};#t=new Fr;#r=0;paths=E();insert(e,t){if(t){this.#t.insert(e.split(""),0,[],this.#e,!0);return}let r=[],n=[],o=e;for(let i=0;;){let a=!1;if(o=o.replace(/\{[^}]+\}/g,c=>{let l=`@\\${i}`;return n[i]=[l,c],i++,a=!0,l}),!a)break}let s=o.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=n.length-1;i>=0;i--){let[a]=n[i];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(a)!==-1){s[c]=s[c].replace(a,n[i][1]);break}}this.#t.insert(s,this.#r,r,this.#e,!1),this.paths[e]=[this.#r++,r]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0,r=[],n=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(o,s,i)=>s!==void 0?(r[++t]=Number(s),"$()"):(i!==void 0&&(n[Number(i)]=++t),"")),[new RegExp(`^${e}`),r,n]}};var Wr=E();function zr(e){return Wr[e]??=new RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(t,r)=>r?`\\${r}`:t==="/*"?$:t==="*"?X:`/:${ue}`)}$`)}function Be(e,t){for(let r of Object.keys(e).sort((n,o)=>o.length-n.length))if(zr(r).test(t))return[...e[r]]}var He=class{name="RegExpRouter";#e;#t;#r;constructor(){this.#e={[P]:E()},this.#t={[P]:E()},this.#r={[P]:new mt}}#s(e,t){try{this.#r[e].insert(t,!/\*|\/:/.test(t))}catch(r){throw r===Y?new Ne(t):r}}add(e,t,r){let n=this.#e,o=this.#t;if(!n)throw new Error(ke);if(!n[e]){this.#r[e]=new mt;for(let a of[n,o]){a[e]=E();for(let c in a[P])a[e][c]=[...a[P][c]],this.#s(e,c)}}t==="/*"&&(t="*");let s=e===P?Object.keys(n):[e];if(/\*$/.test(t)){let a=zr(t);for(let c of s)n[c][t]||(this.#s(c,t),n[c][t]=Be(n[c],t)||Be(n[P],t)||[]);for(let c of[n,o])for(let l of s)for(let u in c[l])a.test(u)&&c[l][u].push([r,t]);return}let i=Me(t)||[t];for(let a of i)for(let c of s)o[c][a]||(this.#s(c,a),o[c][a]=Be(n[c],a)||Be(n[P],a)||[]),o[c][a].push([r,a])}match=pt;buildAllMatchers(){let e=E();for(let t of Object.keys(this.#t))e[t]=this.#n(t);return this.#e=this.#t=this.#r=void 0,Wr=E(),e}#n(e){let t=this.#e[e],r=this.#t[e],n=this.#r[e],o=E(),s=[],[i,a,c]=n.buildRegExp();for(let l of[t,r])for(let u in l){let d=l[u],f=n.paths[u];if(!f){o[u]=[d.map(([h])=>[h,E()]),Ue];continue}s[f[0]]=d.map(([h,y])=>[h,n.paths[y][1].reduceRight((m,[b],w)=>(m[b]=c[f[1][w][1]],m),E())])}return[i,a.map(l=>s[l]),o]}};var gt=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,r){if(!this.#t)throw new Error(ke);this.#t.push([e,t,r])}match(e,t){if(!this.#t)throw new Error("Fatal error");let r=this.#e,n=this.#t,o=r.length,s=0,i;for(;s<o;s++){let a=r[s];try{for(let c=0,l=n.length;c<l;c++)a.add(...n[c]);i=a.match(e,t)}catch(c){if(c instanceof Ne)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(s===o)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.#t||this.#e.length!==1)throw new Error("No active router has been determined yet.");return this.#e[0]}};var yt=E(),ls=0,qr=class Kr{#e=[];#t=E();#r=[];#s;#n=yt;insert(t,r,n){let o=this,s=Ar(r),i=new Set,a=0;for(let c of s){let l=s[++a],u=Cr(c,l)||(l===void 0&&c&&c.indexOf("*")===c.length-1?c:null),d=Array.isArray(u),f=d?u[0]:u||c,h=o.#t[f]||=new Kr;u&&!h.#s&&(h.#s=u,o.#r.push(h)),o=h,d&&i.add(u[1])}o.#e.push({[t]:{handler:n,possibleKeys:[...i],score:++ls}})}#o(t,r,n,o,s){for(let i=0,a=r.#e.length;i<a;i++){let c=r.#e[i],l=c[n]||c[P];if(l){l.params=E(),t.push(l);for(let u=0,d=l.possibleKeys.length;u<d;u++){let f=l.possibleKeys[u];l.params[f]=s?.[f]&&!u?s[f]:o[f]??s?.[f]}}}}search(t,r){let n=[];this.#n=yt;let s=[this],i=ct(r),a=[],c=i.length,l=null;for(let u=0;u<c;u++){let d=i[u],f=u===c-1,h=[];for(let m=0,b=s.length;m<b;m++){let w=s[m],p=w.#t[d];p&&(p.#n=w.#n,f?(p.#t["*"]&&this.#o(n,p.#t["*"],t,w.#n),this.#o(n,p,t,w.#n)):h.push(p));for(let g of w.#r){let v=g.#s,S=w.#n===yt?{}:{...w.#n};if(typeof v=="string"){(v==="*"||d.startsWith(v.slice(0,-1)))&&(this.#o(n,g,t,w.#n),v==="*"&&(g.#n=S,h.push(g)));continue}let[,M,T]=v;if(!(!d&&T===!0)){if(T!==!0){if(!l){l=[];let x=r[0]==="/"?1:0;for(let O=0;O<c;O++)l[O]=x,x+=i[O].length+1}let R=r.slice(l[u]),A=T.exec(R);if(A){S[M]=A[0],this.#o(n,g,t,w.#n,S),A[0].length===R.length&&g.#t["*"]&&this.#o(n,g.#t["*"],t,w.#n,S);for(let x in g.#t){g.#n=S;let O=A[0].match(/\//g)?.length??0;(a[O]||=[]).push(g);break}continue}}(T===!0||T.test(d))&&(S[M]=d,f?(this.#o(n,g,t,S,w.#n),g.#t["*"]&&this.#o(n,g.#t["*"],t,S,w.#n)):(g.#n=S,h.push(g)))}}}let y=a.shift();s=y?h.concat(y):h}return n[1]&&n.sort((u,d)=>u.score-d.score),[n.map(({handler:u,params:d})=>[u,d])]}};var wt=class{name="TrieRouter";#e=new qr;add(e,t,r){for(let n of Me(t)||[t])this.#e.insert(e,n,r)}match(e,t){return this.#e.search(e,t)}};var bt=class extends Hr{constructor(e={}){super(e),this.router=e.router??new gt({routers:[new He,new wt]})}};var je=e=>{let t={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH","QUERY"],allowHeaders:[],exposeHeaders:[],...e},r=t.exposeHeaders?.length?t.exposeHeaders.join(","):void 0,n=t.allowHeaders?.length?t.allowHeaders.join(","):void 0,o=(i=>typeof i=="string"?i==="*"?()=>i:a=>i===a?a:null:typeof i=="function"?i:a=>i.includes(a)?a:null)(t.origin),s=(i=>{if(typeof i=="function")return async(a,c)=>(await i(a,c)).join(",");if(Array.isArray(i)){let a=i.join(",");return()=>a}else return()=>""})(t.allowMethods);return async function(a,c){function l(d,f){a.res.headers.set(d,f)}let u=await o(a.req.header("origin")||"",a);if(u&&l("Access-Control-Allow-Origin",u),t.credentials&&l("Access-Control-Allow-Credentials","true"),r&&l("Access-Control-Expose-Headers",r),a.req.method==="OPTIONS"){t.origin!=="*"&&a.res.headers.append("Vary","Origin"),t.maxAge!=null&&l("Access-Control-Max-Age",t.maxAge.toString());let d=await s(a.req.header("origin")||"",a);d&&l("Access-Control-Allow-Methods",d);let f=n;if(!f){let h=a.req.header("Access-Control-Request-Headers");h&&(f=h.split(",").map(y=>y.trim()).join(","))}return f&&(l("Access-Control-Allow-Headers",f),a.res.headers.append("Vary","Access-Control-Request-Headers")),a.res.headers.delete("Content-Length"),a.res.headers.delete("Content-Type"),new Response(null,{headers:a.res.headers,status:204,statusText:"No Content"})}await c(),t.origin!=="*"&&a.header("Vary","Origin",{append:!0})}};import un from"process";import dn from"path";import{fileURLToPath as $s}from"url";import Fs from"child_process";import Ws,{constants as zs}from"fs/promises";import{promisify as vs}from"util";import xs from"child_process";import Rt,{constants as Zr}from"fs/promises";import Yr from"process";import hs from"os";import ms from"fs";import fs from"fs";import Vr from"fs";var vt;function us(){try{return Vr.statSync("/.dockerenv"),!0}catch{return!1}}function ds(){try{return Vr.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function xt(){return vt===void 0&&(vt=us()||ds()),vt}var Et,ps=()=>{try{return fs.statSync("/run/.containerenv"),!0}catch{return!1}};function de(){return Et===void 0&&(Et=ps()||xt()),Et}var Gr=()=>{if(Yr.platform!=="linux")return!1;if(hs.release().toLowerCase().includes("microsoft"))return!de();try{return ms.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!de():!1}catch{return!1}},F=Yr.env.__IS_WSL_TEST__?Gr:Gr();import Xr from"process";import{Buffer as gs}from"buffer";import{promisify as ys}from"util";import ws from"child_process";import Wc,{constants as zc}from"fs/promises";var bs=ys(ws.execFile),St=()=>`${Xr.env.SYSTEMROOT||Xr.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var L=async(e,t={})=>{let{powerShellPath:r,...n}=t,o=L.encodeCommand(e);return bs(r??St(),[...L.argumentsPrefix,o],{encoding:"utf8",...n})};L.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];L.encodeCommand=e=>gs.from(e,"utf16le").toString("base64");L.escapeArgument=e=>`'${String(e).replaceAll("'","''")}'`;function Jr(e){for(let t of e.split(`
|
|
7
7
|
`)){if(/^\s*#/.test(t))continue;let r=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(r)return r.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var Es=vs(xs.execFile),Ss=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let r="/etc/wsl.conf",n=!1;try{await Rt.access(r,Zr.F_OK),n=!0}catch{}if(!n)return e;let o=await Rt.readFile(r,{encoding:"utf8"}),s=Jr(o);return s===void 0?e:(t=s,t=t.endsWith("/")?t:`${t}/`,t)}})(),Rs=async()=>`${await Ss()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,$e=F?Rs:St,Qr,en=async()=>(Qr??=(async()=>{try{let e=await $e();return await Rt.access(e,Zr.X_OK),!0}catch{return!1}})(),Qr),tn=async()=>{let e=await $e(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:r}=await L(t,{powerShellPath:e});return r.trim()},rn=async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await Es("wslpath",["-aw",e],{encoding:"utf8"});return t.trim()}catch{return e}};function re(e,t,r){let n=o=>Object.defineProperty(e,t,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let o=r();return n(o),o},set(o){n(o)}}),e}import{promisify as Ns}from"util";import Ot from"process";import{execFile as Us}from"child_process";import{promisify as Ps}from"util";import As from"process";import{execFile as Cs}from"child_process";var _s=Ps(Cs);async function Pt(){if(As.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await _s("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return r==="com.apple.safari"?"com.apple.Safari":r}import Ts from"process";import{promisify as Os}from"util";import{execFile as Ls,execFileSync as ll}from"child_process";var Is=Os(Ls);async function nn(e,{humanReadableOutput:t=!0,signal:r}={}){if(Ts.platform!=="darwin")throw new Error("macOS only");let n=t?[]:["-ss"],o={};r&&(o.signal=r);let{stdout:s}=await Is("osascript",["-e",e,n],o);return s.trim()}async function At(e){return nn(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
8
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as Ms}from"util";import{execFile as Ds}from"child_process";var ks=Ms(Ds),Fe={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},_t=new Map(Object.entries(Fe)),Ct=class extends Error{};async function Tt(e=ks){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!r)throw new Ct(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,o=n.lastIndexOf("."),s=n.lastIndexOf("-"),i=o===-1?void 0:n.slice(0,o),a=s===-1?void 0:n.slice(0,s);return Fe[n]??Fe[i]??Fe[a]??{name:n,id:n}}var Bs=Ns(Us),Hs=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function Lt(){if(Ot.platform==="darwin"){let e=await Pt();return{name:await At(e),id:e}}if(Ot.platform==="linux"){let{stdout:e}=await Bs("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:Hs(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(Ot.platform==="win32")return Tt();throw new Error("Only macOS, Linux, and Windows are supported")}import It from"process";var js=!!(It.env.SSH_CONNECTION||It.env.SSH_CLIENT||It.env.SSH_TTY),on=js;var We=Symbol("fallbackAttempt"),Mt=import.meta.url?dn.dirname($s(import.meta.url)):"",sn=dn.join(Mt,"xdg-open"),{platform:fe,arch:an}=un,cn=async(e,t)=>{if(e.length===0)return;let r=[];for(let n of e)try{return await t(n)}catch(o){r.push(o)}throw new AggregateError(r,"Failed to open in all supported apps")},ze=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[We]===!0;if(delete e[We],Array.isArray(e.app))return cn(e.app,l=>ze({...e,app:l,[We]:!0}));let{name:r,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(r))return cn(r,l=>ze({...e,app:{name:l,arguments:n},[We]:!0}));if(r==="browser"||r==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d;if(F){let f=await tn();d=_t.get(f)??{}}else d=await Lt();if(d.id in l){let f=l[d.id.toLowerCase()];if(r==="browserPrivate"){if(f==="safari")throw new Error("Safari doesn't support opening in private mode via command line");n.push(u[f])}return ze({...e,app:{name:pe[f],arguments:n}})}throw new Error(`${d.name} is not supported as a default browser`)}let o,s=[],i={},a=!1;if(F&&!de()&&!on&&!r&&(a=await en()),fe==="darwin")o="open",e.wait&&s.push("--wait-apps"),e.background&&s.push("--background"),e.newInstance&&s.push("--new"),r&&s.push("-a",r);else if(fe==="win32"||a){o=await $e(),s.push(...L.argumentsPrefix),F||(i.windowsVerbatimArguments=!0),F&&e.target&&(e.target=await rn(e.target));let l=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&l.push("-Wait"),r?(l.push(L.escapeArgument(r)),e.target&&n.push(e.target)):e.target&&l.push(L.escapeArgument(e.target)),n.length>0&&(n=n.map(u=>L.escapeArgument(u)),l.push("-ArgumentList",n.join(","))),e.target=L.encodeCommand(l.join(" ")),e.wait||(i.stdio="ignore")}else{if(r)o=r;else{let l=!Mt||Mt==="/",u=!1;try{await Ws.access(sn,zs.X_OK),u=!0}catch{}o=un.versions.electron??(fe==="android"||l||!u)?"xdg-open":sn}n.length>0&&s.push(...n),e.wait||(i.stdio="ignore",i.detached=!0)}fe==="darwin"&&n.length>0&&s.push("--args",...n),e.target&&s.push(e.target);let c=Fs.spawn(o,s,i);return e.wait?new Promise((l,u)=>{c.once("error",u),c.once("close",d=>{if(!e.allowNonzeroExitCode&&d!==0){u(new Error(`Exited with code ${d}`));return}l(c)})}):t?new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.once("close",d=>{if(c.off("error",u),d!==0){u(new Error(`Exited with code ${d}`));return}c.unref(),l(c)})})}):(c.unref(),new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.off("error",u),l(c)})}))},qs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return ze({...t,target:e})};function ln(e){if(typeof e=="string"||Array.isArray(e))return e;let{[an]:t}=e;if(!t)throw new Error(`${an} is not supported`);return t}function xe({[fe]:e},{wsl:t}={}){if(t&&F)return ln(t);if(!e)throw new Error(`${fe} is not supported`);return ln(e)}var pe={browser:"browser",browserPrivate:"browserPrivate"};re(pe,"chrome",()=>xe({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));re(pe,"brave",()=>xe({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));re(pe,"firefox",()=>xe({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));re(pe,"edge",()=>xe({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));re(pe,"safari",()=>xe({darwin:"Safari"}));var fn=qs;function pn(e=""){return`<link rel="icon" type="image/svg+xml" href="${`${e.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as Pn,readFileSync as Xs}from"fs";import z from"path";import{fileURLToPath as Js}from"url";import{gunzipSync as Qs}from"zlib";var W=lo(Rn(),1);function he(e,t){return e.header("Retry-After",String(Gs(t))),e.json({error:"Too Many Requests"},429)}function Gs(e){return e&&typeof e=="object"&&"msBeforeNext"in e&&typeof e.msBeforeNext=="number"&&Number.isFinite(e.msBeforeNext)?Math.max(1,Math.ceil(e.msBeforeNext/1e3)):60}var Zs={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function ei(){let e=z.dirname(Js(import.meta.url));for(let t of[z.resolve(e,"app"),z.resolve(e,"../app"),z.resolve(e,"../../dist/app")])if(Pn(z.join(t,"inspector.js.gz")))return t;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function An(e,t="/inspector/assets"){let r=ei(),n=new Map,o=new W.default({points:600,duration:60}),s=async(i,a)=>{try{await o.consume(i.req)}catch(c){return he(i,c)}return a()};e.use(`${t}/*`,s),e.get(`${t}/*`,async i=>{let a=i.req.path.slice(t.length),c=a.startsWith("/")?a.slice(1):a;if(!c||c.includes(".."))return i.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=z.resolve(r,l),d=r.endsWith(z.sep)?r:`${r}${z.sep}`;if(!u.startsWith(d)||!Pn(u))return i.notFound();let f=z.extname(c),h=l.endsWith(".gz"),y=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(i.req.header("accept-encoding")??""),m=Xs(u),b=h&&!y?n.get(u)??ti(n,u,m):m,w=b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength);return i.body(w,200,{"Content-Type":Zs[f]??"application/octet-stream",...h&&y?{"Content-Encoding":"gzip"}:{},...h?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function ti(e,t,r){let n=Qs(r);return e.set(t,n),n}var Cn={name:"@mcp-use/inspector",type:"module",version:"20.3.14",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"},"./client/styles.css":{default:"./dist/client/styles.css"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"pnpm run clean && pnpm run build:client-exports && pnpm run build:server && pnpm run build:app && pnpm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts && node scripts/copy-client-styles.mjs","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs",test:"vitest run","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.16 || ^2.0.17 || ^2.0.18 || ^2.0.19 || ^2.0.20","@mcp-use/client":"^2.0.1 || ^2.1.0 || ^2.1.1 || ^2.1.2 || ^2.1.3 || ^2.1.4 || ^2.1.5 || ^2.2.0 || ^2.2.1 || ^2.2.2 || ^2.2.3 || ^2.2.4 || ^2.2.5 || ^2.3.0 || ^2.3.1 || ^2.3.2 || ^2.3.3 || ^2.3.4 || ^2.3.5 || ^2.4.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"^2.4.3 || ^2.4.4 || ^2.5.0 || ^2.5.1 || ^2.5.2 || ^2.6.0 || ^2.6.1 || ^2.7.0 || ^2.7.1 || ^2.7.2",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.13.5",jsdom:"^27.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",yaml:"^2.8.3",zod:"^4.2.0"}};var ni=Cn.version;function qe(){return ni}var oi=`<!doctype html>
|
|
8
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as Ms}from"util";import{execFile as Ds}from"child_process";var ks=Ms(Ds),Fe={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},_t=new Map(Object.entries(Fe)),Ct=class extends Error{};async function Tt(e=ks){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!r)throw new Ct(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,o=n.lastIndexOf("."),s=n.lastIndexOf("-"),i=o===-1?void 0:n.slice(0,o),a=s===-1?void 0:n.slice(0,s);return Fe[n]??Fe[i]??Fe[a]??{name:n,id:n}}var Bs=Ns(Us),Hs=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function Lt(){if(Ot.platform==="darwin"){let e=await Pt();return{name:await At(e),id:e}}if(Ot.platform==="linux"){let{stdout:e}=await Bs("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:Hs(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(Ot.platform==="win32")return Tt();throw new Error("Only macOS, Linux, and Windows are supported")}import It from"process";var js=!!(It.env.SSH_CONNECTION||It.env.SSH_CLIENT||It.env.SSH_TTY),on=js;var We=Symbol("fallbackAttempt"),Mt=import.meta.url?dn.dirname($s(import.meta.url)):"",sn=dn.join(Mt,"xdg-open"),{platform:fe,arch:an}=un,cn=async(e,t)=>{if(e.length===0)return;let r=[];for(let n of e)try{return await t(n)}catch(o){r.push(o)}throw new AggregateError(r,"Failed to open in all supported apps")},ze=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[We]===!0;if(delete e[We],Array.isArray(e.app))return cn(e.app,l=>ze({...e,app:l,[We]:!0}));let{name:r,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(r))return cn(r,l=>ze({...e,app:{name:l,arguments:n},[We]:!0}));if(r==="browser"||r==="browserPrivate"){let l={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d;if(F){let f=await tn();d=_t.get(f)??{}}else d=await Lt();if(d.id in l){let f=l[d.id.toLowerCase()];if(r==="browserPrivate"){if(f==="safari")throw new Error("Safari doesn't support opening in private mode via command line");n.push(u[f])}return ze({...e,app:{name:pe[f],arguments:n}})}throw new Error(`${d.name} is not supported as a default browser`)}let o,s=[],i={},a=!1;if(F&&!de()&&!on&&!r&&(a=await en()),fe==="darwin")o="open",e.wait&&s.push("--wait-apps"),e.background&&s.push("--background"),e.newInstance&&s.push("--new"),r&&s.push("-a",r);else if(fe==="win32"||a){o=await $e(),s.push(...L.argumentsPrefix),F||(i.windowsVerbatimArguments=!0),F&&e.target&&(e.target=await rn(e.target));let l=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&l.push("-Wait"),r?(l.push(L.escapeArgument(r)),e.target&&n.push(e.target)):e.target&&l.push(L.escapeArgument(e.target)),n.length>0&&(n=n.map(u=>L.escapeArgument(u)),l.push("-ArgumentList",n.join(","))),e.target=L.encodeCommand(l.join(" ")),e.wait||(i.stdio="ignore")}else{if(r)o=r;else{let l=!Mt||Mt==="/",u=!1;try{await Ws.access(sn,zs.X_OK),u=!0}catch{}o=un.versions.electron??(fe==="android"||l||!u)?"xdg-open":sn}n.length>0&&s.push(...n),e.wait||(i.stdio="ignore",i.detached=!0)}fe==="darwin"&&n.length>0&&s.push("--args",...n),e.target&&s.push(e.target);let c=Fs.spawn(o,s,i);return e.wait?new Promise((l,u)=>{c.once("error",u),c.once("close",d=>{if(!e.allowNonzeroExitCode&&d!==0){u(new Error(`Exited with code ${d}`));return}l(c)})}):t?new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.once("close",d=>{if(c.off("error",u),d!==0){u(new Error(`Exited with code ${d}`));return}c.unref(),l(c)})})}):(c.unref(),new Promise((l,u)=>{c.once("error",u),c.once("spawn",()=>{c.off("error",u),l(c)})}))},qs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return ze({...t,target:e})};function ln(e){if(typeof e=="string"||Array.isArray(e))return e;let{[an]:t}=e;if(!t)throw new Error(`${an} is not supported`);return t}function xe({[fe]:e},{wsl:t}={}){if(t&&F)return ln(t);if(!e)throw new Error(`${fe} is not supported`);return ln(e)}var pe={browser:"browser",browserPrivate:"browserPrivate"};re(pe,"chrome",()=>xe({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));re(pe,"brave",()=>xe({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));re(pe,"firefox",()=>xe({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));re(pe,"edge",()=>xe({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));re(pe,"safari",()=>xe({darwin:"Safari"}));var fn=qs;function pn(e=""){return`<link rel="icon" type="image/svg+xml" href="${`${e.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as Pn,readFileSync as Xs}from"fs";import z from"path";import{fileURLToPath as Js}from"url";import{gunzipSync as Qs}from"zlib";var W=lo(Rn(),1);function he(e,t){return e.header("Retry-After",String(Gs(t))),e.json({error:"Too Many Requests"},429)}function Gs(e){return e&&typeof e=="object"&&"msBeforeNext"in e&&typeof e.msBeforeNext=="number"&&Number.isFinite(e.msBeforeNext)?Math.max(1,Math.ceil(e.msBeforeNext/1e3)):60}var Zs={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function ei(){let e=z.dirname(Js(import.meta.url));for(let t of[z.resolve(e,"app"),z.resolve(e,"../app"),z.resolve(e,"../../dist/app")])if(Pn(z.join(t,"inspector.js.gz")))return t;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function An(e,t="/inspector/assets"){let r=ei(),n=new Map,o=new W.default({points:600,duration:60}),s=async(i,a)=>{try{await o.consume(i.req)}catch(c){return he(i,c)}return a()};e.use(`${t}/*`,s),e.get(`${t}/*`,async i=>{let a=i.req.path.slice(t.length),c=a.startsWith("/")?a.slice(1):a;if(!c||c.includes(".."))return i.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=z.resolve(r,l),d=r.endsWith(z.sep)?r:`${r}${z.sep}`;if(!u.startsWith(d)||!Pn(u))return i.notFound();let f=z.extname(c),h=l.endsWith(".gz"),y=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(i.req.header("accept-encoding")??""),m=Xs(u),b=h&&!y?n.get(u)??ti(n,u,m):m,w=b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength);return i.body(w,200,{"Content-Type":Zs[f]??"application/octet-stream",...h&&y?{"Content-Encoding":"gzip"}:{},...h?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function ti(e,t,r){let n=Qs(r);return e.set(t,n),n}var Cn={name:"@mcp-use/inspector",type:"module",version:"20.3.15-canary.1",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"},"./client/styles.css":{default:"./dist/client/styles.css"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"pnpm run clean && pnpm run build:client-exports && pnpm run build:server && pnpm run build:app && pnpm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts && node scripts/copy-client-styles.mjs","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs",test:"vitest run","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.16 || ^2.0.17 || ^2.0.18 || ^2.0.19 || ^2.0.20","@mcp-use/client":"^2.0.1 || ^2.1.0 || ^2.1.1 || ^2.1.2 || ^2.1.3 || ^2.1.4 || ^2.1.5 || ^2.2.0 || ^2.2.1 || ^2.2.2 || ^2.2.3 || ^2.2.4 || ^2.2.5 || ^2.3.0 || ^2.3.1 || ^2.3.2 || ^2.3.3 || ^2.3.4 || ^2.3.5 || ^2.4.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"^2.4.3 || ^2.4.4 || ^2.5.0 || ^2.5.1 || ^2.5.2 || ^2.6.0 || ^2.6.1 || ^2.7.0 || ^2.7.1 || ^2.7.2 || ^2.7.3-canary.0",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.13.5",jsdom:"^27.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",yaml:"^2.8.3",zod:"^4.2.0"}};var ni=Cn.version;function qe(){return ni}var oi=`<!doctype html>
|
|
9
9
|
<html>
|
|
10
10
|
<head>
|
|
11
11
|
<meta charset="utf-8" />
|
package/dist/client/index.js
CHANGED
|
@@ -198,7 +198,7 @@ void main(){
|
|
|
198
198
|
color=mix(color,grainOC,.35*grainOS);
|
|
199
199
|
opacity+=.5*grainOS;
|
|
200
200
|
fragColor=vec4(color,clamp(opacity,0.,1.));
|
|
201
|
-
}`;function MT(e){return[parseInt(e.slice(1,3),16)/255,parseInt(e.slice(3,5),16)/255,parseInt(e.slice(5,7),16)/255,1]}function Yl({className:e,colors:t=["#e0eaff","#f9ffbd","#dedede","#ffffff"],distortion:n=.8,swirl:o=.1,grainMixer:r=0,grainOverlay:s=.2,speed:a=1}){let i=Au(null),c=Au(null),l=Au({colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a});return l.current={colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a},kT(()=>{let u=i.current,p=c.current;if(!u||!p)return;let d=u.getContext("webgl2");if(!d)return;let h=(H,Y)=>{let U=d.createShader(H);return U?(d.shaderSource(U,Y),d.compileShader(U),d.getShaderParameter(U,d.COMPILE_STATUS)?U:(console.error(d.getShaderInfoLog(U)),null)):null},m=h(d.VERTEX_SHADER,PT),b=h(d.FRAGMENT_SHADER,RT);if(!m||!b)return;let f=d.createProgram();if(!f)return;if(d.attachShader(f,m),d.attachShader(f,b),d.linkProgram(f),!d.getProgramParameter(f,d.LINK_STATUS)){console.error(d.getProgramInfoLog(f));return}d.useProgram(f);let v=d.getAttribLocation(f,"a_position"),x=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,x),d.bufferData(d.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),d.STATIC_DRAW),d.enableVertexAttribArray(v),d.vertexAttribPointer(v,2,d.FLOAT,!1,0,0);let y=d.getUniformLocation(f,"u_time"),g=d.getUniformLocation(f,"u_resolution"),C=[0,1,2,3].map(H=>d.getUniformLocation(f,`u_colors[${H}]`)),k=d.getUniformLocation(f,"u_colorsCount"),I=d.getUniformLocation(f,"u_distortion"),M=d.getUniformLocation(f,"u_swirl"),N=d.getUniformLocation(f,"u_grainMixer"),E=d.getUniformLocation(f,"u_grainOverlay"),T=0,S=performance.now(),P=0,A=()=>{let H=Math.min(2,window.devicePixelRatio||1);u.width=Math.floor(p.clientWidth*H),u.height=Math.floor(p.clientHeight*H),d.viewport(0,0,u.width,u.height)},R=H=>{if(document.hidden){S=H,P=requestAnimationFrame(R);return}let{colors:Y,distortion:U,swirl:V,grainMixer:K,grainOverlay:$,speed:G}=l.current,te=H-S;S=H,T+=te*G;let Z=Y.map(MT);d.uniform1f(y,T*.001),d.uniform2f(g,u.width,u.height);for(let z=0;z<4;z++){let F=C[z];F&&d.uniform4fv(F,Z[z]??[1,1,1,1])}d.uniform1f(k,Z.length),d.uniform1f(I,U),d.uniform1f(M,V),d.uniform1f(N,K),d.uniform1f(E,$),d.drawArrays(d.TRIANGLES,0,6),P=requestAnimationFrame(R)};A();let W=new ResizeObserver(A);return W.observe(p),P=requestAnimationFrame(R),()=>{cancelAnimationFrame(P),W.disconnect()}},[]),Wh("div",{ref:c,className:e,children:Wh("canvas",{ref:i,className:"h-full w-full","aria-hidden":!0})})}var IT=["#e0eaff","#f9ffbd","#dedede","#ffffff"],ET=["#27272a","#9a9448","#3f3f46","#18181b"];function Xl(e){return e==="dark"?ET:IT}import{useCallback as AT,useState as LT}from"react";import{Play as DT,Square as _T}from"lucide-react";import{jsx as Bs,jsxs as BT}from"react/jsx-runtime";var Kh="mcp-inspector-chat-mesh-animation-paused";function OT(e){try{return localStorage.getItem(e)==="true"}catch{return!1}}function Jh(e){let[t,n]=LT(()=>OT(e)),o=AT(()=>{n(r=>{let s=!r;try{localStorage.setItem(e,s?"true":"false")}catch{}return s})},[e]);return{paused:t,toggle:o}}var zT="z-50 flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border border-zinc-500/60 bg-transparent text-zinc-600 transition-colors hover:border-zinc-500 hover:text-zinc-800 dark:border-zinc-500/50 dark:text-zinc-400 dark:hover:border-zinc-400 dark:hover:text-zinc-200";function Gh({paused:e,onToggle:t,className:n}){return BT(Ie,{children:[Bs(Re,{render:Bs("button",{type:"button",onClick:t,"aria-label":e?"Resume animation":"Pause animation",className:w(zT,n),children:e?Bs(DT,{className:"ml-px h-3 w-3",fill:"currentColor"}):Bs(_T,{className:"h-2.5 w-2.5",fill:"currentColor"})}),nativeButton:!0}),Bs(Me,{side:"left",children:Bs("p",{children:e?"Resume animation":"Pause animation"})})]})}import{jsx as Ya,jsxs as Qh}from"react/jsx-runtime";var FT=.54,$T=.4,Xh="linear-gradient(to top, black 0%, black 12%, rgba(0,0,0,0.55) 38%, transparent 100%)";function Zh({className:e,children:t,shaderPhase:n="hidden",onShaderFadeComplete:o,meshAnimationPaused:r=!1,...s}){let a=HT(null),[i,c]=UT(!1),{resolvedTheme:l}=go(),u=Xl(l),p=l==="dark",{paused:d,toggle:h}=Jh(Kh),m=d||r;Yh(()=>{let x=window.requestAnimationFrame(()=>c(!0));return()=>window.cancelAnimationFrame(x)},[]),Yh(()=>{n==="fading"&&!i&&o?.()},[n,i,o]);let b=n!=="hidden",f=n==="visible"&&i,v=x=>{x.propertyName==="opacity"&&n==="fading"&&o?.()};return Qh("div",{ref:a,className:w("relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",e),...s,children:[b&&Ya("div",{className:w("pointer-events-none absolute inset-x-0 bottom-0 z-0 transition-opacity duration-500",f?"opacity-100":"opacity-0"),style:{height:`${FT*100}%`},"aria-hidden":!0,onTransitionEnd:v,children:Qh("div",{className:w("absolute inset-0",i?p?"opacity-90":"opacity-75":"opacity-0"),style:{maskImage:Xh,WebkitMaskImage:Xh},children:[Ya("div",{className:"absolute inset-0 bg-[#edf2ff] dark:hidden"}),Ya(Yl,{className:"absolute inset-0 h-full w-full",colors:[...u],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:p?.12:.3,speed:m?0:$T})]})}),b&&Ya(Gh,{paused:d,onToggle:h,className:"absolute bottom-3 right-3 sm:bottom-5 sm:right-5"}),Ya("div",{className:"relative z-10 flex min-h-0 flex-1 flex-col",children:t})]})}function ev(e){return e?e.apiKey==="server-managed"||e.baseUrl?.includes("/inspector/llm")===!0:!1}function Xa(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("failed to fetch")||t.includes("networkerror")||t.includes("network request failed")||t.includes("load failed")}function Lu(e,t){if(!t)return e>=502&&e<=504?{kind:"cloud_unavailable"}:null;if(e===402)return{kind:"credits_exhausted",billingUrl:typeof t.upgradeUrl=="string"?t.upgradeUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(e===429){if(t.loginRequired&&t.loginUrl)return{kind:"login_required",loginUrl:String(t.loginUrl)};if(t.creditsExhausted)return{kind:"credits_exhausted",billingUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(t.error==="free_org_rate_limited"||typeof t.reason=="string")return{kind:"credits_exhausted",message:typeof t.message=="string"?t.message:"You've reached your included chat quota for this workspace."}}return e>=502&&e<=504?{kind:"cloud_unavailable"}:null}function VT(e){let t=e.match(/^OpenAI request failed \((\d+) /);if(!t)return null;let n=Number(t[1]),o=e.indexOf("{");if(o===-1)return null;try{let r=JSON.parse(e.slice(o));if(r&&typeof r=="object"&&!Array.isArray(r))return{status:n,body:r}}catch{}return null}function tv(e){if(e instanceof Error&&e.name==="LlmRequestError"){let t=e.status??0,n=e.body,o=n&&typeof n=="object"&&!Array.isArray(n)?n:void 0;return Lu(t,o)}if(e instanceof Error){let t=VT(e.message);if(t)return Lu(t.status,t.body)}return Xa(e)?{kind:"cloud_unavailable"}:null}function nv(e,t){return Lu(e,t)}import{useCallback as Ql,useEffect as jT,useSyncExternalStore as qT}from"react";var Hu="openid profile email offline_access",rv="mcp-inspector:manufact-auth",WT="manufact:session-changed",Qa={loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null},Zr=new Map,zu=new Set,Du=new Map,_u=new Map,sv=null,Ou=!1;typeof window<"u"&&window.addEventListener("message",e=>{if(e.data?.type!=="manufact:invalidate-oauth-client")return;for(let n of Zr.keys())Gn()?.removeItem(Pn(n,"client"));let t=sv;!t||Ou||(Ou=!0,uv(t,{isRetry:!0}).finally(()=>{Ou=!1}))});function KT(e){let t=Zr.get(e);if(t)return t;let n={...Qa,loaded:!1};return Zr.set(e,n),n}function Gn(){return typeof window>"u"?null:window.localStorage}function tc(e){return new URL(e).origin}function JT(e,t){let n=new URL(e),o=new URL(t),r=new Set(["localhost","127.0.0.1"]);return r.has(n.hostname)&&r.has(o.hostname)?n.origin===o.origin:(n.hostname==="manufact.com"||n.hostname.endsWith(".manufact.com"))&&(o.hostname==="manufact.com"||o.hostname.endsWith(".manufact.com"))}function av(e){let t=window.__MANUFACT_LOGIN_URL__;if(t)return new URL(t).origin;let n=new URL(e);return n.hostname==="localhost"||n.hostname==="127.0.0.1"?`${n.protocol}//${n.hostname}:3000`:`${n.protocol}//manufact.com`}function GT(e){return`${av(e)}/auth/embedded-sign-out`}function Pn(e,t){return`${rv}:${t}:${e}`}function YT(e){return Gn()?.getItem(Pn(e,"skip-session"))==="1"}function ec(e,t){let n=Pn(e,"skip-session");t?Gn()?.setItem(n,"1"):Gn()?.removeItem(n)}function XT(e){return`${rv}:state:${e}`}function Hs(e){let t=Gn()?.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return Gn()?.removeItem(e),null}}function Uu(e,t){Gn()?.setItem(e,JSON.stringify(t))}function xo(e,t){Zr.set(e,{...Zr.get(e)??Qa,...t}),zu.forEach(n=>n()),window.dispatchEvent(new CustomEvent(WT))}function iv(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Bu(e=32){let t=new Uint8Array(e);return crypto.getRandomValues(t),iv(t)}async function lv(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return iv(new Uint8Array(t))}async function nc(e){let t=await fetch(`${e}/api/auth/.well-known/openid-configuration`);if(!t.ok)throw new Error("Manufact OAuth discovery failed");return await t.json()}function cv(){return`${window.location.origin}${Yo()}/auth/callback`}function ov(e){return e==="localhost"||e==="127.0.0.1"}function QT(e){try{let t=new URL(e).hostname,n=typeof window<"u"?new URL(window.location.href).hostname:"";return ov(t)&&ov(n)}catch{return!1}}async function ZT(e,t,n){let o=new URL(`${e}/api/auth/oauth2/authorize`);o.searchParams.set("response_type","code"),o.searchParams.set("client_id",t),o.searchParams.set("redirect_uri",n),o.searchParams.set("scope",Hu),o.searchParams.set("code_challenge",await lv(Bu(32))),o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("state","client-probe"),o.searchParams.set("prompt","none");try{let r=await fetch(o.toString(),{method:"GET",redirect:"manual",credentials:"include"}),s=r.headers.get("location")??"";return s.includes("/auth/error")&&s.includes("invalid_client")?!1:r.status>=300&&r.status<400||r.type==="opaqueredirect"?!!s&&!s.includes("/auth/error"):!0}catch{return!1}}async function ek(e,t){let n=cv(),o=Pn(e,"client"),r=Hs(o),s=QT(e);if(!s&&r?.client_id&&r.redirect_uri===n){if(await ZT(e,r.client_id,n))return r;Gn()?.removeItem(o)}else s&&r?.client_id&&Gn()?.removeItem(o);if(!t.registration_endpoint)throw new Error("Manufact OAuth registration is unavailable");let a=await fetch(t.registration_endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"mcp-use Inspector",redirect_uris:[n],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",scope:Hu})});if(!a.ok)throw new Error("Could not register Inspector with Manufact");let i=await a.json();if(!i.client_id)throw new Error("Manufact returned no OAuth client ID");let c={...i,redirect_uri:n};return Uu(o,c),c}async function tk(e,t){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t)}),o=await n.json().catch(()=>({}));if(!n.ok||!o.access_token)throw new Error(o.error_description??"Manufact token exchange failed");return{access_token:o.access_token,refresh_token:o.refresh_token,token_type:o.token_type,expires_at:Date.now()+(o.expires_in??3600)*1e3}}async function nk(e,t){if(!t.refresh_token)return null;let n=_u.get(e);if(n)return n;let o=(async()=>{try{let r=await nc(e),s=Hs(Pn(e,"client"));if(!s?.client_id)return null;let a=await tk(r.token_endpoint,{grant_type:"refresh_token",refresh_token:t.refresh_token,client_id:s.client_id}),i={...a,refresh_token:a.refresh_token??t.refresh_token};return Uu(Pn(e,"tokens"),i),i}catch{return Gn()?.removeItem(Pn(e,"tokens")),null}finally{_u.delete(e)}})();return _u.set(e,o),o}async function ok(e){let t=Hs(Pn(e,"tokens"));return t?.access_token?t.expires_at>Date.now()+3e4?t:nk(e,t):null}async function rk(e,t){let n=await nc(e);if(!n.userinfo_endpoint)return null;let o=await fetch(n.userinfo_endpoint,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok)return null;let r=await o.json();return r.sub?{id:r.sub,name:r.name,email:r.email,image:r.picture}:null}async function dv(e){try{let t=await fetch(`${e}/api/auth/get-session`,{credentials:"include"});return t.ok?(await t.json())?.user??null:null}catch{return null}}async function Zl(e){let t=Du.get(e);if(t)return t;Zr.set(e,{...Zr.get(e)??Qa,loaded:!1});let n=(async()=>{try{let o=typeof window<"u"?window.location.href:e,r=JT(o,e),s=YT(e),a=await ok(e),i=a?await rk(e,a.access_token):null;if(i&&a){ec(e,!1),xo(e,{loaded:!0,accessToken:a.access_token,user:i,mode:"oauth"});return}a&&!i&&Gn()?.removeItem(Pn(e,"tokens"));let c=r&&!s?await dv(e):null;if(c){xo(e,{loaded:!0,accessToken:null,user:c,mode:"session"});return}xo(e,{loaded:!0,accessToken:null,user:null,mode:null})}catch{xo(e,{loaded:!0,accessToken:null,user:null,mode:null})}})().finally(()=>Du.delete(e));return Du.set(e,n),n}async function uv(e,t){let n=tc(e);sv=e,ec(n,!1);let o=window.open("","manufact-oauth","width=600,height=700,resizable=yes,scrollbars=yes");if(!o)throw new Error("Allow popups to sign in with Manufact");xo(n,{authorizing:!0});try{let r=await nc(n),s=await ek(n,r),a=Bu(64),i=Bu(),c=cv();Uu(XT(i),{authOrigin:n,clientId:s.client_id,redirectUri:c,codeVerifier:a,expiresAt:Date.now()+600*1e3});let l=new URL(r.authorization_endpoint);l.searchParams.set("response_type","code"),l.searchParams.set("client_id",s.client_id),l.searchParams.set("redirect_uri",c),l.searchParams.set("scope",Hu),l.searchParams.set("state",i),l.searchParams.set("code_challenge",await lv(a)),l.searchParams.set("code_challenge_method","S256"),l.searchParams.set("prompt","consent"),o.location.href=l.toString();let u=window.setInterval(()=>{o.closed&&(window.clearInterval(u),Zl(n).finally(()=>xo(n,{authorizing:!1})))},500)}catch(r){throw o.close(),xo(n,{authorizing:!1}),r}}function sk(e){let t=tc(e);Gn()?.removeItem(Pn(t,"tokens")),xo(t,{loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null})}async function ak(e){let t=Hs(Pn(e,"tokens")),n=Hs(Pn(e,"client")),o=t?.refresh_token??t?.access_token;if(!n?.client_id||!o)return null;try{let s=(await nc(e)).revocation_endpoint??`${e}/api/auth/oauth2/revoke`;return(await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:n.client_id,token:o,token_type_hint:t?.refresh_token?"refresh_token":"access_token"})})).status}catch{return-1}}async function ik(e){let t=av(e),n=window.open(GT(e),"manufact-sign-out","width=420,height=320");return n?new Promise(o=>{let r=!1,s=l=>{r||(r=!0,window.clearTimeout(a),window.clearInterval(c),window.removeEventListener("message",i),o(l))},a=window.setTimeout(()=>{s({attempted:!0,signOutOk:!1,signOutStatus:null})},3e4),i=l=>{l.origin===t&&l.data?.type==="manufact:sign-out-complete"&&s({attempted:!0,signOutOk:!0,signOutStatus:200})},c=window.setInterval(()=>{n.closed&&dv(e).then(l=>{s({attempted:!0,signOutOk:!l,signOutStatus:l?401:200})})},500);window.addEventListener("message",i)}):{attempted:!0,signOutOk:!1,signOutStatus:null}}async function lk(e,t){let n=tc(e),o=!!Hs(Pn(n,"tokens"))?.access_token;t==="oauth"||o?(await ak(n),ec(n,!0)):t==="session"&&(await ik(n),ec(n,!1)),sk(e)}function mv(e){let t=e?tc(e):null,n=Ql(s=>(zu.add(s),()=>zu.delete(s)),[]),o=Ql(()=>t?KT(t):Qa,[t]),r=qT(n,o,()=>Qa);return jT(()=>{if(!t)return;Zl(t);let s=i=>{i.origin===window.location.origin&&i.data?.type==="manufact:oauth-complete"&&i.data.authOrigin===t&&Zl(t).finally(()=>xo(t,{authorizing:!1}))},a=i=>{i.key!==Pn(t,"tokens")||!i.newValue||Zl(t).finally(()=>xo(t,{authorizing:!1}))};return window.addEventListener("message",s),window.addEventListener("storage",a),()=>{window.removeEventListener("message",s),window.removeEventListener("storage",a)}},[t]),{...r,authorize:Ql(async()=>{e&&await uv(e)},[e]),logout:Ql(async()=>{e&&await lk(e,r.mode)},[e,r.mode])}}function pv(e){return mv(e)}import{useEffect as ck}from"react";function fv(e){ck(()=>{let t=n=>{let o=n.target,r=o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.contentEditable==="true";if((n.metaKey||n.ctrlKey)&&n.key==="k"){n.preventDefault(),e.onCommandPalette?.();return}if((n.metaKey||n.ctrlKey)&&n.key==="o"&&e.onNewChat){n.preventDefault(),e.onNewChat();return}if(n.key==="Escape"){n.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.onBlurSearch?.();return}if(!r&&!(n.metaKey||n.ctrlKey||n.altKey||n.shiftKey))switch(n.key.toLowerCase()){case"t":n.preventDefault(),e.onToolsTab?.();break;case"p":n.preventDefault(),e.onPromptsTab?.();break;case"r":n.preventDefault(),e.onResourcesTab?.();break;case"c":n.preventDefault(),e.onChatTab?.();break;case"h":n.preventDefault(),e.onHome?.();break;case"f":n.preventDefault(),e.onFocusSearch?.();break;default:break}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}import{Copy as Wk,Download as Kk,SquarePen as Jk}from"lucide-react";import{Check as Sv,ChevronsUpDown as Nv,Eye as Pk,EyeOff as Rk,Key as Mk,Loader2 as Tv}from"lucide-react";import{useEffect as Yu,useRef as Ik,useState as ts}from"react";import{Tabs as Vu}from"@base-ui/react/tabs";import{AnimatePresence as ju,motion as oc}from"motion/react";import{createContext as pk,forwardRef as Ku,useCallback as $u,useContext as fk,useEffect as qu,useRef as rc,useState as gk}from"react";import{useCallback as Us,useEffect as Fu,useRef as Fs,useState as gv}from"react";function hv(e,t){let n=e.getBoundingClientRect(),o=t==="x"?e.offsetWidth:e.offsetHeight,r=t==="x"?n.width:n.height;return o>0?r/o:1}function dk(e,t){let n=e.getBoundingClientRect(),o=hv(e,"x"),r=hv(e,"y"),s=[];return t.forEach((a,i)=>{let c=a.getBoundingClientRect();s[i]={top:(c.top-n.top)/r+e.scrollTop,left:(c.left-n.left)/o+e.scrollLeft,width:a.offsetWidth,height:a.offsetHeight}}),s}function uk(e,t,n,o){let r=o==="x"?t:n,s=null,a=1/0,i=null;return e.forEach((c,l)=>{let u=c.getBoundingClientRect(),p=o==="x"?u.left:u.top,d=o==="x"?u.right:u.bottom;r>=p&&r<=d&&(i=l);let h=(p+d)/2,m=Math.abs(r-h);m<a&&(a=m,s=l)}),i??s}function mk(e,t){if(e.length!==t.length)return!0;for(let n=0;n<t.length;n++){let o=e[n],r=t[n];if(o!==r&&(!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height))return!0}return!1}function vv(e,t={}){let{axis:n="y"}=t,o=Fs(new Map),[r,s]=gv(null),[a,i]=gv([]),c=Fs([]),l=Fs(0),u=Fs(null),p=Fs(null),d=Fs(null),h=Us(()=>{let y=e.current;if(!y)return;let g=dk(y,o.current);mk(c.current,g)&&(c.current=g,i(g))},[e]),m=Us((y,g)=>{s(uk(o.current,y,g,n))},[n]),b=Us((y,g)=>{g?o.current.set(y,g):o.current.delete(y),p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,h()})},[h]),f=Us(y=>{d.current={x:y.clientX,y:y.clientY},u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null,h(),m(y.clientX,y.clientY)})},[h,m]),v=Us(()=>{l.current+=1},[]),x=Us(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),d.current=null,s(null)},[]);return Fu(()=>{let y=e.current;if(!y||typeof ResizeObserver>"u")return;let g=new ResizeObserver(()=>{p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,h()})});return g.observe(y),()=>g.disconnect()},[e,h]),Fu(()=>{let y=e.current;if(!y)return;let g=()=>{h();let C=d.current;C&&m(C.x,C.y)};return y.addEventListener("scroll",g,{capture:!0,passive:!0}),()=>y.removeEventListener("scroll",g,{capture:!0})},[e,h,m]),Fu(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),p.current!==null&&cancelAnimationFrame(p.current)},[]),{activeIndex:r,setActiveIndex:s,itemRects:a,sessionRef:l,handlers:{onMouseMove:f,onMouseEnter:v,onMouseLeave:x},registerItem:b,measureItems:h}}import{jsx as On,jsxs as Wu}from"react/jsx-runtime";var bv=pk(null);function hk(){let e=fk(bv);if(!e)throw new Error("useTabsSubtle must be used within a TabsSubtle");return e}var Za=Ku(({children:e,selectedIndex:t,onSelect:n,idPrefix:o,activeLabel:r=!1,className:s,...a},i)=>{let c=rc(null),l=rc(!1),u=kt(),{activeIndex:p,setActiveIndex:d,itemRects:h,handlers:m,registerItem:b,measureItems:f}=vv(c,{axis:"x"}),v=rc(new Map),x=$u((S,P)=>{b(S,P),P?v.current.set(S,P):v.current.delete(S)},[b]);qu(()=>{f()},[f,e]),qu(()=>{let S=v.current;if(S.size===0)return;let P=new ResizeObserver(()=>f());return S.forEach(A=>P.observe(A)),()=>P.disconnect()},[f,e]);let y=$u(S=>{l.current=!0,m.onMouseMove(S)},[m]),g=$u(()=>{l.current=!1,m.onMouseLeave()},[m]),[C,k]=gk(null),I=h[t],M=p!==null?h[p]:null,N=C!==null?h[C]:null,E=p===t,T=p!==null&&!E;return On(bv.Provider,{value:{registerTab:x,hoveredIndex:p,selectedIndex:t,idPrefix:o,activeLabel:r},children:On(Vu.Root,{value:t,onValueChange:S=>{typeof S=="number"&&n(S)},render:Wu(Vu.List,{activateOnFocus:!1,ref:S=>{c.current=S,typeof i=="function"?i(S):i&&(i.current=S)},onMouseMove:y,onMouseLeave:g,onFocus:S=>{let P=S.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(P!=null){let A=Number(P);d(A),k(S.target.matches(":focus-visible")?A:null)}},onBlur:S=>{c.current?.contains(S.relatedTarget)||(k(null),!l.current&&d(null))},className:w("relative flex items-center gap-0.5 select-none overflow-x-auto max-w-full -mx-1 px-1 -my-1 py-1",s),...a,children:[I&&On(oc.div,{className:w("absolute bg-accent pointer-events-none",u.bg),initial:!1,animate:{left:I.left,width:I.width,top:I.top,height:I.height,opacity:T?.8:1},transition:{...ce.moderate,opacity:{duration:.08}}}),On(ju,{children:M&&!E&&I&&On(oc.div,{className:w("absolute bg-accent pointer-events-none",u.bg),initial:{left:I.left,width:I.width,top:I.top,height:I.height,opacity:0},animate:{left:M.left,width:M.width,top:M.top,height:M.height,opacity:.4},exit:!l.current&&I?{left:I.left,width:I.width,top:I.top,height:I.height,opacity:0,transition:{...ce.moderate,opacity:{duration:.06}}}:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}})}),On(ju,{children:N&&On(oc.div,{className:w("absolute pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]",u.focusRing),initial:!1,animate:{left:N.left-2,top:N.top-2,width:N.width+4,height:N.height+4},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}})}),e]})})})});Za.displayName="TabsSubtle";var es=Ku(({icon:e,label:t,index:n,className:o,...r},s)=>{let a=rc(null),i=kt(),{registerTab:c,hoveredIndex:l,selectedIndex:u,idPrefix:p,activeLabel:d}=hk();qu(()=>(c(n,a.current),()=>c(n,null)),[n,c]);let h=u===n,m=l===n||h,b=d&&!!e,f=!b||h,v=Wu("span",{className:"inline-grid",children:[On("span",{className:"col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic]",style:{fontVariationSettings:At.semibold},"aria-hidden":"true",children:t}),On("span",{className:w("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]",m?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:h?At.semibold:At.normal},children:t})]});return Wu(Vu.Tab,{ref:x=>{let y=x;a.current=y,typeof s=="function"?s(y):s&&(s.current=y)},value:n,"data-proximity-index":n,id:p?`${p}-tab-${n}`:void 0,"aria-controls":p?`${p}-panel-${n}`:void 0,"aria-label":b&&!f?t:void 0,className:w("relative z-10 flex items-center px-2 cursor-pointer bg-transparent border-none outline-none text-xs",b?"h-7":"h-7 gap-1.5",i.bg,o),...r,children:[e&&On(e,{size:14,strokeWidth:m?2:1.5,className:w("shrink-0 transition-[color,stroke-width] duration-80",m?"text-foreground":"text-muted-foreground")}),b?On(ju,{children:f&&On(oc.span,{className:"overflow-hidden",initial:{width:0,opacity:0,marginLeft:0},animate:{width:"auto",opacity:1,marginLeft:6},exit:{width:0,opacity:0,marginLeft:0},transition:{...ce.fast,opacity:{duration:.06}},children:v},"label")}):v]})});es.displayName="TabsSubtleItem";var vk=Ku(({index:e,selectedIndex:t,idPrefix:n,children:o,className:r,...s},a)=>{let i=t===e;return On("div",{ref:a,id:`${n}-panel-${e}`,role:"tabpanel","aria-labelledby":`${n}-tab-${e}`,hidden:!i,tabIndex:-1,className:w("outline-none",r),...s,children:i&&o})});vk.displayName="TabsSubtlePanel";import*as Ut from"react";import{jsx as hr,jsxs as yk}from"react/jsx-runtime";var yv=Ut.createContext(null);function Ju(){let e=Ut.useContext(yv);if(!e)throw new Error("Command components must be used within <Command>");return e}function bk(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}var sc=Ut.forwardRef(({className:e,...t},n)=>{let[o,r]=Ut.useState(""),[s,a]=Ut.useState(null),[i,c]=Ut.useState(0),l=Ut.useCallback(()=>(c(u=>u+1),()=>c(u=>Math.max(0,u-1))),[]);return hr(yv.Provider,{value:{search:o,setSearch:r,activeValue:s,setActiveValue:a,visibleCount:i,registerVisible:l},children:hr("div",{ref:n,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})})});sc.displayName="Command";var ac=Ut.forwardRef(({className:e,...t},n)=>{let{search:o,setSearch:r}=Ju();return hr("div",{className:"flex items-center border-b px-3",children:hr("input",{ref:n,value:o,onChange:s=>r(s.target.value),className:w("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})})});ac.displayName="CommandInput";var ic=Ut.forwardRef(({className:e,...t},n)=>hr("div",{ref:n,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ic.displayName="CommandList";var lc=Ut.forwardRef(({className:e,...t},n)=>{let{visibleCount:o}=Ju();return o>0?null:hr("div",{ref:n,className:w("py-6 text-center text-sm",e),...t})});lc.displayName="CommandEmpty";var cc=Ut.forwardRef(({className:e,heading:t,children:n,...o},r)=>yk("div",{ref:r,className:w("overflow-hidden p-1 text-foreground [&_[data-command-group-heading]]:px-2 [&_[data-command-group-heading]]:py-1.5 [&_[data-command-group-heading]]:text-xs [&_[data-command-group-heading]]:font-medium [&_[data-command-group-heading]]:text-muted-foreground",e),...o,children:[t?hr("div",{"data-command-group-heading":"",children:t}):null,n]}));cc.displayName="CommandGroup";var dc=Ut.forwardRef(({className:e,value:t,keywords:n,onSelect:o,disabled:r,onClick:s,...a},i)=>{let{search:c,activeValue:l,setActiveValue:u,registerVisible:p}=Ju(),d=Array.isArray(n)?n.join(" "):n,h=d?`${t} ${d}`:t,m=bk(h,c),b=l===t;return Ut.useLayoutEffect(()=>{if(m)return p()},[m,p]),Ut.useEffect(()=>{m&&l===null&&!r&&u(t)},[m,l,r,u,t]),m?hr("div",{ref:i,role:"option","aria-selected":b,"data-selected":b,"data-disabled":r,className:w("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),onMouseEnter:()=>!r&&u(t),onClick:f=>{s?.(f),r||o?.(t)},...a}):null});dc.displayName="CommandItem";import{buildOllamaApiUrl as Ek,normalizeOllamaBaseUrl as Ak,OllamaCorsError as Lk}from"@mcp-use/agent";import{ChevronDown as xk,Key as wk}from"lucide-react";import{jsx as Yn,jsxs as Gu}from"react/jsx-runtime";var Ck="https://cdn.mcp-use.com/mcpuse_logo_circle_dark.svg";function xv({symbolSize:e=14,className:t,textClassName:n}){return Gu("span",{className:w("inline-flex items-center gap-1.5 text-black dark:text-white",t),children:[Yn(Sk,{size:e}),Yn("span",{className:w("font-medium leading-none text-current [font-family:var(--font-family-outfit)]",n),children:"Manufact"})]})}function Sk({size:e=14,className:t}){return Gu("svg",{width:e,height:e,viewBox:"0 0 480 480","aria-hidden":!0,className:w("block shrink-0",t),children:[Yn("path",{d:"M101.7 0 C157.9 0 203.4 45.7 203.4 102.1 C203.4 126.6 202.1 152.1 212.2 174.3 L219.8 191 C233.8 221.8 258.5 246.4 289.2 260.5 L303.5 267 C326.5 277.5 353 275.8 378.3 275.8 C434.5 275.8 480 321.5 480 377.9 C480 434.3 434.5 480 378.3 480 C322.1 480 276.6 434.3 276.6 377.9 C276.6 354.2 277.7 329.6 267.8 308 L259.8 290.3 C245.7 259.5 221 234.8 190.2 220.7 L173 212.9 C151 202.9 125.8 204.2 101.7 204.2 C45.5 204.2 0 158.5 0 102.1 C0 45.7 45.5 0 101.7 0 Z",fill:"currentColor"}),Yn("circle",{cx:"96.4",cy:"383.6",r:"96.4",fill:"currentColor"}),Yn("circle",{cx:"383.6",cy:"96.4",r:"96.4",fill:"currentColor"})]})}var Nk='<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" fill="#94A3B8" stroke="#94A3B8"><g><path fill="none" d="M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945" stroke-width="90"/><path d="M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"/><path fill="none" d="M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377" stroke-width="90"/><path d="M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"/></g></svg>',Tk=`data:image/svg+xml,${encodeURIComponent(Nk)}`,wv={openai:"OpenAI",anthropic:"Anthropic",google:"Google",deepseek:"DeepSeek","z-ai":"Z.AI",nvidia:"NVIDIA",minimax:"MiniMax",moonshotai:"Moonshot AI",inclusionai:"InclusionAI","nex-agi":"Nex AGI","x-ai":"xAI",thinkingmachines:"Thinking Machines",mistralai:"Mistral AI",stepfun:"StepFun","aion-labs":"Aion Labs","bytedance-seed":"ByteDance Seed","ibm-granite":"IBM Granite","arcee-ai":"Arcee AI",rekaai:"Reka AI",kwaipilot:"KwaiPilot"};function uc(e,t){let n=e.trim(),o=wv[t];if(o){let s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`^${s}\\s*:\\s*`,"i"),i=n.replace(a,"").trim();if(i.length>0)return i}let r=n.indexOf(": ");return r>0&&r<48?n.slice(r+2).trim():n}function Cv({provider:e,model:t,displayName:n,managedModel:o,mode:r="byok",className:s,...a}){let i=r==="managed"?o:null,c=i?uc(i.name,i.provider):n??t,l=i?i.provider:r==="managed"&&e==="openai-compatible"&&t.split("/")[0]||e;return Gu("button",{type:"button",className:w("inline-flex items-center gap-1.5 min-w-0 border-0 bg-transparent p-1","font-mono text-[11px] text-muted-foreground cursor-pointer","hover:text-foreground transition-colors","rounded-md outline-none focus-visible:ring-1 focus-visible:ring-ring",s),...a,children:[r==="managed"?Yn("img",{src:Ck,alt:"Manufact",className:"h-3.5 w-3.5 shrink-0 rounded-full object-cover"}):Yn(wk,{className:"size-3 shrink-0 opacity-70","aria-hidden":!0}),Yn(so,{provider:l,className:"shrink-0"}),Yn("span",{className:"whitespace-nowrap",children:c}),Yn(xk,{className:"size-3 shrink-0 opacity-60","aria-hidden":!0})]})}function qt(e){let t=wv[e];if(t)return t;switch(e){case"openai":return"OpenAI";case"openai-compatible":return"OpenAI Compatible";case"anthropic":return"Anthropic";case"google":return"Google";case"openrouter":return"OpenRouter";case"ollama":return"Ollama";default:return e.split(/[-_]/).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}}function kk(e,t){switch(e){case"openai":case"anthropic":case"google":return ma(`${e}.png`);case"ollama":return ma(`${t==="dark"?"ollama_dark":"ollama_light"}.png`);case"openrouter":return Tk;case"openai-compatible":return null;default:return null}}function so({provider:e,className:t}){let{resolvedTheme:n}=go();if(e==="openai-compatible")return null;let o=kk(e,n);if(o){let r=e==="ollama"?"h-3.5 w-3.5 object-contain":"h-4 w-4 rounded-full object-cover";return Yn("img",{src:o,alt:qt(e),className:w(r,t)})}return Yn("div",{"aria-label":qt(e),className:w("flex h-4 w-4 items-center justify-center rounded-full bg-neutral-900 text-[9px] font-semibold text-white dark:bg-neutral-100 dark:text-neutral-900",t),children:qt(e).charAt(0)})}import{Fragment as qk,jsx as ee,jsxs as $e}from"react/jsx-runtime";var Xu="mcp-inspector-models-cache",Dk=1440*60*1e3;function Pv(){try{let e=localStorage.getItem(Xu);if(e)return JSON.parse(e)}catch(e){console.error("Failed to load models cache:",e)}return{}}function _k(e,t){try{let n=Pv();n[e]={models:t,timestamp:Date.now()},localStorage.setItem(Xu,JSON.stringify(n))}catch(n){console.error("Failed to save models cache:",n)}}function Ok(e){try{let t=Pv(),n=t[e];if(n){if(Date.now()-n.timestamp<Dk)return n.models;delete t[e],localStorage.setItem(Xu,JSON.stringify(t))}}catch(t){console.error("Failed to get cached models:",t)}return null}function zk(e,t){if(!_o(e)||!t?.trim())return e;let n=e==="ollama"?Ak(t):t.trim().toLowerCase();return`${e}:${n}`}var Bk="chat-config-source",kv=["openai","anthropic","google"];async function Hk(e,t){let n={};t&&(n.Authorization=`Bearer ${t}`);let o;try{o=await fetch(`${e}/models`,{headers:n})}catch{throw new Error("Failed to reach the server. Check the URL is correct and that CORS is enabled on the server.")}if(!o.ok)throw new Error(`Failed to fetch models: ${o.statusText}`);if(!(o.headers.get("content-type")??"").includes("application/json"))throw new Error("Invalid URL \u2014 response was not JSON");let s=await o.json();if(!Array.isArray(s?.data))throw new Error("Unexpected response format \u2014 expected { data: [...] } from the OpenAI-compatible endpoint");return s.data.map(a=>({id:a.id}))}async function Uk(e){let t=await fetch("https://api.openai.com/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenAI models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id}))}async function Fk(e){let t=await fetch("https://api.anthropic.com/v1/models",{headers:{"x-api-key":e,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"}});if(!t.ok)throw new Error(`Failed to fetch Anthropic models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.display_name}))}async function $k(e){let t=await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${e}`);if(!t.ok)throw new Error(`Failed to fetch Google models: ${t.statusText}`);return((await t.json()).models||[]).map(o=>({id:o.name,displayName:o.displayName}))}async function Vk(e){let t=await fetch("https://openrouter.ai/api/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenRouter models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.name}))}async function jk(e,t){let n;try{n=await fetch(Ek(e,"/api/tags"),{headers:{...t.trim()?{Authorization:`Bearer ${t.trim()}`}:{}}})}catch(r){throw new Lk(r)}if(!n.ok)throw new Error(`Failed to fetch Ollama models: ${n.statusText}`);return((await n.json()).models||[]).map(r=>({id:r.model||r.name||""}))}function ei({open:e,onOpenChange:t,tempProvider:n,tempModel:o,tempApiKey:r,tempBaseUrl:s,onProviderChange:a,onModelChange:i,onApiKeyChange:c,onBaseUrlChange:l,onSave:u,onClear:p,showClearButton:d=!1,buttonLabel:h="Configure API Key",hostedInspector:m=!1,freeTierInfo:b,managedCloudInfo:f,useManagedCloud:v=!1,onSaveManagedCloud:x}){let{resolvedTheme:y}=go(),g=Xl(y),C=y==="dark",[k,I]=ts([]),[M,N]=ts(!1),[E,T]=ts(null),[S,P]=ts(!1),[A,R]=ts(!1),[W,H]=ts(!1),[Y,U]=ts(v?0:1),V=zk(n,s),K=!!(m||b||f),$=!!(f&&Y===0);Yu(()=>{e&&U(v?0:1)},[e,v]),Yu(()=>{let D=Kr(n),_=_o(n);if($||!e||!n||D&&!r.trim()||_&&!s.trim()){I([]),T(null);return}let Le=setTimeout(async()=>{let Oe=Ok(V);if(Oe){I(Oe),T(null);return}N(!0),T(null);try{let He=[];n==="openai-compatible"?He=await Hk(s,r):n==="openai"?He=await Uk(r):n==="anthropic"?He=await Fk(r):n==="google"?He=await $k(r):n==="openrouter"?He=await Vk(r):n==="ollama"&&(He=await jk(s,r)),_k(V,He),I(He)}catch(He){T(He instanceof Error?He.message:"Failed to fetch models. Please check your API key."),I([])}finally{N(!1)}},500);return()=>clearTimeout(Le)},[r,s,n,e,V,$]);let G=Ik(null);Yu(()=>{if(!e||$){e||(G.current=null);return}let D=G.current;D!==null&&D!==n&&i(""),G.current=n},[n,e,i,$]);let te=_o(n),Z=!Kr(n),z=e&&(!Kr(n)||!!r.trim())&&(!te||!!s.trim()),F=Z?"API Key (optional)":"API Key",ie=Z?n==="ollama"?"Leave empty for local Ollama":"Enter your API key (optional)":"Enter your API key",le=n==="openai-compatible"?"http://localhost:11434/v1":dr(n),Ne=n==="openai-compatible"?"Base URL of your OpenAI-compatible API. Local servers must have CORS enabled.":null,de=n==="ollama"?"Optional for local Ollama. Stored locally and never sent to our servers.":"Your API key is stored locally and never sent to our servers.",re=f?f.models.reduce((D,_)=>(D[_.provider]||(D[_.provider]=[]),D[_.provider].push(_),D),{}):{},me=f?.models.find(D=>D.id===f.selectedModelId),be=kv.filter(D=>re[D]?.length),pe=me?.provider??be[0]??"",We=!!me&&!kv.includes(me.provider),Ke=pe?re[pe]??[]:[],Ve=!!p&&d&&(!f||Y===1),pt=()=>{if($&&x){x();return}u()},lt=$?!!(f?.isLoading||!f?.selectedModelId||f?.models.length===0):Kr(n)&&!r.trim()||te&&!s.trim()||!o.trim();return ee(on,{open:e,onOpenChange:t,children:$e(Xt,{className:"max-w-md","data-testid":"chat-config-dialog",children:[$e(Gt,{children:[ee($t,{children:K?"Configure Chat":"LLM Provider Configuration"}),ee(To,{children:f?"Pick a Manufact cloud model or bring your own API key.":b?"Chat requires an LLM. You can chat for free if you have a Manufact account, or you can use your own API key (not sent to Manufact).":"Configure your LLM provider and API key to start chatting with the MCP server"})]}),$e("div",{className:"space-y-4",children:[b&&$e("button",{type:"button",onClick:b.onLoginClick,"data-testid":"chat-config-sign-in-card",className:"relative w-full cursor-pointer overflow-hidden rounded-2xl border-0 text-left transition-opacity hover:opacity-95 active:opacity-90",children:[ee("div",{className:"absolute inset-0 bg-[#edf2ff] dark:bg-background","aria-hidden":!0}),ee("div",{className:"absolute inset-0 dark:opacity-90",children:ee(Yl,{className:"absolute inset-0 h-full w-full",colors:[...g],grainOverlay:C?.1:.15})}),$e("div",{className:"relative flex items-center justify-between gap-4 px-4 py-3.5",children:[$e("div",{className:"text-sm font-medium text-foreground",children:[ee("p",{children:"Chat for free with a"}),$e("p",{className:"mt-1 flex items-center gap-1.5",children:[ee(xv,{symbolSize:14,textClassName:"text-sm"}),"account"]})]}),ee(L,{size:"sm",render:ee("span",{"aria-hidden":"true"}),nativeButton:!1,tabIndex:-1,className:"pointer-events-none shrink-0",children:"Sign in"})]})]}),f&&ee("div",{className:"flex justify-center",children:$e(Za,{selectedIndex:Y,onSelect:U,idPrefix:Bk,className:"w-fit",children:[ee(es,{index:0,label:"Manufact cloud"}),ee(es,{index:1,label:"API key"})]})}),$e("div",{className:w("space-y-2",f&&"!mt-2"),children:[ee(Be,{children:"Provider"}),$?$e(un,{value:pe,onValueChange:D=>{let _=f?.models.find(j=>j.provider===D);_&&f?.onModelChange(_.id)},children:[ee(hn,{className:"rounded-md",leading:pe?ee(so,{provider:pe,className:"shrink-0"}):void 0,children:ee(fn,{})}),$e(gn,{children:[We&&$e(ht,{value:pe,label:qt(pe),disabled:!0,children:[qt(pe)," (current)"]}),be.map(D=>ee(ht,{value:D,label:qt(D),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:D}),ee("span",{children:qt(D)})]})},D))]})]}):$e(un,{value:n,onValueChange:D=>a(D),children:[ee(hn,{className:"rounded-md",leading:ee(so,{provider:n,className:"shrink-0"}),children:ee(fn,{})}),$e(gn,{children:[ee(ht,{value:"openai",label:qt("openai"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"openai"}),ee("span",{children:qt("openai")})]})}),ee(ht,{value:"anthropic",label:qt("anthropic"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"anthropic"}),ee("span",{children:qt("anthropic")})]})}),ee(ht,{value:"google",label:qt("google"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"google"}),ee("span",{children:qt("google")})]})}),ee(ht,{value:"ollama",label:qt("ollama"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"ollama"}),ee("span",{children:qt("ollama")})]})}),ee(ht,{value:"openrouter",label:qt("openrouter"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"openrouter"}),ee("span",{children:qt("openrouter")})]})}),ee(ht,{value:"openai-compatible",label:qt("openai-compatible"),children:ee("div",{className:"flex items-center gap-2",children:ee("span",{children:qt("openai-compatible")})})})]})]})]}),!$&&te&&$e("div",{className:"space-y-2",children:[ee(Be,{children:"Base URL"}),ee(Ae,{value:s,onChange:D=>l(D.target.value),placeholder:le,"data-testid":"chat-config-base-url-input"}),Ne&&ee("p",{className:"text-xs text-muted-foreground",children:Ne})]}),!$&&$e("div",{className:"space-y-2",children:[ee(Be,{children:F}),$e("div",{className:"relative",children:[ee(Ae,{type:W?"text":"password",value:r,onChange:D=>c(D.target.value),placeholder:ie,className:"pr-10","data-testid":"chat-config-api-key-input"}),ee(L,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>H(!W),children:W?ee(Rk,{className:"h-4 w-4 text-muted-foreground"}):ee(Pk,{className:"h-4 w-4 text-muted-foreground"})})]}),ee("p",{className:"text-xs text-muted-foreground",children:de})]}),$?$e("div",{className:"space-y-2",children:[ee(Be,{children:"Model"}),f?.isLoading?$e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[ee(Tv,{className:"h-4 w-4 animate-spin"}),ee("span",{children:"Loading models\u2026"})]}):Ke.length>0?$e(rr,{open:A,modal:!0,onOpenChange:R,children:[ee(sr,{render:$e(L,{variant:"outline",role:"combobox","aria-expanded":A,className:"w-full justify-between rounded-md","data-testid":"chat-config-cloud-model-select",disabled:We,children:[ee("span",{className:"inline-flex min-w-0 items-center gap-2 truncate",children:me?$e(qk,{children:[ee(so,{provider:me.provider,className:"shrink-0"}),ee("span",{className:"truncate",children:uc(me.name,me.provider)})]}):"Select a model\u2026"}),ee(Nv,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),ee(ar,{className:"w-full p-0",align:"start",children:$e(sc,{children:[ee(ac,{placeholder:"Search models\u2026",className:"h-9"}),$e(ic,{children:[ee(lc,{children:"No model found."}),ee(cc,{children:Ke.map(D=>$e(dc,{value:D.id,keywords:[D.name,D.id,D.provider],onSelect:_=>{f?.onModelChange(_),R(!1)},children:[uc(D.name,D.provider),ee(Sv,{className:w("ml-auto h-4 w-4",f?.selectedModelId===D.id?"opacity-100":"opacity-0")})]},D.id))})]})]})})]}):ee("p",{className:"text-sm text-muted-foreground",children:"Cloud models unavailable \u2014 try again or use your own key."})]}):z&&$e("div",{className:"space-y-2",children:[ee(Be,{children:"Model"}),M?$e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[ee(Tv,{className:"h-4 w-4 animate-spin"}),ee("span",{children:"Loading models..."})]}):E?ee("div",{className:"text-sm text-destructive",children:E}):k.length>0?$e(rr,{open:S,modal:!0,onOpenChange:P,children:[ee(sr,{render:$e(L,{variant:"outline",role:"combobox","aria-expanded":S,className:"w-full justify-between rounded-md","data-testid":"chat-config-model-select",children:[ee("span",{className:"truncate",children:o&&(k.find(D=>D.id===o)?.displayName||k.find(D=>D.id===o)?.id)||"Select a model..."}),ee(Nv,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),ee(ar,{className:"w-full p-0",align:"start",children:$e(sc,{children:[ee(ac,{placeholder:"Search models...",className:"h-9"}),$e(ic,{children:[ee(lc,{children:"No model found."}),ee(cc,{children:k.map(D=>$e(dc,{value:D.id,keywords:D.displayName,onSelect:_=>{i(_===o?"":_),P(!1)},children:[D.displayName||D.id,ee(Sv,{className:w("ml-auto h-4 w-4",o===D.id?"opacity-100":"opacity-0")})]},D.id))})]})]})})]}):ee(Ae,{value:o,onChange:D=>i(D.target.value),placeholder:"Enter model name manually","data-testid":"chat-config-model-input"})]}),$e("div",{className:"flex justify-between",children:[Ve&&ee(L,{variant:"outline",onClick:p,children:"Clear Config"}),$e(L,{onClick:pt,disabled:lt,className:Ve?"ml-auto":"","data-testid":"chat-config-save-button",children:[ee(Mk,{className:"h-4 w-4 mr-2"}),"Save Configuration"]})]})]})]})})}var Qu="rounded-full bg-background/80 backdrop-blur-md supports-[backdrop-filter]:bg-background/60 dark:bg-zinc-950/75 dark:supports-[backdrop-filter]:bg-zinc-950/55",Zu=w(Qu,"w-fit"),mc=w(Qu,"h-9 gap-1.5 px-3");import{jsx as Ft,jsxs as wo}from"react/jsx-runtime";var Gk="chat-view";function em({llmConfig:e,hasMessages:t,configDialogOpen:n,onConfigDialogOpenChange:o,onClearChat:r,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:c,onProviderChange:l,onModelChange:u,onApiKeyChange:p,onBaseUrlChange:d,onSaveConfig:h,onClearConfig:m,hideConfigButton:b,hostedInspector:f,freeTierInfo:v,managedCloudInfo:x,useManagedCloud:y,onSaveManagedCloud:g,showClearButton:C,clearButtonLabel:k,hideTitle:I,clearButtonHideIcon:M,clearButtonHideShortcut:N,clearButtonVariant:E,hideClearButton:T,onCopyChat:S,onExportChat:P,activeChatId:A,chatTitle:R,showViewToggle:W,viewIndex:H=0,onViewIndexChange:Y,elevatedHeader:U}){return wo("div",{className:w("relative flex w-full items-center gap-2 overflow-visible",jo,U?"pointer-events-none absolute top-0 right-0 z-50":"absolute top-0 right-0 z-10"),children:[Ft("div",{className:w("flex min-w-0 flex-1 items-center",U&&"pointer-events-auto"),children:!I&&Ft("h2",{className:w(qo,Zu),children:A?Ft(Ka,{chatId:A,title:R??fr},A):fr})}),W&&Y&&Ft("div",{className:w("absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible px-1",U&&"pointer-events-auto"),children:wo(Za,{selectedIndex:H,onSelect:Y,idPrefix:Gk,className:"shrink-0 overflow-visible","data-testid":"chat-view-tabs",children:[Ft(es,{label:"Conv",index:0}),Ft(es,{label:"Raw",index:1})]})}),wo("div",{className:w("ml-auto flex shrink-0 items-center gap-2",U&&"pointer-events-auto"),children:[!T&&t&&wo("div",{className:"flex items-center gap-1",children:[S&&wo(L,{"data-testid":"chat-copy-button",variant:"ghost",size:"sm",className:mc,onClick:S,children:[Ft(Wk,{className:"h-4 w-4"}),Ft("span",{className:"hidden sm:inline",children:"Copy"})]}),P&&wo(Ir,{children:[Ft(Go,{render:wo(L,{"data-testid":"chat-export-button",variant:"ghost",size:"sm",className:mc,children:[Ft(Kk,{className:"h-4 w-4"}),Ft("span",{className:"hidden sm:inline",children:"Export"})]}),nativeButton:!0}),wo(Er,{align:"end",children:[Ft(Un,{"data-testid":"chat-export-json",onClick:()=>P("json"),children:"Export as JSON"}),Ft(Un,{"data-testid":"chat-export-markdown",onClick:()=>P("markdown"),children:"Export as Markdown"})]})]}),Ft("div",{className:"w-px h-4 bg-border mx-1"}),wo(Ie,{children:[Ft(Re,{render:wo(L,{variant:E??"default",size:"default",className:`p-2 cursor-pointer ${N?"sm:px-3":"sm:pr-1 sm:pl-3"}`,onClick:r,children:[!M&&Ft(Jk,{className:"h-4 w-4 sm:mr-2"}),Ft("span",{className:"hidden sm:inline",children:k??"New Chat"}),!N&&Ft("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:"\u2318O"})]}),nativeButton:!0}),Ft(Me,{children:Ft("p",{children:k??"New Chat"})})]})]}),(!b||f||v||x)&&Ft(ei,{open:n,onOpenChange:o,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:c,onProviderChange:l,onModelChange:u,onApiKeyChange:p,onBaseUrlChange:d,onSave:h,onClear:m,showClearButton:C??(!!e&&!v&&!x),buttonLabel:e?"Change API Key":"Configure API Key",hostedInspector:f,freeTierInfo:v,managedCloudInfo:x,useManagedCloud:y,onSaveManagedCloud:g})]})]})}import{ArrowUp as AP,Loader2 as LP}from"lucide-react";import{Image as Zk,Paperclip as eP,X as tP}from"lucide-react";import{useRef as nP}from"react";import{Wrench as Yk}from"lucide-react";import{useCallback as Rv,useMemo as Xk,useState as Qk}from"react";import{jsx as Ho,jsxs as vr}from"react/jsx-runtime";function Mv({tools:e,disabledTools:t,onDisabledToolsChange:n,disabled:o}){let[r,s]=Qk(!1),a=e.length-t.size,i=t.size===0,c=t.size>0&&t.size<e.length,l=Rv(d=>{let h=new Set(t);h.has(d)?h.delete(d):h.add(d),n(h)},[t,n]),u=Rv(()=>{n(i?new Set(e.map(d=>d.name)):new Set)},[i,e,n]),p=Xk(()=>[...e].sort((d,h)=>d.name.localeCompare(h.name)),[e]);return e.length===0?null:vr(rr,{open:r,onOpenChange:s,children:[vr(Ie,{children:[Ho(Re,{render:Ho(sr,{render:vr(L,{variant:"ghost",size:"sm",disabled:o,className:w("h-auto gap-1 rounded-full px-2 py-2",c?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"),type:"button","data-testid":"chat-tool-selector",children:[Ho(Yk,{className:"h-4 w-4 shrink-0"}),c&&Ho("span",{className:"flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-bold leading-none text-white",children:a})]}),nativeButton:!0}),nativeButton:!0}),Ho(Me,{side:"top",children:vr("p",{children:["Tools (",a,"/",e.length,")"]})})]}),vr(ar,{className:"w-72 gap-0 p-0",align:"start",side:"top",sideOffset:8,children:[vr("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[vr("span",{className:"text-xs font-medium text-muted-foreground",children:["Allowed Tools (",a,"/",e.length,")"]}),Ho(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:u,type:"button",children:i?"Disable All":"Enable All"})]}),Ho("div",{className:"max-h-64 overflow-y-auto",children:p.map(d=>{let h=!t.has(d.name);return vr("button",{type:"button",className:"flex items-center gap-2.5 w-full px-3 py-1.5 text-left hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>l(d.name),children:[Ho($a,{checked:h,className:"pointer-events-none",tabIndex:-1}),Ho("span",{className:"min-w-0 flex-1 truncate text-sm font-mono",children:d.name})]},d.name)})})]})]})}import{jsx as zn,jsxs as ti}from"react/jsx-runtime";function Iv({variant:e="default",inputValue:t,isConnected:n,isLoading:o,textareaRef:r,attachments:s,placeholder:a="Ask a question",className:i,showAttachButton:c=!0,tools:l,disabledTools:u,onDisabledToolsChange:p,onInputChange:d,onKeyDown:h,onKeyUp:m,onClick:b,onAttachmentAdd:f,onAttachmentRemove:v,inlineControls:x,trailingControls:y}){let g=kt(),C=nP(null),k=e==="fullscreen",I=N=>{let E=N.target.files;if(E&&E.length>0)for(let T=0;T<E.length;T++)f(E[T]);C.current&&(C.current.value="")},M=s.length>0;return ti("div",{className:"relative w-full","data-chat-input-variant":e,children:[!k&&M&&zn("div",{className:"absolute top-0 left-0 right-0 z-20 p-3 flex gap-2 flex-wrap",children:s.map((N,E)=>ti("div",{className:"relative group bg-zinc-100/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-lg p-2 flex items-center gap-2 border border-zinc-200 dark:border-zinc-700","data-testid":`chat-attachment-${E}`,children:[zn(Zk,{className:"h-4 w-4 text-muted-foreground shrink-0"}),ti("div",{className:"flex flex-col min-w-0",children:[zn("span",{className:"text-xs font-medium truncate max-w-[150px]",children:N.name||"Image"}),N.size&&zn("span",{className:"text-xs text-muted-foreground",children:Ng(N.size)})]}),zn("button",{onClick:()=>v(E),className:"shrink-0 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 transition-colors",title:"Remove attachment",type:"button","data-testid":`chat-attachment-remove-${E}`,children:zn(tP,{className:"h-3 w-3"})})]},E))}),zn(fo,{ref:r,value:t,onChange:N=>d(N.target.value),onKeyDown:h,onKeyUp:m,onClick:b,placeholder:n?a:"Server not connected",className:w(k?"field-sizing-fixed h-11 min-h-11 max-h-11 resize-none overflow-hidden py-2.5 pl-4 pr-12":"p-4 min-h-[150px] max-h-[300px]",g.container,!k&&M&&"pt-20",i),rows:k?1:void 0,disabled:!n||o,"data-testid":"chat-input"}),zn("input",{ref:C,type:"file",accept:"image/*",multiple:!0,onChange:I,className:"hidden","aria-label":"Upload images"}),k?y?zn("div",{className:"absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center",children:y}):null:ti("div",{className:"absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 p-3",children:[ti("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[c&&zn(L,{variant:"ghost",size:"sm",onClick:()=>C.current?.click(),disabled:!n||o,className:"h-auto w-auto aspect-square rounded-full p-2 text-muted-foreground hover:text-foreground",title:"Attach images",type:"button","data-testid":"chat-attach-button",children:zn(eP,{className:"h-4 w-4"})}),l&&l.length>0&&u&&p&&zn(Mv,{tools:l,disabledTools:u,onDisabledToolsChange:p,disabled:!n||o}),x]}),y?zn("div",{className:"flex shrink-0 items-center gap-1.5",children:y}):null]})]})}import{MessageSquare as oP,X as rP}from"lucide-react";import{jsx as ni,jsxs as sP}from"react/jsx-runtime";function Ev({promptResults:e,onDeletePromptResult:t,offsetForSkills:n=!1}){return ni("div",{className:`absolute ${n?"top-12":"top-4"} left-4 right-4 flex gap-2 overflow-x-auto z-20 flex-nowrap`,style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(({promptName:o},r)=>sP(L,{type:"button",className:"flex items-center gap-2 bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 dark:bg-zinc-700 rounded-lg border border-zinc-200 dark:border-zinc-300 font-medium hover:bg-zinc-300 dark:hover:bg-zinc-600",children:[ni(oP,{className:"h-3.5 w-3.5 shrink-0"}),ni("span",{className:"truncate",title:o,children:o}),ni("span",{className:"ml-1 h-4 w-4 rounded-full bg-zinc-400 dark:bg-zinc-600 hover:bg-zinc-500 dark:hover:bg-zinc-500 flex items-center justify-center cursor-pointer shrink-0 transition-colors",onClick:s=>{s.stopPropagation(),t(r)},title:"Remove prompt",role:"button",tabIndex:0,children:ni(rP,{className:"h-2.5 w-2.5 text-white"})})]},r))})}import{MessageSquare as aP}from"lucide-react";import{useEffect as iP}from"react";import{jsx as br,jsxs as pc}from"react/jsx-runtime";function Av({isOpen:e,focusedIndex:t,prompts:n,selectedPrompt:o,onPromptSelect:r}){return e?(iP(()=>{if(t>=0){let s=document.getElementById(`prompt-suggestion-${t}`);s&&s.scrollIntoView({behavior:"smooth",block:"nearest"})}},[t]),br("div",{className:"absolute bottom-full left-0 right-0 max-w-3xl w-full max-h-[300px] overflow-y-auto rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-lg z-30 flex flex-col gap-2 mb-1","data-testid":"chat-prompts-dropdown",children:pc("div",{className:"p-2",children:[n.length>0&&br("div",{className:"text-xs font-medium text-zinc-900 dark:text-zinc-100 mb-2",children:"Prompts"}),n.map((s,a)=>pc(Ie,{children:[br(Re,{render:pc(L,{id:`prompt-suggestion-${a}`,type:"button",variant:"ghost",className:w("w-full flex items-center px-3 py-2 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-left justify-start",t===a&&"bg-zinc-200 dark:bg-zinc-700"),onClick:()=>r(s),"data-testid":`chat-prompt-option-${a}`,children:[br("div",{className:"flex items-center justify-center shrink-0",children:br(aP,{className:"h-4 w-4 text-zinc-600 dark:text-zinc-400"})}),br("div",{className:"flex-1 min-w-0",children:pc("div",{className:"text-sm font-medium text-zinc-900 dark:text-zinc-100 flex items-center gap-2",children:[s.name,o?.name===s.name&&br(An,{className:"size-3 text-zinc-600 dark:text-zinc-400"})]})})]}),nativeButton:!0}),br(Me,{children:s.description})]},a))]})})):null}import{motion as TP}from"motion/react";import{useMemo as Wv,useState as Kv}from"react";import{ExternalLink as NP}from"lucide-react";import{toast as Jv}from"sonner";import{forwardRef as hP,useCallback as Rn,useEffect as ao,useId as vP,useMemo as ri,useRef as Uo,useState as ns}from"react";import{AnimatePresence as js,motion as Co}from"motion/react";import{RadioGroup as bP}from"@base-ui/react/radio-group";import{Radio as yP}from"@base-ui/react/radio";import{CheckboxGroup as xP}from"@base-ui/react/checkbox-group";import{Checkbox as wP}from"@base-ui/react/checkbox";import{Field as sm}from"@base-ui/react/field";import{useEffect as rm,useLayoutEffect as lP,useRef as tm,useState as cP}from"react";import{AnimatePresence as dP,motion as uP}from"motion/react";import{jsx as Dv}from"react/jsx-runtime";var mP=typeof window<"u"?lP:rm,$s=ce.moderate,oi=.07,pP=($s.duration+oi)*1e3+80,fP=$s.duration*1e3+80;function nm(e,t){let n=t.filter(s=>s.start>=e.start&&s.end<=e.end).sort((s,a)=>s.start-a.start);if(n.length!==2)return null;let[o,r]=n;return r.start===o.end+2?{up:o,lo:r,gap:o.end+1}:null}function gP(e,t,n,o){let r=n[e],s=n[t];if(!r||!s)return null;if(o==="y")return{top:r.top,left:Math.min(r.left,s.left),width:Math.max(r.width,s.width),height:s.top+s.height-r.top};let a=Math.min(r.left,s.left),i=Math.max(r.left+r.width,s.left+s.width);return{top:Math.min(r.top,s.top),left:a,width:i-a,height:Math.max(r.height,s.height)}}function _v(e,t){return t==="y"?e.top+e.height/2:e.left+e.width/2}function fc(e,t){return t==="y"?[e,e,0,0]:[e,0,0,e]}function yr(e,t){return t==="y"?[0,0,e,e]:[0,e,e,0]}function om(e){return[e,e,e,e]}function Lv(e,t,n,o,r){let s=_v(n,o);if(o==="y"){let i=t.top+t.height;e.height=s-e.top,e.radii=fc(r,o),e.instant=!0,t.top=s,t.height=i-s,t.radii=yr(r,o),t.instant=!0,t.enterFrom={top:s,left:t.left,width:t.width,height:i-s,radii:yr(r,o)};return}let a=t.left+t.width;e.width=s-e.left,e.radii=fc(r,o),e.instant=!0,t.left=s,t.width=a-s,t.radii=yr(r,o),t.instant=!0,t.enterFrom={top:t.top,left:s,width:a-s,height:t.height,radii:yr(r,o)}}function Ov(e,t,n,o="y"){let[r,s]=cP([]),a=tm([]),i=tm(0),c=tm(new Map),l=e.map(d=>`${d.id}:${d.start}-${d.end}`).join("|");mP(()=>{let d=a.current,h=e,m=[];for(let f of h){let v=nm(f,d);v&&(f.id===v.up.id||f.id===v.lo.id)&&m.push({tid:++i.current,kind:"merge",survivorId:f.id,otherId:f.id===v.up.id?v.lo.id:v.up.id,gapIndex:v.gap,phase:"converge"})}for(let f of d){let v=nm(f,h);v&&m.push({tid:++i.current,kind:"split",survivorId:v.up.id,otherId:v.lo.id,gapIndex:v.gap,phase:"splitIn"})}a.current=h.map(f=>({...f}));for(let f of m)c.current.set(f.tid,setTimeout(()=>{c.current.delete(f.tid),s(v=>v.some(x=>x.tid===f.tid)?v.flatMap(x=>x.tid!==f.tid?[x]:x.kind==="merge"?[{...x,phase:"commit"}]:[]):v)},f.kind==="merge"?pP:fP));let b=f=>f.kind==="merge"?h.some(v=>v.id===f.survivorId&&f.gapIndex>v.start&&f.gapIndex<v.end):h.some(v=>v.id===f.survivorId&&v.end===f.gapIndex-1)&&h.some(v=>v.id===f.otherId&&v.start===f.gapIndex+1);s(f=>{for(let v of f){if(b(v))continue;let x=c.current.get(v.tid);x!==void 0&&(clearTimeout(x),c.current.delete(v.tid))}return[...f.filter(b),...m]})},[l]),rm(()=>{let d=c.current;return()=>d.forEach(clearTimeout)},[]),rm(()=>{r.some(d=>d.phase==="splitIn"||d.phase==="commit")&&s(d=>d.flatMap(h=>h.phase==="commit"?[]:[{...h,phase:h.phase==="splitIn"?"diverge":h.phase}]))},[r]);let u=[];for(let d of e){let h=gP(d.start,d.end,t,o);h&&u.push({key:`sel-${d.id}`,...h,radii:om(n),instant:!1,exitInstant:!1,delayCorners:!1})}let p=new Map(u.map(d=>[d.key,d]));for(let d of r){let h=t[d.gapIndex],m=p.get(`sel-${d.survivorId}`);if(!h||!m)continue;let b=_v(h,o);if(d.kind==="merge"){if(d.phase==="commit"){m.instant=!0,o==="y"?u.push({key:`sel-${d.otherId}`,top:b,left:m.left,width:m.width,height:m.top+m.height-b,radii:yr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0}):u.push({key:`sel-${d.otherId}`,top:m.top,left:b,width:m.left+m.width-b,height:m.height,radii:yr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0});continue}let f=Math.min(oi+.03,Math.max(oi,oi+b/Math.max(o==="y"?h.height:h.width,1)*.002));if(o==="y"){let v=m.top+m.height;m.height=b-m.top,m.radii=fc(n,o),m.delayCorners=!0,m.cornerDelay=f,u.push({key:`sel-${d.otherId}`,top:b,left:m.left,width:m.width,height:v-b,radii:yr(n,o),enterFrom:{top:b,left:m.left,width:m.width,height:v-b,radii:om(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}else{let v=m.left+m.width;m.width=b-m.left,m.radii=fc(n,o),m.delayCorners=!0,m.cornerDelay=f,u.push({key:`sel-${d.otherId}`,top:m.top,left:b,width:v-b,height:m.height,radii:yr(n,o),enterFrom:{top:m.top,left:b,width:v-b,height:m.height,radii:om(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}}else if(d.phase==="splitIn"){let f=p.get(`sel-${d.otherId}`);if(!f)continue;Lv(m,f,h,o,n)}}for(let d of a.current){let h=nm(d,e),m=h&&t[h.gap];if(!h||!m)continue;let b=p.get(`sel-${h.up.id}`),f=p.get(`sel-${h.lo.id}`);!b||!f||Lv(b,f,m,o,n)}return u}function zv({blocks:e,dimmed:t}){return Dv(dP,{children:e.map(n=>{let o=n.delayCorners?{...$s,delay:n.cornerDelay??oi}:$s,r=n.opacity??(t?.8:1);return Dv(uP.div,{"aria-hidden":!0,className:"absolute bg-active pointer-events-none",initial:n.enterFrom?{opacity:r,top:n.enterFrom.top,left:n.enterFrom.left,width:n.enterFrom.width,height:n.enterFrom.height,borderTopLeftRadius:n.enterFrom.radii[0],borderTopRightRadius:n.enterFrom.radii[1],borderBottomRightRadius:n.enterFrom.radii[2],borderBottomLeftRadius:n.enterFrom.radii[3]}:!1,animate:{top:n.top,left:n.left,width:n.width,height:n.height,borderTopLeftRadius:n.radii[0],borderTopRightRadius:n.radii[1],borderBottomRightRadius:n.radii[2],borderBottomLeftRadius:n.radii[3],opacity:r},exit:{opacity:0,transition:n.exitInstant?{duration:0}:$s.exit},transition:n.instant?{duration:0}:{...$s,borderTopLeftRadius:o,borderTopRightRadius:o,borderBottomRightRadius:o,borderBottomLeftRadius:o,opacity:{duration:.08}}},n.key)})})}import{Fragment as Hv,jsx as he,jsxs as an}from"react/jsx-runtime";function CP(e,t){return e.id??`q-${t}`}function gc(e,t){return e.id??`o-${t}`}var Vs=[],am=hP(function({questions:t,currentIndex:n,defaultCurrentIndex:o=0,onCurrentIndexChange:r,answers:s,defaultAnswers:a,onAnswersChange:i,onComplete:c,onSkip:l,skipLabel:u="Skip",intro:p,onCancel:d,cancelLabel:h="Cancel",footerLeading:m,className:b,...f},v){let[x,y]=ns(o),g=n!==void 0,C=g?n:x,k=Rn(O=>{g||y(O),r?.(O)},[g,r]),[I,M]=ns(a??{}),N=s!==void 0,E=N?s:I,T=Uo(E);ao(()=>{T.current=E},[E]);let S=Rn(O=>{let ne=O(T.current);return T.current=ne,N||M(ne),i?.(ne),ne},[N,i]),P=kt(),A=Tr("arrow-left"),R=Tr("arrow-right"),W=ri(()=>function(ne){return he(A,{...ne,className:w(ne.className,"hidden sm:block")})},[A]),H=ri(()=>function(ne){return he(R,{...ne,className:w(ne.className,"hidden sm:block")})},[R]),[Y]=ns(()=>{if(typeof navigator>"u")return!1;let O=navigator,ne=O.userAgentData?.platform||O.platform||"";return/mac/i.test(ne)}),U=vP(),V=t.length,K=Math.max(0,Math.min(C,Math.max(0,V-1))),$=t[K],G=$?CP($,K):"",te=E[G],Z=!!$?.multiSelect,z=$?.skippable!==!1,F=!!$?.freeText,ie=$?.freeTextMultiline!==!1,le=!F&&!!$?.allowOther,Ne=ri(()=>te?.selectedIds??[],[te]),de=te?.otherText??"",re=$?.options??[],me=le?re.length:-1,be=re.length+(le?1:0),pe=Uo(null),We=!!$;ao(()=>{if(!We)return;let O=pe.current;if(O)return Vs.push(O),()=>{let ne=Vs.indexOf(O);ne!==-1&&Vs.splice(ne,1)}},[We]);let Ke=Uo(null),Ve=Uo(null),pt=Uo(0),lt=Uo(new Map),{activeIndex:D,setActiveIndex:_,itemRects:j,sessionRef:Le,handlers:Oe,registerItem:He,measureItems:tt}=Rr(Ke);ao(()=>{tt()},[tt,G,be,P]);let[ln,Nt]=ns(!1);ao(()=>{Nt(!1)},[G]),ao(()=>{let O=Ve.current;if(!O)return;O.style.height="0px",O.style.height=`${O.scrollHeight}px`;let ne=parseFloat(window.getComputedStyle(O).lineHeight)||18;Nt(O.scrollHeight>ne*1.5),tt()},[de,tt,G]),ao(()=>{F&&Ve.current?.focus({preventScroll:!0})},[F,G]);let Ze=Uo(null),[cn,co]=ns("auto");ao(()=>{let O=Ze.current;if(!O)return;let ne=()=>co(O.offsetHeight);ne();let Ee=new ResizeObserver(ne);return Ee.observe(O),()=>Ee.disconnect()},[]);let[Pt,Kt]=ns(null),[Cn,Tt]=ns(null);ao(()=>{_(null),Kt(null),Tt(null)},[K,_]);let Yt=Uo(!1),oe=Rn(()=>{Ke.current?.contains(document.activeElement)&&(Yt.current=!0)},[]);ao(()=>{if(!Yt.current)return;Yt.current=!1,Ke.current?.querySelector('[data-proximity-index="0"]')?.focus()},[K]);let fe=Rn(O=>{K>=V-1?c?.(O):(oe(),k(K+1))},[K,V,c,k,oe]),Ue=Rn(O=>{if(!$)return;let ne=T.current[G]?.otherText,Ee=S(Ct=>({...Ct,[G]:{questionId:G,selectedIds:[O],otherText:ne||void 0,skipped:!1}}));fe(Ee)},[$,G,S,fe]),ft=Rn(O=>{$&&S(ne=>{let Ee=ne[G],Ct=new Set(Ee?.selectedIds??[]);return Ct.has(O)?Ct.delete(O):Ct.add(O),{...ne,[G]:{questionId:G,selectedIds:Array.from(Ct),otherText:Ee?.otherText,skipped:!1}}})},[$,G,S]),Rt=Rn(O=>{$&&S(ne=>({...ne,[G]:{questionId:G,selectedIds:O,otherText:ne[G]?.otherText,skipped:!1}}))},[$,G,S]),ue=Rn(O=>{$&&(Tt(null),S(ne=>({...ne,[G]:{questionId:G,selectedIds:ne[G]?.selectedIds??[],otherText:O,skipped:!1}})))},[$,G,S]),ve=Rn(()=>{if(!$)return;let O=(T.current[G]?.otherText??"").trim();if(!O)return;if($.freeText&&$.freeTextValidate){let Ee=$.freeTextValidate(O);if(Ee){Tt(Ee);return}}Tt(null);let ne=S(Ee=>({...Ee,[G]:{questionId:G,selectedIds:Ee[G]?.selectedIds??[],otherText:O,skipped:!1}}));fe(ne)},[$,G,S,fe]),mt=Rn(()=>{if(!$)return;let O=S(ne=>({...ne,[G]:{questionId:G,selectedIds:ne[G]?.selectedIds??[],otherText:ne[G]?.otherText,skipped:!0}}));l?.(G,K),fe(O)},[$,G,S,l,K,fe]),nt=Rn(()=>{d?.()},[d]),B=Rn(()=>{fe(E)},[fe,E]),se=Rn(()=>{K>0&&(oe(),k(K-1))},[K,k,oe]);ao(()=>{if(!$)return;let O=ne=>{if(ne.metaKey||ne.ctrlKey||ne.altKey)return;let Ee=ne.target;if(!Ee)return;let Ct=Ee.tagName;if(Ct==="INPUT"||Ct==="TEXTAREA"||Ee.isContentEditable)return;let It=pe.current;if(!It||!It.contains(Ee)&&(Vs.some(eo=>eo!==It&&eo.contains(Ee))||Vs[Vs.length-1]!==It))return;let St=ne.key;if(St<"1"||St>"9")return;let Et=parseInt(St,10)-1;if(Et>=0&&Et<re.length){ne.preventDefault();let eo=gc(re[Et],Et);Z?ft(eo):Ue(eo)}else Et===re.length&&le&&(ne.preventDefault(),Ve.current?.focus())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[$,re,Z,le,Ue,ft]);let we=O=>{Ke.current?.querySelector(`[data-proximity-index="${O}"]`)?.focus()},Te=Rn(O=>{_(O),le&&O===me?Ve.current?.focus():we(O)},[le,me,_]),Ce=O=>{let ne=O.target,Ee=ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.isContentEditable;if(Ee&&O.key!=="ArrowDown"&&O.key!=="ArrowUp")return;if(Ee&&(O.key==="ArrowUp"||O.key==="ArrowDown")&&ne.tagName==="TEXTAREA"){let It=ne;if(O.key==="ArrowUp"&&It.selectionStart>0||O.key==="ArrowDown"&&It.selectionEnd<It.value.length)return}let Ct=O.preventBaseUIHandler;if(O.key==="ArrowLeft"||O.key==="ArrowRight"){O.preventDefault(),O.stopPropagation(),Ct?.(),O.key==="ArrowLeft"?K>0&&se():z&&V>1&&mt();return}if(be!==0&&(O.key==="ArrowDown"||O.key==="ArrowUp"||O.key==="Home"||O.key==="End")){O.preventDefault(),O.stopPropagation(),Ct?.();let It;if(O.key==="Home")It=0;else if(O.key==="End")It=be-1;else{let St=Ee?me:D??-1;It=O.key==="ArrowDown"?St+1:St-1,It=(It+be)%be}Te(It)}},je=O=>{if(O.key!=="Enter"||!(Y?O.metaKey:O.ctrlKey)||!(Z||F))return;if(O.preventDefault(),F){de.trim().length>0&&ve();return}(Ne.length>0||de.trim().length>0)&&B()};if(!$)return he("div",{ref:v,className:w("w-full max-w-[520px] p-5 bg-card border border-border",P.container,b),...f,children:he("p",{className:"text-[13px] text-muted-foreground",children:"No questions."})});let Fe=D!==null?j[D]:null,rt=Pt!==null&&!(le&&Pt===me)?j[Pt]:null,ut=ri(()=>{let O=new Set;return re.forEach((ne,Ee)=>{Ne.includes(gc(ne,Ee))&&O.add(Ee)}),le&&de.length>0&&O.add(me),O},[re,Ne,le,de,me]),Mt=ri(()=>{let O=[],ne=[...ut].sort((St,Et)=>St-Et);for(let St of ne){let Et=O[O.length-1];Et&&St===Et.end+1?Et.end=St:O.push({start:St,end:St})}let Ee=new Set,Ct=new Map,It=O.map(St=>{let Et=null;for(let dn=St.start;dn<=St.end;dn++){let In=lt.current.get(dn);if(In!==void 0&&!Ee.has(In)){Et=In;break}}let eo=Et??++pt.current;Ee.add(eo);for(let dn=St.start;dn<=St.end;dn++)Ct.set(dn,eo);return{...St,id:eo}});return lt.current=Ct,It},[ut]),ls=D!==null&&!ut.has(D),Cr=Ov(Mt,j,P.bgRadius),Bn=V>1&&K>0,Mn=d!=null,Zn=!Mn&&V>1&&z,gt=Z||F,So=Bn||Zn||gt||Mn||m!=null,yi=re.findIndex((O,ne)=>Ne.includes(gc(O,ne))),xi=an("div",{ref:Ke,role:Z?"group":"radiogroup","aria-labelledby":`${U}-${G}-title`,onMouseEnter:Oe.onMouseEnter,onMouseMove:Oe.onMouseMove,onMouseLeave:Oe.onMouseLeave,onFocus:O=>{let ne=O.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(ne!=null){let Ee=Number(ne);_(Ee),Kt(O.target.matches(":focus-visible")?Ee:null)}},onBlur:O=>{Ke.current?.contains(O.relatedTarget)||(Kt(null),_(null))},onKeyDown:Ce,className:"relative flex flex-col gap-0.5 -mx-3",children:[he(js,{children:(()=>{if(!le)return null;let O=j[me],ne=Pt===me&&de.length===0;return!O||!ne?null:he(Co.div,{"aria-hidden":!0,className:w("absolute pointer-events-none bg-card ring-1 ring-inset ring-border",P.bg),initial:{opacity:0,top:O.top,left:O.left,width:O.width,height:O.height},animate:{opacity:1,top:O.top,left:O.left,width:O.width,height:O.height},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}},"other-input")})()}),he(js,{children:Fe&&he(Co.div,{"aria-hidden":!0,className:w("absolute pointer-events-none bg-hover",P.bg),initial:{opacity:0,top:Fe.top,left:Fe.left,width:Fe.width,height:Fe.height},animate:{opacity:1,top:Fe.top,left:Fe.left,width:Fe.width,height:Fe.height},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}},`hover-${Le.current}`)}),he(zv,{blocks:Cr,dimmed:ls}),he(js,{children:rt&&he(Co.div,{"aria-hidden":!0,className:w("absolute pointer-events-none border border-[color:var(--focus-ring,#6B97FF)] z-20",P.focusRing),initial:{opacity:0,top:rt.top-2,left:rt.left-2,width:rt.width+4,height:rt.height+4},animate:{opacity:1,top:rt.top-2,left:rt.left-2,width:rt.width+4,height:rt.height+4},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}})}),re.map((O,ne)=>{let Ee=gc(O,ne),Ct=Ne.includes(Ee),St=!Z&&D===ne;return he(Bv,{index:ne,registerItem:He,role:Z?"checkbox":"radio",isSelected:Ct,tabIndex:ne===yi||yi===-1&&ne===0?0:-1,onClick:()=>Z?ft(Ee):Ue(Ee),onKeyDown:Et=>{(Et.key===" "||Et.key==="Enter")&&!Et.metaKey&&!Et.ctrlKey&&(Et.preventDefault(),Z?ft(Ee):Ue(Ee))},shape:P,"aria-checked":Ct,chipContent:ne+1,chipFilled:Ct,isMulti:Z,showArrow:St,bodyLayout:$.layout==="stacked"?"stacked":"inline",topAlign:$.layout==="stacked",chipPosition:$.chipPosition??"right",arrowIcon:he(R,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),hiddenControl:Z?he(wP.Root,{name:Ee,className:"sr-only",tabIndex:-1,"aria-hidden":!0}):he(yP.Root,{value:Ee,className:"sr-only",tabIndex:-1,"aria-hidden":!0}),children:$.layout==="stacked"?an(Hv,{children:[an("span",{className:"inline-grid",children:[he("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:At.semibold},"aria-hidden":"true",children:O.title}),he("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:Ct?At.semibold:At.medium},children:O.title})]}),O.description&&he("span",{className:"text-[12px] text-muted-foreground leading-snug",children:O.description})]}):an("span",{children:[an("span",{className:"inline-grid",children:[he("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:At.semibold},"aria-hidden":"true",children:O.title}),he("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:Ct?At.semibold:At.medium},children:O.title})]}),O.description&&an(Hv,{children:[" ",he("span",{className:"text-muted-foreground",children:O.description})]})]})},Ee)}),le&&he(Bv,{index:me,registerItem:He,role:null,isSelected:de.length>0,tabIndex:-1,onClick:()=>Ve.current?.focus(),shape:P,chipContent:me+1,chipFilled:de.length>0,isMulti:Z,topAlign:ln,chipPosition:$.chipPosition??"right",ariaLabel:$.otherPlaceholder??"Describe in your own words",showArrow:!Z&&(Pt===me||D===me)&&de.trim().length>0,arrowIcon:he(R,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),onArrowClick:!Z&&de.trim().length>0?ve:void 0,children:he("span",{className:"inline-grid w-full",children:he("textarea",{ref:Ve,rows:1,value:de,placeholder:$.otherPlaceholder??"Describe in your own words\u2026","aria-label":$.otherPlaceholder??"Describe in your own words",onChange:O=>ue(O.target.value),onKeyDown:O=>{O.key==="Enter"&&(O.shiftKey||Z||(O.preventDefault(),ve()))},onClick:O=>O.stopPropagation(),className:w("col-start-1 row-start-1 block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground"),style:{fontVariationSettings:At.medium}})})})]});return an("div",{ref:O=>{pe.current=O,typeof v=="function"?v(O):v&&(v.current=O)},className:w("relative w-full max-w-[520px] overflow-hidden bg-card border border-border",P.container,b),...f,onKeyDown:O=>{f.onKeyDown?.(O),je(O)},children:[he("div",{className:"flex items-center px-4 sm:px-5 pt-4 sm:pt-5 pb-2 text-[12px] text-muted-foreground",children:an("span",{children:["Question ",K+1," of ",V]})}),p!=null&&he("div",{className:"px-4 sm:px-5 pb-3 text-[13px] leading-snug text-muted-foreground",children:p}),an(sm.Root,{invalid:Cn!==null,className:"contents",children:[he(Co.div,{animate:{height:cn},initial:!1,transition:ce.slow,className:"overflow-hidden",children:he("div",{ref:Ze,className:w("px-4 sm:px-5",So?"pb-1":"pb-2.5 sm:pb-3"),children:an("div",{className:"flex flex-col gap-2",children:[he("h3",{id:`${U}-${G}-title`,className:"text-[16px] text-foreground leading-snug",style:{fontVariationSettings:At.semibold},children:$.title}),F?he("div",{onClick:()=>Ve.current?.focus(),className:w("relative mt-1 -mx-3 px-3 py-2.5 cursor-text transition-colors",ie?"min-h-[76px]":"min-h-10",P.bg,de.length>0?"bg-active":"hover:bg-hover focus-within:bg-card focus-within:ring-1 focus-within:ring-inset focus-within:ring-border"),children:he(sm.Control,{value:de,onValueChange:ue,render:he("textarea",{ref:Ve,rows:1,placeholder:$.freeTextPlaceholder??"Type your answer\u2026","aria-labelledby":`${U}-${G}-title`,onKeyDown:O=>{O.key==="Enter"&&(O.shiftKey||O.metaKey||O.ctrlKey||ie||(O.preventDefault(),ve()))},className:"block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground",style:{fontVariationSettings:At.medium}})})}):Z?he(xP,{value:Ne,onValueChange:Rt,render:xi}):he(bP,{value:Ne[0]??null,onValueChange:O=>{typeof O=="string"&&Ue(O)},render:xi})]},G)})}),So&&he("div",{className:"px-4 sm:px-5 pt-1 pb-2",children:an("div",{className:"flex items-center justify-between gap-2 -mx-2 sm:-mx-3",children:[an("div",{className:"relative flex flex-1 min-w-0 items-center gap-2",children:[m!=null&&he("div",{className:"shrink-0 px-2 sm:px-3",children:m}),he(js,{mode:"popLayout",initial:!1,children:Bn&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"ghost",size:"sm",leadingIcon:W,onClick:se,className:"pl-3 sm:pl-[6px]",children:"Back"})},"back")}),Cn&&he(sm.Error,{match:!0,render:he(Co.p,{role:"alert",initial:{opacity:0,y:-2},animate:{opacity:1,y:0},transition:{...ce.fast,opacity:{duration:.12}},className:"min-w-0 px-2 sm:px-3 text-left text-[12px] leading-snug text-destructive"}),children:Cn},"ft-error")]}),he("div",{className:"relative flex items-center gap-2",children:an(js,{mode:"popLayout",initial:!1,children:[Mn&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"ghost",size:"sm",trailingIcon:H,onClick:nt,className:"pr-3 sm:pr-[6px]",children:h})},"cancel"),Zn&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"ghost",size:"sm",trailingIcon:H,onClick:mt,className:"pr-3 sm:pr-[6px]",children:u})},"skip"),gt&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"primary",size:"sm",onClick:F?ve:B,disabled:(F||Ne.length===0)&&de.trim().length===0,className:"pr-3 sm:pr-[6px]",children:an("span",{className:"inline-flex items-center gap-1.5",children:[$.nextLabel??(K>=V-1?"Finish":"Continue"),he("span",{className:"hidden sm:contents",children:an(SP,{shape:P,tone:"inverted",children:[Y?"\u2318":"\u2303","\u21B5"]})})]})})},"continue")]})})]})})]})]})});am.displayName="AskUserQuestions";function SP({children:e,tone:t="muted",shape:n}){return he("kbd",{"aria-hidden":!0,suppressHydrationWarning:!0,className:w("inline-flex items-center justify-center gap-0.5 px-1 min-w-[18px] h-[18px] text-[11px] leading-none font-sans tracking-wide",t==="inverted"?"bg-background/15 text-background":"bg-foreground/10 text-muted-foreground",n.bg),children:e})}function Bv({index:e,registerItem:t,role:n,isSelected:o,tabIndex:r,onClick:s,onKeyDown:a,shape:i,chipContent:c,chipFilled:l,isMulti:u,ariaLabel:p,showArrow:d,arrowIcon:h,onArrowClick:m,bodyLayout:b="inline",topAlign:f=!1,chipPosition:v="right",hiddenControl:x,children:y,...g}){let C=Uo(null);ao(()=>(t(e,C.current),()=>t(e,null)),[e,t]);let k=he(js,{children:d&&he(Co.span,{"aria-hidden":!m,role:m?"button":void 0,onClick:m?N=>{N.stopPropagation(),m()}:void 0,className:w("absolute inset-0 inline-flex items-center justify-center bg-foreground text-background",i.bg,m&&"cursor-pointer"),initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}},children:h})}),I=an("span",{className:w("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(b==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:[he("span",{"aria-hidden":!0,className:w("absolute inline-flex items-center justify-center w-5 h-5 text-[11px] transition-[opacity,font-variation-settings] duration-80",u&&i.bg,u?l?"bg-foreground text-background":"border border-border text-muted-foreground":l?"text-foreground":"text-muted-foreground",v==="right"&&d&&"opacity-0"),style:{fontVariationSettings:l?At.semibold:At.medium},children:c}),v==="right"&&k]}),M=v==="left"&&!u&&he("span",{className:w("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(b==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:k});return an("div",{ref:C,"data-proximity-index":e,"data-state":o?"checked":"unchecked",role:n??void 0,"aria-checked":n==="radio"||n==="checkbox"?!!g["aria-checked"]:void 0,"aria-label":p,tabIndex:r,onMouseDown:N=>{let E=N.target.closest('button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])');E&&E!==N.currentTarget||(N.preventDefault(),N.currentTarget.focus())},onClick:s,onKeyDown:a,className:w("relative z-10 flex cursor-pointer select-none outline-none",v==="left"?"gap-2":"gap-3",f?"items-start":"items-center",b==="stacked"?"min-h-14 py-2":"min-h-10 py-1.5",v==="left"?u?"pl-1.5 pr-3":"pl-1.5 pr-1.5":"pl-3 pr-1.5",i.item),children:[v==="left"&&I,he("span",{className:w("min-w-0 flex-1 text-[13px] leading-snug",b==="stacked"?"flex flex-col gap-0.5":"inline-flex items-center gap-0"),children:y}),v==="right"?I:M,x]})}function hc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.const=="string"&&(t.title===void 0||typeof t.title=="string")}function Uv(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(hc):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(hc):[];return t.length>0?t:n}function Fv(e){let t=e.items&&typeof e.items=="object"?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(hc):[],o=Array.isArray(t.oneOf)?t.oneOf.filter(hc):[];return n.length>0?n:o}function $v(e){if(e.mode==="url"&&"url"in e)return[{id:"__url_confirm__",title:"Confirm completion",layout:"stacked",options:[{id:"confirmed",title:"I've completed the required action",description:e.url}],skippable:!1,nextLabel:"Confirm"}];let t="requestedSchema"in e?e.requestedSchema:void 0;if(!t||t.type!=="object"||!t.properties)return[{id:"__freeform__",title:"Your response",freeText:!0,freeTextPlaceholder:"Type your response\u2026",skippable:!1}];let n=t.properties,o=t.required??[];return Object.entries(n).map(([r,s])=>{let a=s,i=o.includes(r),c=a.title||r,l=a.description,u=a.type||"string",p=Uv(a),d=Fv(a),h=Array.isArray(a.enum),m=u==="array"&&Array.isArray(a.items?.enum),b=u==="array"&&d.length>0,f={id:r,title:c,skippable:!i,layout:l&&l.length>60?"stacked":"inline"};if(u==="boolean")return{...f,options:[{id:"true",title:"Yes"},{id:"false",title:"No"}]};if(b||m){let v=b?d:a.items.enum.map(x=>({const:x,title:x}))??[];return{...f,multiSelect:!0,options:v.map(x=>({id:x.const,title:x.title||x.const}))}}if(p.length>0)return{...f,layout:"stacked",options:p.map(v=>({id:v.const,title:v.title||v.const}))};if(h){let v=a.enum,x=a.enumNames;return{...f,options:v.map((y,g)=>({id:y,title:x?.[g]||y}))}}return u==="number"||u==="integer"?{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Enter a number\u2026",freeTextValidate:v=>{let x=v.trim();if(!x)return i?"Required":null;let y=u==="integer"?parseInt(x,10):parseFloat(x);return Number.isNaN(y)?"Enter a valid number":null}}:u==="string"&&(a.format==="textarea"||(a.maxLength??0)>100)?{...f,freeText:!0,freeTextPlaceholder:a.default||"Type your answer\u2026"}:{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Type your answer\u2026",freeTextValidate:v=>!v.trim()&&i?"Required":null}})}function Vv(e,t,n){if(n.mode==="url")return{};let o="requestedSchema"in n?n.requestedSchema:void 0,r=o?.type==="object"&&o.properties?o.properties:{},s={};for(let a of e){let i=a.id??"";if(i==="__freeform__"){let p=t[i]?.otherText?.trim();p&&(s.response=p);continue}let c=t[i];if(!c||c.skipped)continue;let u=r[i]?.type||"string";if(a.freeText){let p=c.otherText?.trim()??"";if(!p)continue;s[i]=u==="number"||u==="integer"?u==="integer"?parseInt(p,10):parseFloat(p):p;continue}if(a.multiSelect){s[i]=c.selectedIds;continue}if(u==="boolean"){s[i]=c.selectedIds[0]==="true";continue}c.selectedIds[0]!==void 0&&(s[i]=c.selectedIds[0])}return s}function jv(e,t,n){if(n.mode==="url")return[];let o="requestedSchema"in n?n.requestedSchema:void 0;return(o?.type==="object"?o.required??[]:[]).filter(s=>{let a=t[s];if(!a||a.skipped)return!0;let i=e.find(c=>c.id===s);return i?i.freeText?!a.otherText?.trim():(i.multiSelect,a.selectedIds.length===0):!0})}function qv(e,t){if(t.mode==="url")return{};let n="requestedSchema"in t?t.requestedSchema:void 0,o=n?.type==="object"&&n.properties?n.properties:{},r={};for(let s of e){let a=s.id;if(!a||a.startsWith("__"))continue;let i=o[a];if(!(!i||i.default===void 0)){if(s.freeText){r[a]={questionId:a,selectedIds:[],otherText:String(i.default),skipped:!1};continue}if(s.multiSelect&&Array.isArray(i.default)){r[a]={questionId:a,selectedIds:i.default.map(String),skipped:!1};continue}if(i.type==="boolean"){r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1};continue}r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1}}}return r}import{jsx as si,jsxs as vc}from"react/jsx-runtime";function Gv({request:e,onApprove:t,onReject:n,testId:o="inline-elicitation",actionTestIdPrefix:r="inline-elicitation"}){let[s,a]=Kv(!1),[i,c]=Kv(""),l=Wv(()=>$v(e.request),[e.request]),u=Wv(()=>qv(l,e.request),[l,e.request]),d=(e.request.mode||"form")==="url",h=d&&"url"in e.request?e.request.url:void 0,m=(v,x)=>{a(!0),c(v),t(e.id,x)},b=v=>{if(s)return;if(d){if(!v.__url_confirm__?.selectedIds.includes("confirmed")){Jv.error("Confirm you've completed the external action");return}m("accepted",{action:"accept"});return}let x=jv(l,v,e.request);if(x.length>0){Jv.error("Missing required fields",{description:`Please fill in: ${x.join(", ")}`});return}m("accepted",{action:"accept",content:Vv(l,v,e.request)})};if(s)return vc("p",{className:"text-sm text-muted-foreground","data-testid":`${o}-responded`,children:["Elicitation ",i," \u2014 the tool will continue executing."]});let f=vc("div",{className:"space-y-2",children:[si("p",{className:"text-foreground/90",children:e.request.message}),d&&h&&vc("div",{className:"flex items-center gap-2 rounded-md border bg-muted/40 p-2",children:[si("code",{className:"flex-1 text-xs font-mono break-all",children:h}),vc(L,{size:"sm",variant:"outline",onClick:()=>window.open(h,"_blank"),"data-testid":`${r}-open-url`,children:[si(NP,{className:"h-3 w-3 mr-1"}),"Open"]})]})]});return si(am,{questions:l,defaultAnswers:u,onComplete:b,intro:f,onCancel:()=>n(e.id,"User cancelled elicitation request"),cancelLabel:"Cancel",footerLeading:si("button",{type:"button",className:"shrink-0 cursor-pointer text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:()=>m("declined",{action:"decline"}),"data-testid":`${r}-decline-button`,children:"Decline"}),className:"w-full max-w-none shadow-lg","data-testid":o})}import{jsx as im}from"react/jsx-runtime";function Yv({requests:e,onApprove:t,onReject:n}){return e.length===0?null:im("div",{className:"mb-3 space-y-3 pointer-events-auto","data-testid":"floating-elicitation-stack",children:e.map(o=>im(TP.div,{initial:{opacity:0,y:12,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},transition:ce.moderate,children:im(Gv,{request:o,onApprove:t,onReject:n})},o.id))})}import{Check as kP,Loader2 as PP,Settings2 as RP}from"lucide-react";import{useCallback as MP,useEffect as IP,useState as lm}from"react";var os="You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.";import{jsx as io,jsxs as ai}from"react/jsx-runtime";function EP(e){let t=e?.trim();return t?t!==os:!1}function Xv({value:e,onSave:t,disabled:n,isSaving:o=!1,compact:r=!1}){let[s,a]=lm(!1),[i,c]=lm(e??""),[l,u]=lm(!1);IP(()=>{c(e??"")},[e]);let p=MP(async()=>{u(!0);try{await t(i),a(!1)}finally{u(!1)}},[i,t]),d=o||l,h=EP(e),m=ai("button",{type:"button","data-testid":"chat-system-prompt-button",onClick:()=>a(!0),disabled:n,className:r?w("inline-flex h-auto w-auto aspect-square items-center justify-center rounded-full p-2 transition-colors disabled:pointer-events-none disabled:opacity-50",h?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"):w("inline-flex h-9 items-center justify-center gap-1.5 rounded-full border border-input bg-secondary px-3 text-sm font-medium shadow-xs transition-colors hover:bg-secondary/80 disabled:pointer-events-none disabled:opacity-50",h?"text-amber-600 dark:text-amber-400":"text-secondary-foreground"),children:[io(RP,{className:"h-4 w-4"}),!r&&io("span",{className:"hidden sm:inline",children:"System Prompt"})]});return ai(on,{open:s,onOpenChange:a,children:[r?ai(Ie,{children:[io(Re,{render:m,nativeButton:!0}),io(Me,{side:"top",children:io("p",{children:h?"Custom system prompt":"System Prompt"})})]}):m,ai(Xt,{className:"sm:max-w-xl",children:[io(Gt,{children:io($t,{children:"System Prompt"})}),io(fo,{value:i,onChange:b=>c(b.target.value),placeholder:"Describe the assistant's behavior...",className:"min-h-[160px] text-sm"}),io($i,{children:ai(L,{size:"sm",onClick:p,disabled:d||i===(e??""),className:"gap-1.5",children:[d?io(PP,{className:"h-3.5 w-3.5 animate-spin"}):io(kP,{className:"h-3.5 w-3.5"}),"Save"]})})]})]})}import{Fragment as Qv,jsx as wn,jsxs as bc}from"react/jsx-runtime";function ii({variant:e="default",inputValue:t,isConnected:n,isLoading:o,textareaRef:r,llmConfig:s,promptsDropdownOpen:a,promptFocusedIndex:i,prompts:c,selectedPrompt:l,promptResults:u,attachments:p,tools:d,disabledTools:h,onDisabledToolsChange:m,onInputChange:b,onKeyDown:f,onKeyUp:v,onClick:x,onSendMessage:y,onStopStreaming:g,onConfigDialogOpenChange:C,onPromptSelect:k,onDeletePromptResult:I,onAttachmentAdd:M,onAttachmentRemove:N,hideModelBadge:E,freeTierInfo:T,managedCloudInfo:S,modelBadgeMode:P="byok",managedModel:A,followups:R=[],onFollowupSelect:W,pendingElicitationRequests:H,onApproveElicitation:Y,onRejectElicitation:U,systemPromptProvider:V}){let K=e==="fullscreen",$=t.trim()||u.length>0||p.length>0,G=(H?.length??0)>0,te=s&&(!E||T||S)?bc(Ie,{children:[wn(Re,{render:wn(Cv,{provider:s.provider,model:s.model,managedModel:A,mode:P,className:"shrink-0","data-testid":"chat-model-badge",onClick:()=>C(!0)}),nativeButton:!0}),wn(Me,{children:wn("p",{children:S||T?"Change model":"Change API Key"})})]}):null;return wn("div",{className:w("w-full flex shrink-0 flex-col items-center px-2 pt-0 sm:px-4 text-foreground",K?"pb-4 sm:pb-4":"pb-2 sm:pb-2"),children:bc("div",{className:w("relative w-full max-w-3xl",!K&&"backdrop-blur-xl"),children:[!K&&G&&Y&&U&&wn(Yv,{requests:H,onApprove:Y,onReject:U}),!K&&R.length>0&&wn("div",{className:"mb-2 flex flex-wrap gap-2",children:R.map(Z=>wn(L,{type:"button",variant:"outline",size:"sm",className:"rounded-full",onClick:()=>W?.(Z),disabled:o||!n,children:Z},Z))}),!K&&bc(Qv,{children:[wn(Av,{isOpen:a,prompts:c,selectedPrompt:l,focusedIndex:i,onPromptSelect:k}),wn(Ev,{promptResults:u,onDeletePromptResult:I})]}),wn(Iv,{variant:e,inputValue:t,isConnected:n,isLoading:o,textareaRef:r,attachments:p,placeholder:"Ask a question or request an action...",className:w("bg-white/80 dark:text-white dark:bg-black backdrop-blur-sm border-gray-200 dark:border-zinc-800",!K&&u.length>0&&"pt-16"),showAttachButton:!K,tools:K?void 0:d,disabledTools:K?void 0:h,onDisabledToolsChange:K?void 0:m,onInputChange:b,onKeyDown:f,onKeyUp:v,onClick:x,onAttachmentAdd:M,onAttachmentRemove:N,inlineControls:!K&&s&&V?wn(Xv,{compact:!0,value:V.prompt,onSave:V.savePrompt,disabled:!n||o||V.disabled,isSaving:V.isSaving}):null,trailingControls:bc(Qv,{children:[!K&&te,wn(L,{type:"button",size:"sm",className:w("h-8 w-8 rounded-full p-0",o&&"animate-spin",!$&&!o&&"bg-zinc-400"),disabled:!o&&(!$||!n||G),title:o?"Stop streaming":"Send",onClick:o?g:y,"data-testid":"chat-send-button",children:o?wn(LP,{className:"h-3.5 w-3.5 animate-spin"}):wn(AP,{className:"h-3.5 w-3.5"})})]})})]})})}import{AnimatePresence as DP,motion as _P,useInView as OP}from"motion/react";import{useRef as zP}from"react";import{jsx as Zv}from"react/jsx-runtime";function eb({children:e,className:t,variant:n,duration:o=.4,delay:r=0,offset:s=6,direction:a="down",inView:i=!1,inViewMargin:c="-50px",blur:l="6px",...u}){let p=zP(null),d=OP(p,{once:!0,margin:c}),h=!i||d,m={hidden:{[a==="left"||a==="right"?"x":"y"]:a==="right"||a==="down"?-s:s,opacity:0,filter:`blur(${l})`},visible:{[a==="left"||a==="right"?"x":"y"]:0,opacity:1,filter:"blur(0px)"}},b=n||m;return Zv(DP,{children:Zv(_P.div,{ref:p,initial:"hidden",animate:h?"visible":"hidden",exit:"hidden",variants:b,transition:{delay:.04+r,duration:o,ease:"easeOut"},className:t,...u,children:e})})}import{jsx as li,jsxs as yc}from"react/jsx-runtime";function cm({serverDisplayName:e,composerNotice:t,quickQuestions:n=[],onQuickQuestionSelect:o,...r}){return li("div",{className:"flex h-full flex-col items-center justify-center",children:yc(eb,{className:"w-full max-w-4xl mx-auto px-2 sm:px-4",children:[yc("div",{className:"text-center mb-6 sm:mb-8",children:[yc("h1",{className:"text-2xl sm:text-4xl font-light mb-2 dark:text-white","data-testid":"chat-landing-header",children:["Chat with ",e]}),li("p",{className:"mx-auto max-w-xl text-sm text-muted-foreground sm:text-base","data-testid":"chat-landing-description",children:"Chat, inspect traces, preview widgets, and more."})]}),yc("div",{className:"space-y-6",children:[t,li(ii,{...r}),n.length>0&&li("div",{className:"flex flex-wrap items-center justify-center gap-2 px-2",children:n.map(s=>li(L,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-white/70 dark:bg-black/50 text-gray-900 dark:text-white",onClick:()=>o?.(s),disabled:r.isLoading||!r.isConnected,children:s},s))})]})]})})}import{Key as BP,Settings as HP}from"lucide-react";import{jsx as xc,jsxs as tb}from"react/jsx-runtime";function dm({onConfigureClick:e}){return tb("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[xc(BP,{className:"h-12 w-12 text-muted-foreground mb-4"}),xc("h3",{className:"text-lg font-semibold mb-2",children:"Configure Your LLM Provider"}),xc("p",{className:"text-sm text-muted-foreground mb-4 max-w-md",children:"To start chatting with the MCP server, you need to configure your LLM provider and API key. Your credentials are stored locally and used only for this chat."}),tb(L,{onClick:e,"data-testid":"chat-configure-api-key-button",children:[xc(HP,{className:"h-4 w-4 mr-2"}),"Configure API Key"]})]})}import{motion as UP}from"motion/react";import{useMemo as FP}from"react";import{jsx as $P}from"react/jsx-runtime";function nb({children:e,as:t="p",className:n,duration:o=2,spread:r=2}){let s=UP.create(t),a=FP(()=>e.length*r,[e,r]);return $P(s,{className:w("relative inline-block bg-[length:250%_100%,auto] bg-clip-text","text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]","dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]",n),initial:{backgroundPosition:"100% center"},animate:{backgroundPosition:"0% center"},transition:{repeat:1/0,duration:o,ease:"linear"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--base-color), var(--base-color))"},children:e})}import{memo as fR,useCallback as gR,useMemo as hR,useRef as xm}from"react";import{memo as VP,useMemo as jP}from"react";import{jsx as ob,jsxs as WP}from"react/jsx-runtime";function qP(e){let t=e.match(/```/g);return t&&t.length%2===1?`${e}
|
|
201
|
+
}`;function MT(e){return[parseInt(e.slice(1,3),16)/255,parseInt(e.slice(3,5),16)/255,parseInt(e.slice(5,7),16)/255,1]}function Yl({className:e,colors:t=["#e0eaff","#f9ffbd","#dedede","#ffffff"],distortion:n=.8,swirl:o=.1,grainMixer:r=0,grainOverlay:s=.2,speed:a=1}){let i=Au(null),c=Au(null),l=Au({colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a});return l.current={colors:t,distortion:n,swirl:o,grainMixer:r,grainOverlay:s,speed:a},kT(()=>{let u=i.current,p=c.current;if(!u||!p)return;let d=u.getContext("webgl2");if(!d)return;let h=(H,Y)=>{let U=d.createShader(H);return U?(d.shaderSource(U,Y),d.compileShader(U),d.getShaderParameter(U,d.COMPILE_STATUS)?U:(console.error(d.getShaderInfoLog(U)),null)):null},m=h(d.VERTEX_SHADER,PT),b=h(d.FRAGMENT_SHADER,RT);if(!m||!b)return;let f=d.createProgram();if(!f)return;if(d.attachShader(f,m),d.attachShader(f,b),d.linkProgram(f),!d.getProgramParameter(f,d.LINK_STATUS)){console.error(d.getProgramInfoLog(f));return}d.useProgram(f);let v=d.getAttribLocation(f,"a_position"),x=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,x),d.bufferData(d.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),d.STATIC_DRAW),d.enableVertexAttribArray(v),d.vertexAttribPointer(v,2,d.FLOAT,!1,0,0);let y=d.getUniformLocation(f,"u_time"),g=d.getUniformLocation(f,"u_resolution"),C=[0,1,2,3].map(H=>d.getUniformLocation(f,`u_colors[${H}]`)),k=d.getUniformLocation(f,"u_colorsCount"),I=d.getUniformLocation(f,"u_distortion"),M=d.getUniformLocation(f,"u_swirl"),N=d.getUniformLocation(f,"u_grainMixer"),E=d.getUniformLocation(f,"u_grainOverlay"),T=0,S=performance.now(),P=0,A=()=>{let H=Math.min(2,window.devicePixelRatio||1);u.width=Math.floor(p.clientWidth*H),u.height=Math.floor(p.clientHeight*H),d.viewport(0,0,u.width,u.height)},R=H=>{if(document.hidden){S=H,P=requestAnimationFrame(R);return}let{colors:Y,distortion:U,swirl:V,grainMixer:K,grainOverlay:$,speed:G}=l.current,te=H-S;S=H,T+=te*G;let Z=Y.map(MT);d.uniform1f(y,T*.001),d.uniform2f(g,u.width,u.height);for(let z=0;z<4;z++){let F=C[z];F&&d.uniform4fv(F,Z[z]??[1,1,1,1])}d.uniform1f(k,Z.length),d.uniform1f(I,U),d.uniform1f(M,V),d.uniform1f(N,K),d.uniform1f(E,$),d.drawArrays(d.TRIANGLES,0,6),P=requestAnimationFrame(R)};A();let W=new ResizeObserver(A);return W.observe(p),P=requestAnimationFrame(R),()=>{cancelAnimationFrame(P),W.disconnect()}},[]),Wh("div",{ref:c,className:e,children:Wh("canvas",{ref:i,className:"h-full w-full","aria-hidden":!0})})}var IT=["#e0eaff","#f9ffbd","#dedede","#ffffff"],ET=["#27272a","#9a9448","#3f3f46","#18181b"];function Xl(e){return e==="dark"?ET:IT}import{useCallback as AT,useState as LT}from"react";import{Play as DT,Square as _T}from"lucide-react";import{jsx as Bs,jsxs as BT}from"react/jsx-runtime";var Kh="mcp-inspector-chat-mesh-animation-paused";function OT(e){try{return localStorage.getItem(e)==="true"}catch{return!1}}function Jh(e){let[t,n]=LT(()=>OT(e)),o=AT(()=>{n(r=>{let s=!r;try{localStorage.setItem(e,s?"true":"false")}catch{}return s})},[e]);return{paused:t,toggle:o}}var zT="z-50 flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border border-zinc-500/60 bg-transparent text-zinc-600 transition-colors hover:border-zinc-500 hover:text-zinc-800 dark:border-zinc-500/50 dark:text-zinc-400 dark:hover:border-zinc-400 dark:hover:text-zinc-200";function Gh({paused:e,onToggle:t,className:n}){return BT(Ie,{children:[Bs(Re,{render:Bs("button",{type:"button",onClick:t,"aria-label":e?"Resume animation":"Pause animation",className:w(zT,n),children:e?Bs(DT,{className:"ml-px h-3 w-3",fill:"currentColor"}):Bs(_T,{className:"h-2.5 w-2.5",fill:"currentColor"})}),nativeButton:!0}),Bs(Me,{side:"left",children:Bs("p",{children:e?"Resume animation":"Pause animation"})})]})}import{jsx as Ya,jsxs as Qh}from"react/jsx-runtime";var FT=.54,$T=.4,Xh="linear-gradient(to top, black 0%, black 12%, rgba(0,0,0,0.55) 38%, transparent 100%)";function Zh({className:e,children:t,shaderPhase:n="hidden",onShaderFadeComplete:o,meshAnimationPaused:r=!1,...s}){let a=HT(null),[i,c]=UT(!1),{resolvedTheme:l}=go(),u=Xl(l),p=l==="dark",{paused:d,toggle:h}=Jh(Kh),m=d||r;Yh(()=>{let x=window.requestAnimationFrame(()=>c(!0));return()=>window.cancelAnimationFrame(x)},[]),Yh(()=>{n==="fading"&&!i&&o?.()},[n,i,o]);let b=n!=="hidden",f=n==="visible"&&i,v=x=>{x.propertyName==="opacity"&&n==="fading"&&o?.()};return Qh("div",{ref:a,className:w("relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",e),...s,children:[b&&Ya("div",{className:w("pointer-events-none absolute inset-x-0 bottom-0 z-0 transition-opacity duration-500",f?"opacity-100":"opacity-0"),style:{height:`${FT*100}%`},"aria-hidden":!0,onTransitionEnd:v,children:Qh("div",{className:w("absolute inset-0",i?p?"opacity-90":"opacity-75":"opacity-0"),style:{maskImage:Xh,WebkitMaskImage:Xh},children:[Ya("div",{className:"absolute inset-0 bg-[#edf2ff] dark:hidden"}),Ya(Yl,{className:"absolute inset-0 h-full w-full",colors:[...u],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:p?.12:.3,speed:m?0:$T})]})}),b&&Ya(Gh,{paused:d,onToggle:h,className:"absolute bottom-3 right-3 sm:bottom-5 sm:right-5"}),Ya("div",{className:"relative z-10 flex min-h-0 flex-1 flex-col",children:t})]})}function ev(e){return e?e.apiKey==="server-managed"||e.baseUrl?.includes("/inspector/llm")===!0:!1}function Xa(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("failed to fetch")||t.includes("networkerror")||t.includes("network request failed")||t.includes("load failed")}function Lu(e,t){if(!t)return e>=502&&e<=504?{kind:"cloud_unavailable"}:null;if(e===402)return{kind:"credits_exhausted",billingUrl:typeof t.upgradeUrl=="string"?t.upgradeUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(e===429){if(t.loginRequired&&t.loginUrl)return{kind:"login_required",loginUrl:String(t.loginUrl)};if(t.creditsExhausted)return{kind:"credits_exhausted",billingUrl:typeof t.billingUrl=="string"?t.billingUrl:void 0,message:typeof t.message=="string"?t.message:"You've used your included free plan credits."};if(t.error==="free_org_rate_limited"||typeof t.reason=="string")return{kind:"credits_exhausted",message:typeof t.message=="string"?t.message:"You've reached your included chat quota for this workspace."}}return e>=502&&e<=504?{kind:"cloud_unavailable"}:null}function VT(e){let t=e.match(/^OpenAI request failed \((\d+) /);if(!t)return null;let n=Number(t[1]),o=e.indexOf("{");if(o===-1)return null;try{let r=JSON.parse(e.slice(o));if(r&&typeof r=="object"&&!Array.isArray(r))return{status:n,body:r}}catch{}return null}function tv(e){if(e instanceof Error&&e.name==="LlmRequestError"){let t=e.status??0,n=e.body,o=n&&typeof n=="object"&&!Array.isArray(n)?n:void 0;return Lu(t,o)}if(e instanceof Error){let t=VT(e.message);if(t)return Lu(t.status,t.body)}return Xa(e)?{kind:"cloud_unavailable"}:null}function nv(e,t){return Lu(e,t)}import{useCallback as Ql,useEffect as jT,useSyncExternalStore as qT}from"react";var Hu="openid profile email offline_access",rv="mcp-inspector:manufact-auth",WT="manufact:session-changed",Qa={loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null},Zr=new Map,zu=new Set,Du=new Map,_u=new Map,sv=null,Ou=!1;typeof window<"u"&&window.addEventListener("message",e=>{if(e.data?.type!=="manufact:invalidate-oauth-client")return;for(let n of Zr.keys())Gn()?.removeItem(Pn(n,"client"));let t=sv;!t||Ou||(Ou=!0,uv(t,{isRetry:!0}).finally(()=>{Ou=!1}))});function KT(e){let t=Zr.get(e);if(t)return t;let n={...Qa,loaded:!1};return Zr.set(e,n),n}function Gn(){return typeof window>"u"?null:window.localStorage}function tc(e){return new URL(e).origin}function JT(e,t){let n=new URL(e),o=new URL(t),r=new Set(["localhost","127.0.0.1"]);return r.has(n.hostname)&&r.has(o.hostname)?n.origin===o.origin:(n.hostname==="manufact.com"||n.hostname.endsWith(".manufact.com"))&&(o.hostname==="manufact.com"||o.hostname.endsWith(".manufact.com"))}function av(e){let t=window.__MANUFACT_LOGIN_URL__;if(t)return new URL(t).origin;let n=new URL(e);return n.hostname==="localhost"||n.hostname==="127.0.0.1"?`${n.protocol}//${n.hostname}:3000`:`${n.protocol}//manufact.com`}function GT(e){return`${av(e)}/auth/embedded-sign-out`}function Pn(e,t){return`${rv}:${t}:${e}`}function YT(e){return Gn()?.getItem(Pn(e,"skip-session"))==="1"}function ec(e,t){let n=Pn(e,"skip-session");t?Gn()?.setItem(n,"1"):Gn()?.removeItem(n)}function XT(e){return`${rv}:state:${e}`}function Hs(e){let t=Gn()?.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return Gn()?.removeItem(e),null}}function Uu(e,t){Gn()?.setItem(e,JSON.stringify(t))}function xo(e,t){Zr.set(e,{...Zr.get(e)??Qa,...t}),zu.forEach(n=>n()),window.dispatchEvent(new CustomEvent(WT))}function iv(e){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Bu(e=32){let t=new Uint8Array(e);return crypto.getRandomValues(t),iv(t)}async function lv(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return iv(new Uint8Array(t))}async function nc(e){let t=await fetch(`${e}/api/auth/.well-known/openid-configuration`);if(!t.ok)throw new Error("Manufact OAuth discovery failed");return await t.json()}function cv(){return`${window.location.origin}${Yo()}/auth/callback`}function ov(e){return e==="localhost"||e==="127.0.0.1"}function QT(e){try{let t=new URL(e).hostname,n=typeof window<"u"?new URL(window.location.href).hostname:"";return ov(t)&&ov(n)}catch{return!1}}async function ZT(e,t,n){let o=new URL(`${e}/api/auth/oauth2/authorize`);o.searchParams.set("response_type","code"),o.searchParams.set("client_id",t),o.searchParams.set("redirect_uri",n),o.searchParams.set("scope",Hu),o.searchParams.set("code_challenge",await lv(Bu(32))),o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("state","client-probe"),o.searchParams.set("prompt","none");try{let r=await fetch(o.toString(),{method:"GET",redirect:"manual",credentials:"include"}),s=r.headers.get("location")??"";return s.includes("/auth/error")&&s.includes("invalid_client")?!1:r.status>=300&&r.status<400||r.type==="opaqueredirect"?!!s&&!s.includes("/auth/error"):!0}catch{return!1}}async function ek(e,t){let n=cv(),o=Pn(e,"client"),r=Hs(o),s=QT(e);if(!s&&r?.client_id&&r.redirect_uri===n){if(await ZT(e,r.client_id,n))return r;Gn()?.removeItem(o)}else s&&r?.client_id&&Gn()?.removeItem(o);if(!t.registration_endpoint)throw new Error("Manufact OAuth registration is unavailable");let a=await fetch(t.registration_endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:"mcp-use Inspector",redirect_uris:[n],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",scope:Hu})});if(!a.ok)throw new Error("Could not register Inspector with Manufact");let i=await a.json();if(!i.client_id)throw new Error("Manufact returned no OAuth client ID");let c={...i,redirect_uri:n};return Uu(o,c),c}async function tk(e,t){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t)}),o=await n.json().catch(()=>({}));if(!n.ok||!o.access_token)throw new Error(o.error_description??"Manufact token exchange failed");return{access_token:o.access_token,refresh_token:o.refresh_token,token_type:o.token_type,expires_at:Date.now()+(o.expires_in??3600)*1e3}}async function nk(e,t){if(!t.refresh_token)return null;let n=_u.get(e);if(n)return n;let o=(async()=>{try{let r=await nc(e),s=Hs(Pn(e,"client"));if(!s?.client_id)return null;let a=await tk(r.token_endpoint,{grant_type:"refresh_token",refresh_token:t.refresh_token,client_id:s.client_id}),i={...a,refresh_token:a.refresh_token??t.refresh_token};return Uu(Pn(e,"tokens"),i),i}catch{return Gn()?.removeItem(Pn(e,"tokens")),null}finally{_u.delete(e)}})();return _u.set(e,o),o}async function ok(e){let t=Hs(Pn(e,"tokens"));return t?.access_token?t.expires_at>Date.now()+3e4?t:nk(e,t):null}async function rk(e,t){let n=await nc(e);if(!n.userinfo_endpoint)return null;let o=await fetch(n.userinfo_endpoint,{headers:{Authorization:`Bearer ${t}`}});if(!o.ok)return null;let r=await o.json();return r.sub?{id:r.sub,name:r.name,email:r.email,image:r.picture}:null}async function dv(e){try{let t=await fetch(`${e}/api/auth/get-session`,{credentials:"include"});return t.ok?(await t.json())?.user??null:null}catch{return null}}async function Zl(e){let t=Du.get(e);if(t)return t;Zr.set(e,{...Zr.get(e)??Qa,loaded:!1});let n=(async()=>{try{let o=typeof window<"u"?window.location.href:e,r=JT(o,e),s=YT(e),a=await ok(e),i=a?await rk(e,a.access_token):null;if(i&&a){ec(e,!1),xo(e,{loaded:!0,accessToken:a.access_token,user:i,mode:"oauth"});return}a&&!i&&Gn()?.removeItem(Pn(e,"tokens"));let c=r&&!s?await dv(e):null;if(c){xo(e,{loaded:!0,accessToken:null,user:c,mode:"session"});return}xo(e,{loaded:!0,accessToken:null,user:null,mode:null})}catch{xo(e,{loaded:!0,accessToken:null,user:null,mode:null})}})().finally(()=>Du.delete(e));return Du.set(e,n),n}async function uv(e,t){let n=tc(e);sv=e,ec(n,!1);let o=window.open("","manufact-oauth","width=600,height=700,resizable=yes,scrollbars=yes");if(!o)throw new Error("Allow popups to sign in with Manufact");xo(n,{authorizing:!0});try{let r=await nc(n),s=await ek(n,r),a=Bu(64),i=Bu(),c=cv();Uu(XT(i),{authOrigin:n,clientId:s.client_id,redirectUri:c,codeVerifier:a,expiresAt:Date.now()+600*1e3});let l=new URL(r.authorization_endpoint);l.searchParams.set("response_type","code"),l.searchParams.set("client_id",s.client_id),l.searchParams.set("redirect_uri",c),l.searchParams.set("scope",Hu),l.searchParams.set("state",i),l.searchParams.set("code_challenge",await lv(a)),l.searchParams.set("code_challenge_method","S256"),l.searchParams.set("prompt","consent"),o.location.href=l.toString();let u=window.setInterval(()=>{o.closed&&(window.clearInterval(u),Zl(n).finally(()=>xo(n,{authorizing:!1})))},500)}catch(r){throw o.close(),xo(n,{authorizing:!1}),r}}function sk(e){let t=tc(e);Gn()?.removeItem(Pn(t,"tokens")),xo(t,{loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null})}async function ak(e){let t=Hs(Pn(e,"tokens")),n=Hs(Pn(e,"client")),o=t?.refresh_token??t?.access_token;if(!n?.client_id||!o)return null;try{let s=(await nc(e)).revocation_endpoint??`${e}/api/auth/oauth2/revoke`;return(await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:n.client_id,token:o,token_type_hint:t?.refresh_token?"refresh_token":"access_token"})})).status}catch{return-1}}async function ik(e){let t=av(e),n=window.open(GT(e),"manufact-sign-out","width=420,height=320");return n?new Promise(o=>{let r=!1,s=l=>{r||(r=!0,window.clearTimeout(a),window.clearInterval(c),window.removeEventListener("message",i),o(l))},a=window.setTimeout(()=>{s({attempted:!0,signOutOk:!1,signOutStatus:null})},3e4),i=l=>{l.origin===t&&l.data?.type==="manufact:sign-out-complete"&&s({attempted:!0,signOutOk:!0,signOutStatus:200})},c=window.setInterval(()=>{n.closed&&dv(e).then(l=>{s({attempted:!0,signOutOk:!l,signOutStatus:l?401:200})})},500);window.addEventListener("message",i)}):{attempted:!0,signOutOk:!1,signOutStatus:null}}async function lk(e,t){let n=tc(e),o=!!Hs(Pn(n,"tokens"))?.access_token;t==="oauth"||o?(await ak(n),ec(n,!0)):t==="session"&&(await ik(n),ec(n,!1)),sk(e)}function mv(e){let t=e?tc(e):null,n=Ql(s=>(zu.add(s),()=>zu.delete(s)),[]),o=Ql(()=>t?KT(t):Qa,[t]),r=qT(n,o,()=>Qa);return jT(()=>{if(!t)return;Zl(t);let s=i=>{i.origin===window.location.origin&&i.data?.type==="manufact:oauth-complete"&&i.data.authOrigin===t&&Zl(t).finally(()=>xo(t,{authorizing:!1}))},a=i=>{i.key!==Pn(t,"tokens")||!i.newValue||Zl(t).finally(()=>xo(t,{authorizing:!1}))};return window.addEventListener("message",s),window.addEventListener("storage",a),()=>{window.removeEventListener("message",s),window.removeEventListener("storage",a)}},[t]),{...r,authorize:Ql(async()=>{e&&await uv(e)},[e]),logout:Ql(async()=>{e&&await lk(e,r.mode)},[e,r.mode])}}function pv(e){return mv(e)}import{useEffect as ck}from"react";function fv(e){ck(()=>{let t=n=>{let o=n.target,r=o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.contentEditable==="true";if((n.metaKey||n.ctrlKey)&&n.key==="k"){n.preventDefault(),e.onCommandPalette?.();return}if((n.metaKey||n.ctrlKey)&&n.key==="o"&&e.onNewChat){n.preventDefault(),e.onNewChat();return}if(n.key==="Escape"){n.preventDefault(),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e.onBlurSearch?.();return}if(!r&&!(n.metaKey||n.ctrlKey||n.altKey||n.shiftKey))switch(n.key.toLowerCase()){case"t":n.preventDefault(),e.onToolsTab?.();break;case"p":n.preventDefault(),e.onPromptsTab?.();break;case"r":n.preventDefault(),e.onResourcesTab?.();break;case"c":n.preventDefault(),e.onChatTab?.();break;case"h":n.preventDefault(),e.onHome?.();break;case"f":n.preventDefault(),e.onFocusSearch?.();break;default:break}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}import{Copy as Wk,Download as Kk,SquarePen as Jk}from"lucide-react";import{Check as Sv,ChevronsUpDown as Nv,Eye as Pk,EyeOff as Rk,Key as Mk,Loader2 as Tv}from"lucide-react";import{useEffect as Yu,useRef as Ik,useState as ts}from"react";import{Tabs as Vu}from"@base-ui/react/tabs";import{AnimatePresence as ju,motion as oc}from"motion/react";import{createContext as pk,forwardRef as Ku,useCallback as $u,useContext as fk,useEffect as qu,useRef as rc,useState as gk}from"react";import{useCallback as Us,useEffect as Fu,useRef as Fs,useState as gv}from"react";function hv(e,t){let n=e.getBoundingClientRect(),o=t==="x"?e.offsetWidth:e.offsetHeight,r=t==="x"?n.width:n.height;return o>0?r/o:1}function dk(e,t){let n=e.getBoundingClientRect(),o=hv(e,"x"),r=hv(e,"y"),s=[];return t.forEach((a,i)=>{let c=a.getBoundingClientRect();s[i]={top:(c.top-n.top)/r+e.scrollTop,left:(c.left-n.left)/o+e.scrollLeft,width:a.offsetWidth,height:a.offsetHeight}}),s}function uk(e,t,n,o){let r=o==="x"?t:n,s=null,a=1/0,i=null;return e.forEach((c,l)=>{let u=c.getBoundingClientRect(),p=o==="x"?u.left:u.top,d=o==="x"?u.right:u.bottom;r>=p&&r<=d&&(i=l);let h=(p+d)/2,m=Math.abs(r-h);m<a&&(a=m,s=l)}),i??s}function mk(e,t){if(e.length!==t.length)return!0;for(let n=0;n<t.length;n++){let o=e[n],r=t[n];if(o!==r&&(!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height))return!0}return!1}function vv(e,t={}){let{axis:n="y"}=t,o=Fs(new Map),[r,s]=gv(null),[a,i]=gv([]),c=Fs([]),l=Fs(0),u=Fs(null),p=Fs(null),d=Fs(null),h=Us(()=>{let y=e.current;if(!y)return;let g=dk(y,o.current);mk(c.current,g)&&(c.current=g,i(g))},[e]),m=Us((y,g)=>{s(uk(o.current,y,g,n))},[n]),b=Us((y,g)=>{g?o.current.set(y,g):o.current.delete(y),p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,h()})},[h]),f=Us(y=>{d.current={x:y.clientX,y:y.clientY},u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null,h(),m(y.clientX,y.clientY)})},[h,m]),v=Us(()=>{l.current+=1},[]),x=Us(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),d.current=null,s(null)},[]);return Fu(()=>{let y=e.current;if(!y||typeof ResizeObserver>"u")return;let g=new ResizeObserver(()=>{p.current!==null&&cancelAnimationFrame(p.current),p.current=requestAnimationFrame(()=>{p.current=null,h()})});return g.observe(y),()=>g.disconnect()},[e,h]),Fu(()=>{let y=e.current;if(!y)return;let g=()=>{h();let C=d.current;C&&m(C.x,C.y)};return y.addEventListener("scroll",g,{capture:!0,passive:!0}),()=>y.removeEventListener("scroll",g,{capture:!0})},[e,h,m]),Fu(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),p.current!==null&&cancelAnimationFrame(p.current)},[]),{activeIndex:r,setActiveIndex:s,itemRects:a,sessionRef:l,handlers:{onMouseMove:f,onMouseEnter:v,onMouseLeave:x},registerItem:b,measureItems:h}}import{jsx as On,jsxs as Wu}from"react/jsx-runtime";var bv=pk(null);function hk(){let e=fk(bv);if(!e)throw new Error("useTabsSubtle must be used within a TabsSubtle");return e}var Za=Ku(({children:e,selectedIndex:t,onSelect:n,idPrefix:o,activeLabel:r=!1,className:s,...a},i)=>{let c=rc(null),l=rc(!1),u=kt(),{activeIndex:p,setActiveIndex:d,itemRects:h,handlers:m,registerItem:b,measureItems:f}=vv(c,{axis:"x"}),v=rc(new Map),x=$u((S,P)=>{b(S,P),P?v.current.set(S,P):v.current.delete(S)},[b]);qu(()=>{f()},[f,e]),qu(()=>{let S=v.current;if(S.size===0)return;let P=new ResizeObserver(()=>f());return S.forEach(A=>P.observe(A)),()=>P.disconnect()},[f,e]);let y=$u(S=>{l.current=!0,m.onMouseMove(S)},[m]),g=$u(()=>{l.current=!1,m.onMouseLeave()},[m]),[C,k]=gk(null),I=h[t],M=p!==null?h[p]:null,N=C!==null?h[C]:null,E=p===t,T=p!==null&&!E;return On(bv.Provider,{value:{registerTab:x,hoveredIndex:p,selectedIndex:t,idPrefix:o,activeLabel:r},children:On(Vu.Root,{value:t,onValueChange:S=>{typeof S=="number"&&n(S)},render:Wu(Vu.List,{activateOnFocus:!1,ref:S=>{c.current=S,typeof i=="function"?i(S):i&&(i.current=S)},onMouseMove:y,onMouseLeave:g,onFocus:S=>{let P=S.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(P!=null){let A=Number(P);d(A),k(S.target.matches(":focus-visible")?A:null)}},onBlur:S=>{c.current?.contains(S.relatedTarget)||(k(null),!l.current&&d(null))},className:w("relative flex items-center gap-0.5 select-none overflow-x-auto max-w-full -mx-1 px-1 -my-1 py-1",s),...a,children:[I&&On(oc.div,{className:w("absolute bg-accent pointer-events-none",u.bg),initial:!1,animate:{left:I.left,width:I.width,top:I.top,height:I.height,opacity:T?.8:1},transition:{...ce.moderate,opacity:{duration:.08}}}),On(ju,{children:M&&!E&&I&&On(oc.div,{className:w("absolute bg-accent pointer-events-none",u.bg),initial:{left:I.left,width:I.width,top:I.top,height:I.height,opacity:0},animate:{left:M.left,width:M.width,top:M.top,height:M.height,opacity:.4},exit:!l.current&&I?{left:I.left,width:I.width,top:I.top,height:I.height,opacity:0,transition:{...ce.moderate,opacity:{duration:.06}}}:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}})}),On(ju,{children:N&&On(oc.div,{className:w("absolute pointer-events-none z-20 border border-[color:var(--focus-ring,#6B97FF)]",u.focusRing),initial:!1,animate:{left:N.left-2,top:N.top-2,width:N.width+4,height:N.height+4},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}})}),e]})})})});Za.displayName="TabsSubtle";var es=Ku(({icon:e,label:t,index:n,className:o,...r},s)=>{let a=rc(null),i=kt(),{registerTab:c,hoveredIndex:l,selectedIndex:u,idPrefix:p,activeLabel:d}=hk();qu(()=>(c(n,a.current),()=>c(n,null)),[n,c]);let h=u===n,m=l===n||h,b=d&&!!e,f=!b||h,v=Wu("span",{className:"inline-grid",children:[On("span",{className:"col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic]",style:{fontVariationSettings:At.semibold},"aria-hidden":"true",children:t}),On("span",{className:w("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80 [text-box:trim-both_cap_alphabetic]",m?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:h?At.semibold:At.normal},children:t})]});return Wu(Vu.Tab,{ref:x=>{let y=x;a.current=y,typeof s=="function"?s(y):s&&(s.current=y)},value:n,"data-proximity-index":n,id:p?`${p}-tab-${n}`:void 0,"aria-controls":p?`${p}-panel-${n}`:void 0,"aria-label":b&&!f?t:void 0,className:w("relative z-10 flex items-center px-2 cursor-pointer bg-transparent border-none outline-none text-xs",b?"h-7":"h-7 gap-1.5",i.bg,o),...r,children:[e&&On(e,{size:14,strokeWidth:m?2:1.5,className:w("shrink-0 transition-[color,stroke-width] duration-80",m?"text-foreground":"text-muted-foreground")}),b?On(ju,{children:f&&On(oc.span,{className:"overflow-hidden",initial:{width:0,opacity:0,marginLeft:0},animate:{width:"auto",opacity:1,marginLeft:6},exit:{width:0,opacity:0,marginLeft:0},transition:{...ce.fast,opacity:{duration:.06}},children:v},"label")}):v]})});es.displayName="TabsSubtleItem";var vk=Ku(({index:e,selectedIndex:t,idPrefix:n,children:o,className:r,...s},a)=>{let i=t===e;return On("div",{ref:a,id:`${n}-panel-${e}`,role:"tabpanel","aria-labelledby":`${n}-tab-${e}`,hidden:!i,tabIndex:-1,className:w("outline-none",r),...s,children:i&&o})});vk.displayName="TabsSubtlePanel";import*as Ut from"react";import{jsx as hr,jsxs as yk}from"react/jsx-runtime";var yv=Ut.createContext(null);function Ju(){let e=Ut.useContext(yv);if(!e)throw new Error("Command components must be used within <Command>");return e}function bk(e,t){return t?e.toLowerCase().includes(t.toLowerCase()):!0}var sc=Ut.forwardRef(({className:e,...t},n)=>{let[o,r]=Ut.useState(""),[s,a]=Ut.useState(null),[i,c]=Ut.useState(0),l=Ut.useCallback(()=>(c(u=>u+1),()=>c(u=>Math.max(0,u-1))),[]);return hr(yv.Provider,{value:{search:o,setSearch:r,activeValue:s,setActiveValue:a,visibleCount:i,registerVisible:l},children:hr("div",{ref:n,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})})});sc.displayName="Command";var ac=Ut.forwardRef(({className:e,...t},n)=>{let{search:o,setSearch:r}=Ju();return hr("div",{className:"flex items-center border-b px-3",children:hr("input",{ref:n,value:o,onChange:s=>r(s.target.value),className:w("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})})});ac.displayName="CommandInput";var ic=Ut.forwardRef(({className:e,...t},n)=>hr("div",{ref:n,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ic.displayName="CommandList";var lc=Ut.forwardRef(({className:e,...t},n)=>{let{visibleCount:o}=Ju();return o>0?null:hr("div",{ref:n,className:w("py-6 text-center text-sm",e),...t})});lc.displayName="CommandEmpty";var cc=Ut.forwardRef(({className:e,heading:t,children:n,...o},r)=>yk("div",{ref:r,className:w("overflow-hidden p-1 text-foreground [&_[data-command-group-heading]]:px-2 [&_[data-command-group-heading]]:py-1.5 [&_[data-command-group-heading]]:text-xs [&_[data-command-group-heading]]:font-medium [&_[data-command-group-heading]]:text-muted-foreground",e),...o,children:[t?hr("div",{"data-command-group-heading":"",children:t}):null,n]}));cc.displayName="CommandGroup";var dc=Ut.forwardRef(({className:e,value:t,keywords:n,onSelect:o,disabled:r,onClick:s,...a},i)=>{let{search:c,activeValue:l,setActiveValue:u,registerVisible:p}=Ju(),d=Array.isArray(n)?n.join(" "):n,h=d?`${t} ${d}`:t,m=bk(h,c),b=l===t;return Ut.useLayoutEffect(()=>{if(m)return p()},[m,p]),Ut.useEffect(()=>{m&&l===null&&!r&&u(t)},[m,l,r,u,t]),m?hr("div",{ref:i,role:"option","aria-selected":b,"data-selected":b,"data-disabled":r,className:w("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),onMouseEnter:()=>!r&&u(t),onClick:f=>{s?.(f),r||o?.(t)},...a}):null});dc.displayName="CommandItem";import{buildOllamaApiUrl as Ek,normalizeOllamaBaseUrl as Ak,OllamaCorsError as Lk}from"@mcp-use/agent";import{ChevronDown as xk,Key as wk}from"lucide-react";import{jsx as Yn,jsxs as Gu}from"react/jsx-runtime";var Ck="https://cdn.mcp-use.com/mcpuse_logo_circle_dark.svg";function xv({symbolSize:e=14,className:t,textClassName:n}){return Gu("span",{className:w("inline-flex items-center gap-1.5 text-black dark:text-white",t),children:[Yn(Sk,{size:e}),Yn("span",{className:w("font-medium leading-none text-current [font-family:var(--font-family-outfit)]",n),children:"Manufact"})]})}function Sk({size:e=14,className:t}){return Gu("svg",{width:e,height:e,viewBox:"0 0 480 480","aria-hidden":!0,className:w("block shrink-0",t),children:[Yn("path",{d:"M101.7 0 C157.9 0 203.4 45.7 203.4 102.1 C203.4 126.6 202.1 152.1 212.2 174.3 L219.8 191 C233.8 221.8 258.5 246.4 289.2 260.5 L303.5 267 C326.5 277.5 353 275.8 378.3 275.8 C434.5 275.8 480 321.5 480 377.9 C480 434.3 434.5 480 378.3 480 C322.1 480 276.6 434.3 276.6 377.9 C276.6 354.2 277.7 329.6 267.8 308 L259.8 290.3 C245.7 259.5 221 234.8 190.2 220.7 L173 212.9 C151 202.9 125.8 204.2 101.7 204.2 C45.5 204.2 0 158.5 0 102.1 C0 45.7 45.5 0 101.7 0 Z",fill:"currentColor"}),Yn("circle",{cx:"96.4",cy:"383.6",r:"96.4",fill:"currentColor"}),Yn("circle",{cx:"383.6",cy:"96.4",r:"96.4",fill:"currentColor"})]})}var Nk='<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" fill="#94A3B8" stroke="#94A3B8"><g><path fill="none" d="M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945" stroke-width="90"/><path d="M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"/><path fill="none" d="M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377" stroke-width="90"/><path d="M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"/></g></svg>',Tk=`data:image/svg+xml,${encodeURIComponent(Nk)}`,wv={openai:"OpenAI",anthropic:"Anthropic",google:"Google",deepseek:"DeepSeek","z-ai":"Z.AI",nvidia:"NVIDIA",minimax:"MiniMax",moonshotai:"Moonshot AI",inclusionai:"InclusionAI","nex-agi":"Nex AGI","x-ai":"xAI",thinkingmachines:"Thinking Machines",mistralai:"Mistral AI",stepfun:"StepFun","aion-labs":"Aion Labs","bytedance-seed":"ByteDance Seed","ibm-granite":"IBM Granite","arcee-ai":"Arcee AI",rekaai:"Reka AI",kwaipilot:"KwaiPilot"};function uc(e,t){let n=e.trim(),o=wv[t];if(o){let s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`^${s}\\s*:\\s*`,"i"),i=n.replace(a,"").trim();if(i.length>0)return i}let r=n.indexOf(": ");return r>0&&r<48?n.slice(r+2).trim():n}function Cv({provider:e,model:t,displayName:n,managedModel:o,mode:r="byok",className:s,...a}){let i=r==="managed"?o:null,c=i?uc(i.name,i.provider):n??t,l=i?i.provider:r==="managed"&&e==="openai-compatible"&&t.split("/")[0]||e;return Gu("button",{type:"button",className:w("inline-flex items-center gap-1.5 min-w-0 border-0 bg-transparent p-1","font-mono text-[11px] text-muted-foreground cursor-pointer","hover:text-foreground transition-colors","rounded-md outline-none focus-visible:ring-1 focus-visible:ring-ring",s),...a,children:[r==="managed"?Yn("img",{src:Ck,alt:"Manufact",className:"h-3.5 w-3.5 shrink-0 rounded-full object-cover"}):Yn(wk,{className:"size-3 shrink-0 opacity-70","aria-hidden":!0}),Yn(so,{provider:l,className:"shrink-0"}),Yn("span",{className:"whitespace-nowrap",children:c}),Yn(xk,{className:"size-3 shrink-0 opacity-60","aria-hidden":!0})]})}function qt(e){let t=wv[e];if(t)return t;switch(e){case"openai":return"OpenAI";case"openai-compatible":return"OpenAI Compatible";case"anthropic":return"Anthropic";case"google":return"Google";case"openrouter":return"OpenRouter";case"ollama":return"Ollama";default:return e.split(/[-_]/).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}}function kk(e,t){switch(e){case"openai":case"anthropic":case"google":return ma(`${e}.png`);case"ollama":return ma(`${t==="dark"?"ollama_dark":"ollama_light"}.png`);case"openrouter":return Tk;case"openai-compatible":return null;default:return null}}function so({provider:e,className:t}){let{resolvedTheme:n}=go();if(e==="openai-compatible")return null;let o=kk(e,n);if(o){let r=e==="ollama"?"h-3.5 w-3.5 object-contain":"h-4 w-4 rounded-full object-cover";return Yn("img",{src:o,alt:qt(e),className:w(r,t)})}return Yn("div",{"aria-label":qt(e),className:w("flex h-4 w-4 items-center justify-center rounded-full bg-neutral-900 text-[9px] font-semibold text-white dark:bg-neutral-100 dark:text-neutral-900",t),children:qt(e).charAt(0)})}import{Fragment as qk,jsx as ee,jsxs as $e}from"react/jsx-runtime";var Xu="mcp-inspector-models-cache",Dk=1440*60*1e3;function Pv(){try{let e=localStorage.getItem(Xu);if(e)return JSON.parse(e)}catch(e){console.error("Failed to load models cache:",e)}return{}}function _k(e,t){try{let n=Pv();n[e]={models:t,timestamp:Date.now()},localStorage.setItem(Xu,JSON.stringify(n))}catch(n){console.error("Failed to save models cache:",n)}}function Ok(e){try{let t=Pv(),n=t[e];if(n){if(Date.now()-n.timestamp<Dk)return n.models;delete t[e],localStorage.setItem(Xu,JSON.stringify(t))}}catch(t){console.error("Failed to get cached models:",t)}return null}function zk(e,t){if(!_o(e)||!t?.trim())return e;let n=e==="ollama"?Ak(t):t.trim().toLowerCase();return`${e}:${n}`}var Bk="chat-config-source",kv=["openai","anthropic","google"];async function Hk(e,t){let n={};t&&(n.Authorization=`Bearer ${t}`);let o;try{o=await fetch(`${e}/models`,{headers:n})}catch{throw new Error("Failed to reach the server. Check the URL is correct and that CORS is enabled on the server.")}if(!o.ok)throw new Error(`Failed to fetch models: ${o.statusText}`);if(!(o.headers.get("content-type")??"").includes("application/json"))throw new Error("Invalid URL \u2014 response was not JSON");let s=await o.json();if(!Array.isArray(s?.data))throw new Error("Unexpected response format \u2014 expected { data: [...] } from the OpenAI-compatible endpoint");return s.data.map(a=>({id:a.id}))}async function Uk(e){let t=await fetch("https://api.openai.com/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenAI models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id}))}async function Fk(e){let t=await fetch("https://api.anthropic.com/v1/models",{headers:{"x-api-key":e,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"}});if(!t.ok)throw new Error(`Failed to fetch Anthropic models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.display_name}))}async function $k(e){let t=await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${e}`);if(!t.ok)throw new Error(`Failed to fetch Google models: ${t.statusText}`);return((await t.json()).models||[]).map(o=>({id:o.name,displayName:o.displayName}))}async function Vk(e){let t=await fetch("https://openrouter.ai/api/v1/models",{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`Failed to fetch OpenRouter models: ${t.statusText}`);return(await t.json()).data.map(o=>({id:o.id,displayName:o.name}))}async function jk(e,t){let n;try{n=await fetch(Ek(e,"/api/tags"),{headers:{...t.trim()?{Authorization:`Bearer ${t.trim()}`}:{}}})}catch(r){throw new Lk(r)}if(!n.ok)throw new Error(`Failed to fetch Ollama models: ${n.statusText}`);return((await n.json()).models||[]).map(r=>({id:r.model||r.name||""}))}function ei({open:e,onOpenChange:t,tempProvider:n,tempModel:o,tempApiKey:r,tempBaseUrl:s,onProviderChange:a,onModelChange:i,onApiKeyChange:c,onBaseUrlChange:l,onSave:u,onClear:p,showClearButton:d=!1,buttonLabel:h="Configure API Key",hostedInspector:m=!1,freeTierInfo:b,managedCloudInfo:f,useManagedCloud:v=!1,onSaveManagedCloud:x}){let{resolvedTheme:y}=go(),g=Xl(y),C=y==="dark",[k,I]=ts([]),[M,N]=ts(!1),[E,T]=ts(null),[S,P]=ts(!1),[A,R]=ts(!1),[W,H]=ts(!1),[Y,U]=ts(v?0:1),V=zk(n,s),K=!!(m||b||f),$=!!(f&&Y===0);Yu(()=>{e&&U(v?0:1)},[e,v]),Yu(()=>{let D=Kr(n),_=_o(n);if($||!e||!n||D&&!r.trim()||_&&!s.trim()){I([]),T(null);return}let Le=setTimeout(async()=>{let Oe=Ok(V);if(Oe){I(Oe),T(null);return}N(!0),T(null);try{let He=[];n==="openai-compatible"?He=await Hk(s,r):n==="openai"?He=await Uk(r):n==="anthropic"?He=await Fk(r):n==="google"?He=await $k(r):n==="openrouter"?He=await Vk(r):n==="ollama"&&(He=await jk(s,r)),_k(V,He),I(He)}catch(He){T(He instanceof Error?He.message:"Failed to fetch models. Please check your API key."),I([])}finally{N(!1)}},500);return()=>clearTimeout(Le)},[r,s,n,e,V,$]);let G=Ik(null);Yu(()=>{if(!e||$){e||(G.current=null);return}let D=G.current;D!==null&&D!==n&&i(""),G.current=n},[n,e,i,$]);let te=_o(n),Z=!Kr(n),z=e&&(!Kr(n)||!!r.trim())&&(!te||!!s.trim()),F=Z?"API Key (optional)":"API Key",ie=Z?n==="ollama"?"Leave empty for local Ollama":"Enter your API key (optional)":"Enter your API key",le=n==="openai-compatible"?"http://localhost:11434/v1":dr(n),Ne=n==="openai-compatible"?"Base URL of your OpenAI-compatible API. Local servers must have CORS enabled.":null,de=n==="ollama"?"Optional for local Ollama. Stored locally and never sent to our servers.":"Your API key is stored locally and never sent to our servers.",re=f?f.models.reduce((D,_)=>(D[_.provider]||(D[_.provider]=[]),D[_.provider].push(_),D),{}):{},me=f?.models.find(D=>D.id===f.selectedModelId),be=kv.filter(D=>re[D]?.length),pe=me?.provider??be[0]??"",We=!!me&&!kv.includes(me.provider),Ke=pe?re[pe]??[]:[],Ve=!!p&&d&&(!f||Y===1),pt=()=>{if($&&x){x();return}u()},lt=$?!!(f?.isLoading||!f?.selectedModelId||f?.models.length===0):Kr(n)&&!r.trim()||te&&!s.trim()||!o.trim();return ee(on,{open:e,onOpenChange:t,children:$e(Xt,{className:"max-w-md","data-testid":"chat-config-dialog",children:[$e(Gt,{children:[ee($t,{children:K?"Configure Chat":"LLM Provider Configuration"}),ee(To,{children:f?"Pick a Manufact cloud model or bring your own API key.":b?"Chat requires an LLM. You can chat for free if you have a Manufact account, or you can use your own API key (not sent to Manufact).":"Configure your LLM provider and API key to start chatting with the MCP server"})]}),$e("div",{className:"space-y-4",children:[b&&$e("button",{type:"button",onClick:b.onLoginClick,"data-testid":"chat-config-sign-in-card",className:"relative w-full cursor-pointer overflow-hidden rounded-2xl border-0 text-left transition-opacity hover:opacity-95 active:opacity-90",children:[ee("div",{className:"absolute inset-0 bg-[#edf2ff] dark:bg-background","aria-hidden":!0}),ee("div",{className:"absolute inset-0 dark:opacity-90",children:ee(Yl,{className:"absolute inset-0 h-full w-full",colors:[...g],grainOverlay:C?.1:.15})}),$e("div",{className:"relative flex items-center justify-between gap-4 px-4 py-3.5",children:[$e("div",{className:"text-sm font-medium text-foreground",children:[ee("p",{children:"Chat for free with a"}),$e("p",{className:"mt-1 flex items-center gap-1.5",children:[ee(xv,{symbolSize:14,textClassName:"text-sm"}),"account"]})]}),ee(L,{size:"sm",render:ee("span",{"aria-hidden":"true"}),nativeButton:!1,tabIndex:-1,className:"pointer-events-none shrink-0",children:"Sign in"})]})]}),f&&ee("div",{className:"flex justify-center",children:$e(Za,{selectedIndex:Y,onSelect:U,idPrefix:Bk,className:"w-fit",children:[ee(es,{index:0,label:"Manufact cloud"}),ee(es,{index:1,label:"API key"})]})}),$e("div",{className:w("space-y-2",f&&"!mt-2"),children:[ee(Be,{children:"Provider"}),$?$e(un,{value:pe,onValueChange:D=>{let _=f?.models.find(j=>j.provider===D);_&&f?.onModelChange(_.id)},children:[ee(hn,{className:"rounded-md",leading:pe?ee(so,{provider:pe,className:"shrink-0"}):void 0,children:ee(fn,{})}),$e(gn,{children:[We&&$e(ht,{value:pe,label:qt(pe),disabled:!0,children:[qt(pe)," (current)"]}),be.map(D=>ee(ht,{value:D,label:qt(D),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:D}),ee("span",{children:qt(D)})]})},D))]})]}):$e(un,{value:n,onValueChange:D=>a(D),children:[ee(hn,{className:"rounded-md",leading:ee(so,{provider:n,className:"shrink-0"}),children:ee(fn,{})}),$e(gn,{children:[ee(ht,{value:"openai",label:qt("openai"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"openai"}),ee("span",{children:qt("openai")})]})}),ee(ht,{value:"anthropic",label:qt("anthropic"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"anthropic"}),ee("span",{children:qt("anthropic")})]})}),ee(ht,{value:"google",label:qt("google"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"google"}),ee("span",{children:qt("google")})]})}),ee(ht,{value:"ollama",label:qt("ollama"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"ollama"}),ee("span",{children:qt("ollama")})]})}),ee(ht,{value:"openrouter",label:qt("openrouter"),children:$e("div",{className:"flex items-center gap-2",children:[ee(so,{provider:"openrouter"}),ee("span",{children:qt("openrouter")})]})}),ee(ht,{value:"openai-compatible",label:qt("openai-compatible"),children:ee("div",{className:"flex items-center gap-2",children:ee("span",{children:qt("openai-compatible")})})})]})]})]}),!$&&te&&$e("div",{className:"space-y-2",children:[ee(Be,{children:"Base URL"}),ee(Ae,{value:s,onChange:D=>l(D.target.value),placeholder:le,"data-testid":"chat-config-base-url-input"}),Ne&&ee("p",{className:"text-xs text-muted-foreground",children:Ne})]}),!$&&$e("div",{className:"space-y-2",children:[ee(Be,{children:F}),$e("div",{className:"relative",children:[ee(Ae,{type:W?"text":"password",value:r,onChange:D=>c(D.target.value),placeholder:ie,className:"pr-10","data-testid":"chat-config-api-key-input"}),ee(L,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>H(!W),children:W?ee(Rk,{className:"h-4 w-4 text-muted-foreground"}):ee(Pk,{className:"h-4 w-4 text-muted-foreground"})})]}),ee("p",{className:"text-xs text-muted-foreground",children:de})]}),$?$e("div",{className:"space-y-2",children:[ee(Be,{children:"Model"}),f?.isLoading?$e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[ee(Tv,{className:"h-4 w-4 animate-spin"}),ee("span",{children:"Loading models\u2026"})]}):Ke.length>0?$e(rr,{open:A,modal:!0,onOpenChange:R,children:[ee(sr,{render:$e(L,{variant:"outline",role:"combobox","aria-expanded":A,className:"w-full justify-between rounded-md","data-testid":"chat-config-cloud-model-select",disabled:We,children:[ee("span",{className:"inline-flex min-w-0 items-center gap-2 truncate",children:me?$e(qk,{children:[ee(so,{provider:me.provider,className:"shrink-0"}),ee("span",{className:"truncate",children:uc(me.name,me.provider)})]}):"Select a model\u2026"}),ee(Nv,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),ee(ar,{className:"w-full p-0",align:"start",children:$e(sc,{children:[ee(ac,{placeholder:"Search models\u2026",className:"h-9"}),$e(ic,{children:[ee(lc,{children:"No model found."}),ee(cc,{children:Ke.map(D=>$e(dc,{value:D.id,keywords:[D.name,D.id,D.provider],onSelect:_=>{f?.onModelChange(_),R(!1)},children:[uc(D.name,D.provider),ee(Sv,{className:w("ml-auto h-4 w-4",f?.selectedModelId===D.id?"opacity-100":"opacity-0")})]},D.id))})]})]})})]}):ee("p",{className:"text-sm text-muted-foreground",children:"Cloud models unavailable \u2014 try again or use your own key."})]}):z&&$e("div",{className:"space-y-2",children:[ee(Be,{children:"Model"}),M?$e("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[ee(Tv,{className:"h-4 w-4 animate-spin"}),ee("span",{children:"Loading models..."})]}):E?ee("div",{className:"text-sm text-destructive",children:E}):k.length>0?$e(rr,{open:S,modal:!0,onOpenChange:P,children:[ee(sr,{render:$e(L,{variant:"outline",role:"combobox","aria-expanded":S,className:"w-full justify-between rounded-md","data-testid":"chat-config-model-select",children:[ee("span",{className:"truncate",children:o&&(k.find(D=>D.id===o)?.displayName||k.find(D=>D.id===o)?.id)||"Select a model..."}),ee(Nv,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),nativeButton:!0}),ee(ar,{className:"w-full p-0",align:"start",children:$e(sc,{children:[ee(ac,{placeholder:"Search models...",className:"h-9"}),$e(ic,{children:[ee(lc,{children:"No model found."}),ee(cc,{children:k.map(D=>$e(dc,{value:D.id,keywords:D.displayName,onSelect:_=>{i(_===o?"":_),P(!1)},children:[D.displayName||D.id,ee(Sv,{className:w("ml-auto h-4 w-4",o===D.id?"opacity-100":"opacity-0")})]},D.id))})]})]})})]}):ee(Ae,{value:o,onChange:D=>i(D.target.value),placeholder:"Enter model name manually","data-testid":"chat-config-model-input"})]}),$e("div",{className:"flex justify-between",children:[Ve&&ee(L,{variant:"outline",onClick:p,children:"Clear Config"}),$e(L,{onClick:pt,disabled:lt,className:Ve?"ml-auto":"","data-testid":"chat-config-save-button",children:[ee(Mk,{className:"h-4 w-4 mr-2"}),"Save Configuration"]})]})]})]})})}var Qu="rounded-full bg-background/80 backdrop-blur-md supports-[backdrop-filter]:bg-background/60 dark:bg-zinc-950/75 dark:supports-[backdrop-filter]:bg-zinc-950/55",Zu=w(Qu,"w-fit"),mc=w(Qu,"h-9 gap-1.5 px-3");import{jsx as Ft,jsxs as wo}from"react/jsx-runtime";var Gk="chat-view";function em({llmConfig:e,hasMessages:t,configDialogOpen:n,onConfigDialogOpenChange:o,onClearChat:r,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:c,onProviderChange:l,onModelChange:u,onApiKeyChange:p,onBaseUrlChange:d,onSaveConfig:h,onClearConfig:m,hideConfigButton:b,hostedInspector:f,freeTierInfo:v,managedCloudInfo:x,useManagedCloud:y,onSaveManagedCloud:g,showClearButton:C,clearButtonLabel:k,hideTitle:I,clearButtonHideIcon:M,clearButtonHideShortcut:N,clearButtonVariant:E,hideClearButton:T,onCopyChat:S,onExportChat:P,activeChatId:A,chatTitle:R,showViewToggle:W,viewIndex:H=0,onViewIndexChange:Y,elevatedHeader:U}){return wo("div",{className:w("relative flex w-full items-center gap-2 overflow-visible",jo,U?"pointer-events-none absolute top-0 right-0 z-50":"absolute top-0 right-0 z-10"),children:[Ft("div",{className:w("flex min-w-0 flex-1 items-center",U&&"pointer-events-auto"),children:!I&&Ft("h2",{className:w(qo,Zu),children:A?Ft(Ka,{chatId:A,title:R??fr},A):fr})}),W&&Y&&Ft("div",{className:w("absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 overflow-visible px-1",U&&"pointer-events-auto"),children:wo(Za,{selectedIndex:H,onSelect:Y,idPrefix:Gk,className:"shrink-0 overflow-visible","data-testid":"chat-view-tabs",children:[Ft(es,{label:"Conv",index:0}),Ft(es,{label:"Raw",index:1})]})}),wo("div",{className:w("ml-auto flex shrink-0 items-center gap-2",U&&"pointer-events-auto"),children:[!T&&t&&wo("div",{className:"flex items-center gap-1",children:[S&&wo(L,{"data-testid":"chat-copy-button",variant:"ghost",size:"sm",className:mc,onClick:S,children:[Ft(Wk,{className:"h-4 w-4"}),Ft("span",{className:"hidden sm:inline",children:"Copy"})]}),P&&wo(Ir,{children:[Ft(Go,{render:wo(L,{"data-testid":"chat-export-button",variant:"ghost",size:"sm",className:mc,children:[Ft(Kk,{className:"h-4 w-4"}),Ft("span",{className:"hidden sm:inline",children:"Export"})]}),nativeButton:!0}),wo(Er,{align:"end",children:[Ft(Un,{"data-testid":"chat-export-json",onClick:()=>P("json"),children:"Export as JSON"}),Ft(Un,{"data-testid":"chat-export-markdown",onClick:()=>P("markdown"),children:"Export as Markdown"})]})]}),Ft("div",{className:"w-px h-4 bg-border mx-1"}),wo(Ie,{children:[Ft(Re,{render:wo(L,{variant:E??"default",size:"default",className:`p-2 cursor-pointer ${N?"sm:px-3":"sm:pr-1 sm:pl-3"}`,onClick:r,children:[!M&&Ft(Jk,{className:"h-4 w-4 sm:mr-2"}),Ft("span",{className:"hidden sm:inline",children:k??"New Chat"}),!N&&Ft("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:"\u2318O"})]}),nativeButton:!0}),Ft(Me,{children:Ft("p",{children:k??"New Chat"})})]})]}),(!b||f||v||x)&&Ft(ei,{open:n,onOpenChange:o,tempProvider:s,tempModel:a,tempApiKey:i,tempBaseUrl:c,onProviderChange:l,onModelChange:u,onApiKeyChange:p,onBaseUrlChange:d,onSave:h,onClear:m,showClearButton:C??(!!e&&!v&&!x),buttonLabel:e?"Change API Key":"Configure API Key",hostedInspector:f,freeTierInfo:v,managedCloudInfo:x,useManagedCloud:y,onSaveManagedCloud:g})]})]})}import{ArrowUp as AP,Loader2 as LP}from"lucide-react";import{Image as Zk,Paperclip as eP,X as tP}from"lucide-react";import{useRef as nP}from"react";import{Wrench as Yk}from"lucide-react";import{useCallback as Rv,useMemo as Xk,useState as Qk}from"react";import{jsx as Ho,jsxs as vr}from"react/jsx-runtime";function Mv({tools:e,disabledTools:t,onDisabledToolsChange:n,disabled:o}){let[r,s]=Qk(!1),a=e.length-t.size,i=t.size===0,c=t.size>0&&t.size<e.length,l=Rv(d=>{let h=new Set(t);h.has(d)?h.delete(d):h.add(d),n(h)},[t,n]),u=Rv(()=>{n(i?new Set(e.map(d=>d.name)):new Set)},[i,e,n]),p=Xk(()=>[...e].sort((d,h)=>d.name.localeCompare(h.name)),[e]);return e.length===0?null:vr(rr,{open:r,onOpenChange:s,children:[vr(Ie,{children:[Ho(Re,{render:Ho(sr,{render:vr(L,{variant:"ghost",size:"sm",disabled:o,className:w("h-auto gap-1 rounded-full px-2 py-2",c?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"),type:"button","data-testid":"chat-tool-selector",children:[Ho(Yk,{className:"h-4 w-4 shrink-0"}),c&&Ho("span",{className:"flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-bold leading-none text-white",children:a})]}),nativeButton:!0}),nativeButton:!0}),Ho(Me,{side:"top",children:vr("p",{children:["Tools (",a,"/",e.length,")"]})})]}),vr(ar,{className:"w-72 gap-0 p-0",align:"start",side:"top",sideOffset:8,children:[vr("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[vr("span",{className:"text-xs font-medium text-muted-foreground",children:["Allowed Tools (",a,"/",e.length,")"]}),Ho(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:u,type:"button",children:i?"Disable All":"Enable All"})]}),Ho("div",{className:"max-h-64 overflow-y-auto",children:p.map(d=>{let h=!t.has(d.name);return vr("button",{type:"button",className:"flex items-center gap-2.5 w-full px-3 py-1.5 text-left hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>l(d.name),children:[Ho($a,{checked:h,className:"pointer-events-none",tabIndex:-1}),Ho("span",{className:"min-w-0 flex-1 truncate text-sm font-mono",children:d.name})]},d.name)})})]})]})}import{jsx as zn,jsxs as ti}from"react/jsx-runtime";function Iv({variant:e="default",inputValue:t,isConnected:n,isLoading:o,textareaRef:r,attachments:s,placeholder:a="Ask a question",className:i,showAttachButton:c=!0,tools:l,disabledTools:u,onDisabledToolsChange:p,onInputChange:d,onKeyDown:h,onKeyUp:m,onClick:b,onAttachmentAdd:f,onAttachmentRemove:v,inlineControls:x,trailingControls:y}){let g=kt(),C=nP(null),k=e==="fullscreen",I=N=>{let E=N.target.files;if(E&&E.length>0)for(let T=0;T<E.length;T++)f(E[T]);C.current&&(C.current.value="")},M=s.length>0;return ti("div",{className:"relative w-full","data-chat-input-variant":e,children:[!k&&M&&zn("div",{className:"absolute top-0 left-0 right-0 z-20 p-3 flex gap-2 flex-wrap",children:s.map((N,E)=>ti("div",{className:"relative group bg-zinc-100/90 dark:bg-zinc-900/90 backdrop-blur-sm rounded-lg p-2 flex items-center gap-2 border border-zinc-200 dark:border-zinc-700","data-testid":`chat-attachment-${E}`,children:[zn(Zk,{className:"h-4 w-4 text-muted-foreground shrink-0"}),ti("div",{className:"flex flex-col min-w-0",children:[zn("span",{className:"text-xs font-medium truncate max-w-[150px]",children:N.name||"Image"}),N.size&&zn("span",{className:"text-xs text-muted-foreground",children:Ng(N.size)})]}),zn("button",{onClick:()=>v(E),className:"shrink-0 p-1 rounded-full hover:bg-zinc-200 dark:hover:bg-zinc-800 transition-colors",title:"Remove attachment",type:"button","data-testid":`chat-attachment-remove-${E}`,children:zn(tP,{className:"h-3 w-3"})})]},E))}),zn(fo,{ref:r,value:t,onChange:N=>d(N.target.value),onKeyDown:h,onKeyUp:m,onClick:b,placeholder:n?a:"Server not connected",className:w(k?"field-sizing-fixed h-11 min-h-11 max-h-11 resize-none overflow-hidden py-2.5 pl-4 pr-12":"p-4 pb-14 min-h-[150px] max-h-[300px]",g.container,!k&&M&&"pt-20",i),rows:k?1:void 0,disabled:!n||o,"data-testid":"chat-input"}),zn("input",{ref:C,type:"file",accept:"image/*",multiple:!0,onChange:I,className:"hidden","aria-label":"Upload images"}),k?y?zn("div",{className:"absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center",children:y}):null:ti("div",{className:"absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 p-3",children:[ti("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[c&&zn(L,{variant:"ghost",size:"sm",onClick:()=>C.current?.click(),disabled:!n||o,className:"h-auto w-auto aspect-square rounded-full p-2 text-muted-foreground hover:text-foreground",title:"Attach images",type:"button","data-testid":"chat-attach-button",children:zn(eP,{className:"h-4 w-4"})}),l&&l.length>0&&u&&p&&zn(Mv,{tools:l,disabledTools:u,onDisabledToolsChange:p,disabled:!n||o}),x]}),y?zn("div",{className:"flex shrink-0 items-center gap-1.5",children:y}):null]})]})}import{MessageSquare as oP,X as rP}from"lucide-react";import{jsx as ni,jsxs as sP}from"react/jsx-runtime";function Ev({promptResults:e,onDeletePromptResult:t,offsetForSkills:n=!1}){return ni("div",{className:`absolute ${n?"top-12":"top-4"} left-4 right-4 flex gap-2 overflow-x-auto z-20 flex-nowrap`,style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(({promptName:o},r)=>sP(L,{type:"button",className:"flex items-center gap-2 bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 dark:bg-zinc-700 rounded-lg border border-zinc-200 dark:border-zinc-300 font-medium hover:bg-zinc-300 dark:hover:bg-zinc-600",children:[ni(oP,{className:"h-3.5 w-3.5 shrink-0"}),ni("span",{className:"truncate",title:o,children:o}),ni("span",{className:"ml-1 h-4 w-4 rounded-full bg-zinc-400 dark:bg-zinc-600 hover:bg-zinc-500 dark:hover:bg-zinc-500 flex items-center justify-center cursor-pointer shrink-0 transition-colors",onClick:s=>{s.stopPropagation(),t(r)},title:"Remove prompt",role:"button",tabIndex:0,children:ni(rP,{className:"h-2.5 w-2.5 text-white"})})]},r))})}import{MessageSquare as aP}from"lucide-react";import{useEffect as iP}from"react";import{jsx as br,jsxs as pc}from"react/jsx-runtime";function Av({isOpen:e,focusedIndex:t,prompts:n,selectedPrompt:o,onPromptSelect:r}){return e?(iP(()=>{if(t>=0){let s=document.getElementById(`prompt-suggestion-${t}`);s&&s.scrollIntoView({behavior:"smooth",block:"nearest"})}},[t]),br("div",{className:"absolute bottom-full left-0 right-0 max-w-3xl w-full max-h-[300px] overflow-y-auto rounded-lg border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-lg z-30 flex flex-col gap-2 mb-1","data-testid":"chat-prompts-dropdown",children:pc("div",{className:"p-2",children:[n.length>0&&br("div",{className:"text-xs font-medium text-zinc-900 dark:text-zinc-100 mb-2",children:"Prompts"}),n.map((s,a)=>pc(Ie,{children:[br(Re,{render:pc(L,{id:`prompt-suggestion-${a}`,type:"button",variant:"ghost",className:w("w-full flex items-center px-3 py-2 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-left justify-start",t===a&&"bg-zinc-200 dark:bg-zinc-700"),onClick:()=>r(s),"data-testid":`chat-prompt-option-${a}`,children:[br("div",{className:"flex items-center justify-center shrink-0",children:br(aP,{className:"h-4 w-4 text-zinc-600 dark:text-zinc-400"})}),br("div",{className:"flex-1 min-w-0",children:pc("div",{className:"text-sm font-medium text-zinc-900 dark:text-zinc-100 flex items-center gap-2",children:[s.name,o?.name===s.name&&br(An,{className:"size-3 text-zinc-600 dark:text-zinc-400"})]})})]}),nativeButton:!0}),br(Me,{children:s.description})]},a))]})})):null}import{motion as TP}from"motion/react";import{useMemo as Wv,useState as Kv}from"react";import{ExternalLink as NP}from"lucide-react";import{toast as Jv}from"sonner";import{forwardRef as hP,useCallback as Rn,useEffect as ao,useId as vP,useMemo as ri,useRef as Uo,useState as ns}from"react";import{AnimatePresence as js,motion as Co}from"motion/react";import{RadioGroup as bP}from"@base-ui/react/radio-group";import{Radio as yP}from"@base-ui/react/radio";import{CheckboxGroup as xP}from"@base-ui/react/checkbox-group";import{Checkbox as wP}from"@base-ui/react/checkbox";import{Field as sm}from"@base-ui/react/field";import{useEffect as rm,useLayoutEffect as lP,useRef as tm,useState as cP}from"react";import{AnimatePresence as dP,motion as uP}from"motion/react";import{jsx as Dv}from"react/jsx-runtime";var mP=typeof window<"u"?lP:rm,$s=ce.moderate,oi=.07,pP=($s.duration+oi)*1e3+80,fP=$s.duration*1e3+80;function nm(e,t){let n=t.filter(s=>s.start>=e.start&&s.end<=e.end).sort((s,a)=>s.start-a.start);if(n.length!==2)return null;let[o,r]=n;return r.start===o.end+2?{up:o,lo:r,gap:o.end+1}:null}function gP(e,t,n,o){let r=n[e],s=n[t];if(!r||!s)return null;if(o==="y")return{top:r.top,left:Math.min(r.left,s.left),width:Math.max(r.width,s.width),height:s.top+s.height-r.top};let a=Math.min(r.left,s.left),i=Math.max(r.left+r.width,s.left+s.width);return{top:Math.min(r.top,s.top),left:a,width:i-a,height:Math.max(r.height,s.height)}}function _v(e,t){return t==="y"?e.top+e.height/2:e.left+e.width/2}function fc(e,t){return t==="y"?[e,e,0,0]:[e,0,0,e]}function yr(e,t){return t==="y"?[0,0,e,e]:[0,e,e,0]}function om(e){return[e,e,e,e]}function Lv(e,t,n,o,r){let s=_v(n,o);if(o==="y"){let i=t.top+t.height;e.height=s-e.top,e.radii=fc(r,o),e.instant=!0,t.top=s,t.height=i-s,t.radii=yr(r,o),t.instant=!0,t.enterFrom={top:s,left:t.left,width:t.width,height:i-s,radii:yr(r,o)};return}let a=t.left+t.width;e.width=s-e.left,e.radii=fc(r,o),e.instant=!0,t.left=s,t.width=a-s,t.radii=yr(r,o),t.instant=!0,t.enterFrom={top:t.top,left:s,width:a-s,height:t.height,radii:yr(r,o)}}function Ov(e,t,n,o="y"){let[r,s]=cP([]),a=tm([]),i=tm(0),c=tm(new Map),l=e.map(d=>`${d.id}:${d.start}-${d.end}`).join("|");mP(()=>{let d=a.current,h=e,m=[];for(let f of h){let v=nm(f,d);v&&(f.id===v.up.id||f.id===v.lo.id)&&m.push({tid:++i.current,kind:"merge",survivorId:f.id,otherId:f.id===v.up.id?v.lo.id:v.up.id,gapIndex:v.gap,phase:"converge"})}for(let f of d){let v=nm(f,h);v&&m.push({tid:++i.current,kind:"split",survivorId:v.up.id,otherId:v.lo.id,gapIndex:v.gap,phase:"splitIn"})}a.current=h.map(f=>({...f}));for(let f of m)c.current.set(f.tid,setTimeout(()=>{c.current.delete(f.tid),s(v=>v.some(x=>x.tid===f.tid)?v.flatMap(x=>x.tid!==f.tid?[x]:x.kind==="merge"?[{...x,phase:"commit"}]:[]):v)},f.kind==="merge"?pP:fP));let b=f=>f.kind==="merge"?h.some(v=>v.id===f.survivorId&&f.gapIndex>v.start&&f.gapIndex<v.end):h.some(v=>v.id===f.survivorId&&v.end===f.gapIndex-1)&&h.some(v=>v.id===f.otherId&&v.start===f.gapIndex+1);s(f=>{for(let v of f){if(b(v))continue;let x=c.current.get(v.tid);x!==void 0&&(clearTimeout(x),c.current.delete(v.tid))}return[...f.filter(b),...m]})},[l]),rm(()=>{let d=c.current;return()=>d.forEach(clearTimeout)},[]),rm(()=>{r.some(d=>d.phase==="splitIn"||d.phase==="commit")&&s(d=>d.flatMap(h=>h.phase==="commit"?[]:[{...h,phase:h.phase==="splitIn"?"diverge":h.phase}]))},[r]);let u=[];for(let d of e){let h=gP(d.start,d.end,t,o);h&&u.push({key:`sel-${d.id}`,...h,radii:om(n),instant:!1,exitInstant:!1,delayCorners:!1})}let p=new Map(u.map(d=>[d.key,d]));for(let d of r){let h=t[d.gapIndex],m=p.get(`sel-${d.survivorId}`);if(!h||!m)continue;let b=_v(h,o);if(d.kind==="merge"){if(d.phase==="commit"){m.instant=!0,o==="y"?u.push({key:`sel-${d.otherId}`,top:b,left:m.left,width:m.width,height:m.top+m.height-b,radii:yr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0}):u.push({key:`sel-${d.otherId}`,top:m.top,left:b,width:m.left+m.width-b,height:m.height,radii:yr(n,o),instant:!0,exitInstant:!0,delayCorners:!1,opacity:0});continue}let f=Math.min(oi+.03,Math.max(oi,oi+b/Math.max(o==="y"?h.height:h.width,1)*.002));if(o==="y"){let v=m.top+m.height;m.height=b-m.top,m.radii=fc(n,o),m.delayCorners=!0,m.cornerDelay=f,u.push({key:`sel-${d.otherId}`,top:b,left:m.left,width:m.width,height:v-b,radii:yr(n,o),enterFrom:{top:b,left:m.left,width:m.width,height:v-b,radii:om(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}else{let v=m.left+m.width;m.width=b-m.left,m.radii=fc(n,o),m.delayCorners=!0,m.cornerDelay=f,u.push({key:`sel-${d.otherId}`,top:m.top,left:b,width:v-b,height:m.height,radii:yr(n,o),enterFrom:{top:m.top,left:b,width:v-b,height:m.height,radii:om(n)},instant:!1,exitInstant:!0,delayCorners:!0,cornerDelay:f})}}else if(d.phase==="splitIn"){let f=p.get(`sel-${d.otherId}`);if(!f)continue;Lv(m,f,h,o,n)}}for(let d of a.current){let h=nm(d,e),m=h&&t[h.gap];if(!h||!m)continue;let b=p.get(`sel-${h.up.id}`),f=p.get(`sel-${h.lo.id}`);!b||!f||Lv(b,f,m,o,n)}return u}function zv({blocks:e,dimmed:t}){return Dv(dP,{children:e.map(n=>{let o=n.delayCorners?{...$s,delay:n.cornerDelay??oi}:$s,r=n.opacity??(t?.8:1);return Dv(uP.div,{"aria-hidden":!0,className:"absolute bg-active pointer-events-none",initial:n.enterFrom?{opacity:r,top:n.enterFrom.top,left:n.enterFrom.left,width:n.enterFrom.width,height:n.enterFrom.height,borderTopLeftRadius:n.enterFrom.radii[0],borderTopRightRadius:n.enterFrom.radii[1],borderBottomRightRadius:n.enterFrom.radii[2],borderBottomLeftRadius:n.enterFrom.radii[3]}:!1,animate:{top:n.top,left:n.left,width:n.width,height:n.height,borderTopLeftRadius:n.radii[0],borderTopRightRadius:n.radii[1],borderBottomRightRadius:n.radii[2],borderBottomLeftRadius:n.radii[3],opacity:r},exit:{opacity:0,transition:n.exitInstant?{duration:0}:$s.exit},transition:n.instant?{duration:0}:{...$s,borderTopLeftRadius:o,borderTopRightRadius:o,borderBottomRightRadius:o,borderBottomLeftRadius:o,opacity:{duration:.08}}},n.key)})})}import{Fragment as Hv,jsx as he,jsxs as an}from"react/jsx-runtime";function CP(e,t){return e.id??`q-${t}`}function gc(e,t){return e.id??`o-${t}`}var Vs=[],am=hP(function({questions:t,currentIndex:n,defaultCurrentIndex:o=0,onCurrentIndexChange:r,answers:s,defaultAnswers:a,onAnswersChange:i,onComplete:c,onSkip:l,skipLabel:u="Skip",intro:p,onCancel:d,cancelLabel:h="Cancel",footerLeading:m,className:b,...f},v){let[x,y]=ns(o),g=n!==void 0,C=g?n:x,k=Rn(O=>{g||y(O),r?.(O)},[g,r]),[I,M]=ns(a??{}),N=s!==void 0,E=N?s:I,T=Uo(E);ao(()=>{T.current=E},[E]);let S=Rn(O=>{let ne=O(T.current);return T.current=ne,N||M(ne),i?.(ne),ne},[N,i]),P=kt(),A=Tr("arrow-left"),R=Tr("arrow-right"),W=ri(()=>function(ne){return he(A,{...ne,className:w(ne.className,"hidden sm:block")})},[A]),H=ri(()=>function(ne){return he(R,{...ne,className:w(ne.className,"hidden sm:block")})},[R]),[Y]=ns(()=>{if(typeof navigator>"u")return!1;let O=navigator,ne=O.userAgentData?.platform||O.platform||"";return/mac/i.test(ne)}),U=vP(),V=t.length,K=Math.max(0,Math.min(C,Math.max(0,V-1))),$=t[K],G=$?CP($,K):"",te=E[G],Z=!!$?.multiSelect,z=$?.skippable!==!1,F=!!$?.freeText,ie=$?.freeTextMultiline!==!1,le=!F&&!!$?.allowOther,Ne=ri(()=>te?.selectedIds??[],[te]),de=te?.otherText??"",re=$?.options??[],me=le?re.length:-1,be=re.length+(le?1:0),pe=Uo(null),We=!!$;ao(()=>{if(!We)return;let O=pe.current;if(O)return Vs.push(O),()=>{let ne=Vs.indexOf(O);ne!==-1&&Vs.splice(ne,1)}},[We]);let Ke=Uo(null),Ve=Uo(null),pt=Uo(0),lt=Uo(new Map),{activeIndex:D,setActiveIndex:_,itemRects:j,sessionRef:Le,handlers:Oe,registerItem:He,measureItems:tt}=Rr(Ke);ao(()=>{tt()},[tt,G,be,P]);let[ln,Nt]=ns(!1);ao(()=>{Nt(!1)},[G]),ao(()=>{let O=Ve.current;if(!O)return;O.style.height="0px",O.style.height=`${O.scrollHeight}px`;let ne=parseFloat(window.getComputedStyle(O).lineHeight)||18;Nt(O.scrollHeight>ne*1.5),tt()},[de,tt,G]),ao(()=>{F&&Ve.current?.focus({preventScroll:!0})},[F,G]);let Ze=Uo(null),[cn,co]=ns("auto");ao(()=>{let O=Ze.current;if(!O)return;let ne=()=>co(O.offsetHeight);ne();let Ee=new ResizeObserver(ne);return Ee.observe(O),()=>Ee.disconnect()},[]);let[Pt,Kt]=ns(null),[Cn,Tt]=ns(null);ao(()=>{_(null),Kt(null),Tt(null)},[K,_]);let Yt=Uo(!1),oe=Rn(()=>{Ke.current?.contains(document.activeElement)&&(Yt.current=!0)},[]);ao(()=>{if(!Yt.current)return;Yt.current=!1,Ke.current?.querySelector('[data-proximity-index="0"]')?.focus()},[K]);let fe=Rn(O=>{K>=V-1?c?.(O):(oe(),k(K+1))},[K,V,c,k,oe]),Ue=Rn(O=>{if(!$)return;let ne=T.current[G]?.otherText,Ee=S(Ct=>({...Ct,[G]:{questionId:G,selectedIds:[O],otherText:ne||void 0,skipped:!1}}));fe(Ee)},[$,G,S,fe]),ft=Rn(O=>{$&&S(ne=>{let Ee=ne[G],Ct=new Set(Ee?.selectedIds??[]);return Ct.has(O)?Ct.delete(O):Ct.add(O),{...ne,[G]:{questionId:G,selectedIds:Array.from(Ct),otherText:Ee?.otherText,skipped:!1}}})},[$,G,S]),Rt=Rn(O=>{$&&S(ne=>({...ne,[G]:{questionId:G,selectedIds:O,otherText:ne[G]?.otherText,skipped:!1}}))},[$,G,S]),ue=Rn(O=>{$&&(Tt(null),S(ne=>({...ne,[G]:{questionId:G,selectedIds:ne[G]?.selectedIds??[],otherText:O,skipped:!1}})))},[$,G,S]),ve=Rn(()=>{if(!$)return;let O=(T.current[G]?.otherText??"").trim();if(!O)return;if($.freeText&&$.freeTextValidate){let Ee=$.freeTextValidate(O);if(Ee){Tt(Ee);return}}Tt(null);let ne=S(Ee=>({...Ee,[G]:{questionId:G,selectedIds:Ee[G]?.selectedIds??[],otherText:O,skipped:!1}}));fe(ne)},[$,G,S,fe]),mt=Rn(()=>{if(!$)return;let O=S(ne=>({...ne,[G]:{questionId:G,selectedIds:ne[G]?.selectedIds??[],otherText:ne[G]?.otherText,skipped:!0}}));l?.(G,K),fe(O)},[$,G,S,l,K,fe]),nt=Rn(()=>{d?.()},[d]),B=Rn(()=>{fe(E)},[fe,E]),se=Rn(()=>{K>0&&(oe(),k(K-1))},[K,k,oe]);ao(()=>{if(!$)return;let O=ne=>{if(ne.metaKey||ne.ctrlKey||ne.altKey)return;let Ee=ne.target;if(!Ee)return;let Ct=Ee.tagName;if(Ct==="INPUT"||Ct==="TEXTAREA"||Ee.isContentEditable)return;let It=pe.current;if(!It||!It.contains(Ee)&&(Vs.some(eo=>eo!==It&&eo.contains(Ee))||Vs[Vs.length-1]!==It))return;let St=ne.key;if(St<"1"||St>"9")return;let Et=parseInt(St,10)-1;if(Et>=0&&Et<re.length){ne.preventDefault();let eo=gc(re[Et],Et);Z?ft(eo):Ue(eo)}else Et===re.length&&le&&(ne.preventDefault(),Ve.current?.focus())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[$,re,Z,le,Ue,ft]);let we=O=>{Ke.current?.querySelector(`[data-proximity-index="${O}"]`)?.focus()},Te=Rn(O=>{_(O),le&&O===me?Ve.current?.focus():we(O)},[le,me,_]),Ce=O=>{let ne=O.target,Ee=ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.isContentEditable;if(Ee&&O.key!=="ArrowDown"&&O.key!=="ArrowUp")return;if(Ee&&(O.key==="ArrowUp"||O.key==="ArrowDown")&&ne.tagName==="TEXTAREA"){let It=ne;if(O.key==="ArrowUp"&&It.selectionStart>0||O.key==="ArrowDown"&&It.selectionEnd<It.value.length)return}let Ct=O.preventBaseUIHandler;if(O.key==="ArrowLeft"||O.key==="ArrowRight"){O.preventDefault(),O.stopPropagation(),Ct?.(),O.key==="ArrowLeft"?K>0&&se():z&&V>1&&mt();return}if(be!==0&&(O.key==="ArrowDown"||O.key==="ArrowUp"||O.key==="Home"||O.key==="End")){O.preventDefault(),O.stopPropagation(),Ct?.();let It;if(O.key==="Home")It=0;else if(O.key==="End")It=be-1;else{let St=Ee?me:D??-1;It=O.key==="ArrowDown"?St+1:St-1,It=(It+be)%be}Te(It)}},je=O=>{if(O.key!=="Enter"||!(Y?O.metaKey:O.ctrlKey)||!(Z||F))return;if(O.preventDefault(),F){de.trim().length>0&&ve();return}(Ne.length>0||de.trim().length>0)&&B()};if(!$)return he("div",{ref:v,className:w("w-full max-w-[520px] p-5 bg-card border border-border",P.container,b),...f,children:he("p",{className:"text-[13px] text-muted-foreground",children:"No questions."})});let Fe=D!==null?j[D]:null,rt=Pt!==null&&!(le&&Pt===me)?j[Pt]:null,ut=ri(()=>{let O=new Set;return re.forEach((ne,Ee)=>{Ne.includes(gc(ne,Ee))&&O.add(Ee)}),le&&de.length>0&&O.add(me),O},[re,Ne,le,de,me]),Mt=ri(()=>{let O=[],ne=[...ut].sort((St,Et)=>St-Et);for(let St of ne){let Et=O[O.length-1];Et&&St===Et.end+1?Et.end=St:O.push({start:St,end:St})}let Ee=new Set,Ct=new Map,It=O.map(St=>{let Et=null;for(let dn=St.start;dn<=St.end;dn++){let In=lt.current.get(dn);if(In!==void 0&&!Ee.has(In)){Et=In;break}}let eo=Et??++pt.current;Ee.add(eo);for(let dn=St.start;dn<=St.end;dn++)Ct.set(dn,eo);return{...St,id:eo}});return lt.current=Ct,It},[ut]),ls=D!==null&&!ut.has(D),Cr=Ov(Mt,j,P.bgRadius),Bn=V>1&&K>0,Mn=d!=null,Zn=!Mn&&V>1&&z,gt=Z||F,So=Bn||Zn||gt||Mn||m!=null,yi=re.findIndex((O,ne)=>Ne.includes(gc(O,ne))),xi=an("div",{ref:Ke,role:Z?"group":"radiogroup","aria-labelledby":`${U}-${G}-title`,onMouseEnter:Oe.onMouseEnter,onMouseMove:Oe.onMouseMove,onMouseLeave:Oe.onMouseLeave,onFocus:O=>{let ne=O.target.closest("[data-proximity-index]")?.getAttribute("data-proximity-index");if(ne!=null){let Ee=Number(ne);_(Ee),Kt(O.target.matches(":focus-visible")?Ee:null)}},onBlur:O=>{Ke.current?.contains(O.relatedTarget)||(Kt(null),_(null))},onKeyDown:Ce,className:"relative flex flex-col gap-0.5 -mx-3",children:[he(js,{children:(()=>{if(!le)return null;let O=j[me],ne=Pt===me&&de.length===0;return!O||!ne?null:he(Co.div,{"aria-hidden":!0,className:w("absolute pointer-events-none bg-card ring-1 ring-inset ring-border",P.bg),initial:{opacity:0,top:O.top,left:O.left,width:O.width,height:O.height},animate:{opacity:1,top:O.top,left:O.left,width:O.width,height:O.height},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}},"other-input")})()}),he(js,{children:Fe&&he(Co.div,{"aria-hidden":!0,className:w("absolute pointer-events-none bg-hover",P.bg),initial:{opacity:0,top:Fe.top,left:Fe.left,width:Fe.width,height:Fe.height},animate:{opacity:1,top:Fe.top,left:Fe.left,width:Fe.width,height:Fe.height},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}},`hover-${Le.current}`)}),he(zv,{blocks:Cr,dimmed:ls}),he(js,{children:rt&&he(Co.div,{"aria-hidden":!0,className:w("absolute pointer-events-none border border-[color:var(--focus-ring,#6B97FF)] z-20",P.focusRing),initial:{opacity:0,top:rt.top-2,left:rt.left-2,width:rt.width+4,height:rt.height+4},animate:{opacity:1,top:rt.top-2,left:rt.left-2,width:rt.width+4,height:rt.height+4},exit:{opacity:0,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}}})}),re.map((O,ne)=>{let Ee=gc(O,ne),Ct=Ne.includes(Ee),St=!Z&&D===ne;return he(Bv,{index:ne,registerItem:He,role:Z?"checkbox":"radio",isSelected:Ct,tabIndex:ne===yi||yi===-1&&ne===0?0:-1,onClick:()=>Z?ft(Ee):Ue(Ee),onKeyDown:Et=>{(Et.key===" "||Et.key==="Enter")&&!Et.metaKey&&!Et.ctrlKey&&(Et.preventDefault(),Z?ft(Ee):Ue(Ee))},shape:P,"aria-checked":Ct,chipContent:ne+1,chipFilled:Ct,isMulti:Z,showArrow:St,bodyLayout:$.layout==="stacked"?"stacked":"inline",topAlign:$.layout==="stacked",chipPosition:$.chipPosition??"right",arrowIcon:he(R,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),hiddenControl:Z?he(wP.Root,{name:Ee,className:"sr-only",tabIndex:-1,"aria-hidden":!0}):he(yP.Root,{value:Ee,className:"sr-only",tabIndex:-1,"aria-hidden":!0}),children:$.layout==="stacked"?an(Hv,{children:[an("span",{className:"inline-grid",children:[he("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:At.semibold},"aria-hidden":"true",children:O.title}),he("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:Ct?At.semibold:At.medium},children:O.title})]}),O.description&&he("span",{className:"text-[12px] text-muted-foreground leading-snug",children:O.description})]}):an("span",{children:[an("span",{className:"inline-grid",children:[he("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:At.semibold},"aria-hidden":"true",children:O.title}),he("span",{className:"col-start-1 row-start-1 text-foreground transition-[color,font-variation-settings] duration-80",style:{fontVariationSettings:Ct?At.semibold:At.medium},children:O.title})]}),O.description&&an(Hv,{children:[" ",he("span",{className:"text-muted-foreground",children:O.description})]})]})},Ee)}),le&&he(Bv,{index:me,registerItem:He,role:null,isSelected:de.length>0,tabIndex:-1,onClick:()=>Ve.current?.focus(),shape:P,chipContent:me+1,chipFilled:de.length>0,isMulti:Z,topAlign:ln,chipPosition:$.chipPosition??"right",ariaLabel:$.otherPlaceholder??"Describe in your own words",showArrow:!Z&&(Pt===me||D===me)&&de.trim().length>0,arrowIcon:he(R,{size:14,strokeWidth:2,className:"h-3.5 w-3.5"}),onArrowClick:!Z&&de.trim().length>0?ve:void 0,children:he("span",{className:"inline-grid w-full",children:he("textarea",{ref:Ve,rows:1,value:de,placeholder:$.otherPlaceholder??"Describe in your own words\u2026","aria-label":$.otherPlaceholder??"Describe in your own words",onChange:O=>ue(O.target.value),onKeyDown:O=>{O.key==="Enter"&&(O.shiftKey||Z||(O.preventDefault(),ve()))},onClick:O=>O.stopPropagation(),className:w("col-start-1 row-start-1 block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground"),style:{fontVariationSettings:At.medium}})})})]});return an("div",{ref:O=>{pe.current=O,typeof v=="function"?v(O):v&&(v.current=O)},className:w("relative w-full max-w-[520px] overflow-hidden bg-card border border-border",P.container,b),...f,onKeyDown:O=>{f.onKeyDown?.(O),je(O)},children:[he("div",{className:"flex items-center px-4 sm:px-5 pt-4 sm:pt-5 pb-2 text-[12px] text-muted-foreground",children:an("span",{children:["Question ",K+1," of ",V]})}),p!=null&&he("div",{className:"px-4 sm:px-5 pb-3 text-[13px] leading-snug text-muted-foreground",children:p}),an(sm.Root,{invalid:Cn!==null,className:"contents",children:[he(Co.div,{animate:{height:cn},initial:!1,transition:ce.slow,className:"overflow-hidden",children:he("div",{ref:Ze,className:w("px-4 sm:px-5",So?"pb-1":"pb-2.5 sm:pb-3"),children:an("div",{className:"flex flex-col gap-2",children:[he("h3",{id:`${U}-${G}-title`,className:"text-[16px] text-foreground leading-snug",style:{fontVariationSettings:At.semibold},children:$.title}),F?he("div",{onClick:()=>Ve.current?.focus(),className:w("relative mt-1 -mx-3 px-3 py-2.5 cursor-text transition-colors",ie?"min-h-[76px]":"min-h-10",P.bg,de.length>0?"bg-active":"hover:bg-hover focus-within:bg-card focus-within:ring-1 focus-within:ring-inset focus-within:ring-border"),children:he(sm.Control,{value:de,onValueChange:ue,render:he("textarea",{ref:Ve,rows:1,placeholder:$.freeTextPlaceholder??"Type your answer\u2026","aria-labelledby":`${U}-${G}-title`,onKeyDown:O=>{O.key==="Enter"&&(O.shiftKey||O.metaKey||O.ctrlKey||ie||(O.preventDefault(),ve()))},className:"block w-full bg-transparent border-0 p-0 m-0 outline-none resize-none overflow-hidden text-[13px] leading-snug text-foreground placeholder:text-muted-foreground",style:{fontVariationSettings:At.medium}})})}):Z?he(xP,{value:Ne,onValueChange:Rt,render:xi}):he(bP,{value:Ne[0]??null,onValueChange:O=>{typeof O=="string"&&Ue(O)},render:xi})]},G)})}),So&&he("div",{className:"px-4 sm:px-5 pt-1 pb-2",children:an("div",{className:"flex items-center justify-between gap-2 -mx-2 sm:-mx-3",children:[an("div",{className:"relative flex flex-1 min-w-0 items-center gap-2",children:[m!=null&&he("div",{className:"shrink-0 px-2 sm:px-3",children:m}),he(js,{mode:"popLayout",initial:!1,children:Bn&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"ghost",size:"sm",leadingIcon:W,onClick:se,className:"pl-3 sm:pl-[6px]",children:"Back"})},"back")}),Cn&&he(sm.Error,{match:!0,render:he(Co.p,{role:"alert",initial:{opacity:0,y:-2},animate:{opacity:1,y:0},transition:{...ce.fast,opacity:{duration:.12}},className:"min-w-0 px-2 sm:px-3 text-left text-[12px] leading-snug text-destructive"}),children:Cn},"ft-error")]}),he("div",{className:"relative flex items-center gap-2",children:an(js,{mode:"popLayout",initial:!1,children:[Mn&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"ghost",size:"sm",trailingIcon:H,onClick:nt,className:"pr-3 sm:pr-[6px]",children:h})},"cancel"),Zn&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"ghost",size:"sm",trailingIcon:H,onClick:mt,className:"pr-3 sm:pr-[6px]",children:u})},"skip"),gt&&he(Co.div,{layout:"position",initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{...ce.fast,opacity:{duration:.1}},children:he(L,{variant:"primary",size:"sm",onClick:F?ve:B,disabled:(F||Ne.length===0)&&de.trim().length===0,className:"pr-3 sm:pr-[6px]",children:an("span",{className:"inline-flex items-center gap-1.5",children:[$.nextLabel??(K>=V-1?"Finish":"Continue"),he("span",{className:"hidden sm:contents",children:an(SP,{shape:P,tone:"inverted",children:[Y?"\u2318":"\u2303","\u21B5"]})})]})})},"continue")]})})]})})]})]})});am.displayName="AskUserQuestions";function SP({children:e,tone:t="muted",shape:n}){return he("kbd",{"aria-hidden":!0,suppressHydrationWarning:!0,className:w("inline-flex items-center justify-center gap-0.5 px-1 min-w-[18px] h-[18px] text-[11px] leading-none font-sans tracking-wide",t==="inverted"?"bg-background/15 text-background":"bg-foreground/10 text-muted-foreground",n.bg),children:e})}function Bv({index:e,registerItem:t,role:n,isSelected:o,tabIndex:r,onClick:s,onKeyDown:a,shape:i,chipContent:c,chipFilled:l,isMulti:u,ariaLabel:p,showArrow:d,arrowIcon:h,onArrowClick:m,bodyLayout:b="inline",topAlign:f=!1,chipPosition:v="right",hiddenControl:x,children:y,...g}){let C=Uo(null);ao(()=>(t(e,C.current),()=>t(e,null)),[e,t]);let k=he(js,{children:d&&he(Co.span,{"aria-hidden":!m,role:m?"button":void 0,onClick:m?N=>{N.stopPropagation(),m()}:void 0,className:w("absolute inset-0 inline-flex items-center justify-center bg-foreground text-background",i.bg,m&&"cursor-pointer"),initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6,transition:ce.fast.exit},transition:{...ce.fast,opacity:{duration:.08}},children:h})}),I=an("span",{className:w("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(b==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:[he("span",{"aria-hidden":!0,className:w("absolute inline-flex items-center justify-center w-5 h-5 text-[11px] transition-[opacity,font-variation-settings] duration-80",u&&i.bg,u?l?"bg-foreground text-background":"border border-border text-muted-foreground":l?"text-foreground":"text-muted-foreground",v==="right"&&d&&"opacity-0"),style:{fontVariationSettings:l?At.semibold:At.medium},children:c}),v==="right"&&k]}),M=v==="left"&&!u&&he("span",{className:w("shrink-0 w-7 h-7 relative inline-flex items-center justify-center",f&&(b==="stacked"?"-mt-[1px]":"-mt-[5px]")),children:k});return an("div",{ref:C,"data-proximity-index":e,"data-state":o?"checked":"unchecked",role:n??void 0,"aria-checked":n==="radio"||n==="checkbox"?!!g["aria-checked"]:void 0,"aria-label":p,tabIndex:r,onMouseDown:N=>{let E=N.target.closest('button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])');E&&E!==N.currentTarget||(N.preventDefault(),N.currentTarget.focus())},onClick:s,onKeyDown:a,className:w("relative z-10 flex cursor-pointer select-none outline-none",v==="left"?"gap-2":"gap-3",f?"items-start":"items-center",b==="stacked"?"min-h-14 py-2":"min-h-10 py-1.5",v==="left"?u?"pl-1.5 pr-3":"pl-1.5 pr-1.5":"pl-3 pr-1.5",i.item),children:[v==="left"&&I,he("span",{className:w("min-w-0 flex-1 text-[13px] leading-snug",b==="stacked"?"flex flex-col gap-0.5":"inline-flex items-center gap-0"),children:y}),v==="right"?I:M,x]})}function hc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.const=="string"&&(t.title===void 0||typeof t.title=="string")}function Uv(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(hc):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(hc):[];return t.length>0?t:n}function Fv(e){let t=e.items&&typeof e.items=="object"?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(hc):[],o=Array.isArray(t.oneOf)?t.oneOf.filter(hc):[];return n.length>0?n:o}function $v(e){if(e.mode==="url"&&"url"in e)return[{id:"__url_confirm__",title:"Confirm completion",layout:"stacked",options:[{id:"confirmed",title:"I've completed the required action",description:e.url}],skippable:!1,nextLabel:"Confirm"}];let t="requestedSchema"in e?e.requestedSchema:void 0;if(!t||t.type!=="object"||!t.properties)return[{id:"__freeform__",title:"Your response",freeText:!0,freeTextPlaceholder:"Type your response\u2026",skippable:!1}];let n=t.properties,o=t.required??[];return Object.entries(n).map(([r,s])=>{let a=s,i=o.includes(r),c=a.title||r,l=a.description,u=a.type||"string",p=Uv(a),d=Fv(a),h=Array.isArray(a.enum),m=u==="array"&&Array.isArray(a.items?.enum),b=u==="array"&&d.length>0,f={id:r,title:c,skippable:!i,layout:l&&l.length>60?"stacked":"inline"};if(u==="boolean")return{...f,options:[{id:"true",title:"Yes"},{id:"false",title:"No"}]};if(b||m){let v=b?d:a.items.enum.map(x=>({const:x,title:x}))??[];return{...f,multiSelect:!0,options:v.map(x=>({id:x.const,title:x.title||x.const}))}}if(p.length>0)return{...f,layout:"stacked",options:p.map(v=>({id:v.const,title:v.title||v.const}))};if(h){let v=a.enum,x=a.enumNames;return{...f,options:v.map((y,g)=>({id:y,title:x?.[g]||y}))}}return u==="number"||u==="integer"?{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Enter a number\u2026",freeTextValidate:v=>{let x=v.trim();if(!x)return i?"Required":null;let y=u==="integer"?parseInt(x,10):parseFloat(x);return Number.isNaN(y)?"Enter a valid number":null}}:u==="string"&&(a.format==="textarea"||(a.maxLength??0)>100)?{...f,freeText:!0,freeTextPlaceholder:a.default||"Type your answer\u2026"}:{...f,freeText:!0,freeTextMultiline:!1,freeTextPlaceholder:a.default!==void 0?String(a.default):"Type your answer\u2026",freeTextValidate:v=>!v.trim()&&i?"Required":null}})}function Vv(e,t,n){if(n.mode==="url")return{};let o="requestedSchema"in n?n.requestedSchema:void 0,r=o?.type==="object"&&o.properties?o.properties:{},s={};for(let a of e){let i=a.id??"";if(i==="__freeform__"){let p=t[i]?.otherText?.trim();p&&(s.response=p);continue}let c=t[i];if(!c||c.skipped)continue;let u=r[i]?.type||"string";if(a.freeText){let p=c.otherText?.trim()??"";if(!p)continue;s[i]=u==="number"||u==="integer"?u==="integer"?parseInt(p,10):parseFloat(p):p;continue}if(a.multiSelect){s[i]=c.selectedIds;continue}if(u==="boolean"){s[i]=c.selectedIds[0]==="true";continue}c.selectedIds[0]!==void 0&&(s[i]=c.selectedIds[0])}return s}function jv(e,t,n){if(n.mode==="url")return[];let o="requestedSchema"in n?n.requestedSchema:void 0;return(o?.type==="object"?o.required??[]:[]).filter(s=>{let a=t[s];if(!a||a.skipped)return!0;let i=e.find(c=>c.id===s);return i?i.freeText?!a.otherText?.trim():(i.multiSelect,a.selectedIds.length===0):!0})}function qv(e,t){if(t.mode==="url")return{};let n="requestedSchema"in t?t.requestedSchema:void 0,o=n?.type==="object"&&n.properties?n.properties:{},r={};for(let s of e){let a=s.id;if(!a||a.startsWith("__"))continue;let i=o[a];if(!(!i||i.default===void 0)){if(s.freeText){r[a]={questionId:a,selectedIds:[],otherText:String(i.default),skipped:!1};continue}if(s.multiSelect&&Array.isArray(i.default)){r[a]={questionId:a,selectedIds:i.default.map(String),skipped:!1};continue}if(i.type==="boolean"){r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1};continue}r[a]={questionId:a,selectedIds:[String(i.default)],skipped:!1}}}return r}import{jsx as si,jsxs as vc}from"react/jsx-runtime";function Gv({request:e,onApprove:t,onReject:n,testId:o="inline-elicitation",actionTestIdPrefix:r="inline-elicitation"}){let[s,a]=Kv(!1),[i,c]=Kv(""),l=Wv(()=>$v(e.request),[e.request]),u=Wv(()=>qv(l,e.request),[l,e.request]),d=(e.request.mode||"form")==="url",h=d&&"url"in e.request?e.request.url:void 0,m=(v,x)=>{a(!0),c(v),t(e.id,x)},b=v=>{if(s)return;if(d){if(!v.__url_confirm__?.selectedIds.includes("confirmed")){Jv.error("Confirm you've completed the external action");return}m("accepted",{action:"accept"});return}let x=jv(l,v,e.request);if(x.length>0){Jv.error("Missing required fields",{description:`Please fill in: ${x.join(", ")}`});return}m("accepted",{action:"accept",content:Vv(l,v,e.request)})};if(s)return vc("p",{className:"text-sm text-muted-foreground","data-testid":`${o}-responded`,children:["Elicitation ",i," \u2014 the tool will continue executing."]});let f=vc("div",{className:"space-y-2",children:[si("p",{className:"text-foreground/90",children:e.request.message}),d&&h&&vc("div",{className:"flex items-center gap-2 rounded-md border bg-muted/40 p-2",children:[si("code",{className:"flex-1 text-xs font-mono break-all",children:h}),vc(L,{size:"sm",variant:"outline",onClick:()=>window.open(h,"_blank"),"data-testid":`${r}-open-url`,children:[si(NP,{className:"h-3 w-3 mr-1"}),"Open"]})]})]});return si(am,{questions:l,defaultAnswers:u,onComplete:b,intro:f,onCancel:()=>n(e.id,"User cancelled elicitation request"),cancelLabel:"Cancel",footerLeading:si("button",{type:"button",className:"shrink-0 cursor-pointer text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",onClick:()=>m("declined",{action:"decline"}),"data-testid":`${r}-decline-button`,children:"Decline"}),className:"w-full max-w-none shadow-lg","data-testid":o})}import{jsx as im}from"react/jsx-runtime";function Yv({requests:e,onApprove:t,onReject:n}){return e.length===0?null:im("div",{className:"mb-3 space-y-3 pointer-events-auto","data-testid":"floating-elicitation-stack",children:e.map(o=>im(TP.div,{initial:{opacity:0,y:12,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},transition:ce.moderate,children:im(Gv,{request:o,onApprove:t,onReject:n})},o.id))})}import{Check as kP,Loader2 as PP,Settings2 as RP}from"lucide-react";import{useCallback as MP,useEffect as IP,useState as lm}from"react";var os="You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.";import{jsx as io,jsxs as ai}from"react/jsx-runtime";function EP(e){let t=e?.trim();return t?t!==os:!1}function Xv({value:e,onSave:t,disabled:n,isSaving:o=!1,compact:r=!1}){let[s,a]=lm(!1),[i,c]=lm(e??""),[l,u]=lm(!1);IP(()=>{c(e??"")},[e]);let p=MP(async()=>{u(!0);try{await t(i),a(!1)}finally{u(!1)}},[i,t]),d=o||l,h=EP(e),m=ai("button",{type:"button","data-testid":"chat-system-prompt-button",onClick:()=>a(!0),disabled:n,className:r?w("inline-flex h-auto w-auto aspect-square items-center justify-center rounded-full p-2 transition-colors disabled:pointer-events-none disabled:opacity-50",h?"text-amber-500 dark:text-amber-400":"text-muted-foreground hover:text-foreground"):w("inline-flex h-9 items-center justify-center gap-1.5 rounded-full border border-input bg-secondary px-3 text-sm font-medium shadow-xs transition-colors hover:bg-secondary/80 disabled:pointer-events-none disabled:opacity-50",h?"text-amber-600 dark:text-amber-400":"text-secondary-foreground"),children:[io(RP,{className:"h-4 w-4"}),!r&&io("span",{className:"hidden sm:inline",children:"System Prompt"})]});return ai(on,{open:s,onOpenChange:a,children:[r?ai(Ie,{children:[io(Re,{render:m,nativeButton:!0}),io(Me,{side:"top",children:io("p",{children:h?"Custom system prompt":"System Prompt"})})]}):m,ai(Xt,{className:"sm:max-w-xl",children:[io(Gt,{children:io($t,{children:"System Prompt"})}),io(fo,{value:i,onChange:b=>c(b.target.value),placeholder:"Describe the assistant's behavior...",className:"min-h-[160px] text-sm"}),io($i,{children:ai(L,{size:"sm",onClick:p,disabled:d||i===(e??""),className:"gap-1.5",children:[d?io(PP,{className:"h-3.5 w-3.5 animate-spin"}):io(kP,{className:"h-3.5 w-3.5"}),"Save"]})})]})]})}import{Fragment as Qv,jsx as wn,jsxs as bc}from"react/jsx-runtime";function ii({variant:e="default",inputValue:t,isConnected:n,isLoading:o,textareaRef:r,llmConfig:s,promptsDropdownOpen:a,promptFocusedIndex:i,prompts:c,selectedPrompt:l,promptResults:u,attachments:p,tools:d,disabledTools:h,onDisabledToolsChange:m,onInputChange:b,onKeyDown:f,onKeyUp:v,onClick:x,onSendMessage:y,onStopStreaming:g,onConfigDialogOpenChange:C,onPromptSelect:k,onDeletePromptResult:I,onAttachmentAdd:M,onAttachmentRemove:N,hideModelBadge:E,freeTierInfo:T,managedCloudInfo:S,modelBadgeMode:P="byok",managedModel:A,followups:R=[],onFollowupSelect:W,pendingElicitationRequests:H,onApproveElicitation:Y,onRejectElicitation:U,systemPromptProvider:V}){let K=e==="fullscreen",$=t.trim()||u.length>0||p.length>0,G=(H?.length??0)>0,te=s&&(!E||T||S)?bc(Ie,{children:[wn(Re,{render:wn(Cv,{provider:s.provider,model:s.model,managedModel:A,mode:P,className:"shrink-0","data-testid":"chat-model-badge",onClick:()=>C(!0)}),nativeButton:!0}),wn(Me,{children:wn("p",{children:S||T?"Change model":"Change API Key"})})]}):null;return wn("div",{className:w("w-full flex shrink-0 flex-col items-center px-2 pt-0 sm:px-4 text-foreground",K?"pb-4 sm:pb-4":"pb-2 sm:pb-2"),children:bc("div",{className:w("relative w-full max-w-3xl",!K&&"backdrop-blur-xl"),children:[!K&&G&&Y&&U&&wn(Yv,{requests:H,onApprove:Y,onReject:U}),!K&&R.length>0&&wn("div",{className:"mb-2 flex flex-wrap gap-2",children:R.map(Z=>wn(L,{type:"button",variant:"outline",size:"sm",className:"rounded-full",onClick:()=>W?.(Z),disabled:o||!n,children:Z},Z))}),!K&&bc(Qv,{children:[wn(Av,{isOpen:a,prompts:c,selectedPrompt:l,focusedIndex:i,onPromptSelect:k}),wn(Ev,{promptResults:u,onDeletePromptResult:I})]}),wn(Iv,{variant:e,inputValue:t,isConnected:n,isLoading:o,textareaRef:r,attachments:p,placeholder:"Ask a question or request an action...",className:w("bg-white/80 dark:text-white dark:bg-black backdrop-blur-sm border-gray-200 dark:border-zinc-800",!K&&u.length>0&&"pt-16"),showAttachButton:!K,tools:K?void 0:d,disabledTools:K?void 0:h,onDisabledToolsChange:K?void 0:m,onInputChange:b,onKeyDown:f,onKeyUp:v,onClick:x,onAttachmentAdd:M,onAttachmentRemove:N,inlineControls:!K&&s&&V?wn(Xv,{compact:!0,value:V.prompt,onSave:V.savePrompt,disabled:!n||o||V.disabled,isSaving:V.isSaving}):null,trailingControls:bc(Qv,{children:[!K&&te,wn(L,{type:"button",size:"sm",className:w("h-8 w-8 rounded-full p-0",o&&"animate-spin",!$&&!o&&"bg-zinc-400"),disabled:!o&&(!$||!n||G),title:o?"Stop streaming":"Send",onClick:o?g:y,"data-testid":"chat-send-button",children:o?wn(LP,{className:"h-3.5 w-3.5 animate-spin"}):wn(AP,{className:"h-3.5 w-3.5"})})]})})]})})}import{AnimatePresence as DP,motion as _P,useInView as OP}from"motion/react";import{useRef as zP}from"react";import{jsx as Zv}from"react/jsx-runtime";function eb({children:e,className:t,variant:n,duration:o=.4,delay:r=0,offset:s=6,direction:a="down",inView:i=!1,inViewMargin:c="-50px",blur:l="6px",...u}){let p=zP(null),d=OP(p,{once:!0,margin:c}),h=!i||d,m={hidden:{[a==="left"||a==="right"?"x":"y"]:a==="right"||a==="down"?-s:s,opacity:0,filter:`blur(${l})`},visible:{[a==="left"||a==="right"?"x":"y"]:0,opacity:1,filter:"blur(0px)"}},b=n||m;return Zv(DP,{children:Zv(_P.div,{ref:p,initial:"hidden",animate:h?"visible":"hidden",exit:"hidden",variants:b,transition:{delay:.04+r,duration:o,ease:"easeOut"},className:t,...u,children:e})})}import{jsx as li,jsxs as yc}from"react/jsx-runtime";function cm({serverDisplayName:e,composerNotice:t,quickQuestions:n=[],onQuickQuestionSelect:o,...r}){return li("div",{className:"flex h-full flex-col items-center justify-center",children:yc(eb,{className:"w-full max-w-4xl mx-auto px-2 sm:px-4",children:[yc("div",{className:"text-center mb-6 sm:mb-8",children:[yc("h1",{className:"text-2xl sm:text-4xl font-light mb-2 dark:text-white","data-testid":"chat-landing-header",children:["Chat with ",e]}),li("p",{className:"mx-auto max-w-xl text-sm text-muted-foreground sm:text-base","data-testid":"chat-landing-description",children:"Chat, inspect traces, preview widgets, and more."})]}),yc("div",{className:"space-y-6",children:[t,li(ii,{...r}),n.length>0&&li("div",{className:"flex flex-wrap items-center justify-center gap-2 px-2",children:n.map(s=>li(L,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-white/70 dark:bg-black/50 text-gray-900 dark:text-white",onClick:()=>o?.(s),disabled:r.isLoading||!r.isConnected,children:s},s))})]})]})})}import{Key as BP,Settings as HP}from"lucide-react";import{jsx as xc,jsxs as tb}from"react/jsx-runtime";function dm({onConfigureClick:e}){return tb("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[xc(BP,{className:"h-12 w-12 text-muted-foreground mb-4"}),xc("h3",{className:"text-lg font-semibold mb-2",children:"Configure Your LLM Provider"}),xc("p",{className:"text-sm text-muted-foreground mb-4 max-w-md",children:"To start chatting with the MCP server, you need to configure your LLM provider and API key. Your credentials are stored locally and used only for this chat."}),tb(L,{onClick:e,"data-testid":"chat-configure-api-key-button",children:[xc(HP,{className:"h-4 w-4 mr-2"}),"Configure API Key"]})]})}import{motion as UP}from"motion/react";import{useMemo as FP}from"react";import{jsx as $P}from"react/jsx-runtime";function nb({children:e,as:t="p",className:n,duration:o=2,spread:r=2}){let s=UP.create(t),a=FP(()=>e.length*r,[e,r]);return $P(s,{className:w("relative inline-block bg-[length:250%_100%,auto] bg-clip-text","text-transparent [--base-color:#a1a1aa] [--base-gradient-color:#000]","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]","dark:[--base-color:#71717a] dark:[--base-gradient-color:#ffffff] dark:[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--base-gradient-color),#0000_calc(50%+var(--spread)))]",n),initial:{backgroundPosition:"100% center"},animate:{backgroundPosition:"0% center"},transition:{repeat:1/0,duration:o,ease:"linear"},style:{"--spread":`${a}px`,backgroundImage:"var(--bg), linear-gradient(var(--base-color), var(--base-color))"},children:e})}import{memo as fR,useCallback as gR,useMemo as hR,useRef as xm}from"react";import{memo as VP,useMemo as jP}from"react";import{jsx as ob,jsxs as WP}from"react/jsx-runtime";function qP(e){let t=e.match(/```/g);return t&&t.length%2===1?`${e}
|
|
202
202
|
\`\`\``:e}var rb=VP(function({content:t,isStreaming:n=!1}){let o=jP(()=>n?qP(t):t,[t,n]);return WP("div",{children:[ob(Ds,{className:w("text-[14px] leading-relaxed text-foreground","[&_p]:mb-2 [&_p:last-child]:mb-0","[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2"),content:o}),n?ob("span",{className:"inline-block w-0.5 h-[1em] ml-0.5 -mt-1 align-middle bg-foreground/60 animate-pulse","aria-hidden":!0}):null]})});import{forwardRef as ZP}from"react";import{motion as eR}from"motion/react";import{useEffect as KP,useState as JP}from"react";function sb(){let[e,t]=JP(!1);return KP(()=>{if(typeof window>"u")return;let n=new AbortController,{signal:o}=n,r=()=>{let a="ontouchstart"in window||navigator.maxTouchPoints>0,i=window.matchMedia("(pointer: coarse)").matches;t(a&&i)};return window.matchMedia("(pointer: coarse)").addEventListener("change",r,{signal:o}),window.addEventListener("pointerdown",r,{signal:o}),r(),()=>n.abort()},[]),e}import{useEffect as GP,useState as YP}from"react";import{jsx as xr,jsxs as QP}from"react/jsx-runtime";function XP({size:e}){return QP("svg",{width:Math.max(16,e*.35),height:Math.max(16,e*.35),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[xr("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"}),xr("path",{d:"M14 3v5h5"})]})}function ab({file:e,size:t,className:n}){let o=kt(),r=e.type.startsWith("image/"),[s,a]=YP(null);GP(()=>{if(!r){a(null);return}let c=URL.createObjectURL(e);return a(c),()=>URL.revokeObjectURL(c)},[r,e]);let i=r&&!s;return xr("div",{className:w("relative shrink-0 overflow-hidden bg-accent border border-border",o.bg,n),style:{width:t,height:t},children:s?xr("img",{src:s,alt:e.name,className:"absolute inset-0 w-full h-full object-cover"}):i?xr("div",{className:"absolute inset-0 flex items-center justify-center",children:xr("div",{className:"w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin","aria-label":"Loading preview",role:"status"})}):xr("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground",role:"img","aria-label":e.name,children:xr(XP,{size:t})})})}import{jsx as ci,jsxs as ib}from"react/jsx-runtime";var di=ZP(({from:e,files:t,thumbnailSize:n=64,time:o,actions:r,children:s,className:a,...i},c)=>{let l=kt(),u=e==="user",p=sb(),d=u&&o!=null;return ib(eR.div,{ref:c,layout:"position",initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:ce.moderate,style:{transformOrigin:u?"bottom right":"bottom left"},className:w("group flex max-w-[80%] flex-col gap-1.5",u?"items-end self-end":"items-start self-start",a),...i,children:[t&&t.length>0&&ci("div",{className:w("flex flex-wrap gap-1.5",u?"justify-end":"justify-start"),children:t.map((h,m)=>ci(ab,{file:h,size:n},`${h.name}-${h.size}-${h.lastModified}-${m}`))}),s!=null&&s!==""&&ci("div",{className:w("py-2 text-[14px] whitespace-pre-wrap break-words",u?w(l.bg,"px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground"):"text-foreground"),children:s}),(d||r!=null)&&ib("div",{className:w("flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none",!p&&["opacity-0 pointer-events-none transition-opacity duration-150","group-hover:opacity-100 group-hover:pointer-events-auto","group-focus-within:opacity-100 group-focus-within:pointer-events-auto"]),children:[d&&ci("span",{className:"tabular-nums",children:o}),r!=null&&ci("span",{className:"flex items-center gap-0.5",children:r})]})]})});di.displayName="ChatMessage";import{Check as tR,Copy as nR}from"lucide-react";import{useState as oR}from"react";import{jsx as um}from"react/jsx-runtime";function lb({text:e}){let[t,n]=oR(!1);return um("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex items-center rounded p-0.5",onClick:async()=>{await st(e),n(!0),setTimeout(()=>n(!1),2e3)},title:"Copy message content","data-testid":"copy-button",children:t?um(tR,{className:"h-3.5 w-3.5"}):um(nR,{className:"h-3.5 w-3.5"})})}import{Fragment as ub,jsx as db,jsxs as mb}from"react/jsx-runtime";function cb(e,t){let n=e===1?"token":"tokens";return`${e.toLocaleString()} ${n} ${t}`}function wc({variant:e,copyText:t,inputTokens:n,outputTokens:o}){let r=!!t,s=e==="user"&&n!=null?cb(n,"in"):e==="assistant"&&o!=null?cb(o,"out"):null;if(!r&&!s)return null;let a=r?db(lb,{text:t}):null,i=s?db("span",{className:"tabular-nums",title:e==="user"?"Input tokens":"Output tokens","data-testid":e==="user"?"message-input-tokens":"message-output-tokens",children:s}):null;return e==="user"?mb(ub,{children:[i,a]}):mb(ub,{children:[a,i]})}import{jsx as Cc,jsxs as rR}from"react/jsx-runtime";function mm({content:e,timestamp:t,_isStreaming:n,outputTokens:o}){return!e||e.length===0?null:rR("div",{"data-testid":"chat-message-assistant",children:[Cc(di,{from:"assistant",actions:Cc(wc,{variant:"assistant",copyText:e,outputTokens:o}),"data-testid":"chat-message-content",children:Cc(rb,{content:e,isStreaming:n})}),t!=null&&Cc("span",{className:"sr-only",children:new Date(t).toLocaleTimeString()})]})}import{Check as pb,Copy as pm,Loader2 as fm,LockKeyhole as gm,Wrench as fb,X as sR}from"lucide-react";import{jsx as it,jsxs as Wt}from"react/jsx-runtime";function hm({toolName:e,args:t,result:n,state:o="result",partialArgs:r,onAuthenticate:s,isAuthenticating:a=!1,authorizationError:i,toolCallId:c}){let l=o==="call"&&r?r:t,u=()=>{switch(o){case"call":return it(fm,{className:"h-4 w-4 animate-spin text-blue-500 dark:text-blue-400"});case"authorization-required":return it(gm,{className:"h-4 w-4 text-amber-700 dark:text-amber-300"});case"result":return it(pb,{className:"h-4 w-4 text-emerald-800 dark:text-emerald-400"});case"error":return it(sR,{className:"h-4 w-4 text-red-500 dark:text-red-400"});default:return it(pb,{className:"h-4 w-4 text-emerald-800 dark:text-emerald-400"})}},p=()=>{switch(o){case"call":return" bg-blue-500/20 dark:bg-blue-500/20";case"authorization-required":return" bg-amber-400/30 dark:bg-amber-500/25";case"result":return" bg-emerald-500/20 dark:bg-emerald-500/20";case"error":return" bg-red-500/20 dark:bg-red-500/20";default:return" bg-emerald-500/20 dark:bg-emerald-500/20"}},d=h=>typeof h=="object"?Cl(h).preview:String(h);return Wt("div",{className:"my-4 flex w-fit max-w-full flex-col items-start gap-2",children:[Wt(Ss,{children:[it(hl,{render:Wt("div",{className:w("flex max-w-min items-center gap-3 rounded-full border p-1 transition-colors cursor-pointer",o==="authorization-required"?"border-amber-400/70 bg-amber-50 hover:bg-amber-100 dark:border-amber-500/50 dark:bg-amber-950/40 dark:hover:bg-amber-950/60":"bg-card hover:bg-accent/50"),"data-testid":`chat-tool-call-${e}`,children:[it("div",{className:"w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0",children:it(fb,{className:"size-4 text-muted-foreground"})}),it("div",{className:"flex-1 min-w-0",children:it("div",{className:"flex items-center gap-2",children:Wt("span",{className:"text-sm font-medium truncate",children:[e,"(",Object.keys(l).length>0?Wt("span",{className:"bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs",children:[Object.keys(l).length," args"]}):"",")"]})})}),it("div",{className:w("w-8 h-8 rounded-full flex items-center justify-center",p()),"data-testid":`chat-tool-call-status-${o}`,children:u()})]}),nativeButton:!1}),Wt(Ns,{side:"right",className:"w-[400px] sm:w-[540px] p-4 overflow-y-auto","data-testid":"chat-tool-drawer",children:[Wt(vl,{children:[Wt(bl,{className:"flex items-center gap-2",children:[it(fb,{className:"h-5 w-5"}),"Tool Call Details"]}),Wt(ag,{className:"flex items-center gap-2",children:[e," \u2014 ",o,o==="call"&&Wt("span",{className:"flex items-center gap-1 text-blue-500 dark:text-blue-400",children:[it(fm,{className:"h-3 w-3 animate-spin"}),"streaming\u2026"]}),o==="authorization-required"&&Wt("span",{className:"flex items-center gap-1 text-amber-700 dark:text-amber-300",children:[it(gm,{className:"h-3 w-3"}),"authentication required"]})]})]}),Wt("div",{className:"flex flex-col gap-6 py-4",children:[Wt("div",{children:[it("h3",{className:"text-sm font-medium mb-2",children:"Arguments"}),Wt("div",{className:"relative","data-testid":"chat-tool-drawer-args",children:[it("pre",{className:"text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words",children:d(l)}),it(L,{variant:"ghost",size:"sm",onClick:()=>st(d(l)),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy arguments",children:it(pm,{className:"h-3 w-3"})})]})]}),n&&Wt("div",{children:[it("h3",{className:"text-sm font-medium mb-2",children:"Result"}),it("div",{className:"relative","data-testid":"chat-tool-drawer-result",children:typeof n=="string"?Wt("div",{className:w("p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full",o==="error"?"bg-destructive/10 border-destructive/20 text-destructive-foreground":"bg-muted/30 border-border"),children:[n.startsWith("Error")?Wt("div",{className:"font-mono",children:[it("div",{className:"font-semibold text-destructive mb-1",children:"Error:"}),it("div",{className:"whitespace-pre-wrap break-words",children:n.replace(/^Error:\s*/,"")})]}):it("div",{className:"whitespace-pre-wrap font-mono break-words",children:n}),it(L,{variant:"ghost",size:"sm",onClick:()=>st(n),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy result",children:it(pm,{className:"h-3 w-3"})})]}):Wt("div",{className:w("p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full",o==="error"?"bg-destructive/10 border-destructive/20 text-destructive-foreground":"bg-muted/30 border-border"),children:[it(Dt,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),it(L,{variant:"ghost",size:"sm",onClick:()=>st(JSON.stringify(n,null,2)),className:"absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100",title:"Copy result",children:it(pm,{className:"h-3 w-3"})})]})})]})]})]})]}),o==="authorization-required"&&c&&s&&Wt("div",{className:"flex flex-col items-start gap-1.5 pl-1",children:[Wt(L,{"data-testid":`chat-tool-authenticate-${c}`,size:"sm",onClick:()=>{s(c)},disabled:a,className:"bg-amber-600 text-white hover:bg-amber-700 focus-visible:ring-amber-600 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400",children:[a?it(fm,{className:"size-3.5 animate-spin","aria-hidden":!0}):it(gm,{className:"size-3.5","aria-hidden":!0}),a?"Authenticating\u2026":"Authenticate"]}),i&&it("p",{className:"max-w-sm text-xs text-red-700 dark:text-red-300",children:i})]})]})}import{useMemo as aR}from"react";import{jsx as vm}from"react/jsx-runtime";function iR(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new File([n],e.name||"attachment",{type:e.mimeType})}function gb({content:e,timestamp:t,attachments:n,inputTokens:o}){let r=aR(()=>n?.map(iR),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:vm("div",{"data-testid":"chat-message-user",className:"flex flex-col items-end",children:vm(di,{from:"user",files:r,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||o!=null?vm(wc,{variant:"user",copyText:e||void 0,inputTokens:o}):void 0,"data-testid":"chat-message-content",children:e&&e.length>0?e:void 0})})}import{isViewTool as vR}from"@mcp-use/client/react";var wr={events:[],spans:[]};function Nc(e){if(!e||typeof e!="object")return;let t=e,n=(...p)=>{for(let d of p)if(typeof t[d]=="number")return t[d]},o=n("inputTokens","input_tokens","promptTokens"),r=n("outputTokens","output_tokens","completionTokens"),s=n("cachedInputTokens","cache_read_input_tokens"),a=n("cacheCreationInputTokens","cache_creation_input_tokens"),i=n("reasoningTokens","thoughtsTokenCount"),l=(n("cache_read_input_tokens")??0)+(a??0),u=n("totalTokens","total_tokens")??(o!==void 0&&r!==void 0?o+r+l:void 0);if(!(o===void 0&&r===void 0&&u===void 0&&s===void 0&&a===void 0&&i===void 0))return{inputTokens:o,outputTokens:r,totalTokens:u,cachedInputTokens:s,cacheCreationInputTokens:a,reasoningTokens:i}}var lR=new Set(["apikey","authorization","accesstoken","refreshtoken","password","cookie","secret"]);function Sc(e){return Array.isArray(e)?e.map(Sc):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,lR.has(t.toLowerCase().replace(/[_-]/g,""))?"[REDACTED]":Sc(n)]))}function hb(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}\u2026`:n}function rs(e){switch(e.type){case"request":return"LLM request";case"text-delta":return e.delta.trim()||"Text delta";case"tool-call-start":return e.toolName;case"tool-call-args":return hb(e.args);case"tool-result":return hb(e.result);case"usage":return`${e.usage.totalTokens??"?"} tokens`;case"error":return e.message;case"done":return"Completed";default:return e}}function bm(e,t){let n=(o,r)=>o===void 0&&r===void 0?void 0:(o??0)+(r??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),cacheCreationInputTokens:n(e?.cacheCreationInputTokens,t.cacheCreationInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function Tc(e,t){let n=e.spans.map(s=>({...s})),o=e.usage,r=[...n].reverse().find(s=>s.kind==="llm"&&s.status==="running");if(t.type==="request")n.push({id:`llm-${t.id}`,kind:"llm",name:"LLM",status:"running",startedAt:t.timestamp,preview:rs(t)});else if((t.type==="text-delta"||t.type==="tool-call-start")&&!r)r={id:`llm-${t.id}`,kind:"llm",name:"LLM",status:"running",startedAt:t.timestamp,preview:t.type==="text-delta"?rs(t):"LLM response"},n.push(r),t.type==="tool-call-start"&&n.push({id:t.toolCallId,kind:"tool",name:t.toolName,status:"running",startedAt:t.timestamp,preview:rs(t)});else if(t.type==="tool-call-start")n.push({id:t.toolCallId,kind:"tool",name:t.toolName,status:"running",startedAt:t.timestamp,preview:rs(t)});else if(t.type==="tool-call-args"){let s=n.find(a=>a.id===t.toolCallId);s&&(s.preview=rs(t))}else if(t.type==="tool-result"){let s=t.toolCallId?n.find(a=>a.id===t.toolCallId):[...n].reverse().find(a=>a.kind==="tool"&&a.name===t.toolName&&a.status==="running");s&&(s.status=t.isError?"error":"success",s.endedAt=t.timestamp,s.preview=rs(t))}else t.type==="usage"?(o=bm(o,t.usage),r&&(r.usage=bm(r.usage,t.usage))):(t.type==="error"||t.type==="done")&&r&&(r.status=t.type==="error"?"error":"success",r.endedAt=t.timestamp,r.preview=rs(t));return{events:[...e.events,t],spans:n,usage:o}}function ym(e,t){let n=[],o=null;for(let r of e)r.type==="request"?(o&&n.push(o),o={request:r,response:[]}):o&&o.response.push(r);return o&&n.push(o),{turns:n,tokenUsage:t??null}}function cR(e){let t;for(let n of e)n.type==="usage"&&(t=bm(t,n.usage));return t}function dR(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!=="user"){n++;continue}let o=e[n].id;n++;let r=null;for(;n<e.length&&e[n]?.role==="assistant";)r=e[n].id,n++;t.push({userId:o,assistantId:r})}return t}function vb(e,t){let{turns:n}=ym(t),o=dR(e),r=new Map,s=Math.min(n.length,o.length);for(let a=0;a<s;a++){let i=cR(n[a].response);if(!i)continue;let{userId:c,assistantId:l}=o[a];i.inputTokens!=null&&r.set(c,{...r.get(c),inputTokens:i.inputTokens}),l!=null&&i.outputTokens!=null&&r.set(l,{...r.get(l),outputTokens:i.outputTokens})}return r}var uR=new Set(["image/png","image/jpeg","image/jpg","image/gif","image/webp","image/svg+xml"]);function mR(e){for(let t of e)if(t>10485760)throw new Error("ui/message image exceeds the 10 MB per-file limit");if(e.reduce((t,n)=>t+n,0)>20971520)throw new Error("ui/message images exceed the 20 MB total limit")}function pR(e){let t=e.replace(/\s/g,"");if(t.length===0||t.length%4===1||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new Error("ui/message image data must be valid base64");let n=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.floor(t.length*3/4)-n}function bb(e){if(e.length===0)throw new Error("ui/message requires at least one content block");let t=[],n=[];for(let[r,s]of e.entries()){if(s.type==="text"){if(typeof s.text!="string")throw new Error(`ui/message text block ${r} is invalid`);t.push(s.text);continue}if(s.type==="image"){if(typeof s.data!="string"||typeof s.mimeType!="string")throw new Error(`ui/message image block ${r} is invalid`);if(!uR.has(s.mimeType))throw new Error(`Unsupported ui/message image type: ${s.mimeType}`);let a=pR(s.data);mR([...n.map(i=>i.size??0),a]),n.push({type:"image",data:s.data,mimeType:s.mimeType,name:`widget-image-${n.length+1}`,size:a});continue}throw new Error(`Unsupported ui/message content block: ${s.type||"unknown"}`)}let o=t.join(`
|
|
203
203
|
`);if(!o.trim()&&n.length===0)throw new Error("ui/message must include text or an image");return{text:o,attachments:n}}import{Fragment as bR,jsx as Zt,jsxs as kc}from"react/jsx-runtime";var ui=fR(({messages:e,isLoading:t,serverId:n,readResource:o,tools:r,sendMessage:s,messagesEndRef:a,traceEvents:i=[],modelContextScope:c,llmConfig:l,renderToolResults:u=!0,onAuthenticateTool:p,authenticatingToolCallId:d,toolAuthorizationError:h})=>{let m=xm(!1),b=xm(t);b.current=t;let f=xm(s);f.current=s;let v=hR(()=>vb(e,i),[e,i]),x=T=>{let S=R=>R.replace(/-/g,"_"),P=S(T);return r?.find(R=>S(R.name)===P)?._meta},y=T=>{let S=x(T);return vR(S)},g=gR(async T=>{if(b.current||m.current)throw new Error("Chat is busy with another turn");let S=f.current;if(!S)throw new Error("Chat is not available on this host surface");let P=bb(T);m.current=!0;try{await S(P.text,P.attachments.length>0?P.attachments:void 0)}finally{m.current=!1}},[]),C=t&&(()=>{if(e.length===0)return!0;let T=e[e.length-1];if(T.role==="user")return!0;if(T.role==="assistant"){if(T.parts&&T.parts.length>0)return!1;let S=typeof T.content=="string"?T.content:Array.isArray(T.content)?T.content.map(A=>typeof A=="string"?A:A.text||JSON.stringify(A)).join(""):JSON.stringify(T.content);return!(S&&S.trim().length>0)}return!1})(),k=e[e.length-1],I=t&&k?.role==="assistant",M=T=>{for(let S=T.length-1;S>=0;S--)if(T[S]?.type==="text")return S;return-1},N=(T,S,P)=>I&&T.id===k?.id&&S===M(P),E=T=>I&&T.id===k?.id;return kc("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(T=>{let S=typeof T.content=="string"?T.content:Array.isArray(T.content)?T.content.map(P=>typeof P=="string"?P:P.text||JSON.stringify(P)).join(""):JSON.stringify(T.content);if(T.role==="user")return Zt(gb,{content:S,timestamp:T.timestamp,attachments:T.attachments,inputTokens:v.get(T.id)?.inputTokens},T.id);if(T.role==="assistant"){let P=v.get(T.id)?.outputTokens,A=T.parts&&T.parts.length>0?M(T.parts):-1;return Zt("div",{className:"space-y-4",children:T.parts&&T.parts.length>0?T.parts.map((R,W)=>{let H=R.type==="text"?`${T.id}-text-${W}`:`${T.id}-tool-${R.toolInvocation?.toolCallId??`${R.toolInvocation?.toolName}-${W}`}`;return R.type==="text"?Zt(mm,{content:R.text||"",timestamp:W===T.parts.length-1?T.timestamp:void 0,_isStreaming:N(T,W,T.parts),outputTokens:W===A?P:void 0},H):R.type==="tool-invocation"&&R.toolInvocation?kc("div",{children:[Zt(hm,{toolName:R.toolInvocation.toolName,toolCallId:R.toolInvocation.toolCallId,args:R.toolInvocation.args,result:R.toolInvocation.result,state:R.toolInvocation.state==="authorization-required"?"authorization-required":R.toolInvocation.state==="error"?"error":R.toolInvocation.state==="streaming"||R.toolInvocation.state==="pending"?"call":"result",partialArgs:R.toolInvocation.partialArgs,onAuthenticate:p,isAuthenticating:d===R.toolInvocation.toolCallId,authorizationError:R.toolInvocation.state==="authorization-required"?h:null}),u&&(R.toolInvocation.result||R.toolInvocation.state==="streaming"||y(R.toolInvocation.toolName))&&Zt("div",{"data-tool-call-id":`${T.id}-${R.toolInvocation.toolName}-${W}`,children:Zt(Al,{toolName:R.toolInvocation.toolName,toolArgs:R.toolInvocation.args,result:R.toolInvocation.result||null,serverId:n,readResource:o,toolMeta:x(R.toolInvocation.toolName),onSendFollowUp:g,modelContextScope:c,llmConfig:l,partialToolArgs:R.toolInvocation.partialArgs,cancelled:R.toolInvocation.state==="error"&&R.toolInvocation.result==="Cancelled by user"})})]},H):null}):kc(bR,{children:[Zt(mm,{content:S,timestamp:T.timestamp,_isStreaming:E(T),outputTokens:P}),T.toolCalls&&T.toolCalls.length>0&&Zt("div",{className:"space-y-2",children:T.toolCalls.map(R=>{let W=`${T.id}-${R.toolName}-${JSON.stringify(R.args).slice(0,50)}`;return kc("div",{children:[Zt(hm,{toolName:R.toolName,args:R.args,result:R.result,state:R.result?"result":"call"}),u&&(R.result||y(R.toolName))&&Zt("div",{"data-tool-call-id":W,children:Zt(Al,{toolName:R.toolName,toolArgs:R.args,result:R.result||null,serverId:n,readResource:o,toolMeta:x(R.toolName),onSendFollowUp:g,modelContextScope:c,llmConfig:l})})]},W)})})]})},T.id)}return null}),C&&Zt("div",{className:"flex items-start gap-3",children:Zt("div",{className:"flex-1",children:Zt("div",{className:"rounded-lg p-4 max-w-fit",children:Zt("div",{className:"flex items-center gap-2",children:Zt("span",{className:"text-sm",children:Zt(nb,{duration:2,spread:1,children:"Thinking..."})})})})})}),Zt("div",{ref:a})]})});import{ArrowDown as yR}from"lucide-react";import{AnimatePresence as xR,motion as wR}from"motion/react";import{jsx as mi}from"react/jsx-runtime";function yb({visible:e,onClick:t}){return mi("div",{className:"pointer-events-none absolute bottom-2 left-0 right-0 z-30 flex justify-center",children:mi(xR,{children:e&&mi(wR.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.18,ease:"easeOut"},children:mi(L,{type:"button",variant:"secondary",className:"pointer-events-auto size-9 rounded-full border bg-background/95 p-0 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80",onClick:t,"aria-label":"Scroll to bottom",title:"Scroll to bottom","data-testid":"chat-scroll-to-bottom",children:mi(yR,{className:"size-4"})})})})})}import{jsx as CR}from"react/jsx-runtime";function xb({visible:e}){return CR("div",{"aria-hidden":!0,className:w("pointer-events-none absolute inset-x-0 top-0 z-[5] h-32 bg-[linear-gradient(to_bottom,var(--background)_0%,var(--background)_24%,transparent_46%)] transition-opacity duration-200 sm:h-36",e?"opacity-100":"opacity-0")})}import{useCallback as wb,useEffect as Cb,useRef as wm,useState as Sb}from"react";function Nb(e,{messageCount:t,isLoading:n,enabled:o=!0}){let r=wm(null),[s,a]=Sb(!0),[i,c]=Sb(!1),l=wm(!0),u=wm({length:0,loading:!1}),p=64,d=8,h=t>0,m=o&&h&&!s,b=wb(()=>{let v=e.current;if(!v)return;let y=v.scrollHeight-(v.scrollTop+v.clientHeight)<=p;l.current=y,a(y),c(v.scrollTop>d)},[e]),f=wb(v=>{let x=e.current;x&&(x.scrollTo({top:x.scrollHeight,behavior:v}),l.current=!0,a(!0))},[e]);return Cb(()=>{if(!o)return;let v=e.current;if(!v)return;b();let x=()=>b();v.addEventListener("scroll",x,{passive:!0});let y=typeof ResizeObserver<"u"?new ResizeObserver(()=>b()):null;return y?.observe(v),()=>{v.removeEventListener("scroll",x),y?.disconnect()}},[o,b,t,e]),Cb(()=>{if(!o||!h||!l.current)return;let v=u.current,x=t!==v.length,y=n!==v.loading;u.current={length:t,loading:n},!(!x&&!y)&&f(n?"auto":"smooth")},[o,h,n,t,f]),{messagesEndRef:r,showScrollToBottom:m,showTopFade:i,scrollToBottom:f}}import{ChevronDown as SR,ChevronUp as NR}from"lucide-react";import{useEffect as Pc,useRef as Tb,useState as kb}from"react";import{jsx as pi,jsxs as TR}from"react/jsx-runtime";function Cm(){let[e,t]=kb(!1);return Pc(()=>{let n=document.documentElement,o=()=>t(n.hasAttribute("data-mcp-widget-fullscreen"));o();let r=new MutationObserver(o);return r.observe(n,{attributes:!0,attributeFilter:["data-mcp-widget-fullscreen"]}),()=>r.disconnect()},[]),e}function Pb({messages:e,isLoading:t}){let n=Cm(),[o,r]=kb(!1),s=Tb(null),a=e.reduce((c,l)=>l.role==="user"?l.id:c,null),i=Tb(a);return Pc(()=>{n||r(!1)},[n]),Pc(()=>{let c=i.current;i.current=a,n&&a!==null&&a!==c&&r(!0)},[n,a]),Pc(()=>{o&&s.current?.scrollIntoView({block:"end"})},[o,e]),n?TR("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-2 px-2 pb-2 sm:px-4","data-testid":"fullscreen-chat-overlay",children:[o&&pi("section",{id:"fullscreen-chat-drawer",className:"max-h-[46vh] overflow-y-auto overscroll-contain rounded-2xl border border-border/80 bg-background/95 px-2 py-4 shadow-2xl backdrop-blur-xl sm:px-4","aria-label":"Current chat messages","data-testid":"fullscreen-chat-drawer",children:pi(ui,{messages:e,isLoading:t,messagesEndRef:s,renderToolResults:!1})}),pi("button",{type:"button",className:"grid size-9 place-items-center self-center rounded-full border border-border/80 bg-background/95 text-foreground shadow-lg backdrop-blur-xl transition-colors hover:bg-muted","aria-label":o?"Hide chat messages":"Show chat messages","aria-expanded":o,"aria-controls":"fullscreen-chat-drawer",onClick:()=>r(c=>!c),"data-testid":"fullscreen-chat-drawer-toggle",children:o?pi(SR,{className:"size-4"}):pi(NR,{className:"size-4"})})]}):null}import{useCallback as Xn,useState as MR}from"react";import{convertMessagesToProvider as kR}from"@mcp-use/agent";function Rc(e){return kR(e)}var Mc=e=>{let t=[];for(let n of e){if(n.error||n.result?.isError){let r={id:`prompt-error-${n.promptName}-${n.timestamp}`,role:"assistant",content:n.error||"Prompt execution failed",timestamp:n.timestamp};t.push(r);continue}let o=n.result;if(o&&"messages"in o&&Array.isArray(o.messages))for(let r of o.messages){let s="",a=[];if(typeof r.content=="string")s=r.content;else if(Array.isArray(r.content)){let c=[];for(let l of r.content)l.type==="text"&&l.text?c.push(l.text):l.type==="image"&&l.data?a.push({type:"image",data:l.data,mimeType:l.mimeType||"image/png"}):l.type==="resource"&&c.push(`[Resource: ${l.resource?.uri||"embedded"}]`);s=c.join(`
|
|
204
204
|
`)}else r.content&&typeof r.content=="object"&&(r.content.type==="text"&&r.content.text?s=r.content.text:r.content.type==="image"&&r.content.data?a.push({type:"image",data:r.content.data,mimeType:r.content.mimeType||"image/png"}):s=JSON.stringify(r.content));!s&&a.length===0&&(s="[no content]");let i={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:s||"",timestamp:n.timestamp,attachments:a.length>0?a:void 0};t.push(i)}}return t};function Ic(e){if(!e)return;let t=Rb(e);if(t)return t;let n=[],o=!1,r=!1;for(let a of e){if(o){r?r=!1:a==="\\"?r=!0:a==='"'&&(o=!1);continue}a==='"'?o=!0:a==="{"?n.push("}"):a==="["?n.push("]"):(a==="}"||a==="]")&&n[n.length-1]===a&&n.pop()}let s=e;return o&&r&&(s=s.slice(0,-1)),o&&(s+='"'),s+=[...n].reverse().join(""),Rb(s)}function Rb(e){try{let t=JSON.parse(e);return t!==null&&!Array.isArray(t)&&typeof t=="object"?t:void 0}catch{return}}function Sm(e,t=[]){return{id:e,messages:t,attachments:[],isLoading:!1,trace:wr,managedChatNotice:null,pendingAuthorization:null,authenticatingToolCallId:null,toolAuthorizationError:null,mcpServerAuthRequired:null,persistedChatId:null,creation:null,runtime:{abortController:null,sendInProgress:!1,traceId:0,authorizationGate:null,pendingTurnResumed:!1}}}function ss(){let e=globalThis.crypto,t=e?.randomUUID?.();if(t)return t;if(!e?.getRandomValues)throw new Error("Secure random generation is unavailable");let n=e.getRandomValues(new Uint8Array(16));return`chat-${Array.from(n,r=>r.toString(16).padStart(2,"0")).join("")}`}import{useCallback as Nm,useRef as PR,useSyncExternalStore as RR}from"react";function Ec(e,t){return typeof t=="function"?t(e):t}var Tm=class{constructor(){ct(this,"sessions",new Map);ct(this,"listeners",new Map)}get(t){let n=this.sessions.get(t);if(n)return n;let o=Sm(t);return this.sessions.set(t,o),o}has(t){return this.sessions.has(t)}seed(t,n){let o=this.sessions.get(t);if(o)return o;let r=Sm(t,n);return this.sessions.set(t,r),r}update(t,n){let o=this.get(t),r=typeof n=="function"?n(o):n;if(Object.keys(r).every(i=>Object.is(o[i],r[i])))return o;let a={...o,...r};this.sessions.set(t,a);for(let i of this.listeners.get(t)??[])i();return a}subscribe(t,n){let o=this.listeners.get(t);return o||(o=new Set,this.listeners.set(t,o)),o.add(n),()=>{o.delete(n),o.size===0&&this.listeners.delete(t)}}delete(t){this.sessions.delete(t)}findByPersistedChatId(t){for(let n of this.sessions.values())if((n.persistedChatId??n.id)===t)return n}};function qs(){let e=PR(null);return e.current||(e.current=new Tm),e.current}function Ac(e,t){let n=Nm(a=>e.subscribe(t,a),[e,t]),o=Nm(()=>e.get(t),[e,t]),r=RR(n,o,o),s=Nm(a=>e.update(t,a),[t,e]);return[r,s]}function km({sessionStore:e,sessionId:t,onMessagesChange:n,mcpServerUrl:o,llmConfig:r,authConfig:s,mcpAuthTokens:a,isConnected:i,chatApiUrl:c,waitForChatApiUrl:l,widgetModelContexts:u,initialMessages:p,disabledTools:d,streamProtocol:h="sse",credentials:m,extraHeaders:b,body:f}){let v=qs(),x=e??v,[y]=MR(ss),g=t??y;p?.length&&!x.has(g)&&x.seed(g,p);let[C,k]=Ac(x,g),{messages:I,isLoading:M,attachments:N,managedChatNotice:E,mcpServerAuthRequired:T,runtime:S}=C,P=C.trace,A=Xn(z=>{let F=x.update(g,ie=>({messages:Ec(ie.messages,z)}));n?.(g,F.messages)},[g,n,x]),R=Xn(z=>{let F={...z,id:`trace-${++S.traceId}`,timestamp:Date.now()};k(ie=>({trace:Tc(ie.trace,F)}))},[S,k]),W=Xn(async(z,F,ie,le)=>{let Ne=[...N,...ie??[]],de=z.trim()||F.length>0||Ne.length>0,re=pe=>{if(le?.throwOnError)throw new Error(pe)};if(!de){re("Chat message must include content");return}if(!r){re("Chat is not configured");return}if(!i){re("The MCP server is not connected");return}if(S.sendInProgress){re("Chat is busy with another turn");return}S.sendInProgress=!0;let be=[...Mc(F)];if(z.trim()||Ne.length>0){let pe={id:`user-${Date.now()}`,role:"user",content:z.trim(),timestamp:Date.now(),attachments:Ne.length>0?Ne:void 0};be.push(pe)}A(pe=>[...pe,...be]),k({isLoading:!0,attachments:[]}),S.abortController=new AbortController;try{let pe=s,We=s?.type==="bearer"&&!!s.token,Ke=s?.type==="basic"&&!!(s.username||s.password);if(!We&&!Ke)if(a?.access_token)pe={type:"oauth",oauthTokens:a};else try{let ue="mcp:auth",ve=Hl(o),mt=`${ue}_${ve}_tokens`,nt=localStorage.getItem(mt);if(nt){let B=JSON.parse(nt);B?.access_token&&(pe={type:"oauth",oauthTokens:B})}}catch(ue){console.warn("Failed to retrieve OAuth tokens:",ue)}let Ve=[...I,...be],pt=Lr(u??new Map),lt=pl(pt),D=[...lt?[lt]:[],...Ve.map(ue=>({role:ue.role,content:ue.content||(ue.parts?.filter(ve=>ve.type==="text").map(ve=>ve.text).join("")??""),attachments:ue.attachments}))],_=c??(l?await l():void 0)??Ki("chat/stream"),j=[...d??[]].sort(),Le={disabledTools:j,...pt?{widgetModelContext:pt}:{}},Oe=f?f(D,Le):{mcpServerUrl:o,llmConfig:r,authConfig:pe,messages:D,...j.length>0?{disabledTools:j}:{}},He=f?Sc(Oe):{mcpServerUrl:o,llmConfig:{provider:r.provider,model:r.model,temperature:r.temperature,baseUrl:r.baseUrl},messages:D,...j.length>0?{disabledTools:j}:{}};R({type:"request",request:{url:_,protocol:h,envelope:He,providerMessages:[...lt?[lt]:[],...Rc(Ve)]}});let tt=await fetch(_,{method:"POST",headers:{"Content-Type":"application/json",...b},signal:S.abortController.signal,...m?{credentials:m}:{},body:JSON.stringify(Oe)});if(!tt.ok){let ue=await tt.json().catch(()=>null);if(c){let ve=nv(tt.status,ue);if(ve){if(k({managedChatNotice:ve}),le?.throwOnError)throw new Error(`Chat request failed with HTTP ${tt.status}`);return}}if(tt.status===401&&ue?.error==="mcp_auth_required"){if(k({mcpServerAuthRequired:{mcpServerUrl:ue.mcpServerUrl??o,message:ue.message}}),le?.throwOnError)throw new Error("The MCP server requires authentication");return}throw new Error(`HTTP error! status: ${tt.status}`)}le?.onAccepted?.();let ln=`assistant-${Date.now()}`,Nt="",Ze=[];A(ue=>[...ue,{id:ln,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);let cn=tt.body?.getReader(),co=new TextDecoder;if(!cn)throw new Error("No response body");let Pt=()=>{A(ue=>ue.map(ve=>ve.id===ln?{...ve,parts:[...Ze]}:ve))},Kt=()=>{A(ue=>ue.map(ve=>ve.id===ln?{...ve,parts:[...Ze],content:""}:ve))},Cn=ue=>{Nt+=ue;let ve=Ze[Ze.length-1];ve&&ve.type==="text"?ve.text=Nt:Ze.push({type:"text",text:Nt}),Pt()},Tt=new Map,Yt=new Map,oe=(ue,ve)=>{Nt&&(Nt=""),!Tt.has(ue)&&(Ze.push({type:"tool-invocation",toolInvocation:{toolCallId:ue,toolName:ve,args:{},state:"streaming",partialArgs:{}}}),Tt.set(ue,Ze.length-1),Yt.set(ue,""),Pt())},fe=(ue,ve)=>{let mt=Tt.get(ue);if(mt===void 0||!ve)return;let nt=(Yt.get(ue)??"")+ve;Yt.set(ue,nt);let B=Ic(nt),se=Ze[mt]?.toolInvocation;!B||!se||(se.partialArgs=B,Pt())},Ue=(ue,ve,mt)=>{Nt&&(Nt="");let nt=Tt.get(ue),B=nt===void 0?void 0:Ze[nt]?.toolInvocation;B?(B.toolName=ve,B.args=mt,B.state="pending",B.partialArgs=void 0):(Ze.push({type:"tool-invocation",toolInvocation:{toolCallId:ue,toolName:ve,args:mt,state:"pending"}}),Tt.set(ue,Ze.length-1)),Yt.delete(ue),Pt()},ft=(ue,ve)=>{let mt;ue.by==="toolName"?mt=Ze.find(nt=>nt.type==="tool-invocation"&&nt.toolInvocation?.toolName===ue.toolName&&!nt.toolInvocation?.result):mt=Ze[ue.index],mt?.toolInvocation&&(mt.toolInvocation.result=ve,mt.toolInvocation.state=ve?.isError?"error":"result",Pt())},Rt="";for(;;){if(S.abortController?.signal.aborted){await cn.cancel();break}let{done:ue,value:ve}=await cn.read();if(ue)break;Rt+=co.decode(ve,{stream:!0});let mt=Rt.split(`
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ar=Object.create;var Be=Object.defineProperty;var cr=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var J=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var pr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of lr(e))!dr.call(t,o)&&o!==r&&Be(t,o,{get:()=>e[o],enumerable:!(n=cr(e,o))||n.enumerable});return t};var hr=(t,e,r)=>(r=t!=null?ar(ur(t)):{},pr(e||!t||!t.__esModule?Be(r,"default",{value:t,enumerable:!0}):r,t));var yt=J((ss,gt)=>{"use strict";gt.exports=class{constructor(e={}){this.points=e.points,this.duration=e.duration,this.blockDuration=e.blockDuration,this.execEvenly=e.execEvenly,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs,this.keyPrefix=e.keyPrefix}get points(){return this._points}set points(e){if(Number.isFinite(e))this._points=e;else throw new Error("points must be set and must be a finite number")}get duration(){return this._duration}set duration(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)this._duration=e;else throw new Error("duration must be set and must be a finite, non-negative number")}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration=typeof e>"u"?0:e}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly=typeof e>"u"?!1:!!e}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs===void 0?this._getExecEvenlyMinDelayMsDefault():this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs=e}_getExecEvenlyMinDelayMsDefault(){return this.points>0?Math.ceil(this.msDuration/this.points):0}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if(typeof e>"u"&&(e="rlflx"),typeof e!="string")throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(e={}){return e&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?`${this.keyPrefix}:${e}`:e}parseKey(e){return this.keyPrefix.length>0?e.substring(this.keyPrefix.length+1):e}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}});var bt=J((as,wt)=>{"use strict";wt.exports=class{constructor(e,r,n=null){this.value=e,this.expiresAt=r,this.timeoutId=n}get value(){return this._value}set value(e){this._value=parseInt(e,10)}get expiresAt(){return this._expiresAt}set expiresAt(e){e instanceof Date?this._expiresAt=e.getTime():this._expiresAt=e}get timeoutId(){return this._timeoutId}set timeoutId(e){this._timeoutId=e}}});var Se=J((ls,xt)=>{"use strict";xt.exports=class{constructor(e,r,n,o){this.remainingPoints=typeof e>"u"?0:e,this.msBeforeNext=typeof r>"u"?0:r,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof o>"u"?!1:o}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(e){return this._msBeforeNext=e,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(e){return this._remainingPoints=e,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(e){return this._consumedPoints=e,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(e){this._isFirstInDuration=!!e}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}});var Et=J((ds,Rt)=>{"use strict";var vt=bt(),Ae=Se();Rt.exports=class{constructor(){this._storage=new Map}incrby(e,r,n){let o=this._storage.get(e);if(o){let s=o.expiresAt?o.expiresAt-Date.now():-1;return!o.expiresAt||s>0?(o.value=o.value+r,new Ae(0,s,o.value,!1)):this.set(e,r,n)}return this.set(e,r,n)}set(e,r,n){let o=n*1e3,s=this._storage.get(e);s&&s.timeoutId&&clearTimeout(s.timeoutId);let a=new vt(r,o>0?Date.now()+o:null);return this._storage.set(e,a),o>0&&(a.timeoutId=setTimeout(()=>{this._storage.delete(e)},o),a.timeoutId.unref&&a.timeoutId.unref()),new Ae(0,o===0?-1:o,a.value,!0)}get(e){let r=this._storage.get(e);if(r){let n=r.expiresAt?r.expiresAt-Date.now():-1;return new Ae(0,n,r.value,!1)}return null}delete(e){let r=this._storage.get(e);return r?(r.timeoutId&&clearTimeout(r.timeoutId),this._storage.delete(e),!0):!1}_restoreRecord(e,r,n){let o=Date.now(),s=n!==null;if(s&&!Number.isFinite(n)||s&&n<=o)return;let a=s?n-o:0,i=this._storage.get(e);i&&i.timeoutId&&clearTimeout(i.timeoutId);let c=new vt(r,n);this._storage.set(e,c),a>0&&(c.timeoutId=setTimeout(()=>{this._storage.delete(e)},a),c.timeoutId.unref&&c.timeoutId.unref())}}});var St=J((ps,_t)=>{"use strict";var Ar=yt(),Cr=Et(),Pt=Se(),Ce=class extends Ar{constructor(e={}){super(e),this._memoryStorage=new Cr}consume(e,r=1,n={}){return new Promise((o,s)=>{let a=this.getKey(e),i=this._getKeySecDuration(n),c=this._memoryStorage.incrby(a,r,i);if(c.remainingPoints=Math.max(this.points-c.consumedPoints,0),c.consumedPoints>this.points)this.blockDuration>0&&c.consumedPoints<=this.points+r&&(c=this._memoryStorage.set(a,c.consumedPoints,this.blockDuration)),s(c);else if(this.execEvenly&&this.points>0&&c.msBeforeNext>0&&!c.isFirstInDuration){let l=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));l<this.execEvenlyMinDelayMs&&(l=c.consumedPoints*this.execEvenlyMinDelayMs),c.msBeforeNext=Math.max(c.msBeforeNext-l,0),setTimeout(o,l,c)}else o(c)})}penalty(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let a=this._getKeySecDuration(n),i=this._memoryStorage.incrby(o,r,a);i.remainingPoints=Math.max(this.points-i.consumedPoints,0),s(i)})}reward(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let a=this._getKeySecDuration(n),i=this._memoryStorage.incrby(o,-r,a);i.remainingPoints=Math.max(this.points-i.consumedPoints,0),s(i)})}block(e,r){let n=r*1e3,o=this.points+1;return this._memoryStorage.set(this.getKey(e),o,r),Promise.resolve(new Pt(0,n===0?-1:n,o))}set(e,r,n){let o=(n>=0?n:this.duration)*1e3;return this._memoryStorage.set(this.getKey(e),r,n),Promise.resolve(new Pt(0,o===0?-1:o,r))}get(e){let r=this._memoryStorage.get(this.getKey(e));return r!==null&&(r.remainingPoints=Math.max(this.points-r.consumedPoints,0)),Promise.resolve(r)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}dump(){let e=[];for(let[r,n]of this._memoryStorage._storage)e.push({key:this.parseKey(r),value:n.value,expiresAt:n.expiresAt});return{version:1,dumpedAt:Date.now(),storage:e}}restore(e,r=!1){if(!e||typeof e!="object"||e.version!==1)return;let n=r?{invalid:{count:0,keys:[]},expired:{count:0,keys:[]},restored:{count:0,keys:[]}}:{invalid:0,expired:0,restored:0},o=(s,a)=>{r?(n[s].count+=1,n[s].keys.push(a)):n[s]+=1};if(!Array.isArray(e.storage))return n;for(let s of e.storage){if(!s||typeof s!="object"){o("invalid","N/A");continue}let a=typeof s.key=="string"||typeof s.key=="number",i=Number.isFinite(s.value),c=s.expiresAt===null||Number.isFinite(s.expiresAt);if(!a||!i||!c){o("invalid",s.key);continue}if(s.expiresAt!==null&&s.expiresAt<=Date.now()){o("expired",s.key);continue}this._memoryStorage._restoreRecord(this.getKey(s.key),s.value,s.expiresAt),o("restored",s.key)}return n}};_t.exports=Ce});var pe=(t,e,r)=>(n,o)=>{let s=-1;return a(0);async function a(i){if(i<=s)throw new Error("next() called multiple times");s=i;let c,l=!1,u;if(t[i]?(u=t[i][0][0],n.req.routeIndex=i):u=i===t.length&&o||void 0,u)try{c=await u(n,()=>a(i+1))}catch(d){if(d instanceof Error&&e)n.error=d,c=await e(d,n),l=!0;else throw d}else n.finalized===!1&&r&&(c=await r(n));return c&&(n.finalized===!1||l)&&(n.res=c),n}};var qe=Symbol();var ze=(t,e)=>new Response(t,{headers:{"Content-Type":e.replace(/^[^;]+/,n=>n.toLowerCase())}}).formData();var Fe=32,fr=1e4,Q=t=>"headers"in t,Ke=async(t,e=Object.create(null))=>{let{all:r=!1,dot:n=!1}=e,a=(Q(t)?t.headers:t.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return a==="multipart/form-data"||a==="application/x-www-form-urlencoded"?mr(t,{all:r,dot:n}):{}};async function mr(t,e){if(!Q(t)&&t.bodyCache.formData)return We(await t.bodyCache.formData,e);let r=Q(t)?t.headers:t.raw.headers,n=await t.arrayBuffer(),o=ze(n,r.get("Content-Type")||"");Q(t)||(t.bodyCache.formData=o);let s=await o;return s?We(s,e):{}}function We(t,e){let r=Object.create(null),n={count:0};return t.forEach((o,s)=>{e.all||s.endsWith("[]")?gr(r,s,o):r[s]=o}),e.dot&&Object.entries(r).forEach(([o,s])=>{o.includes(".")&&(yr(r,o,s,n),delete r[o])}),r}var gr=(t,e,r)=>{t[e]!==void 0?Array.isArray(t[e])?t[e].push(r):t[e]=[t[e],r]:e.endsWith("[]")?t[e]=[r]:t[e]=r},yr=(t,e,r,n)=>{if(/(?:^|\.)__proto__\./.test(e))return;let o=t,s=e.split(".",Fe+2);s.length>Fe+1&&Ve(),s.forEach((a,i)=>{i===s.length-1?o[a]=r:((!o[a]||typeof o[a]!="object"||Array.isArray(o[a])||o[a]instanceof File)&&(n.count++>=fr&&Ve(),o[a]=Object.create(null)),o=o[a])})},Ve=()=>{throw new Error("Nesting limit exceeded")};var fe=t=>{let e=t.split("/");return e[0]===""&&e.shift(),e},Ge=t=>{let{groups:e,path:r}=wr(t),n=fe(r);return br(n,e)},wr=t=>{let e=[];return t=t.replace(/\{[^}]+\}/g,(r,n)=>{let o=`@${n}`;return e.push([o,r]),o}),{groups:e,path:t}},br=(t,e)=>{for(let r=e.length-1;r>=0;r--){let[n]=e[r];for(let o=t.length-1;o>=0;o--)if(t[o].includes(n)){t[o]=t[o].replace(n,e[r][1]);break}}return t},Z={},Je=(t,e)=>{if(t==="*")return"*";let r=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${t}#${e}`;return Z[n]||(r[2]?Z[n]=e&&e[0]!==":"&&e[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${e})`)]:[t,r[1],new RegExp(`^${r[2]}$`)]:Z[n]=[t,r[1],!0]),Z[n]}return null},Xe=(t,e)=>{try{return e(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return e(r)}catch{return r}})}},xr=t=>Xe(t,decodeURI),me=t=>{let e=t.url,r=e.indexOf("/",e.indexOf(":")+4),n=r;for(;n<e.length;n++){let o=e.charCodeAt(n);if(o===37){let s=e.indexOf("?",n),a=e.indexOf("#",n),i=s===-1?a===-1?void 0:a:a===-1?s:Math.min(s,a),c=e.slice(r,i);return xr(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(o===63||o===35)break}return e.slice(r,n)};var Ye=t=>{let e=me(t);return e.length>1&&e.at(-1)==="/"?e.slice(0,-1):e},N=(t,e,...r)=>(r.length&&(e=N(e,...r)),`${t?.[0]==="/"?"":"/"}${t}${e==="/"?"":`${t?.at(-1)==="/"?"":"/"}${e?.[0]==="/"?e.slice(1):e}`}`),ee=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let e=t.split("/"),r=[],n="";return e.forEach(o=>{if(o!==""&&!/\:/.test(o))n+="/"+o;else if(/\:/.test(o))if(o.charCodeAt(o.length-1)===63){r.length===0&&n===""?r.push("/"):r.push(n);let s=o.slice(0,-1);n+="/"+s,r.push(n)}else n+="/"+o}),r.filter((o,s,a)=>a.indexOf(o)===s)},te=t=>t.indexOf("%")!==-1?Xe(t,vr):t,he=t=>(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),te(t)),Qe=(t,e,r)=>{let n=t.indexOf("#",8);n!==-1&&(t=t.slice(0,n));let o;if(!r&&e&&e.indexOf("%")===-1&&e.indexOf("+")===-1){let i=t.indexOf("?",8);if(i===-1)return;for(t.startsWith(e,i+1)||(i=t.indexOf(`&${e}`,i+1));i!==-1;){let c=t.charCodeAt(i+e.length+1);if(c===61){let l=i+e.length+2,u=t.indexOf("&",l);return he(t.slice(l,u===-1?void 0:u))}else if(c==38||isNaN(c))return"";i=t.indexOf(`&${e}`,i+1)}if(o=/[%+]/.test(t),!o)return}let s=Object.create(null);o??=/[%+]/.test(t);let a=t.indexOf("?",8);for(;a!==-1;){let i=t.indexOf("&",a+1),c=t.indexOf("=",a);c>i&&i!==-1&&(c=-1);let l=t.slice(a+1,c===-1?i===-1?void 0:i:c);if(o&&(l=he(l)),a=i,l==="")continue;let u;c===-1?u="":(u=t.slice(c+1,i===-1?void 0:i),o&&(u=he(u))),r?(s[l]&&Array.isArray(s[l])||(s[l]=[]),s[l].push(u)):s[l]??=u}return e?s[e]:s},Ze=Qe,et=(t,e)=>Qe(t,e,!0),vr=decodeURIComponent;var tt=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,e="/",r=[[]]){this.raw=t,this.path=e,this.#e=r}param(t){return t?this.#r(t):this.#s()}#r(t){let e=this.#e[0][this.routeIndex]?.[1][t],r=this.#n(e);return r&&te(r)}#s(){let t={},e=Object.keys(this.#e[0][this.routeIndex]?.[1]??{});for(let r of e){let n=this.#n(this.#e[0][this.routeIndex][1][r]);n!==void 0&&(t[r]=te(n))}return t}#n(t){return this.#e[1]?this.#e[1][t]:t}query(t){return Ze(this.url,t)}queries(t){return et(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let e=Object.create(null);return this.raw.headers.forEach((r,n)=>{e[n]=r}),e}async parseBody(t){return Ke(this,t)}#o=t=>{let{bodyCache:e,raw:r}=this,n=e[t];if(n)return n;for(let o in e)return e[o].then(s=>(o==="json"&&(s=JSON.stringify(s)),new Response(s)[t]()));return e[t]=r[t]()};json(){return this.#o("text").then(t=>JSON.parse(t))}text(){return this.#o("text")}arrayBuffer(){return this.#o("arrayBuffer")}bytes(){return this.#o("arrayBuffer").then(t=>new Uint8Array(t))}blob(){return this.#o("blob")}formData(){return this.#o("formData")}addValidatedData(t,e){(this.#t??={})[t]=e}valid(t){return this.#t?.[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[qe](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var rt={Stringify:1,BeforeStream:2,Stream:3},Rr=(t,e)=>{let r=new String(t);return r.isEscaped=!0,r.callbacks=e,r};var ge=async(t,e,r,n,o)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let s=t.callbacks;if(!s?.length)return Promise.resolve(t);o?o[0]+=t:o=[t];let a=Promise.all(s.map(i=>i({phase:e,buffer:o,context:n}))).then(i=>Promise.all(i.filter(Boolean).map(c=>ge(c,e,!1,n,o))).then(()=>o[0]));return r?Rr(await a,s):a};var Er="text/plain; charset=UTF-8",ye=(t,e)=>({"Content-Type":t,...e}),X=(t,e)=>new Response(t,e),we=class{#t;#e;env={};#r;finalized=!1;error;#s;#n;#o;#u;#c;#l;#a;#d;#p;constructor(t,e){this.#t=t,e&&(this.#n=e.executionCtx,this.env=e.env,this.#l=e.notFoundHandler,this.#p=e.path,this.#d=e.matchResult)}get req(){return this.#e??=new tt(this.#t,this.#p,this.#d),this.#e}get event(){if(this.#n&&"respondWith"in this.#n)return this.#n;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#n)return this.#n;throw Error("This context has no ExecutionContext")}get res(){return this.#o||=X(null,{headers:this.#a??=new Headers})}set res(t){if(this.#o&&t){t=X(t.body,t);for(let[e,r]of this.#o.headers.entries())if(e!=="content-type")if(e==="set-cookie"){let n=this.#o.headers.getSetCookie();t.headers.delete("set-cookie");for(let o of n)t.headers.append("set-cookie",o)}else t.headers.set(e,r)}this.#o=t,this.finalized=!0}render=(...t)=>(this.#c??=e=>this.html(e),this.#c(...t));setLayout=t=>this.#u=t;getLayout=()=>this.#u;setRenderer=t=>{this.#c=t};header=(t,e,r)=>{this.finalized&&(this.#o=X(this.#o.body,this.#o));let n=this.#o?this.#o.headers:this.#a??=new Headers;e===void 0?n.delete(t):r?.append?n.append(t,e):n.set(t,e)};status=t=>{this.#s=t};set=(t,e)=>{this.#r??=new Map,this.#r.set(t,e)};get=t=>this.#r?this.#r.get(t):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(t,e,r){let n=this.#o?new Headers(this.#o.headers):this.#a;if(typeof e=="object"&&e.headers){n??=new Headers;for(let[s,a]of new Headers(e.headers))s==="set-cookie"?n.append(s,a):n.set(s,a)}if(r){if(!n){let s=0;for(let a in r)if(++s>1||typeof r[a]!="string"){n=new Headers;break}}if(n)for(let s in r){let a=r[s];if(typeof a=="string")n.set(s,a);else{n.delete(s);for(let i of a)n.append(s,i)}}}let o=typeof e=="number"?e:e?.status??this.#s;return X(t,{status:o,headers:n??r})}newResponse=(...t)=>this.#i(...t);body=(t,e,r)=>this.#i(t,e,r);text=(t,e,r)=>!this.#a&&!this.#s&&!e&&!r&&!this.finalized?new Response(t):this.#i(t,e,ye(Er,r));json=(t,e,r)=>this.#i(JSON.stringify(t),e,ye("application/json",r));html=(t,e,r)=>{let n=o=>this.#i(o,e,ye("text/html; charset=UTF-8",r));return typeof t=="object"?ge(t,rt.Stringify,!1,{}).then(n):n(t)};redirect=(t,e)=>{let r=String(t);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,e??302)};notFound=()=>(this.#l??=()=>X(),this.#l(this))};var _="ALL",nt="all",ot=["get","post","put","delete","options","patch","query"],re="Can not add a route since the matcher is already built.",ne=class extends Error{};var st="__COMPOSED_HANDLER";var Pr=t=>t.text("404 Not Found",404),it=(t,e)=>{if("getResponse"in t){let r=t.getResponse();return e.newResponse(r.body,r)}return console.error(t),e.text("Internal Server Error",500)},at=class ct{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(e={}){[...ot,nt].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?this.#t=a:this.#s(s,this.#t,a),i.forEach(c=>{this.#s(s,this.#t,c)}),this)}),this.on=(s,a,...i)=>{for(let c of[a].flat()){this.#t=c;for(let l of[s].flat())i.map(u=>{this.#s(l.toUpperCase(),this.#t,u)})}return this},this.use=(s,...a)=>(typeof s=="string"?this.#t=s:(this.#t="*",a.unshift(s)),a.forEach(i=>{this.#s(_,this.#t,i)}),this);let{strict:n,...o}=e;Object.assign(this,o),this.getPath=n??!0?e.getPath??me:Ye}#e(){let e=new ct({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#r=this.#r,e.routes=this.routes,e}#r=Pr;errorHandler=it;route(e,r){let n=this.basePath(e);return r.routes.map(o=>{let s;r.errorHandler===it?s=o.handler:(s=async(a,i)=>(await pe([],r.errorHandler)(a,()=>o.handler(a,i))).res,s[st]=o.handler),n.#s(o.method,o.path,s,o.basePath)}),this}basePath(e){let r=this.#e();return r._basePath=N(this._basePath,e),r}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#r=e,this);mount(e,r,n){let o,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,n.replaceRequest===!1?o=c=>c:o=n.replaceRequest));let a=s?c=>{let l=s(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};o||=(()=>{let c=N(this._basePath,e),l=c==="/"?0:c.length;return u=>{let d=new URL(u.url);return d.pathname=this.getPath(u).slice(l)||"/",new Request(d,u)}})();let i=async(c,l)=>{let u=await r(o(c.req.raw),...a(c));if(u)return u;await l()};return this.#s(_,N(e,"*"),i),this}#s(e,r,n,o){e=e.toUpperCase(),r=N(this._basePath,r);let s={basePath:o!==void 0?N(this._basePath,o):this._basePath,path:r,method:e,handler:n};this.router.add(e,r,[n,s]),this.routes.push(s)}#n(e,r){if(e instanceof Error)return this.errorHandler(e,r);throw e}#o(e,r,n,o){if(o==="HEAD")return(async()=>new Response(null,await this.#o(e,r,n,"GET")))();let s=this.getPath(e,{env:n}),a=this.router.match(o,s),i=new we(e,{path:s,matchResult:a,env:n,executionCtx:r,notFoundHandler:this.#r});if(a[0].length===1){let l;try{l=a[0][0][0][0](i,async()=>{i.res=await this.#r(i)})}catch(u){return this.#n(u,i)}return l instanceof Promise?l.then(u=>u||(i.finalized?i.res:this.#r(i))).catch(u=>this.#n(u,i)):l??this.#r(i)}let c=pe(a[0],this.errorHandler,this.#r);return(async()=>{try{let l=await c(i);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#n(l,i)}})()}fetch=(e,...r)=>this.#o(e,r[1],r[0],e.method);request=(e,r,n,o)=>e instanceof Request?this.fetch(r?new Request(e,r):e,n,o):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${N("/",e)}`,r),n,o));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#o(e.request,e,void 0,e.request.method))})}};var R=()=>Object.create(null);var oe=[];function be(t,e){let r=this.buildAllMatchers(),n=((o,s)=>{let a=r[o]||r[_],i=a[2][s];if(i)return i;let c=s.match(a[0]);if(!c)return[[],oe];let l=c.indexOf("",1);return[a[1][l],c]});return this.match=n,n(t,e)}var K="[^/]+",j=".*",M="(?:|/.*)",U=Symbol(),lt=new Set(".\\+*[^]$()");function _r(t,e){return t.length===1?e.length===1?t<e?-1:1:-1:e.length===1?1:t===j||t===M?e===M?-1:1:e===j||e===M?-1:t===K?1:e===K?-1:t.length===e.length?t<e?-1:1:e.length-t.length}var ut=class xe{#t;#e;#r=R();insert(e,r,n,o,s){let a=this;for(let i=0,c=e.length;i<c;i++){let l=e[i],u=l.length===1?l==="*"?i===c-1?["","",j]:["","",K]:null:l==="/*"?["","",M]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),d;if(u){let h=u[1],f=u[2]||K;if(h&&u[2]&&(f===".*"||(f=f.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(f))||f.length===1&<.has(f)))throw U;if(d=a.#r[f],!d){if(f!==j&&f!==M){for(let x in a.#r)if((f.length>1||x.length>1)&&x!==j&&x!==M)throw U}d=a.#r[f]=new xe}h!==""&&(d.#e??=o.varIndex++,n.push([h,d.#e]))}else if(d=a.#r[l],!d){for(let h in a.#r)if(h.length>1&&h!==j&&h!==M)throw U;d=a.#r[l]=new xe}a=d}if(a.#t!==void 0)throw U;a.#t=s?-1:r}buildRegExpStr(){let r=Object.keys(this.#r).sort(_r).map(n=>{let o=this.#r[n],s=o.buildRegExpStr();return s===""?"":(typeof o.#e=="number"?`(${n})@${o.#e}`:lt.has(n)?`\\${n}`:n)+s}).filter(Boolean);return typeof this.#t=="number"&&this.#t!==-1&&r.unshift(`#${this.#t}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}};var ve=class{#t={varIndex:0};#e=new ut;#r=0;paths=R();insert(t,e){if(e){this.#e.insert(t.split(""),0,[],this.#t,!0);return}let r=[],n=[],o=t;for(let a=0;;){let i=!1;if(o=o.replace(/\{[^}]+\}/g,c=>{let l=`@\\${a}`;return n[a]=[l,c],a++,i=!0,l}),!i)break}let s=o.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=n.length-1;a>=0;a--){let[i]=n[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(i)!==-1){s[c]=s[c].replace(i,n[a][1]);break}}this.#e.insert(s,this.#r,r,this.#t,!1),this.paths[t]=[this.#r++,r]}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let e=0,r=[],n=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(o,s,a)=>s!==void 0?(r[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${t}`),r,n]}};var dt=R();function pt(t){return dt[t]??=new RegExp(`^${t.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(e,r)=>r?`\\${r}`:e==="/*"?M:e==="*"?j:`/:${K}`)}$`)}function se(t,e){for(let r of Object.keys(t).sort((n,o)=>o.length-n.length))if(pt(r).test(e))return[...t[r]]}var ie=class{name="RegExpRouter";#t;#e;#r;constructor(){this.#t={[_]:R()},this.#e={[_]:R()},this.#r={[_]:new ve}}#s(t,e){try{this.#r[t].insert(e,!/\*|\/:/.test(e))}catch(r){throw r===U?new ne(e):r}}add(t,e,r){let n=this.#t,o=this.#e;if(!n)throw new Error(re);if(!n[t]){this.#r[t]=new ve;for(let i of[n,o]){i[t]=R();for(let c in i[_])i[t][c]=[...i[_][c]],this.#s(t,c)}}e==="/*"&&(e="*");let s=t===_?Object.keys(n):[t];if(/\*$/.test(e)){let i=pt(e);for(let c of s)n[c][e]||(this.#s(c,e),n[c][e]=se(n[c],e)||se(n[_],e)||[]);for(let c of[n,o])for(let l of s)for(let u in c[l])i.test(u)&&c[l][u].push([r,e]);return}let a=ee(e)||[e];for(let i of a)for(let c of s)o[c][i]||(this.#s(c,i),o[c][i]=se(n[c],i)||se(n[_],i)||[]),o[c][i].push([r,i])}match=be;buildAllMatchers(){let t=R();for(let e of Object.keys(this.#e))t[e]=this.#n(e);return this.#t=this.#e=this.#r=void 0,dt=R(),t}#n(t){let e=this.#t[t],r=this.#e[t],n=this.#r[t],o=R(),s=[],[a,i,c]=n.buildRegExp();for(let l of[e,r])for(let u in l){let d=l[u],h=n.paths[u];if(!h){o[u]=[d.map(([f])=>[f,R()]),oe];continue}s[h[0]]=d.map(([f,x])=>[f,n.paths[x][1].reduceRight((w,[v],g)=>(w[v]=c[h[1][g][1]],w),R())])}return[a,i.map(l=>s[l]),o]}};var Re=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,e,r){if(!this.#e)throw new Error(re);this.#e.push([t,e,r])}match(t,e){if(!this.#e)throw new Error("Fatal error");let r=this.#t,n=this.#e,o=r.length,s=0,a;for(;s<o;s++){let i=r[s];try{for(let c=0,l=n.length;c<l;c++)i.add(...n[c]);a=i.match(t,e)}catch(c){if(c instanceof ne)continue;throw c}this.match=i.match.bind(i),this.#t=[i],this.#e=void 0;break}if(s===o)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var Ee=R(),Sr=0,ht=class ft{#t=[];#e=R();#r=[];#s;#n=Ee;insert(e,r,n){let o=this,s=Ge(r),a=new Set,i=0;for(let c of s){let l=s[++i],u=Je(c,l)||(l===void 0&&c&&c.indexOf("*")===c.length-1?c:null),d=Array.isArray(u),h=d?u[0]:u||c,f=o.#e[h]||=new ft;u&&!f.#s&&(f.#s=u,o.#r.push(f)),o=f,d&&a.add(u[1])}o.#t.push({[e]:{handler:n,possibleKeys:[...a],score:++Sr}})}#o(e,r,n,o,s){for(let a=0,i=r.#t.length;a<i;a++){let c=r.#t[a],l=c[n]||c[_];if(l){l.params=R(),e.push(l);for(let u=0,d=l.possibleKeys.length;u<d;u++){let h=l.possibleKeys[u];l.params[h]=s?.[h]&&!u?s[h]:o[h]??s?.[h]}}}}search(e,r){let n=[];this.#n=Ee;let s=[this],a=fe(r),i=[],c=a.length,l=null;for(let u=0;u<c;u++){let d=a[u],h=u===c-1,f=[];for(let w=0,v=s.length;w<v;w++){let g=s[w],p=g.#e[d];p&&(p.#n=g.#n,h?(p.#e["*"]&&this.#o(n,p.#e["*"],e,g.#n),this.#o(n,p,e,g.#n)):f.push(p));for(let m of g.#r){let y=m.#s,E=g.#n===Ee?{}:{...g.#n};if(typeof y=="string"){(y==="*"||d.startsWith(y.slice(0,-1)))&&(this.#o(n,m,e,g.#n),y==="*"&&(m.#n=E,f.push(m)));continue}let[,T,C]=y;if(!(!d&&C===!0)){if(C!==!0){if(!l){l=[];let b=r[0]==="/"?1:0;for(let O=0;O<c;O++)l[O]=b,b+=a[O].length+1}let P=r.slice(l[u]),S=C.exec(P);if(S){E[T]=S[0],this.#o(n,m,e,g.#n,E),S[0].length===P.length&&m.#e["*"]&&this.#o(n,m.#e["*"],e,g.#n,E);for(let b in m.#e){m.#n=E;let O=S[0].match(/\//g)?.length??0;(i[O]||=[]).push(m);break}continue}}(C===!0||C.test(d))&&(E[T]=d,h?(this.#o(n,m,e,E,g.#n),m.#e["*"]&&this.#o(n,m.#e["*"],e,E,g.#n)):(m.#n=E,f.push(m)))}}}let x=i.shift();s=x?f.concat(x):f}return n[1]&&n.sort((u,d)=>u.score-d.score),[n.map(({handler:u,params:d})=>[u,d])]}};var Pe=class{name="TrieRouter";#t=new ht;add(t,e,r){for(let n of ee(e)||[e])this.#t.insert(t,n,r)}match(t,e){return this.#t.search(t,e)}};var _e=class extends at{constructor(t={}){super(t),this.router=t.router??new Re({routers:[new ie,new Pe]})}};import{Readable as bn}from"stream";function mt(t=""){return`<link rel="icon" type="image/svg+xml" href="${`${t.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as At,readFileSync as Tr}from"fs";import k from"path";import{fileURLToPath as Ir}from"url";import{gunzipSync as Mr}from"zlib";var D=hr(St(),1);function G(t,e){return t.header("Retry-After",String(Or(e))),t.json({error:"Too Many Requests"},429)}function Or(t){return t&&typeof t=="object"&&"msBeforeNext"in t&&typeof t.msBeforeNext=="number"&&Number.isFinite(t.msBeforeNext)?Math.max(1,Math.ceil(t.msBeforeNext/1e3)):60}var Dr={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function kr(){let t=k.dirname(Ir(import.meta.url));for(let e of[k.resolve(t,"app"),k.resolve(t,"../app"),k.resolve(t,"../../dist/app")])if(At(k.join(e,"inspector.js.gz")))return e;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function Ct(t,e="/inspector/assets"){let r=kr(),n=new Map,o=new D.default({points:600,duration:60}),s=async(a,i)=>{try{await o.consume(a.req)}catch(c){return G(a,c)}return i()};t.use(`${e}/*`,s),t.get(`${e}/*`,async a=>{let i=a.req.path.slice(e.length),c=i.startsWith("/")?i.slice(1):i;if(!c||c.includes(".."))return a.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=k.resolve(r,l),d=r.endsWith(k.sep)?r:`${r}${k.sep}`;if(!u.startsWith(d)||!At(u))return a.notFound();let h=k.extname(c),f=l.endsWith(".gz"),x=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(a.req.header("accept-encoding")??""),w=Tr(u),v=f&&!x?n.get(u)??Nr(n,u,w):w,g=v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength);return a.body(g,200,{"Content-Type":Dr[h]??"application/octet-stream",...f&&x?{"Content-Encoding":"gzip"}:{},...f?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function Nr(t,e,r){let n=Mr(r);return t.set(e,n),n}var Ot={name:"@mcp-use/inspector",type:"module",version:"20.3.14",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"},"./client/styles.css":{default:"./dist/client/styles.css"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"pnpm run clean && pnpm run build:client-exports && pnpm run build:server && pnpm run build:app && pnpm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts && node scripts/copy-client-styles.mjs","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs",test:"vitest run","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.16 || ^2.0.17 || ^2.0.18 || ^2.0.19 || ^2.0.20","@mcp-use/client":"^2.0.1 || ^2.1.0 || ^2.1.1 || ^2.1.2 || ^2.1.3 || ^2.1.4 || ^2.1.5 || ^2.2.0 || ^2.2.1 || ^2.2.2 || ^2.2.3 || ^2.2.4 || ^2.2.5 || ^2.3.0 || ^2.3.1 || ^2.3.2 || ^2.3.3 || ^2.3.4 || ^2.3.5 || ^2.4.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"^2.4.3 || ^2.4.4 || ^2.5.0 || ^2.5.1 || ^2.5.2 || ^2.6.0 || ^2.6.1 || ^2.7.0 || ^2.7.1 || ^2.7.2",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.13.5",jsdom:"^27.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",yaml:"^2.8.3",zod:"^4.2.0"}};var jr=Ot.version;function Lt(){return jr}var Hr=`<!doctype html>
|
|
1
|
+
var ar=Object.create;var Be=Object.defineProperty;var cr=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var J=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var pr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of lr(e))!dr.call(t,o)&&o!==r&&Be(t,o,{get:()=>e[o],enumerable:!(n=cr(e,o))||n.enumerable});return t};var hr=(t,e,r)=>(r=t!=null?ar(ur(t)):{},pr(e||!t||!t.__esModule?Be(r,"default",{value:t,enumerable:!0}):r,t));var yt=J((ss,gt)=>{"use strict";gt.exports=class{constructor(e={}){this.points=e.points,this.duration=e.duration,this.blockDuration=e.blockDuration,this.execEvenly=e.execEvenly,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs,this.keyPrefix=e.keyPrefix}get points(){return this._points}set points(e){if(Number.isFinite(e))this._points=e;else throw new Error("points must be set and must be a finite number")}get duration(){return this._duration}set duration(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)this._duration=e;else throw new Error("duration must be set and must be a finite, non-negative number")}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration=typeof e>"u"?0:e}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly=typeof e>"u"?!1:!!e}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs===void 0?this._getExecEvenlyMinDelayMsDefault():this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs=e}_getExecEvenlyMinDelayMsDefault(){return this.points>0?Math.ceil(this.msDuration/this.points):0}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if(typeof e>"u"&&(e="rlflx"),typeof e!="string")throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(e={}){return e&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?`${this.keyPrefix}:${e}`:e}parseKey(e){return this.keyPrefix.length>0?e.substring(this.keyPrefix.length+1):e}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}});var bt=J((as,wt)=>{"use strict";wt.exports=class{constructor(e,r,n=null){this.value=e,this.expiresAt=r,this.timeoutId=n}get value(){return this._value}set value(e){this._value=parseInt(e,10)}get expiresAt(){return this._expiresAt}set expiresAt(e){e instanceof Date?this._expiresAt=e.getTime():this._expiresAt=e}get timeoutId(){return this._timeoutId}set timeoutId(e){this._timeoutId=e}}});var Se=J((ls,xt)=>{"use strict";xt.exports=class{constructor(e,r,n,o){this.remainingPoints=typeof e>"u"?0:e,this.msBeforeNext=typeof r>"u"?0:r,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof o>"u"?!1:o}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(e){return this._msBeforeNext=e,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(e){return this._remainingPoints=e,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(e){return this._consumedPoints=e,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(e){this._isFirstInDuration=!!e}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}});var Et=J((ds,Rt)=>{"use strict";var vt=bt(),Ae=Se();Rt.exports=class{constructor(){this._storage=new Map}incrby(e,r,n){let o=this._storage.get(e);if(o){let s=o.expiresAt?o.expiresAt-Date.now():-1;return!o.expiresAt||s>0?(o.value=o.value+r,new Ae(0,s,o.value,!1)):this.set(e,r,n)}return this.set(e,r,n)}set(e,r,n){let o=n*1e3,s=this._storage.get(e);s&&s.timeoutId&&clearTimeout(s.timeoutId);let a=new vt(r,o>0?Date.now()+o:null);return this._storage.set(e,a),o>0&&(a.timeoutId=setTimeout(()=>{this._storage.delete(e)},o),a.timeoutId.unref&&a.timeoutId.unref()),new Ae(0,o===0?-1:o,a.value,!0)}get(e){let r=this._storage.get(e);if(r){let n=r.expiresAt?r.expiresAt-Date.now():-1;return new Ae(0,n,r.value,!1)}return null}delete(e){let r=this._storage.get(e);return r?(r.timeoutId&&clearTimeout(r.timeoutId),this._storage.delete(e),!0):!1}_restoreRecord(e,r,n){let o=Date.now(),s=n!==null;if(s&&!Number.isFinite(n)||s&&n<=o)return;let a=s?n-o:0,i=this._storage.get(e);i&&i.timeoutId&&clearTimeout(i.timeoutId);let c=new vt(r,n);this._storage.set(e,c),a>0&&(c.timeoutId=setTimeout(()=>{this._storage.delete(e)},a),c.timeoutId.unref&&c.timeoutId.unref())}}});var St=J((ps,_t)=>{"use strict";var Ar=yt(),Cr=Et(),Pt=Se(),Ce=class extends Ar{constructor(e={}){super(e),this._memoryStorage=new Cr}consume(e,r=1,n={}){return new Promise((o,s)=>{let a=this.getKey(e),i=this._getKeySecDuration(n),c=this._memoryStorage.incrby(a,r,i);if(c.remainingPoints=Math.max(this.points-c.consumedPoints,0),c.consumedPoints>this.points)this.blockDuration>0&&c.consumedPoints<=this.points+r&&(c=this._memoryStorage.set(a,c.consumedPoints,this.blockDuration)),s(c);else if(this.execEvenly&&this.points>0&&c.msBeforeNext>0&&!c.isFirstInDuration){let l=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));l<this.execEvenlyMinDelayMs&&(l=c.consumedPoints*this.execEvenlyMinDelayMs),c.msBeforeNext=Math.max(c.msBeforeNext-l,0),setTimeout(o,l,c)}else o(c)})}penalty(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let a=this._getKeySecDuration(n),i=this._memoryStorage.incrby(o,r,a);i.remainingPoints=Math.max(this.points-i.consumedPoints,0),s(i)})}reward(e,r=1,n={}){let o=this.getKey(e);return new Promise(s=>{let a=this._getKeySecDuration(n),i=this._memoryStorage.incrby(o,-r,a);i.remainingPoints=Math.max(this.points-i.consumedPoints,0),s(i)})}block(e,r){let n=r*1e3,o=this.points+1;return this._memoryStorage.set(this.getKey(e),o,r),Promise.resolve(new Pt(0,n===0?-1:n,o))}set(e,r,n){let o=(n>=0?n:this.duration)*1e3;return this._memoryStorage.set(this.getKey(e),r,n),Promise.resolve(new Pt(0,o===0?-1:o,r))}get(e){let r=this._memoryStorage.get(this.getKey(e));return r!==null&&(r.remainingPoints=Math.max(this.points-r.consumedPoints,0)),Promise.resolve(r)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}dump(){let e=[];for(let[r,n]of this._memoryStorage._storage)e.push({key:this.parseKey(r),value:n.value,expiresAt:n.expiresAt});return{version:1,dumpedAt:Date.now(),storage:e}}restore(e,r=!1){if(!e||typeof e!="object"||e.version!==1)return;let n=r?{invalid:{count:0,keys:[]},expired:{count:0,keys:[]},restored:{count:0,keys:[]}}:{invalid:0,expired:0,restored:0},o=(s,a)=>{r?(n[s].count+=1,n[s].keys.push(a)):n[s]+=1};if(!Array.isArray(e.storage))return n;for(let s of e.storage){if(!s||typeof s!="object"){o("invalid","N/A");continue}let a=typeof s.key=="string"||typeof s.key=="number",i=Number.isFinite(s.value),c=s.expiresAt===null||Number.isFinite(s.expiresAt);if(!a||!i||!c){o("invalid",s.key);continue}if(s.expiresAt!==null&&s.expiresAt<=Date.now()){o("expired",s.key);continue}this._memoryStorage._restoreRecord(this.getKey(s.key),s.value,s.expiresAt),o("restored",s.key)}return n}};_t.exports=Ce});var pe=(t,e,r)=>(n,o)=>{let s=-1;return a(0);async function a(i){if(i<=s)throw new Error("next() called multiple times");s=i;let c,l=!1,u;if(t[i]?(u=t[i][0][0],n.req.routeIndex=i):u=i===t.length&&o||void 0,u)try{c=await u(n,()=>a(i+1))}catch(d){if(d instanceof Error&&e)n.error=d,c=await e(d,n),l=!0;else throw d}else n.finalized===!1&&r&&(c=await r(n));return c&&(n.finalized===!1||l)&&(n.res=c),n}};var qe=Symbol();var ze=(t,e)=>new Response(t,{headers:{"Content-Type":e.replace(/^[^;]+/,n=>n.toLowerCase())}}).formData();var Fe=32,fr=1e4,Q=t=>"headers"in t,Ke=async(t,e=Object.create(null))=>{let{all:r=!1,dot:n=!1}=e,a=(Q(t)?t.headers:t.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return a==="multipart/form-data"||a==="application/x-www-form-urlencoded"?mr(t,{all:r,dot:n}):{}};async function mr(t,e){if(!Q(t)&&t.bodyCache.formData)return We(await t.bodyCache.formData,e);let r=Q(t)?t.headers:t.raw.headers,n=await t.arrayBuffer(),o=ze(n,r.get("Content-Type")||"");Q(t)||(t.bodyCache.formData=o);let s=await o;return s?We(s,e):{}}function We(t,e){let r=Object.create(null),n={count:0};return t.forEach((o,s)=>{e.all||s.endsWith("[]")?gr(r,s,o):r[s]=o}),e.dot&&Object.entries(r).forEach(([o,s])=>{o.includes(".")&&(yr(r,o,s,n),delete r[o])}),r}var gr=(t,e,r)=>{t[e]!==void 0?Array.isArray(t[e])?t[e].push(r):t[e]=[t[e],r]:e.endsWith("[]")?t[e]=[r]:t[e]=r},yr=(t,e,r,n)=>{if(/(?:^|\.)__proto__\./.test(e))return;let o=t,s=e.split(".",Fe+2);s.length>Fe+1&&Ve(),s.forEach((a,i)=>{i===s.length-1?o[a]=r:((!o[a]||typeof o[a]!="object"||Array.isArray(o[a])||o[a]instanceof File)&&(n.count++>=fr&&Ve(),o[a]=Object.create(null)),o=o[a])})},Ve=()=>{throw new Error("Nesting limit exceeded")};var fe=t=>{let e=t.split("/");return e[0]===""&&e.shift(),e},Ge=t=>{let{groups:e,path:r}=wr(t),n=fe(r);return br(n,e)},wr=t=>{let e=[];return t=t.replace(/\{[^}]+\}/g,(r,n)=>{let o=`@${n}`;return e.push([o,r]),o}),{groups:e,path:t}},br=(t,e)=>{for(let r=e.length-1;r>=0;r--){let[n]=e[r];for(let o=t.length-1;o>=0;o--)if(t[o].includes(n)){t[o]=t[o].replace(n,e[r][1]);break}}return t},Z={},Je=(t,e)=>{if(t==="*")return"*";let r=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${t}#${e}`;return Z[n]||(r[2]?Z[n]=e&&e[0]!==":"&&e[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${e})`)]:[t,r[1],new RegExp(`^${r[2]}$`)]:Z[n]=[t,r[1],!0]),Z[n]}return null},Xe=(t,e)=>{try{return e(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return e(r)}catch{return r}})}},xr=t=>Xe(t,decodeURI),me=t=>{let e=t.url,r=e.indexOf("/",e.indexOf(":")+4),n=r;for(;n<e.length;n++){let o=e.charCodeAt(n);if(o===37){let s=e.indexOf("?",n),a=e.indexOf("#",n),i=s===-1?a===-1?void 0:a:a===-1?s:Math.min(s,a),c=e.slice(r,i);return xr(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(o===63||o===35)break}return e.slice(r,n)};var Ye=t=>{let e=me(t);return e.length>1&&e.at(-1)==="/"?e.slice(0,-1):e},N=(t,e,...r)=>(r.length&&(e=N(e,...r)),`${t?.[0]==="/"?"":"/"}${t}${e==="/"?"":`${t?.at(-1)==="/"?"":"/"}${e?.[0]==="/"?e.slice(1):e}`}`),ee=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let e=t.split("/"),r=[],n="";return e.forEach(o=>{if(o!==""&&!/\:/.test(o))n+="/"+o;else if(/\:/.test(o))if(o.charCodeAt(o.length-1)===63){r.length===0&&n===""?r.push("/"):r.push(n);let s=o.slice(0,-1);n+="/"+s,r.push(n)}else n+="/"+o}),r.filter((o,s,a)=>a.indexOf(o)===s)},te=t=>t.indexOf("%")!==-1?Xe(t,vr):t,he=t=>(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),te(t)),Qe=(t,e,r)=>{let n=t.indexOf("#",8);n!==-1&&(t=t.slice(0,n));let o;if(!r&&e&&e.indexOf("%")===-1&&e.indexOf("+")===-1){let i=t.indexOf("?",8);if(i===-1)return;for(t.startsWith(e,i+1)||(i=t.indexOf(`&${e}`,i+1));i!==-1;){let c=t.charCodeAt(i+e.length+1);if(c===61){let l=i+e.length+2,u=t.indexOf("&",l);return he(t.slice(l,u===-1?void 0:u))}else if(c==38||isNaN(c))return"";i=t.indexOf(`&${e}`,i+1)}if(o=/[%+]/.test(t),!o)return}let s=Object.create(null);o??=/[%+]/.test(t);let a=t.indexOf("?",8);for(;a!==-1;){let i=t.indexOf("&",a+1),c=t.indexOf("=",a);c>i&&i!==-1&&(c=-1);let l=t.slice(a+1,c===-1?i===-1?void 0:i:c);if(o&&(l=he(l)),a=i,l==="")continue;let u;c===-1?u="":(u=t.slice(c+1,i===-1?void 0:i),o&&(u=he(u))),r?(s[l]&&Array.isArray(s[l])||(s[l]=[]),s[l].push(u)):s[l]??=u}return e?s[e]:s},Ze=Qe,et=(t,e)=>Qe(t,e,!0),vr=decodeURIComponent;var tt=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,e="/",r=[[]]){this.raw=t,this.path=e,this.#e=r}param(t){return t?this.#r(t):this.#s()}#r(t){let e=this.#e[0][this.routeIndex]?.[1][t],r=this.#n(e);return r&&te(r)}#s(){let t={},e=Object.keys(this.#e[0][this.routeIndex]?.[1]??{});for(let r of e){let n=this.#n(this.#e[0][this.routeIndex][1][r]);n!==void 0&&(t[r]=te(n))}return t}#n(t){return this.#e[1]?this.#e[1][t]:t}query(t){return Ze(this.url,t)}queries(t){return et(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let e=Object.create(null);return this.raw.headers.forEach((r,n)=>{e[n]=r}),e}async parseBody(t){return Ke(this,t)}#o=t=>{let{bodyCache:e,raw:r}=this,n=e[t];if(n)return n;for(let o in e)return e[o].then(s=>(o==="json"&&(s=JSON.stringify(s)),new Response(s)[t]()));return e[t]=r[t]()};json(){return this.#o("text").then(t=>JSON.parse(t))}text(){return this.#o("text")}arrayBuffer(){return this.#o("arrayBuffer")}bytes(){return this.#o("arrayBuffer").then(t=>new Uint8Array(t))}blob(){return this.#o("blob")}formData(){return this.#o("formData")}addValidatedData(t,e){(this.#t??={})[t]=e}valid(t){return this.#t?.[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[qe](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}};var rt={Stringify:1,BeforeStream:2,Stream:3},Rr=(t,e)=>{let r=new String(t);return r.isEscaped=!0,r.callbacks=e,r};var ge=async(t,e,r,n,o)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let s=t.callbacks;if(!s?.length)return Promise.resolve(t);o?o[0]+=t:o=[t];let a=Promise.all(s.map(i=>i({phase:e,buffer:o,context:n}))).then(i=>Promise.all(i.filter(Boolean).map(c=>ge(c,e,!1,n,o))).then(()=>o[0]));return r?Rr(await a,s):a};var Er="text/plain; charset=UTF-8",ye=(t,e)=>({"Content-Type":t,...e}),X=(t,e)=>new Response(t,e),we=class{#t;#e;env={};#r;finalized=!1;error;#s;#n;#o;#u;#c;#l;#a;#d;#p;constructor(t,e){this.#t=t,e&&(this.#n=e.executionCtx,this.env=e.env,this.#l=e.notFoundHandler,this.#p=e.path,this.#d=e.matchResult)}get req(){return this.#e??=new tt(this.#t,this.#p,this.#d),this.#e}get event(){if(this.#n&&"respondWith"in this.#n)return this.#n;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#n)return this.#n;throw Error("This context has no ExecutionContext")}get res(){return this.#o||=X(null,{headers:this.#a??=new Headers})}set res(t){if(this.#o&&t){t=X(t.body,t);for(let[e,r]of this.#o.headers.entries())if(e!=="content-type")if(e==="set-cookie"){let n=this.#o.headers.getSetCookie();t.headers.delete("set-cookie");for(let o of n)t.headers.append("set-cookie",o)}else t.headers.set(e,r)}this.#o=t,this.finalized=!0}render=(...t)=>(this.#c??=e=>this.html(e),this.#c(...t));setLayout=t=>this.#u=t;getLayout=()=>this.#u;setRenderer=t=>{this.#c=t};header=(t,e,r)=>{this.finalized&&(this.#o=X(this.#o.body,this.#o));let n=this.#o?this.#o.headers:this.#a??=new Headers;e===void 0?n.delete(t):r?.append?n.append(t,e):n.set(t,e)};status=t=>{this.#s=t};set=(t,e)=>{this.#r??=new Map,this.#r.set(t,e)};get=t=>this.#r?this.#r.get(t):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#i(t,e,r){let n=this.#o?new Headers(this.#o.headers):this.#a;if(typeof e=="object"&&e.headers){n??=new Headers;for(let[s,a]of new Headers(e.headers))s==="set-cookie"?n.append(s,a):n.set(s,a)}if(r){if(!n){let s=0;for(let a in r)if(++s>1||typeof r[a]!="string"){n=new Headers;break}}if(n)for(let s in r){let a=r[s];if(typeof a=="string")n.set(s,a);else{n.delete(s);for(let i of a)n.append(s,i)}}}let o=typeof e=="number"?e:e?.status??this.#s;return X(t,{status:o,headers:n??r})}newResponse=(...t)=>this.#i(...t);body=(t,e,r)=>this.#i(t,e,r);text=(t,e,r)=>!this.#a&&!this.#s&&!e&&!r&&!this.finalized?new Response(t):this.#i(t,e,ye(Er,r));json=(t,e,r)=>this.#i(JSON.stringify(t),e,ye("application/json",r));html=(t,e,r)=>{let n=o=>this.#i(o,e,ye("text/html; charset=UTF-8",r));return typeof t=="object"?ge(t,rt.Stringify,!1,{}).then(n):n(t)};redirect=(t,e)=>{let r=String(t);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,e??302)};notFound=()=>(this.#l??=()=>X(),this.#l(this))};var _="ALL",nt="all",ot=["get","post","put","delete","options","patch","query"],re="Can not add a route since the matcher is already built.",ne=class extends Error{};var st="__COMPOSED_HANDLER";var Pr=t=>t.text("404 Not Found",404),it=(t,e)=>{if("getResponse"in t){let r=t.getResponse();return e.newResponse(r.body,r)}return console.error(t),e.text("Internal Server Error",500)},at=class ct{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(e={}){[...ot,nt].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?this.#t=a:this.#s(s,this.#t,a),i.forEach(c=>{this.#s(s,this.#t,c)}),this)}),this.on=(s,a,...i)=>{for(let c of[a].flat()){this.#t=c;for(let l of[s].flat())i.map(u=>{this.#s(l.toUpperCase(),this.#t,u)})}return this},this.use=(s,...a)=>(typeof s=="string"?this.#t=s:(this.#t="*",a.unshift(s)),a.forEach(i=>{this.#s(_,this.#t,i)}),this);let{strict:n,...o}=e;Object.assign(this,o),this.getPath=n??!0?e.getPath??me:Ye}#e(){let e=new ct({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#r=this.#r,e.routes=this.routes,e}#r=Pr;errorHandler=it;route(e,r){let n=this.basePath(e);return r.routes.map(o=>{let s;r.errorHandler===it?s=o.handler:(s=async(a,i)=>(await pe([],r.errorHandler)(a,()=>o.handler(a,i))).res,s[st]=o.handler),n.#s(o.method,o.path,s,o.basePath)}),this}basePath(e){let r=this.#e();return r._basePath=N(this._basePath,e),r}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#r=e,this);mount(e,r,n){let o,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,n.replaceRequest===!1?o=c=>c:o=n.replaceRequest));let a=s?c=>{let l=s(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};o||=(()=>{let c=N(this._basePath,e),l=c==="/"?0:c.length;return u=>{let d=new URL(u.url);return d.pathname=this.getPath(u).slice(l)||"/",new Request(d,u)}})();let i=async(c,l)=>{let u=await r(o(c.req.raw),...a(c));if(u)return u;await l()};return this.#s(_,N(e,"*"),i),this}#s(e,r,n,o){e=e.toUpperCase(),r=N(this._basePath,r);let s={basePath:o!==void 0?N(this._basePath,o):this._basePath,path:r,method:e,handler:n};this.router.add(e,r,[n,s]),this.routes.push(s)}#n(e,r){if(e instanceof Error)return this.errorHandler(e,r);throw e}#o(e,r,n,o){if(o==="HEAD")return(async()=>new Response(null,await this.#o(e,r,n,"GET")))();let s=this.getPath(e,{env:n}),a=this.router.match(o,s),i=new we(e,{path:s,matchResult:a,env:n,executionCtx:r,notFoundHandler:this.#r});if(a[0].length===1){let l;try{l=a[0][0][0][0](i,async()=>{i.res=await this.#r(i)})}catch(u){return this.#n(u,i)}return l instanceof Promise?l.then(u=>u||(i.finalized?i.res:this.#r(i))).catch(u=>this.#n(u,i)):l??this.#r(i)}let c=pe(a[0],this.errorHandler,this.#r);return(async()=>{try{let l=await c(i);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#n(l,i)}})()}fetch=(e,...r)=>this.#o(e,r[1],r[0],e.method);request=(e,r,n,o)=>e instanceof Request?this.fetch(r?new Request(e,r):e,n,o):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${N("/",e)}`,r),n,o));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#o(e.request,e,void 0,e.request.method))})}};var R=()=>Object.create(null);var oe=[];function be(t,e){let r=this.buildAllMatchers(),n=((o,s)=>{let a=r[o]||r[_],i=a[2][s];if(i)return i;let c=s.match(a[0]);if(!c)return[[],oe];let l=c.indexOf("",1);return[a[1][l],c]});return this.match=n,n(t,e)}var K="[^/]+",j=".*",M="(?:|/.*)",U=Symbol(),lt=new Set(".\\+*[^]$()");function _r(t,e){return t.length===1?e.length===1?t<e?-1:1:-1:e.length===1?1:t===j||t===M?e===M?-1:1:e===j||e===M?-1:t===K?1:e===K?-1:t.length===e.length?t<e?-1:1:e.length-t.length}var ut=class xe{#t;#e;#r=R();insert(e,r,n,o,s){let a=this;for(let i=0,c=e.length;i<c;i++){let l=e[i],u=l.length===1?l==="*"?i===c-1?["","",j]:["","",K]:null:l==="/*"?["","",M]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),d;if(u){let h=u[1],f=u[2]||K;if(h&&u[2]&&(f===".*"||(f=f.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(f))||f.length===1&<.has(f)))throw U;if(d=a.#r[f],!d){if(f!==j&&f!==M){for(let x in a.#r)if((f.length>1||x.length>1)&&x!==j&&x!==M)throw U}d=a.#r[f]=new xe}h!==""&&(d.#e??=o.varIndex++,n.push([h,d.#e]))}else if(d=a.#r[l],!d){for(let h in a.#r)if(h.length>1&&h!==j&&h!==M)throw U;d=a.#r[l]=new xe}a=d}if(a.#t!==void 0)throw U;a.#t=s?-1:r}buildRegExpStr(){let r=Object.keys(this.#r).sort(_r).map(n=>{let o=this.#r[n],s=o.buildRegExpStr();return s===""?"":(typeof o.#e=="number"?`(${n})@${o.#e}`:lt.has(n)?`\\${n}`:n)+s}).filter(Boolean);return typeof this.#t=="number"&&this.#t!==-1&&r.unshift(`#${this.#t}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}};var ve=class{#t={varIndex:0};#e=new ut;#r=0;paths=R();insert(t,e){if(e){this.#e.insert(t.split(""),0,[],this.#t,!0);return}let r=[],n=[],o=t;for(let a=0;;){let i=!1;if(o=o.replace(/\{[^}]+\}/g,c=>{let l=`@\\${a}`;return n[a]=[l,c],a++,i=!0,l}),!i)break}let s=o.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=n.length-1;a>=0;a--){let[i]=n[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(i)!==-1){s[c]=s[c].replace(i,n[a][1]);break}}this.#e.insert(s,this.#r,r,this.#t,!1),this.paths[t]=[this.#r++,r]}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let e=0,r=[],n=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(o,s,a)=>s!==void 0?(r[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${t}`),r,n]}};var dt=R();function pt(t){return dt[t]??=new RegExp(`^${t.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(e,r)=>r?`\\${r}`:e==="/*"?M:e==="*"?j:`/:${K}`)}$`)}function se(t,e){for(let r of Object.keys(t).sort((n,o)=>o.length-n.length))if(pt(r).test(e))return[...t[r]]}var ie=class{name="RegExpRouter";#t;#e;#r;constructor(){this.#t={[_]:R()},this.#e={[_]:R()},this.#r={[_]:new ve}}#s(t,e){try{this.#r[t].insert(e,!/\*|\/:/.test(e))}catch(r){throw r===U?new ne(e):r}}add(t,e,r){let n=this.#t,o=this.#e;if(!n)throw new Error(re);if(!n[t]){this.#r[t]=new ve;for(let i of[n,o]){i[t]=R();for(let c in i[_])i[t][c]=[...i[_][c]],this.#s(t,c)}}e==="/*"&&(e="*");let s=t===_?Object.keys(n):[t];if(/\*$/.test(e)){let i=pt(e);for(let c of s)n[c][e]||(this.#s(c,e),n[c][e]=se(n[c],e)||se(n[_],e)||[]);for(let c of[n,o])for(let l of s)for(let u in c[l])i.test(u)&&c[l][u].push([r,e]);return}let a=ee(e)||[e];for(let i of a)for(let c of s)o[c][i]||(this.#s(c,i),o[c][i]=se(n[c],i)||se(n[_],i)||[]),o[c][i].push([r,i])}match=be;buildAllMatchers(){let t=R();for(let e of Object.keys(this.#e))t[e]=this.#n(e);return this.#t=this.#e=this.#r=void 0,dt=R(),t}#n(t){let e=this.#t[t],r=this.#e[t],n=this.#r[t],o=R(),s=[],[a,i,c]=n.buildRegExp();for(let l of[e,r])for(let u in l){let d=l[u],h=n.paths[u];if(!h){o[u]=[d.map(([f])=>[f,R()]),oe];continue}s[h[0]]=d.map(([f,x])=>[f,n.paths[x][1].reduceRight((w,[v],g)=>(w[v]=c[h[1][g][1]],w),R())])}return[a,i.map(l=>s[l]),o]}};var Re=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,e,r){if(!this.#e)throw new Error(re);this.#e.push([t,e,r])}match(t,e){if(!this.#e)throw new Error("Fatal error");let r=this.#t,n=this.#e,o=r.length,s=0,a;for(;s<o;s++){let i=r[s];try{for(let c=0,l=n.length;c<l;c++)i.add(...n[c]);a=i.match(t,e)}catch(c){if(c instanceof ne)continue;throw c}this.match=i.match.bind(i),this.#t=[i],this.#e=void 0;break}if(s===o)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var Ee=R(),Sr=0,ht=class ft{#t=[];#e=R();#r=[];#s;#n=Ee;insert(e,r,n){let o=this,s=Ge(r),a=new Set,i=0;for(let c of s){let l=s[++i],u=Je(c,l)||(l===void 0&&c&&c.indexOf("*")===c.length-1?c:null),d=Array.isArray(u),h=d?u[0]:u||c,f=o.#e[h]||=new ft;u&&!f.#s&&(f.#s=u,o.#r.push(f)),o=f,d&&a.add(u[1])}o.#t.push({[e]:{handler:n,possibleKeys:[...a],score:++Sr}})}#o(e,r,n,o,s){for(let a=0,i=r.#t.length;a<i;a++){let c=r.#t[a],l=c[n]||c[_];if(l){l.params=R(),e.push(l);for(let u=0,d=l.possibleKeys.length;u<d;u++){let h=l.possibleKeys[u];l.params[h]=s?.[h]&&!u?s[h]:o[h]??s?.[h]}}}}search(e,r){let n=[];this.#n=Ee;let s=[this],a=fe(r),i=[],c=a.length,l=null;for(let u=0;u<c;u++){let d=a[u],h=u===c-1,f=[];for(let w=0,v=s.length;w<v;w++){let g=s[w],p=g.#e[d];p&&(p.#n=g.#n,h?(p.#e["*"]&&this.#o(n,p.#e["*"],e,g.#n),this.#o(n,p,e,g.#n)):f.push(p));for(let m of g.#r){let y=m.#s,E=g.#n===Ee?{}:{...g.#n};if(typeof y=="string"){(y==="*"||d.startsWith(y.slice(0,-1)))&&(this.#o(n,m,e,g.#n),y==="*"&&(m.#n=E,f.push(m)));continue}let[,T,C]=y;if(!(!d&&C===!0)){if(C!==!0){if(!l){l=[];let b=r[0]==="/"?1:0;for(let O=0;O<c;O++)l[O]=b,b+=a[O].length+1}let P=r.slice(l[u]),S=C.exec(P);if(S){E[T]=S[0],this.#o(n,m,e,g.#n,E),S[0].length===P.length&&m.#e["*"]&&this.#o(n,m.#e["*"],e,g.#n,E);for(let b in m.#e){m.#n=E;let O=S[0].match(/\//g)?.length??0;(i[O]||=[]).push(m);break}continue}}(C===!0||C.test(d))&&(E[T]=d,h?(this.#o(n,m,e,E,g.#n),m.#e["*"]&&this.#o(n,m.#e["*"],e,E,g.#n)):(m.#n=E,f.push(m)))}}}let x=i.shift();s=x?f.concat(x):f}return n[1]&&n.sort((u,d)=>u.score-d.score),[n.map(({handler:u,params:d})=>[u,d])]}};var Pe=class{name="TrieRouter";#t=new ht;add(t,e,r){for(let n of ee(e)||[e])this.#t.insert(t,n,r)}match(t,e){return this.#t.search(t,e)}};var _e=class extends at{constructor(t={}){super(t),this.router=t.router??new Re({routers:[new ie,new Pe]})}};import{Readable as bn}from"stream";function mt(t=""){return`<link rel="icon" type="image/svg+xml" href="${`${t.replace(/\/$/,"")}/favicon-black.svg?v=4`}" />`}import{existsSync as At,readFileSync as Tr}from"fs";import k from"path";import{fileURLToPath as Ir}from"url";import{gunzipSync as Mr}from"zlib";var D=hr(St(),1);function G(t,e){return t.header("Retry-After",String(Or(e))),t.json({error:"Too Many Requests"},429)}function Or(t){return t&&typeof t=="object"&&"msBeforeNext"in t&&typeof t.msBeforeNext=="number"&&Number.isFinite(t.msBeforeNext)?Math.max(1,Math.ceil(t.msBeforeNext/1e3)):60}var Dr={".js":"application/javascript",".css":"text/css",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".webmanifest":"application/manifest+json"};function kr(){let t=k.dirname(Ir(import.meta.url));for(let e of[k.resolve(t,"app"),k.resolve(t,"../app"),k.resolve(t,"../../dist/app")])if(At(k.join(e,"inspector.js.gz")))return e;throw new Error("Inspector bundle not found (expected dist/app/inspector.js.gz)")}function Ct(t,e="/inspector/assets"){let r=kr(),n=new Map,o=new D.default({points:600,duration:60}),s=async(a,i)=>{try{await o.consume(a.req)}catch(c){return G(a,c)}return i()};t.use(`${e}/*`,s),t.get(`${e}/*`,async a=>{let i=a.req.path.slice(e.length),c=i.startsWith("/")?i.slice(1):i;if(!c||c.includes(".."))return a.notFound();let l=c==="inspector.js"||c==="inspector.css"?`${c}.gz`:c,u=k.resolve(r,l),d=r.endsWith(k.sep)?r:`${r}${k.sep}`;if(!u.startsWith(d)||!At(u))return a.notFound();let h=k.extname(c),f=l.endsWith(".gz"),x=/(?:^|,)\s*gzip\s*(?:,|$)/i.test(a.req.header("accept-encoding")??""),w=Tr(u),v=f&&!x?n.get(u)??Nr(n,u,w):w,g=v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength);return a.body(g,200,{"Content-Type":Dr[h]??"application/octet-stream",...f&&x?{"Content-Encoding":"gzip"}:{},...f?{Vary:"Accept-Encoding"}:{},"Cache-Control":"no-cache"})})}function Nr(t,e,r){let n=Mr(r);return t.set(e,n),n}var Ot={name:"@mcp-use/inspector",type:"module",version:"20.3.15-canary.1",description:"MCP Inspector - A tool for inspecting and debugging MCP servers",author:"",license:"MIT",homepage:"https://github.com/mcp-use/mcp-use#readme",repository:{type:"git",url:"git+https://github.com/mcp-use/mcp-use.git",directory:"libraries/typescript/packages/inspector"},bugs:{url:"https://github.com/mcp-use/mcp-use/issues"},keywords:["mcp","inspector","debug","tools"],exports:{".":{types:"./dist/server/index.d.ts",import:"./dist/server/index.js"},"./client":{types:"./dist/client/index.d.ts",import:"./dist/client/index.js"},"./client/styles.css":{default:"./dist/client/styles.css"}},main:"./dist/server/index.js",types:"./dist/server/index.d.ts",bin:{"mcp-inspect":"./dist/cli.js"},files:["dist"],scripts:{dev:"rimraf node_modules/.vite && vite --strictPort","dev:client":"pnpm run dev","dev:server":"VITE_DEV=true tsx watch src/server/server.ts","dev:standalone":"tsx watch src/server/server.ts",clean:"rimraf dist",build:"pnpm run clean && pnpm run build:client-exports && pnpm run build:server && pnpm run build:app && pnpm run verify:package","build:app":"vite build --config vite.app.config.ts && node scripts/compress-app.mjs","watch:app":"vite build --watch --config vite.app.config.ts","preview:app":"vite preview --config vite.app.config.ts --host 127.0.0.1","serve:app":"pnpm build:app && pnpm preview:app","analyze:app":"ANALYZE=true vite build --config vite.app.config.ts","build:client-exports":"tsup --config tsup.client.ts && node scripts/copy-client-styles.mjs","build:server":"tsup --config tsup.server.ts","verify:package":"node scripts/verify-package.mjs",start:"node dist/cli.js --port 3000",preview:"vite preview","type-check":"tsc --noEmit",lint:"eslint .","lint:fix":"eslint . --fix","test:e2e":"playwright test","test:e2e:ui":"playwright test --ui","test:e2e:debug":"playwright test --debug","test:e2e:builtin":"node tests/e2e/scripts/run-test-matrix.mjs builtin","test:e2e:prod":"node tests/e2e/scripts/run-test-matrix.mjs prod","test:e2e:mix":"node tests/e2e/scripts/run-test-matrix.mjs mix","test:e2e:prod:ui":"TEST_MODE=production playwright test --ui","test:e2e:codegen":"playwright codegen http://localhost:3000/inspector","test:e2e:report":"playwright show-report","test:e2e:python":"node tests/e2e/scripts/run-python-e2e.mjs",test:"vitest run","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e:tunnel":"node tests/e2e/scripts/run-tunnel-test.mjs","install:pnpm":"pnpm install","install:npm":"npm install","lint:npm":"npm run lint:fix","lint:pnpm":"pnpm lint:fix"},engines:{node:">=22.22.2"},peerDependencies:{"@base-ui/react":"^1.6.0","@mcp-use/agent":"^2.0.16 || ^2.0.17 || ^2.0.18 || ^2.0.19 || ^2.0.20","@mcp-use/client":"^2.0.1 || ^2.1.0 || ^2.1.1 || ^2.1.2 || ^2.1.3 || ^2.1.4 || ^2.1.5 || ^2.2.0 || ^2.2.1 || ^2.2.2 || ^2.2.3 || ^2.2.4 || ^2.2.5 || ^2.3.0 || ^2.3.1 || ^2.3.2 || ^2.3.3 || ^2.3.4 || ^2.3.5 || ^2.4.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",express:"^4.21.2 || ^5.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4","mcp-use":"^2.4.3 || ^2.4.4 || ^2.5.0 || ^2.5.1 || ^2.5.2 || ^2.6.0 || ^2.6.1 || ^2.7.0 || ^2.7.1 || ^2.7.2 || ^2.7.3-canary.0",motion:"^12.34.2",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-resizable-panels":"^4.6.4",sonner:"^2.0.7","tailwind-merge":"^3.5.0"},peerDependenciesMeta:{"@base-ui/react":{optional:!0},"@mcp-use/agent":{optional:!0},"@mcp-use/client":{optional:!0},"class-variance-authority":{optional:!0},clsx:{optional:!0},express:{optional:!0},"lucide-react":{optional:!0},"markdown-to-jsx":{optional:!0},"mcp-use":{optional:!0},motion:{optional:!0},react:{optional:!0},"react-dom":{optional:!0},"react-resizable-panels":{optional:!0},sonner:{optional:!0},"tailwind-merge":{optional:!0}},dependencies:{},publishConfig:{access:"public"},devDependencies:{"@base-ui/react":"^1.6.0","@hono/node-server":"^2.0.5","@mcp-use/agent":"workspace:*","@mcp-use/client":"workspace:*","@playwright/test":"^1.58.2","@tailwindcss/vite":"^4.2.0","@types/express":"^5.0.6","@vitejs/plugin-react":"^6.0.0","class-variance-authority":"^0.7.1",clsx:"^2.1.1",emulate:"0.5.0",eslint:"^9.39.2",express:"^5.2.1",hono:"^4.13.5",jsdom:"^27.0.0","lucide-react":"^0.562.0","markdown-to-jsx":"^9.7.4",motion:"^12.34.2","oauth2-mock-server":"^8.2.2",open:"^11.0.0",react:"^19.2.3","react-dom":"^19.2.3","react-router":"^8.3.0","react-resizable-panels":"^4.6.4","rate-limiter-flexible":"^11.2.0","rollup-plugin-visualizer":"^6.0.3",sonner:"^2.0.7","tailwind-merge":"^3.5.0",tailwindcss:"^4.2.0",tsup:"^8.5.1",tsx:"^4.21.0","tw-animate-css":"^1.4.0",typescript:"^5.9.3",vite:"^8.0.16",vitest:"^4.1.0","wait-on":"^9.0.4",yaml:"^2.8.3",zod:"^4.2.0"}};var jr=Ot.version;function Lt(){return jr}var Hr=`<!doctype html>
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/inspector",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "20.3.
|
|
4
|
+
"version": "20.3.15-canary.1",
|
|
5
5
|
"description": "MCP Inspector - A tool for inspecting and debugging MCP servers",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"express": "^4.21.2 || ^5.0.0",
|
|
54
54
|
"lucide-react": "^0.562.0",
|
|
55
55
|
"markdown-to-jsx": "^9.7.4",
|
|
56
|
-
"mcp-use": "^2.4.3 || ^2.4.4 || ^2.5.0 || ^2.5.1 || ^2.5.2 || ^2.6.0 || ^2.6.1 || ^2.7.0 || ^2.7.1 || ^2.7.2",
|
|
56
|
+
"mcp-use": "^2.4.3 || ^2.4.4 || ^2.5.0 || ^2.5.1 || ^2.5.2 || ^2.6.0 || ^2.6.1 || ^2.7.0 || ^2.7.1 || ^2.7.2 || ^2.7.3-canary.0",
|
|
57
57
|
"motion": "^12.34.2",
|
|
58
58
|
"react": "^18.0.0 || ^19.0.0",
|
|
59
59
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
@@ -149,8 +149,8 @@
|
|
|
149
149
|
"wait-on": "^9.0.4",
|
|
150
150
|
"yaml": "^2.8.3",
|
|
151
151
|
"zod": "^4.2.0",
|
|
152
|
-
"@mcp-use/
|
|
153
|
-
"@mcp-use/
|
|
152
|
+
"@mcp-use/client": "2.4.0",
|
|
153
|
+
"@mcp-use/agent": "2.0.20"
|
|
154
154
|
},
|
|
155
155
|
"scripts": {
|
|
156
156
|
"dev": "rimraf node_modules/.vite && vite --strictPort",
|