@mcp-use/inspector 8.0.0 → 8.0.1-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -337,7 +337,7 @@ void main() {
|
|
|
337
337
|
|
|
338
338
|
fragColor = vec4(color, opacity);
|
|
339
339
|
}
|
|
340
|
-
`;function Eu(e){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:Mu;if(typeof e!=`string`)return Mu;let t,n,r,i=1;if(e.startsWith(`#`))[t,n,r,i]=Du(e);else if(e.startsWith(`rgb`))[t,n,r,i]=Ou(e);else if(e.startsWith(`hsl`))[t,n,r,i]=Au(ku(e));else return console.error(`Unsupported color format`,e),Mu;return[ju(t,0,1),ju(n,0,1),ju(r,0,1),ju(i,0,1)]}function Du(e){return e=e.replace(/^#/,``),e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),e.length===6&&(e+=`ff`),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255,parseInt(e.slice(6,8),16)/255]}function Ou(e){let t=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`)/255,parseInt(t[2]??`0`)/255,parseInt(t[3]??`0`)/255,t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function ku(e){let t=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`),parseInt(t[2]??`0`),parseInt(t[3]??`0`),t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function Au(e){let[t,n,r,i]=e,a=t/360,o=n/100,s=r/100,c,l,u;if(n===0)c=l=u=s;else{let e=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),t=s<.5?s*(1+o):s+o-s*o,n=2*s-t;c=e(n,t,a+1/3),l=e(n,t,a),u=e(n,t,a-1/3)}return[c,l,u,i]}var ju=(e,t,n)=>Math.min(Math.max(e,t),n),Mu=[0,0,0,1];function Nu(e){let t=w.useRef(void 0),n=w.useCallback(t=>{let n=e.map(e=>{if(e!=null){if(typeof e==`function`){let n=e,r=n(t);return typeof r==`function`?r:()=>{n(null)}}return e.current=t,()=>{e.current=null}}});return()=>{n.forEach(e=>e?.())}},e);return w.useMemo(()=>e.every(e=>e==null)?null:e=>{t.current&&=(t.current(),void 0),e!=null&&(t.current=n(e))},e)}function Pu(e){if(e.naturalWidth<1024&&e.naturalHeight<1024){if(e.naturalWidth<1||e.naturalHeight<1)return;let t=e.naturalWidth/e.naturalHeight;e.width=Math.round(t>1?1024*t:1024),e.height=Math.round(t>1?1024:1024/t)}}async function Fu(e){let t={},n=[],r=e=>{try{return e.startsWith(`/`)||new URL(e),!0}catch{return!1}},i=e=>{try{return e.startsWith(`/`)?!1:new URL(e,window.location.origin).origin!==window.location.origin}catch{return!1}};return Object.entries(e).forEach(([e,a])=>{if(typeof a==`string`){let o=a||`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==`;if(!r(o)){console.warn(`Uniform "${e}" has invalid URL "${o}". Skipping image loading.`);return}let s=new Promise((n,r)=>{let a=new Image;i(o)&&(a.crossOrigin=`anonymous`),a.onload=()=>{Pu(a),t[e]=a,n()},a.onerror=()=>{console.error(`Could not set uniforms. Failed to load image at ${o}`),r()},a.src=o});n.push(s)}else a instanceof HTMLImageElement&&Pu(a),t[e]=a}),await Promise.all(n),t}var Iu=(0,w.forwardRef)(function({fragmentShader:e,uniforms:t,webGlContextAttributes:n,speed:r=0,frame:i=0,width:a,height:o,minPixelRatio:s,maxPixelCount:c,mipmaps:l,style:u,...d},f){let[p,m]=(0,w.useState)(!1),h=(0,w.useRef)(null),g=(0,w.useRef)(null),_=(0,w.useRef)(n);return(0,w.useEffect)(()=>((async()=>{let n=await Fu(t);h.current&&!g.current&&(g.current=new pu(h.current,e,n,_.current,r,i,s,c,l),m(!0))})(),()=>{g.current?.dispose(),g.current=null}),[e]),(0,w.useEffect)(()=>{let e=!1;return(async()=>{let n=await Fu(t);e||g.current?.setUniforms(n)})(),()=>{e=!0}},[t,p]),(0,w.useEffect)(()=>{g.current?.setSpeed(r)},[r,p]),(0,w.useEffect)(()=>{g.current?.setMaxPixelCount(c)},[c,p]),(0,w.useEffect)(()=>{g.current?.setMinPixelRatio(s)},[s,p]),(0,w.useEffect)(()=>{g.current?.setFrame(i)},[i,p]),(0,S.jsx)(`div`,{ref:Nu([h,f]),style:a!==void 0||o!==void 0?{width:typeof a==`string`&&isNaN(+a)===!1?+a:a,height:typeof o==`string`&&isNaN(+o)===!1?+o:o,...u}:u,...d})});Iu.displayName=`ShaderMount`;function Lu(e,t){for(let n in e){if(n===`colors`){let n=Array.isArray(e.colors),r=Array.isArray(t.colors);if(!n||!r){if(Object.is(e.colors,t.colors)===!1)return!1;continue}if(e.colors?.length!==t.colors?.length||!e.colors?.every((e,n)=>e===t.colors?.[n]))return!1;continue}if(Object.is(e[n],t[n])===!1)return!1}return!0}var Ru={name:`Default`,params:{...yu,speed:1,frame:0,colors:[`#e0eaff`,`#241d9a`,`#f75092`,`#9f50d3`],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:0}};({...yu}),{...yu},{...yu};var zu=(0,w.memo)(function({speed:e=Ru.params.speed,frame:t=Ru.params.frame,colors:n=Ru.params.colors,distortion:r=Ru.params.distortion,swirl:i=Ru.params.swirl,grainMixer:a=Ru.params.grainMixer,grainOverlay:o=Ru.params.grainOverlay,fit:s=Ru.params.fit,rotation:c=Ru.params.rotation,scale:l=Ru.params.scale,originX:u=Ru.params.originX,originY:d=Ru.params.originY,offsetX:f=Ru.params.offsetX,offsetY:p=Ru.params.offsetY,worldWidth:m=Ru.params.worldWidth,worldHeight:h=Ru.params.worldHeight,...g}){let _={u_colors:n.map(Eu),u_colorsCount:n.length,u_distortion:r,u_swirl:i,u_grainMixer:a,u_grainOverlay:o,u_fit:bu[s],u_rotation:c,u_scale:l,u_offsetX:f,u_offsetY:p,u_originX:u,u_originY:d,u_worldWidth:m,u_worldHeight:h};return(0,S.jsx)(Iu,{...g,speed:e,frame:t,fragmentShader:Tu,uniforms:_})},Lu),Bu=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Vu=`VisuallyHidden`,Hu=w.forwardRef((e,t)=>(0,S.jsx)(Jt.span,{...e,ref:t,style:{...Bu,...e.style}}));Hu.displayName=Vu;var Uu=Hu,[Wu,nee]=Nt(`Tooltip`,[oa]),Gu=oa(),Ku=`TooltipProvider`,qu=700,Ju=`tooltip.open`,[Yu,Xu]=Wu(Ku),Zu=e=>{let{__scopeTooltip:t,delayDuration:n=qu,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=w.useRef(!0),s=w.useRef(!1),c=w.useRef(0);return w.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,S.jsx)(Yu,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:w.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:w.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:w.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Zu.displayName=Ku;var Qu=`Tooltip`,[$u,ed]=Wu(Qu),td=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Xu(Qu,e.__scopeTooltip),l=Gu(t),[u,d]=w.useState(null),f=In(),p=w.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=w.useRef(!1),[_,v]=Lt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ju))):c.onClose(),a?.(e)},caller:Qu}),y=w.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=w.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=w.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),C=w.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return w.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,S.jsx)(Sa,{...l,children:(0,S.jsx)($u,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:w.useCallback(()=>{c.isOpenDelayedRef.current?C():b()},[c.isOpenDelayedRef,C,b]),onTriggerLeave:w.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};td.displayName=Qu;var nd=`TooltipTrigger`,rd=w.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ed(nd,n),a=Xu(nd,n),o=Gu(n),s=D(t,w.useRef(null),i.onTriggerChange),c=w.useRef(!1),l=w.useRef(!1),u=w.useCallback(()=>c.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,S.jsx)(Ca,{asChild:!0,...o,children:(0,S.jsx)(Jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:jt(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:jt(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:jt(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:jt(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:jt(e.onBlur,i.onClose),onClick:jt(e.onClick,i.onClose)})})});rd.displayName=nd;var id=`TooltipPortal`,[ad,od]=Wu(id,{forceMount:void 0}),sd=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=ed(id,t);return(0,S.jsx)(ad,{scope:t,forceMount:n,children:(0,S.jsx)(ka,{present:n||a.open,children:(0,S.jsx)(Da,{asChild:!0,container:i,children:r})})})};sd.displayName=id;var cd=`TooltipContent`,ld=w.forwardRef((e,t)=>{let n=od(cd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=ed(cd,e.__scopeTooltip);return(0,S.jsx)(ka,{present:r||o.open,children:o.disableHoverableContent?(0,S.jsx)(md,{side:i,...a,ref:t}):(0,S.jsx)(ud,{side:i,...a,ref:t})})}),ud=w.forwardRef((e,t)=>{let n=ed(cd,e.__scopeTooltip),r=Xu(cd,e.__scopeTooltip),i=w.useRef(null),a=D(t,i),[o,s]=w.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=w.useCallback(()=>{s(null),d(!1)},[d]),p=w.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=vd(r,_d(r,n.getBoundingClientRect())),a=yd(t.getBoundingClientRect());s(xd([...i,...a])),d(!0)},[d]);return w.useEffect(()=>()=>f(),[f]),w.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),w.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!bd(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,S.jsx)(md,{...e,ref:a})}),[dd,fd]=Wu(Qu,{isInside:!1}),pd=Wt(`TooltipContent`),md=w.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=ed(cd,n),l=Gu(n),{onClose:u}=c;return w.useEffect(()=>(document.addEventListener(Ju,u),()=>document.removeEventListener(Ju,u)),[u]),w.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,S.jsx)(cn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,S.jsxs)(wa,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,S.jsx)(pd,{children:r}),(0,S.jsx)(dd,{scope:n,isInside:!0,children:(0,S.jsx)(Uu,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ld.displayName=cd;var hd=`TooltipArrow`,gd=w.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Gu(n);return fd(hd,n).isInside?null:(0,S.jsx)(Ta,{...i,...r,ref:t})});gd.displayName=hd;function _d(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function vd(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function yd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function bd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function xd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Sd(t)}function Sd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var ree=Zu,Cd=td,wd=rd,Td=sd,Ed=ld,Dd=gd;function Od({delayDuration:e=0,...t}){return(0,S.jsx)(ree,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function kd({...e}){return(0,S.jsx)(Od,{children:(0,S.jsx)(Cd,{"data-slot":`tooltip`,...e})})}function Ad({...e}){return(0,S.jsx)(wd,{"data-slot":`tooltip-trigger`,...e})}function jd({className:e,sideOffset:t=0,children:n,...r}){return(0,S.jsx)(Td,{children:(0,S.jsxs)(Ed,{"data-slot":`tooltip-content`,sideOffset:t,className:H(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,S.jsx)(Dd,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var Md=class{name=`mcp_inspector_open`;properties;constructor(e){this.properties={server_url:e.serverUrl,connection_count:e.connectionCount}}},Nd=class{name=`mcp_tool_execution`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId,success:e.success,duration:e.duration,error:e.error}}},Pd=class{name=`mcp_resource_read`;properties;constructor(e){this.properties={resource_uri:e.resourceUri,server_id:e.serverId,success:e.success,error:e.error}}},Fd=class{name=`mcp_prompt_call`;properties;constructor(e){this.properties={prompt_name:e.promptName,server_id:e.serverId,success:e.success,error:e.error}}},Id=class{name=`mcp_server_connection`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,success:e.success,connection_type:e.connectionType,error:e.error}}},Ld=class{name=`mcp_chat_message`;properties;constructor(e){this.properties={server_id:e.serverId,provider:e.provider,model:e.model,message_count:e.messageCount,tool_calls_count:e.toolCallsCount,success:e.success,execution_mode:e.executionMode,duration:e.duration,error:e.error}}},Rd=class{name=`mcp_server_added`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,connection_type:e.connectionType,via_proxy:e.viaProxy}}},zd=class{name=`mcp_server_removed`;properties;constructor(e){this.properties={server_id:e.serverId}}},Bd=class{name=`mcp_command_palette_open`;properties;constructor(e){this.properties={trigger:e.trigger}}},Vd=class{name=`mcp_tool_saved`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId}}},Hd=class{name=`mcp_tunnel_action`;properties;constructor(e){this.properties={action:e.action,success:e.success,tunnel_url:e.tunnelUrl}}},Ud=class{name=`mcp_deploy_click`;properties;constructor(e){this.properties={referrer:e.referrer}}},Wd=class{name=`mcp_chat_configured`;properties;constructor(e){this.properties={provider:e.provider,model:e.model}}},Gd=class{name=`mcp_tab_navigation`;properties;constructor(e){this.properties={tab:e.tab,previous_tab:e.previousTab}}},Kd=class{name=`mcp_add_to_client`;properties;constructor(e){this.properties={client:e.client}}},qd=class{name=`mcp_session_duration`;properties;constructor(e){this.properties={duration_seconds:e.durationSeconds,tabs_visited:e.tabsVisited,tools_executed:e.toolsExecuted}}};function Jd(){try{return`8.0.0`}catch{return`0.0.0`}}function Yd(){try{return typeof window<`u`&&typeof document<`u`}catch{return!1}}var Xd=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout),r=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(n),!r.ok)throw Error(`HTTP error! status: ${r.status}`)}catch{}}};function Zd(e){return`mcp_inspector_telemetry_${e}`}function Qd(){if(typeof window>`u`)return`standalone`;let e=window.__MCP_INSPECTOR_MODE__;return e===`standalone`||e===`embedded`||e===`cloud`?e:`standalone`}function $d(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`}var ef=class e{static instance=null;POSTHOG_PROXY_URL=`/inspector/api/tel/posthog`;SCARF_PROXY_URL=`/inspector/api/tel/scarf`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogClient=null;_scarfClient=null;_source=`inspector`;_mode=`standalone`;constructor(){let e=Yd(),t=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||`inspector`,this._mode=Qd(),t)this._posthogClient=null,this._scarfClient=null;else if(!e)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new Xd(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new Xd(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(typeof window<`u`&&window.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||$d()&&localStorage.getItem(Zd(`disabled`))===`true`||typeof process<`u`&&{}?.MCP_USE_ANONYMIZED_TELEMETRY===`false`)}getStoredSource(){return $d()?localStorage.getItem(Zd(`source`)):null}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e,$d()&&localStorage.setItem(Zd(`source`),e)}getSource(){return this._source}getMode(){return this._mode}get userId(){if(this._currUserId)return this._currUserId;if(!Yd())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!$d())throw Error(`localStorage is not available or not functional`);let e=localStorage.getItem(Zd(`user_id`));if(e)this._currUserId=e;else{let e=this.generateUserId();localStorage.setItem(Zd(`user_id`),e),this._currUserId=e}this.trackPackageDownload({triggered_by:`user_id_property`}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){let e=window.crypto;if(e){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);return n.slice(0,8)+`-`+n.slice(8,12)+`-`+n.slice(12,16)+`-`+n.slice(16,20)+`-`+n.slice(20,32)}else return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{let t={event:e.name,user_id:this.userId,properties:{...e.properties,mcp_use_version:Jd(),language:`typescript`,source:this._source,package:`inspector`,mode:this._mode}};await this._posthogClient.logEvent(t)}catch{}if(this._scarfClient)try{let t={};t.mcp_use_version=Jd(),t.user_id=this.userId,t.event=e.name,t.language=`typescript`,t.source=this._source,t.package=`inspector`,t.mode=this._mode,await this._scarfClient.logEvent(t)}catch{}}}async trackPackageDownload(e){if(this._scarfClient&&Yd())try{if(!$d())throw Error(`localStorage is not available or not functional`);let t=Jd(),n=!1,r=!1,i=localStorage.getItem(Zd(`download_version`));if(i?t>i&&(n=!0,r=!1,localStorage.setItem(Zd(`download_version`),t)):(n=!0,r=!0,localStorage.setItem(Zd(`download_version`),t)),n){let n={...e||{}};n.mcp_use_version=t,n.user_id=this.userId,n.event=`package_download`,n.first_download=r,n.language=`typescript`,n.source=this._source,n.package=`inspector`,n.mode=this._mode,await this._scarfClient.logEvent(n)}}catch{}}async trackInspectorOpen(e){let t=new Md(e);await this.capture(t)}},tf=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),nf=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),rf=e=>{let t=nf(e);return t.charAt(0).toUpperCase()+t.slice(1)},af=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),of=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},sf={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},cf=(0,w.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,w.createElement)(`svg`,{ref:c,...sf,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:af(`lucide`,i),...!a&&!of(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,w.createElement)(e,t)),...Array.isArray(a)?a:[a]])),lf=(e,t)=>{let n=(0,w.forwardRef)(({className:n,...r},i)=>(0,w.createElement)(cf,{ref:i,iconNode:t,className:af(`lucide-${tf(rf(e))}`,`lucide-${e}`,n),...r}));return n.displayName=rf(e),n},uf=lf(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),df=lf(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),ff=lf(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),iee=lf(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),pf=lf(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),mf=lf(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),hf=lf(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),gf=lf(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),_f=lf(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),vf=lf(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),yf=lf(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),bf=lf(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),xf=lf(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Sf=lf(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Cf=lf(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),wf=lf(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Tf=lf(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Ef=lf(`circle-minus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),Df=lf(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Of=lf(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),kf=lf(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),Af=lf(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),jf=lf(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Mf=lf(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Nf=lf(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Pf=lf(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ff=lf(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),If=lf(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Lf=lf(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Rf=lf(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),zf=lf(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Bf=lf(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Vf=lf(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Hf=lf(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Uf=lf(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Wf=lf(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Gf=lf(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Kf=lf(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),qf=lf(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Jf=lf(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Yf=lf(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Xf=lf(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Zf=lf(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qf=lf(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),$f=lf(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),ep=lf(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),tp=lf(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),np=lf(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),rp=lf(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ip=lf(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ap=lf(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),op=lf(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),sp=lf(`picture-in-picture`,[[`path`,{d:`M2 10h6V4`,key:`zwrco`}],[`path`,{d:`m2 4 6 6`,key:`ug085t`}],[`path`,{d:`M21 10V7a2 2 0 0 0-2-2h-7`,key:`git5jr`}],[`path`,{d:`M3 14v2a2 2 0 0 0 2 2h3`,key:`1f7fh3`}],[`rect`,{x:`12`,y:`14`,width:`10`,height:`7`,rx:`1`,key:`1wjs3o`}]]),cp=lf(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),lp=lf(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),up=lf(`pointer`,[[`path`,{d:`M22 14a8 8 0 0 1-8 8`,key:`56vcr3`}],[`path`,{d:`M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1agjmk`}],[`path`,{d:`M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1`,key:`wdbh2u`}],[`path`,{d:`M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10`,key:`1ibuk9`}],[`path`,{d:`M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`g6ys72`}]]),dp=lf(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),fp=lf(`rocket`,[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]]),pp=lf(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),mp=lf(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),hp=lf(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),gp=lf(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),_p=lf(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),vp=lf(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),yp=lf(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),bp=lf(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),xp=lf(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Sp=lf(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Cp=lf(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),wp=lf(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Tp=lf(`square-dashed-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]]),Ep=lf(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Dp=lf(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Op=lf(`sun-dim`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]),kp=lf(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Ap=lf(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),jp=lf(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Mp=lf(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Np=lf(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Pp=lf(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Fp=lf(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Ip=lf(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Lp=Object.freeze({status:`aborted`});function W(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Rp=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},zp=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},Bp={};function Vp(e){return e&&Object.assign(Bp,e),Bp}function Hp(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Up(e,t){return typeof t==`bigint`?t.toString():t}function Wp(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Gp(e){return e==null}function Kp(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function aee(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var oee=Symbol(`evaluating`);function qp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==oee)return r===void 0&&(r=oee,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Jp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yp(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function see(e){return JSON.stringify(e)}function cee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var lee=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Xp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var uee=Wp(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Zp(e){if(Xp(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Xp(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function dee(e){return Zp(e)?{...e}:Array.isArray(e)?[...e]:e}var fee=new Set([`string`,`number`,`symbol`]);function Qp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function $p(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function em(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function pee(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var mee={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function hee(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return $p(e,Yp(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Jp(this,`shape`,e),e},checks:[]}))}function gee(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return $p(e,Yp(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Jp(this,`shape`,r),r},checks:[]}))}function _ee(e,t){if(!Zp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $p(e,Yp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Jp(this,`shape`,n),n}}))}function vee(e,t){if(!Zp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return $p(e,Yp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Jp(this,`shape`,n),n}}))}function yee(e,t){return $p(e,Yp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Jp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function bee(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return $p(t,Yp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Jp(this,`shape`,i),i},checks:[]}))}function xee(e,t,n){return $p(t,Yp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Jp(this,`shape`,i),i}}))}function tm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function nm(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function rm(e){return typeof e==`string`?e:e?.message}function im(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=rm(e.inst?._zod.def?.error?.(e))??rm(t?.error?.(e))??rm(n.customError?.(e))??rm(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function am(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function om(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var sm=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,Up,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},cm=W(`$ZodError`,sm),lm=W(`$ZodError`,sm,{Parent:Error});function See(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Cee(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var um=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Rp;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>im(e,a,Vp())));throw lee(t,i?.callee),t}return o.value},dm=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>im(e,a,Vp())));throw lee(t,i?.callee),t}return o.value},fm=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Rp;return a.issues.length?{success:!1,error:new(e??cm)(a.issues.map(e=>im(e,i,Vp())))}:{success:!0,data:a.value}},wee=fm(lm),pm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>im(e,i,Vp())))}:{success:!0,data:a.value}},Tee=pm(lm),Eee=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return um(e)(t,n,i)},Dee=e=>(t,n,r)=>um(e)(t,n,r),Oee=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return dm(e)(t,n,i)},kee=e=>async(t,n,r)=>dm(e)(t,n,r),Aee=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return fm(e)(t,n,i)},jee=e=>(t,n,r)=>fm(e)(t,n,r),Mee=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return pm(e)(t,n,i)},Nee=e=>async(t,n,r)=>pm(e)(t,n,r),Pee=/^[cC][^\s-]{8,}$/,Fee=/^[0-9a-z]+$/,Iee=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Lee=/^[0-9a-vA-V]{20}$/,Ree=/^[A-Za-z0-9]{27}$/,zee=/^[a-zA-Z0-9_-]{21}$/,Bee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Vee=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Hee=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Uee=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Wee(){return new RegExp(Uee,`u`)}var Gee=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Kee=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,qee=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Jee=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yee=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hm=/^[A-Za-z0-9_-]*$/,Xee=/^\+[1-9]\d{6,14}$/,gm=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Zee=RegExp(`^${gm}$`);function _m(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Qee(e){return RegExp(`^${_m(e)}$`)}function $ee(e){let t=_m({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${gm}T(?:${r})$`)}var ete=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},tte=/^-?\d+$/,vm=/^-?\d+(?:\.\d+)?$/,nte=/^(?:true|false)$/i,rte=/^null$/i,ite=/^[^A-Z]*$/,ate=/^[^a-z]*$/,ym=W(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bm={number:`number`,bigint:`bigint`,object:`date`},xm=W(`$ZodCheckLessThan`,(e,t)=>{ym.init(e,t);let n=bm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sm=W(`$ZodCheckGreaterThan`,(e,t)=>{ym.init(e,t);let n=bm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ote=W(`$ZodCheckMultipleOf`,(e,t)=>{ym.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):aee(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ste=W(`$ZodCheckNumberFormat`,(e,t)=>{ym.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=mee[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=tte)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),cte=W(`$ZodCheckMaxLength`,(e,t)=>{var n;ym.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Gp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=am(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lte=W(`$ZodCheckMinLength`,(e,t)=>{var n;ym.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Gp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=am(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ute=W(`$ZodCheckLengthEquals`,(e,t)=>{var n;ym.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Gp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=am(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Cm=W(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ym.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),dte=W(`$ZodCheckRegex`,(e,t)=>{Cm.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),fte=W(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ite,Cm.init(e,t)}),pte=W(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ate,Cm.init(e,t)}),mte=W(`$ZodCheckIncludes`,(e,t)=>{ym.init(e,t);let n=Qp(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),hte=W(`$ZodCheckStartsWith`,(e,t)=>{ym.init(e,t);let n=RegExp(`^${Qp(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),gte=W(`$ZodCheckEndsWith`,(e,t)=>{ym.init(e,t);let n=RegExp(`.*${Qp(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),_te=W(`$ZodCheckOverwrite`,(e,t)=>{ym.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),vte=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
340
|
+
`;function Eu(e){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:Mu;if(typeof e!=`string`)return Mu;let t,n,r,i=1;if(e.startsWith(`#`))[t,n,r,i]=Du(e);else if(e.startsWith(`rgb`))[t,n,r,i]=Ou(e);else if(e.startsWith(`hsl`))[t,n,r,i]=Au(ku(e));else return console.error(`Unsupported color format`,e),Mu;return[ju(t,0,1),ju(n,0,1),ju(r,0,1),ju(i,0,1)]}function Du(e){return e=e.replace(/^#/,``),e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),e.length===6&&(e+=`ff`),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255,parseInt(e.slice(6,8),16)/255]}function Ou(e){let t=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`)/255,parseInt(t[2]??`0`)/255,parseInt(t[3]??`0`)/255,t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function ku(e){let t=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`),parseInt(t[2]??`0`),parseInt(t[3]??`0`),t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function Au(e){let[t,n,r,i]=e,a=t/360,o=n/100,s=r/100,c,l,u;if(n===0)c=l=u=s;else{let e=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),t=s<.5?s*(1+o):s+o-s*o,n=2*s-t;c=e(n,t,a+1/3),l=e(n,t,a),u=e(n,t,a-1/3)}return[c,l,u,i]}var ju=(e,t,n)=>Math.min(Math.max(e,t),n),Mu=[0,0,0,1];function Nu(e){let t=w.useRef(void 0),n=w.useCallback(t=>{let n=e.map(e=>{if(e!=null){if(typeof e==`function`){let n=e,r=n(t);return typeof r==`function`?r:()=>{n(null)}}return e.current=t,()=>{e.current=null}}});return()=>{n.forEach(e=>e?.())}},e);return w.useMemo(()=>e.every(e=>e==null)?null:e=>{t.current&&=(t.current(),void 0),e!=null&&(t.current=n(e))},e)}function Pu(e){if(e.naturalWidth<1024&&e.naturalHeight<1024){if(e.naturalWidth<1||e.naturalHeight<1)return;let t=e.naturalWidth/e.naturalHeight;e.width=Math.round(t>1?1024*t:1024),e.height=Math.round(t>1?1024:1024/t)}}async function Fu(e){let t={},n=[],r=e=>{try{return e.startsWith(`/`)||new URL(e),!0}catch{return!1}},i=e=>{try{return e.startsWith(`/`)?!1:new URL(e,window.location.origin).origin!==window.location.origin}catch{return!1}};return Object.entries(e).forEach(([e,a])=>{if(typeof a==`string`){let o=a||`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==`;if(!r(o)){console.warn(`Uniform "${e}" has invalid URL "${o}". Skipping image loading.`);return}let s=new Promise((n,r)=>{let a=new Image;i(o)&&(a.crossOrigin=`anonymous`),a.onload=()=>{Pu(a),t[e]=a,n()},a.onerror=()=>{console.error(`Could not set uniforms. Failed to load image at ${o}`),r()},a.src=o});n.push(s)}else a instanceof HTMLImageElement&&Pu(a),t[e]=a}),await Promise.all(n),t}var Iu=(0,w.forwardRef)(function({fragmentShader:e,uniforms:t,webGlContextAttributes:n,speed:r=0,frame:i=0,width:a,height:o,minPixelRatio:s,maxPixelCount:c,mipmaps:l,style:u,...d},f){let[p,m]=(0,w.useState)(!1),h=(0,w.useRef)(null),g=(0,w.useRef)(null),_=(0,w.useRef)(n);return(0,w.useEffect)(()=>((async()=>{let n=await Fu(t);h.current&&!g.current&&(g.current=new pu(h.current,e,n,_.current,r,i,s,c,l),m(!0))})(),()=>{g.current?.dispose(),g.current=null}),[e]),(0,w.useEffect)(()=>{let e=!1;return(async()=>{let n=await Fu(t);e||g.current?.setUniforms(n)})(),()=>{e=!0}},[t,p]),(0,w.useEffect)(()=>{g.current?.setSpeed(r)},[r,p]),(0,w.useEffect)(()=>{g.current?.setMaxPixelCount(c)},[c,p]),(0,w.useEffect)(()=>{g.current?.setMinPixelRatio(s)},[s,p]),(0,w.useEffect)(()=>{g.current?.setFrame(i)},[i,p]),(0,S.jsx)(`div`,{ref:Nu([h,f]),style:a!==void 0||o!==void 0?{width:typeof a==`string`&&isNaN(+a)===!1?+a:a,height:typeof o==`string`&&isNaN(+o)===!1?+o:o,...u}:u,...d})});Iu.displayName=`ShaderMount`;function Lu(e,t){for(let n in e){if(n===`colors`){let n=Array.isArray(e.colors),r=Array.isArray(t.colors);if(!n||!r){if(Object.is(e.colors,t.colors)===!1)return!1;continue}if(e.colors?.length!==t.colors?.length||!e.colors?.every((e,n)=>e===t.colors?.[n]))return!1;continue}if(Object.is(e[n],t[n])===!1)return!1}return!0}var Ru={name:`Default`,params:{...yu,speed:1,frame:0,colors:[`#e0eaff`,`#241d9a`,`#f75092`,`#9f50d3`],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:0}};({...yu}),{...yu},{...yu};var zu=(0,w.memo)(function({speed:e=Ru.params.speed,frame:t=Ru.params.frame,colors:n=Ru.params.colors,distortion:r=Ru.params.distortion,swirl:i=Ru.params.swirl,grainMixer:a=Ru.params.grainMixer,grainOverlay:o=Ru.params.grainOverlay,fit:s=Ru.params.fit,rotation:c=Ru.params.rotation,scale:l=Ru.params.scale,originX:u=Ru.params.originX,originY:d=Ru.params.originY,offsetX:f=Ru.params.offsetX,offsetY:p=Ru.params.offsetY,worldWidth:m=Ru.params.worldWidth,worldHeight:h=Ru.params.worldHeight,...g}){let _={u_colors:n.map(Eu),u_colorsCount:n.length,u_distortion:r,u_swirl:i,u_grainMixer:a,u_grainOverlay:o,u_fit:bu[s],u_rotation:c,u_scale:l,u_offsetX:f,u_offsetY:p,u_originX:u,u_originY:d,u_worldWidth:m,u_worldHeight:h};return(0,S.jsx)(Iu,{...g,speed:e,frame:t,fragmentShader:Tu,uniforms:_})},Lu),Bu=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Vu=`VisuallyHidden`,Hu=w.forwardRef((e,t)=>(0,S.jsx)(Jt.span,{...e,ref:t,style:{...Bu,...e.style}}));Hu.displayName=Vu;var Uu=Hu,[Wu,nee]=Nt(`Tooltip`,[oa]),Gu=oa(),Ku=`TooltipProvider`,qu=700,Ju=`tooltip.open`,[Yu,Xu]=Wu(Ku),Zu=e=>{let{__scopeTooltip:t,delayDuration:n=qu,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=w.useRef(!0),s=w.useRef(!1),c=w.useRef(0);return w.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,S.jsx)(Yu,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:w.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:w.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:w.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Zu.displayName=Ku;var Qu=`Tooltip`,[$u,ed]=Wu(Qu),td=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Xu(Qu,e.__scopeTooltip),l=Gu(t),[u,d]=w.useState(null),f=In(),p=w.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=w.useRef(!1),[_,v]=Lt({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ju))):c.onClose(),a?.(e)},caller:Qu}),y=w.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=w.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=w.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),C=w.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return w.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,S.jsx)(Sa,{...l,children:(0,S.jsx)($u,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:w.useCallback(()=>{c.isOpenDelayedRef.current?C():b()},[c.isOpenDelayedRef,C,b]),onTriggerLeave:w.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};td.displayName=Qu;var nd=`TooltipTrigger`,rd=w.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ed(nd,n),a=Xu(nd,n),o=Gu(n),s=D(t,w.useRef(null),i.onTriggerChange),c=w.useRef(!1),l=w.useRef(!1),u=w.useCallback(()=>c.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,S.jsx)(Ca,{asChild:!0,...o,children:(0,S.jsx)(Jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:jt(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:jt(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:jt(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:jt(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:jt(e.onBlur,i.onClose),onClick:jt(e.onClick,i.onClose)})})});rd.displayName=nd;var id=`TooltipPortal`,[ad,od]=Wu(id,{forceMount:void 0}),sd=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=ed(id,t);return(0,S.jsx)(ad,{scope:t,forceMount:n,children:(0,S.jsx)(ka,{present:n||a.open,children:(0,S.jsx)(Da,{asChild:!0,container:i,children:r})})})};sd.displayName=id;var cd=`TooltipContent`,ld=w.forwardRef((e,t)=>{let n=od(cd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=ed(cd,e.__scopeTooltip);return(0,S.jsx)(ka,{present:r||o.open,children:o.disableHoverableContent?(0,S.jsx)(md,{side:i,...a,ref:t}):(0,S.jsx)(ud,{side:i,...a,ref:t})})}),ud=w.forwardRef((e,t)=>{let n=ed(cd,e.__scopeTooltip),r=Xu(cd,e.__scopeTooltip),i=w.useRef(null),a=D(t,i),[o,s]=w.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=w.useCallback(()=>{s(null),d(!1)},[d]),p=w.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=vd(r,_d(r,n.getBoundingClientRect())),a=yd(t.getBoundingClientRect());s(xd([...i,...a])),d(!0)},[d]);return w.useEffect(()=>()=>f(),[f]),w.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),w.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!bd(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,S.jsx)(md,{...e,ref:a})}),[dd,fd]=Wu(Qu,{isInside:!1}),pd=Wt(`TooltipContent`),md=w.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=ed(cd,n),l=Gu(n),{onClose:u}=c;return w.useEffect(()=>(document.addEventListener(Ju,u),()=>document.removeEventListener(Ju,u)),[u]),w.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,S.jsx)(cn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,S.jsxs)(wa,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,S.jsx)(pd,{children:r}),(0,S.jsx)(dd,{scope:n,isInside:!0,children:(0,S.jsx)(Uu,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});ld.displayName=cd;var hd=`TooltipArrow`,gd=w.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Gu(n);return fd(hd,n).isInside?null:(0,S.jsx)(Ta,{...i,...r,ref:t})});gd.displayName=hd;function _d(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function vd(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function yd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function bd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function xd(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Sd(t)}function Sd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var ree=Zu,Cd=td,wd=rd,Td=sd,Ed=ld,Dd=gd;function Od({delayDuration:e=0,...t}){return(0,S.jsx)(ree,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function kd({...e}){return(0,S.jsx)(Od,{children:(0,S.jsx)(Cd,{"data-slot":`tooltip`,...e})})}function Ad({...e}){return(0,S.jsx)(wd,{"data-slot":`tooltip-trigger`,...e})}function jd({className:e,sideOffset:t=0,children:n,...r}){return(0,S.jsx)(Td,{children:(0,S.jsxs)(Ed,{"data-slot":`tooltip-content`,sideOffset:t,className:H(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,S.jsx)(Dd,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var Md=class{name=`mcp_inspector_open`;properties;constructor(e){this.properties={server_url:e.serverUrl,connection_count:e.connectionCount}}},Nd=class{name=`mcp_tool_execution`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId,success:e.success,duration:e.duration,error:e.error}}},Pd=class{name=`mcp_resource_read`;properties;constructor(e){this.properties={resource_uri:e.resourceUri,server_id:e.serverId,success:e.success,error:e.error}}},Fd=class{name=`mcp_prompt_call`;properties;constructor(e){this.properties={prompt_name:e.promptName,server_id:e.serverId,success:e.success,error:e.error}}},Id=class{name=`mcp_server_connection`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,success:e.success,connection_type:e.connectionType,error:e.error}}},Ld=class{name=`mcp_chat_message`;properties;constructor(e){this.properties={server_id:e.serverId,provider:e.provider,model:e.model,message_count:e.messageCount,tool_calls_count:e.toolCallsCount,success:e.success,execution_mode:e.executionMode,duration:e.duration,error:e.error}}},Rd=class{name=`mcp_server_added`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,connection_type:e.connectionType,via_proxy:e.viaProxy}}},zd=class{name=`mcp_server_removed`;properties;constructor(e){this.properties={server_id:e.serverId}}},Bd=class{name=`mcp_command_palette_open`;properties;constructor(e){this.properties={trigger:e.trigger}}},Vd=class{name=`mcp_tool_saved`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId}}},Hd=class{name=`mcp_tunnel_action`;properties;constructor(e){this.properties={action:e.action,success:e.success,tunnel_url:e.tunnelUrl}}},Ud=class{name=`mcp_deploy_click`;properties;constructor(e){this.properties={referrer:e.referrer}}},Wd=class{name=`mcp_chat_configured`;properties;constructor(e){this.properties={provider:e.provider,model:e.model}}},Gd=class{name=`mcp_tab_navigation`;properties;constructor(e){this.properties={tab:e.tab,previous_tab:e.previousTab}}},Kd=class{name=`mcp_add_to_client`;properties;constructor(e){this.properties={client:e.client}}},qd=class{name=`mcp_session_duration`;properties;constructor(e){this.properties={duration_seconds:e.durationSeconds,tabs_visited:e.tabsVisited,tools_executed:e.toolsExecuted}}};function Jd(){try{return`8.0.1-canary.2`}catch{return`0.0.0`}}function Yd(){try{return typeof window<`u`&&typeof document<`u`}catch{return!1}}var Xd=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout),r=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(n),!r.ok)throw Error(`HTTP error! status: ${r.status}`)}catch{}}};function Zd(e){return`mcp_inspector_telemetry_${e}`}function Qd(){if(typeof window>`u`)return`standalone`;let e=window.__MCP_INSPECTOR_MODE__;return e===`standalone`||e===`embedded`||e===`cloud`?e:`standalone`}function $d(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`}var ef=class e{static instance=null;POSTHOG_PROXY_URL=`/inspector/api/tel/posthog`;SCARF_PROXY_URL=`/inspector/api/tel/scarf`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogClient=null;_scarfClient=null;_source=`inspector`;_mode=`standalone`;constructor(){let e=Yd(),t=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||`inspector`,this._mode=Qd(),t)this._posthogClient=null,this._scarfClient=null;else if(!e)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new Xd(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new Xd(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(typeof window<`u`&&window.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||$d()&&localStorage.getItem(Zd(`disabled`))===`true`||typeof process<`u`&&{}?.MCP_USE_ANONYMIZED_TELEMETRY===`false`)}getStoredSource(){return $d()?localStorage.getItem(Zd(`source`)):null}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e,$d()&&localStorage.setItem(Zd(`source`),e)}getSource(){return this._source}getMode(){return this._mode}get userId(){if(this._currUserId)return this._currUserId;if(!Yd())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!$d())throw Error(`localStorage is not available or not functional`);let e=localStorage.getItem(Zd(`user_id`));if(e)this._currUserId=e;else{let e=this.generateUserId();localStorage.setItem(Zd(`user_id`),e),this._currUserId=e}this.trackPackageDownload({triggered_by:`user_id_property`}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){let e=window.crypto;if(e){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);return n.slice(0,8)+`-`+n.slice(8,12)+`-`+n.slice(12,16)+`-`+n.slice(16,20)+`-`+n.slice(20,32)}else return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{let t={event:e.name,user_id:this.userId,properties:{...e.properties,mcp_use_version:Jd(),language:`typescript`,source:this._source,package:`inspector`,mode:this._mode}};await this._posthogClient.logEvent(t)}catch{}if(this._scarfClient)try{let t={};t.mcp_use_version=Jd(),t.user_id=this.userId,t.event=e.name,t.language=`typescript`,t.source=this._source,t.package=`inspector`,t.mode=this._mode,await this._scarfClient.logEvent(t)}catch{}}}async trackPackageDownload(e){if(this._scarfClient&&Yd())try{if(!$d())throw Error(`localStorage is not available or not functional`);let t=Jd(),n=!1,r=!1,i=localStorage.getItem(Zd(`download_version`));if(i?t>i&&(n=!0,r=!1,localStorage.setItem(Zd(`download_version`),t)):(n=!0,r=!0,localStorage.setItem(Zd(`download_version`),t)),n){let n={...e||{}};n.mcp_use_version=t,n.user_id=this.userId,n.event=`package_download`,n.first_download=r,n.language=`typescript`,n.source=this._source,n.package=`inspector`,n.mode=this._mode,await this._scarfClient.logEvent(n)}}catch{}}async trackInspectorOpen(e){let t=new Md(e);await this.capture(t)}},tf=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),nf=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),rf=e=>{let t=nf(e);return t.charAt(0).toUpperCase()+t.slice(1)},af=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),of=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},sf={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},cf=(0,w.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,w.createElement)(`svg`,{ref:c,...sf,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:af(`lucide`,i),...!a&&!of(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,w.createElement)(e,t)),...Array.isArray(a)?a:[a]])),lf=(e,t)=>{let n=(0,w.forwardRef)(({className:n,...r},i)=>(0,w.createElement)(cf,{ref:i,iconNode:t,className:af(`lucide-${tf(rf(e))}`,`lucide-${e}`,n),...r}));return n.displayName=rf(e),n},uf=lf(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),df=lf(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),ff=lf(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),iee=lf(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),pf=lf(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),mf=lf(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),hf=lf(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),gf=lf(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),_f=lf(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),vf=lf(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),yf=lf(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),bf=lf(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),xf=lf(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Sf=lf(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Cf=lf(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),wf=lf(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Tf=lf(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Ef=lf(`circle-minus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),Df=lf(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Of=lf(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),kf=lf(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),Af=lf(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),jf=lf(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Mf=lf(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Nf=lf(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Pf=lf(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ff=lf(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),If=lf(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Lf=lf(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Rf=lf(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),zf=lf(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Bf=lf(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Vf=lf(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Hf=lf(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Uf=lf(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Wf=lf(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Gf=lf(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Kf=lf(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),qf=lf(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Jf=lf(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Yf=lf(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),Xf=lf(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Zf=lf(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Qf=lf(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),$f=lf(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),ep=lf(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),tp=lf(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),np=lf(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),rp=lf(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ip=lf(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ap=lf(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),op=lf(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),sp=lf(`picture-in-picture`,[[`path`,{d:`M2 10h6V4`,key:`zwrco`}],[`path`,{d:`m2 4 6 6`,key:`ug085t`}],[`path`,{d:`M21 10V7a2 2 0 0 0-2-2h-7`,key:`git5jr`}],[`path`,{d:`M3 14v2a2 2 0 0 0 2 2h3`,key:`1f7fh3`}],[`rect`,{x:`12`,y:`14`,width:`10`,height:`7`,rx:`1`,key:`1wjs3o`}]]),cp=lf(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),lp=lf(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),up=lf(`pointer`,[[`path`,{d:`M22 14a8 8 0 0 1-8 8`,key:`56vcr3`}],[`path`,{d:`M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1agjmk`}],[`path`,{d:`M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1`,key:`wdbh2u`}],[`path`,{d:`M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10`,key:`1ibuk9`}],[`path`,{d:`M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`g6ys72`}]]),dp=lf(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),fp=lf(`rocket`,[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]]),pp=lf(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),mp=lf(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),hp=lf(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),gp=lf(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),_p=lf(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),vp=lf(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),yp=lf(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),bp=lf(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),xp=lf(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Sp=lf(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Cp=lf(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),wp=lf(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Tp=lf(`square-dashed-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]]),Ep=lf(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Dp=lf(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Op=lf(`sun-dim`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]),kp=lf(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Ap=lf(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),jp=lf(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Mp=lf(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Np=lf(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Pp=lf(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Fp=lf(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Ip=lf(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Lp=Object.freeze({status:`aborted`});function W(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Rp=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},zp=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},Bp={};function Vp(e){return e&&Object.assign(Bp,e),Bp}function Hp(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Up(e,t){return typeof t==`bigint`?t.toString():t}function Wp(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Gp(e){return e==null}function Kp(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function aee(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var oee=Symbol(`evaluating`);function qp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==oee)return r===void 0&&(r=oee,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Jp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yp(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function see(e){return JSON.stringify(e)}function cee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var lee=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Xp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var uee=Wp(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Zp(e){if(Xp(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Xp(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function dee(e){return Zp(e)?{...e}:Array.isArray(e)?[...e]:e}var fee=new Set([`string`,`number`,`symbol`]);function Qp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function $p(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function em(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function pee(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var mee={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function hee(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return $p(e,Yp(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Jp(this,`shape`,e),e},checks:[]}))}function gee(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return $p(e,Yp(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Jp(this,`shape`,r),r},checks:[]}))}function _ee(e,t){if(!Zp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $p(e,Yp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Jp(this,`shape`,n),n}}))}function vee(e,t){if(!Zp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return $p(e,Yp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Jp(this,`shape`,n),n}}))}function yee(e,t){return $p(e,Yp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Jp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function bee(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return $p(t,Yp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Jp(this,`shape`,i),i},checks:[]}))}function xee(e,t,n){return $p(t,Yp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Jp(this,`shape`,i),i}}))}function tm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function nm(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function rm(e){return typeof e==`string`?e:e?.message}function im(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=rm(e.inst?._zod.def?.error?.(e))??rm(t?.error?.(e))??rm(n.customError?.(e))??rm(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function am(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function om(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var sm=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,Up,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},cm=W(`$ZodError`,sm),lm=W(`$ZodError`,sm,{Parent:Error});function See(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Cee(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var um=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Rp;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>im(e,a,Vp())));throw lee(t,i?.callee),t}return o.value},dm=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>im(e,a,Vp())));throw lee(t,i?.callee),t}return o.value},fm=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Rp;return a.issues.length?{success:!1,error:new(e??cm)(a.issues.map(e=>im(e,i,Vp())))}:{success:!0,data:a.value}},wee=fm(lm),pm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>im(e,i,Vp())))}:{success:!0,data:a.value}},Tee=pm(lm),Eee=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return um(e)(t,n,i)},Dee=e=>(t,n,r)=>um(e)(t,n,r),Oee=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return dm(e)(t,n,i)},kee=e=>async(t,n,r)=>dm(e)(t,n,r),Aee=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return fm(e)(t,n,i)},jee=e=>(t,n,r)=>fm(e)(t,n,r),Mee=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return pm(e)(t,n,i)},Nee=e=>async(t,n,r)=>pm(e)(t,n,r),Pee=/^[cC][^\s-]{8,}$/,Fee=/^[0-9a-z]+$/,Iee=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Lee=/^[0-9a-vA-V]{20}$/,Ree=/^[A-Za-z0-9]{27}$/,zee=/^[a-zA-Z0-9_-]{21}$/,Bee=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Vee=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Hee=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Uee=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Wee(){return new RegExp(Uee,`u`)}var Gee=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Kee=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,qee=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Jee=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yee=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hm=/^[A-Za-z0-9_-]*$/,Xee=/^\+[1-9]\d{6,14}$/,gm=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Zee=RegExp(`^${gm}$`);function _m(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Qee(e){return RegExp(`^${_m(e)}$`)}function $ee(e){let t=_m({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${gm}T(?:${r})$`)}var ete=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},tte=/^-?\d+$/,vm=/^-?\d+(?:\.\d+)?$/,nte=/^(?:true|false)$/i,rte=/^null$/i,ite=/^[^A-Z]*$/,ate=/^[^a-z]*$/,ym=W(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bm={number:`number`,bigint:`bigint`,object:`date`},xm=W(`$ZodCheckLessThan`,(e,t)=>{ym.init(e,t);let n=bm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sm=W(`$ZodCheckGreaterThan`,(e,t)=>{ym.init(e,t);let n=bm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ote=W(`$ZodCheckMultipleOf`,(e,t)=>{ym.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):aee(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ste=W(`$ZodCheckNumberFormat`,(e,t)=>{ym.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=mee[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=tte)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),cte=W(`$ZodCheckMaxLength`,(e,t)=>{var n;ym.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Gp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=am(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lte=W(`$ZodCheckMinLength`,(e,t)=>{var n;ym.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Gp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=am(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ute=W(`$ZodCheckLengthEquals`,(e,t)=>{var n;ym.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Gp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=am(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Cm=W(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ym.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),dte=W(`$ZodCheckRegex`,(e,t)=>{Cm.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),fte=W(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ite,Cm.init(e,t)}),pte=W(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ate,Cm.init(e,t)}),mte=W(`$ZodCheckIncludes`,(e,t)=>{ym.init(e,t);let n=Qp(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),hte=W(`$ZodCheckStartsWith`,(e,t)=>{ym.init(e,t);let n=RegExp(`^${Qp(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),gte=W(`$ZodCheckEndsWith`,(e,t)=>{ym.init(e,t);let n=RegExp(`.*${Qp(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),_te=W(`$ZodCheckOverwrite`,(e,t)=>{ym.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),vte=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
341
341
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
342
342
|
`))}},yte={major:4,minor:3,patch:5},wm=W(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yte;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=tm(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Rp;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=tm(e,t))});else{if(e.issues.length===t)continue;r||=tm(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(tm(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Rp;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Rp;return o.then(e=>t(e,r,a))}return t(o,r,a)}}qp(e,`~standard`,()=>({validate:t=>{try{let n=wee(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Tee(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Tm=W(`$ZodString`,(e,t)=>{wm.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ete(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Em=W(`$ZodStringFormat`,(e,t)=>{Cm.init(e,t),Tm.init(e,t)}),bte=W(`$ZodGUID`,(e,t)=>{t.pattern??=Vee,Em.init(e,t)}),xte=W(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=mm(e)}else t.pattern??=mm();Em.init(e,t)}),Ste=W(`$ZodEmail`,(e,t)=>{t.pattern??=Hee,Em.init(e,t)}),Cte=W(`$ZodURL`,(e,t)=>{Em.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),wte=W(`$ZodEmoji`,(e,t)=>{t.pattern??=Wee(),Em.init(e,t)}),Tte=W(`$ZodNanoID`,(e,t)=>{t.pattern??=zee,Em.init(e,t)}),Ete=W(`$ZodCUID`,(e,t)=>{t.pattern??=Pee,Em.init(e,t)}),Dte=W(`$ZodCUID2`,(e,t)=>{t.pattern??=Fee,Em.init(e,t)}),Ote=W(`$ZodULID`,(e,t)=>{t.pattern??=Iee,Em.init(e,t)}),kte=W(`$ZodXID`,(e,t)=>{t.pattern??=Lee,Em.init(e,t)}),Ate=W(`$ZodKSUID`,(e,t)=>{t.pattern??=Ree,Em.init(e,t)}),jte=W(`$ZodISODateTime`,(e,t)=>{t.pattern??=$ee(t),Em.init(e,t)}),Mte=W(`$ZodISODate`,(e,t)=>{t.pattern??=Zee,Em.init(e,t)}),Nte=W(`$ZodISOTime`,(e,t)=>{t.pattern??=Qee(t),Em.init(e,t)}),Pte=W(`$ZodISODuration`,(e,t)=>{t.pattern??=Bee,Em.init(e,t)}),Fte=W(`$ZodIPv4`,(e,t)=>{t.pattern??=Gee,Em.init(e,t),e._zod.bag.format=`ipv4`}),Ite=W(`$ZodIPv6`,(e,t)=>{t.pattern??=Kee,Em.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Lte=W(`$ZodCIDRv4`,(e,t)=>{t.pattern??=qee,Em.init(e,t)}),Rte=W(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Jee,Em.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Dm(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var zte=W(`$ZodBase64`,(e,t)=>{t.pattern??=Yee,Em.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Dm(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Bte(e){if(!hm.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Dm(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Vte=W(`$ZodBase64URL`,(e,t)=>{t.pattern??=hm,Em.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Bte(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Hte=W(`$ZodE164`,(e,t)=>{t.pattern??=Xee,Em.init(e,t)});function Ute(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Wte=W(`$ZodJWT`,(e,t)=>{Em.init(e,t),e._zod.check=n=>{Ute(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Om=W(`$ZodNumber`,(e,t)=>{wm.init(e,t),e._zod.pattern=e._zod.bag.pattern??vm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Gte=W(`$ZodNumberFormat`,(e,t)=>{ste.init(e,t),Om.init(e,t)}),Kte=W(`$ZodBoolean`,(e,t)=>{wm.init(e,t),e._zod.pattern=nte,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),qte=W(`$ZodNull`,(e,t)=>{wm.init(e,t),e._zod.pattern=rte,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Jte=W(`$ZodAny`,(e,t)=>{wm.init(e,t),e._zod.parse=e=>e}),Yte=W(`$ZodUnknown`,(e,t)=>{wm.init(e,t),e._zod.parse=e=>e}),Xte=W(`$ZodNever`,(e,t)=>{wm.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function km(e,t,n){e.issues.length&&t.issues.push(...nm(n,e.issues)),t.value[n]=e.value}var Zte=W(`$ZodArray`,(e,t)=>{wm.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>km(t,n,e))):km(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Am(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...nm(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function jm(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=pee(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Mm(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Am(e,n,i,t,u))):Am(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Qte=W(`$ZodObject`,(e,t)=>{if(wm.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=Wp(()=>jm(t));qp(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Xp,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>Am(n,t,e,s,r))):Am(i,t,e,s,r)}return i?Mm(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),$te=W(`$ZodObjectJIT`,(e,t)=>{Qte.init(e,t);let n=e._zod.parse,r=Wp(()=>jm(t)),i=e=>{let t=new vte([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=see(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=see(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
|
|
343
343
|
if (${n}.issues.length) {
|
|
@@ -435,7 +435,7 @@ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Rec
|
|
|
435
435
|
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);K.object({method:K.literal(`ui/open-link`),params:K.object({url:K.string().describe(`URL to open in the host's browser`)})}),K.object({isError:K.boolean().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),K.object({isError:K.boolean().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),K.object({method:K.literal(`ui/notifications/sandbox-proxy-ready`),params:K.object({})});var QD=K.object({connectDomains:K.array(K.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).`),resourceDomains:K.array(K.string()).optional().describe(`Origins for static resources (scripts, images, styles, fonts).`),frameDomains:K.array(K.string()).optional().describe(`Origins for nested iframes (frame-src directive).`),baseUriDomains:K.array(K.string()).optional().describe(`Allowed base URIs for the document (base-uri directive).`)}),$D=K.object({camera:K.object({}).optional().describe("Request camera access (Permission Policy `camera` feature)."),microphone:K.object({}).optional().describe("Request microphone access (Permission Policy `microphone` feature)."),geolocation:K.object({}).optional().describe("Request geolocation access (Permission Policy `geolocation` feature)."),clipboardWrite:K.object({}).optional().describe("Request clipboard write access (Permission Policy `clipboard-write` feature).")});K.object({method:K.literal(`ui/notifications/size-changed`),params:K.object({width:K.number().optional().describe(`New width in pixels.`),height:K.number().optional().describe(`New height in pixels.`)})}),K.object({method:K.literal(`ui/notifications/tool-input`),params:K.object({arguments:K.record(K.string(),K.unknown().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),K.object({method:K.literal(`ui/notifications/tool-input-partial`),params:K.object({arguments:K.record(K.string(),K.unknown().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),K.object({method:K.literal(`ui/notifications/tool-cancelled`),params:K.object({reason:K.string().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var iue=K.object({fonts:K.string().optional()}),aue=K.object({variables:rue.optional().describe(`CSS variables for theming the app.`),css:iue.optional().describe(`CSS blocks that apps can inject.`)});K.object({method:K.literal(`ui/resource-teardown`),params:K.object({})}),K.record(K.string(),K.unknown());var eO=K.object({text:K.object({}).optional().describe(`Host supports text content blocks.`),image:K.object({}).optional().describe(`Host supports image content blocks.`),audio:K.object({}).optional().describe(`Host supports audio content blocks.`),resource:K.object({}).optional().describe(`Host supports resource content blocks.`),resourceLink:K.object({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:K.object({}).optional().describe(`Host supports structured content.`)}),oue=K.object({experimental:K.object({}).optional().describe(`Experimental features (structure TBD).`),openLinks:K.object({}).optional().describe(`Host supports opening external URLs.`),serverTools:K.object({listChanged:K.boolean().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:K.object({listChanged:K.boolean().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:K.object({}).optional().describe(`Host accepts log messages.`),sandbox:K.object({permissions:$D.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:QD.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:eO.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:eO.optional().describe(`Host supports receiving content messages (ui/message) from the view.`)}),sue=K.object({experimental:K.object({}).optional().describe(`Experimental features (structure TBD).`),tools:K.object({listChanged:K.boolean().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:K.array(ZD).optional().describe(`Display modes the app supports.`)});K.object({method:K.literal(`ui/notifications/initialized`),params:K.object({}).optional()}),K.object({csp:QD.optional().describe(`Content Security Policy configuration.`),permissions:$D.optional().describe(`Sandbox permissions requested by the UI.`),domain:K.string().optional().describe(`Dedicated origin for view sandbox.`),prefersBorder:K.boolean().optional().describe(`Visual boundary preference - true if UI prefers a visible border.`)}),K.object({method:K.literal(`ui/request-display-mode`),params:K.object({mode:ZD.describe(`The display mode being requested.`)})}),K.object({mode:ZD.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var cue=K.union([K.literal(`model`),K.literal(`app`)]).describe(`Tool visibility scope - who can access the tool.`);K.object({resourceUri:K.string().optional(),visibility:K.array(cue).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
436
436
|
- "model": Tool visible to and callable by the agent
|
|
437
437
|
- "app": Tool callable by the app from this server only`)}),K.object({mimeTypes:K.array(K.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),K.object({method:K.literal(`ui/message`),params:K.object({role:K.literal(`user`).describe(`Message role, currently only "user" is supported.`),content:K.array(Kg).describe(`Message content blocks (text, image, etc.).`)})}),K.object({method:K.literal(`ui/notifications/sandbox-resource-ready`),params:K.object({html:K.string().describe(`HTML content to load into the inner iframe.`),sandbox:K.string().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:QD.optional().describe(`CSP configuration from resource metadata.`),permissions:$D.optional().describe(`Sandbox permissions from resource metadata.`)})}),K.object({method:K.literal(`ui/notifications/tool-result`),params:Zg.describe(`Standard MCP tool execution result.`)});var tO=K.object({toolInfo:K.object({id:Zh.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Yg.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:tue.optional().describe(`Current color theme preference.`),styles:aue.optional().describe(`Style configuration for theming the app.`),displayMode:ZD.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:K.array(ZD).optional().describe(`Display modes the host supports.`),containerDimensions:K.union([K.object({height:K.number().describe(`Fixed container height in pixels.`)}),K.object({maxHeight:K.union([K.number(),K.undefined()]).optional().describe(`Maximum container height in pixels.`)})]).and(K.union([K.object({width:K.number().describe(`Fixed container width in pixels.`)}),K.object({maxWidth:K.union([K.number(),K.undefined()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
438
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:K.string().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:K.string().optional().describe(`User's timezone in IANA format.`),userAgent:K.string().optional().describe(`Host application identifier.`),platform:K.union([K.literal(`web`),K.literal(`desktop`),K.literal(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:K.object({touch:K.boolean().optional().describe(`Whether the device supports touch input.`),hover:K.boolean().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:K.object({top:K.number().describe(`Top safe area inset in pixels.`),right:K.number().describe(`Right safe area inset in pixels.`),bottom:K.number().describe(`Bottom safe area inset in pixels.`),left:K.number().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();K.object({method:K.literal(`ui/notifications/host-context-changed`),params:tO.describe(`Partial context update containing only changed fields.`)}),K.object({method:K.literal(`ui/update-model-context`),params:K.object({content:K.array(Kg).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:K.record(K.string(),K.unknown().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),K.object({method:K.literal(`ui/initialize`),params:K.object({appInfo:ug.describe(`App identification (name and version).`),appCapabilities:sue.describe(`Features and capabilities this app provides.`),protocolVersion:K.string().describe(`Protocol version this app supports.`)})}),K.object({protocolVersion:K.string().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:ug.describe(`Host application identification and version.`),hostCapabilities:oue.describe(`Features and capabilities provided by the host.`),hostContext:tO.describe(`Rich context about the host environment.`)}).passthrough();var lue=`text/html;profile=mcp-app`,uue=`modulepreload`,due=function(e){return`/inspector/`+e},nO={},J=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=due(t,n),t in nO)return;nO[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:uue,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fue=`1.30.0`;function rO(){return fue}a(rO,`getPackageVersion`);var iO=class{static{a(this,`BaseTelemetryEvent`)}},pue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`MCPAgentExecutionEvent`)}get name(){return`mcp_agent_execution`}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}};function aO(e,t){let n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),i=Array.from(e.registrations.resources.values()),a=Array.from(e.registrations.resourceTemplates.values()),o=i.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,uri:e.config.uri??null,mime_type:e.config.mimeType??null})),s=o.filter(e=>e.mime_type===`text/html+skybridge`),c=o.filter(e=>e.mime_type===`text/uri-list`||e.mime_type===`text/html`),l=o.filter(e=>e.mime_type===lue);return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,input_schema:e.config.schema?JSON.stringify(e.config.schema):null,output_schema:e.config.outputSchema?JSON.stringify(e.config.outputSchema):null})):null,resources:o.length>0?o:null,prompts:r.length>0?r.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,args:e.config.args?JSON.stringify(e.config.args):null})):null,templates:a.length>0?a.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:s.length>0?s:null,appsSdkResourcesNumber:s.length,mcpUiResources:c.length>0?c:null,mcpUiResourcesNumber:c.length,mcpAppsResources:l.length>0?l:null,mcpAppsResourcesNumber:l.length}}a(aO,`createServerRunEventData`);var mue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerRunEvent`)}get name(){return`server_run`}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},hue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerInitializeEvent`)}get name(){return`server_initialize_call`}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},gue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerToolCallEvent`)}get name(){return`server_tool_call`}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},_ue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerResourceCallEvent`)}get name(){return`server_resource_call`}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},vue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerPromptCallEvent`)}get name(){return`server_prompt_call`}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},yue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerContextEvent`)}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},bue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`MCPClientInitEvent`)}get name(){return`mcpclient_init`}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},xue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ConnectorInitEvent`)}get name(){return`connector_init`}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},Sue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ClientAddServerEvent`)}get name(){return`client_add_server`}get properties(){let{serverName:e,serverConfig:t}=this.data,n=t.url;return{server_name:e,server_url_domain:n?this._extractHostname(n):null,transport:t.transport??null,has_auth:!!(t.authToken||t.authProvider)}}_extractHostname(e){try{return new URL(e).hostname}catch{return null}}},Cue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ClientRemoveServerEvent`)}get name(){return`client_remove_server`}get properties(){return{server_name:this.data.serverName}}};function oO(e){return e._llm_type||e.constructor.name.toLowerCase()}a(oO,`getModelProvider`);function sO(e){if(`_identifyingParams`in e){let t=e._identifyingParams;if(typeof t==`object`&&t){for(let e of[`model`,`modelName`,`model_name`,`modelId`,`model_id`,`deploymentName`,`deployment_name`])if(e in t)return String(t[e])}}return e.model||e.modelName||e.constructor.name}a(sO,`getModelName`);function wue(e){return[oO(e),sO(e)]}a(wue,`extractModelInfo`);function cO(){if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}a(cO,`generateUUID`);function lO(){if(typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).substring(2,15)}a(lO,`secureRandomString`);var uO=`mcp_use_user_id`;function dO(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`&&typeof localStorage.removeItem==`function`}a(dO,`isLocalStorageFunctional`);function fO(){try{return typeof window<`u`&&typeof document<`u`?`browser`:`unknown`}catch{return`unknown`}}a(fO,`detectRuntimeEnvironment`);function pO(e){if(e===`browser`)try{if(dO())return localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`),`localStorage`}catch{}return`session-only`}a(pO,`getStorageCapability`);var mO=null;function hO(){return mO===null&&(mO=fO()),mO}a(hO,`getRuntimeEnvironment`);var gO=class e{static{a(this,`Telemetry`)}static instance=null;PROJECT_API_KEY=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`;HOST=`https://eu.i.posthog.com`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=hO(),this._storageCapability=pO(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;let e=this._checkTelemetryDisabled(),t=this._runtimeEnvironment!==`unknown`;e?(this._posthogBrowserClient=null,l.debug(`Telemetry disabled via localStorage`)):t?(l.debug(`Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable.`),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,l.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(dO())return localStorage.getItem(`MCP_USE_TELEMETRY_SOURCE`)}catch{}return null}_checkTelemetryDisabled(){return!!(typeof window<`u`&&window.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||dO()&&localStorage.getItem(`MCP_USE_ANONYMIZED_TELEMETRY`)===`false`)}async _initPostHogBrowser(){try{let e=await J(()=>import(`./module-BXKdgN2b.js`),[]),t=e.default||e.posthog;if(!t||typeof t.init!=`function`)throw Error(`posthog-js module did not export expected interface`);t.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:`localStorage`,autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:a(()=>{l.debug(`PostHog browser client initialized`)},`loaded`)}),this._posthogBrowserClient=t}catch(e){l.warn(`Failed to initialize PostHog browser telemetry: ${e}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e;try{dO()&&localStorage.setItem(`MCP_USE_TELEMETRY_SOURCE`,e)}catch{}l.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case`localStorage`:this._currUserId=this._getUserIdFromLocalStorage();break;default:try{this._currUserId=`session-${cO()}`}catch{this._currUserId=`session-${Date.now()}-${lO()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(!dO())throw Error(`localStorage is not available or not functional`);localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`);let e=localStorage.getItem(uO);if(!e){try{e=cO()}catch{e=`${Date.now()}-${lO()}`}localStorage.setItem(uO,e)}return e}catch(e){l.debug(`Failed to access localStorage for user ID: ${e}`);let t;try{t=`session-${cO()}`}catch{t=`session-${Date.now()}-${lO()}`}return t}}async capture(e){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;let t=this.userId,n={...e.properties};if(n.mcp_use_version=rO(),n.language=`typescript`,n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(e.name,{...n,distinct_id:t})}catch(t){l.debug(`Failed to track PostHog Browser event ${e.name}: ${t}`)}}async trackAgentExecution(e){if(!this.isEnabled)return;let t=new pue(e);await this.capture(t)}async trackServerRunFromServer(e,t){if(!this.isEnabled)return;let n=new mue(aO(e,t));await this.capture(n)}async trackServerInitialize(e){if(!this.isEnabled)return;let t=new hue(e);await this.capture(t)}async trackServerToolCall(e){if(!this.isEnabled)return;let t=new gue(e);await this.capture(t)}async trackServerResourceCall(e){if(!this.isEnabled)return;let t=new _ue(e);await this.capture(t)}async trackServerPromptCall(e){if(!this.isEnabled)return;let t=new vue(e);await this.capture(t)}async trackServerContext(e){if(!this.isEnabled)return;let t=new yue(e);await this.capture(t)}async trackMCPClientInit(e){if(!this.isEnabled)return;let t=new bue(e);await this.capture(t)}async trackConnectorInit(e){if(!this.isEnabled)return;let t=new xue(e);await this.capture(t)}async trackClientAddServer(e,t){if(!this.isEnabled)return;let n=new Sue({serverName:e,serverConfig:t});await this.capture(n)}async trackClientRemoveServer(e){if(!this.isEnabled)return;let t=new Cue({serverName:e});await this.capture(t)}async trackUseMcpConnection(e){this.isEnabled&&await this.capture({name:`usemcp_connection`,properties:{url_domain:new URL(e.url).hostname,transport_type:e.transportType,success:e.success,error_type:e.errorType??null,connection_time_ms:e.connectionTimeMs??null,has_oauth:e.hasOAuth,has_sampling:e.hasSampling,has_elicitation:e.hasElicitation}})}async trackUseMcpToolCall(e){this.isEnabled&&await this.capture({name:`usemcp_tool_call`,properties:{tool_name:e.toolName,success:e.success,error_type:e.errorType??null,execution_time_ms:e.executionTimeMs??null}})}async trackUseMcpResourceRead(e){this.isEnabled&&await this.capture({name:`usemcp_resource_read`,properties:{resource_uri_scheme:e.resourceUri.split(`:`)[0],success:e.success,error_type:e.errorType??null}})}identify(e,t){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(e,t)}catch(e){l.debug(`Failed to identify user: ${e}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(e){l.debug(`Failed to reset user: ${e}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(e){}},_O=gO;function Tue(e){_O.getInstance().setSource(e)}a(Tue,`setTelemetrySource`);var Eue=class{static{a(this,`BaseConnector`)}client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];constructor(e={}){let t={...e,onSampling:e.onSampling??e.samplingCallback,onElicitation:e.onElicitation??e.elicitationCallback};e.samplingCallback&&!e.onSampling&&l.warn(`[BaseConnector] The "samplingCallback" option is deprecated. Use "onSampling" instead.`),e.elicitationCallback&&!e.onElicitation&&console.warn(`[BaseConnector] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`),this.opts=t,t.roots&&(this.rootsCache=[...t.roots]),t.onNotification&&this.notificationHandlers.push(t.onNotification)}trackConnectorInit(e){let t=this.constructor.name;gO.getInstance().trackConnectorInit({connectorType:t,...e}).catch(e=>l.debug(`Failed to track connector init: ${e}`))}onNotification(e){this.notificationHandlers.push(e),this.client&&this.setupNotificationHandler()}setupNotificationHandler(){if(!this.client)return;let e=a(async e=>{for(let t of this.notificationHandlers)try{await t(e)}catch(e){l.error(`Error in notification handler:`,e)}},`forwardToUserHandlers`);this.client.fallbackNotificationHandler=async t=>{switch(t.method){case`notifications/tools/list_changed`:await this.refreshToolsCache();break;case`notifications/resources/list_changed`:await this.onResourcesListChanged();break;case`notifications/prompts/list_changed`:await this.onPromptsListChanged();break;default:break}await e(t)};let t=this.client._notificationHandlers;for(let n of[`notifications/progress`,`notifications/cancelled`]){let r=t.get(n);r&&t.set(n,async t=>{await r(t),await e(t)})}}async refreshToolsCache(){if(this.client)try{l.debug(`[Auto] Refreshing tools cache due to list_changed notification`),this.toolsCache=(await this.client.listTools()).tools??[],l.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(e){l.warn(`[Auto] Failed to refresh tools cache:`,e)}}async onResourcesListChanged(){l.debug(`[Auto] Resources list changed - clients should re-fetch if needed`)}async onPromptsListChanged(){l.debug(`[Auto] Prompts list changed - clients should re-fetch if needed`)}async setRoots(e){this.rootsCache=[...e],this.client&&(l.debug(`Sending roots/list_changed notification with ${e.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(l_,async(e,t)=>(l.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){l.debug(`setupSamplingHandler: No client available`);return}let e=this.opts.onSampling??this.opts.samplingCallback;if(!e){l.debug(`setupSamplingHandler: No sampling callback provided`);return}l.debug(`setupSamplingHandler: Setting up sampling request handler`),this.client.setRequestHandler(r_,async(t,n)=>(l.debug(`Server requested sampling, forwarding to callback`),await e(t.params))),l.debug(`setupSamplingHandler: Sampling handler registered successfully`)}setupElicitationHandler(){if(!this.client){l.debug(`setupElicitationHandler: No client available`);return}let e=this.opts.onElicitation??this.opts.elicitationCallback;if(!e){l.debug(`setupElicitationHandler: No elicitation callback provided`);return}l.debug(`setupElicitationHandler: Setting up elicitation request handler`),this.client.setRequestHandler(o_,async(t,n)=>(l.debug(`Server requested elicitation, forwarding to callback`),await e(t.params))),l.debug(`setupElicitationHandler: Elicitation handler registered successfully`)}async disconnect(){if(!this.connected){l.debug(`Not connected to MCP implementation`);return}l.debug(`Disconnecting from MCP implementation`),await this.cleanupResources(),this.connected=!1,l.debug(`Disconnected from MCP implementation`)}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw Error(`MCP client is not connected`);l.debug(`Caching server capabilities & tools`);let t=this.client.getServerCapabilities();this.capabilitiesCache=t||null;let n=this.client.getServerVersion();this.serverInfoCache=n||null;try{this.toolsCache=(await this.client.listTools(void 0,e)).tools??[],l.debug(`Fetched ${this.toolsCache.length} tools from server`)}catch(e){let t=e;t.code===-32601?l.debug(`Server does not implement tools/list, assuming no tools`):l.debug(`Failed to list tools, assuming empty:`,t.message),this.toolsCache=[]}return l.debug(`Server capabilities:`,t),l.debug(`Server info:`,n),t}get tools(){if(!this.toolsCache)throw Error(`MCP client is not initialized; call initialize() first`);return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}async callTool(e,t,n){if(!this.client)throw Error(`MCP client is not connected`);let r=n?{...n}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},l.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)),l.debug(`Calling tool '${e}' with args`,t);let i=await this.client.callTool({name:e,arguments:t},void 0,r);return l.debug(`Tool '${e}' returned`,i),i}async listTools(e){if(!this.client)throw Error(`MCP client is not connected`);l.debug(`[listTools] Fetching fresh tools from server...`);let t=await this.client.listTools(void 0,e),n=t.tools?[...t.tools]:[];return l.debug(`[listTools] Returned ${n.length} tools:`,n.map(e=>e.name)),n}async listResources(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Listing resources`,e?`with cursor: ${e}`:``),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.resources)return l.debug(`Server does not advertise resources capability, skipping`),{resources:[]};try{l.debug(`Listing all resources (with auto-pagination)`);let t=[],n;do{let r=await this.client.listResources({cursor:n},e);t.push(...r.resources||[]),n=r.nextCursor}while(n);return{resources:t}}catch(e){if(e.code===-32601)return l.debug(`Server advertised resources but method not found`),{resources:[]};throw e}}async listResourceTemplates(e){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Listing resource templates`),await this.client.listResourceTemplates(void 0,e)}async complete(e,t){if(!this.client)throw Error(`MCP client is not connected`);l.debug(`[complete] Requesting completions for:`,e.ref);let n=await this.client.complete(e,t);return l.debug(`[complete] Received ${n.completion.values.length} suggestions`),n}async readResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Reading resource ${e}`),await this.client.readResource({uri:e},t)}async subscribeToResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.prompts)return l.debug(`Server does not advertise prompts capability, skipping`),{prompts:[]};try{return l.debug(`Listing prompts`),await this.client.listPrompts()}catch(e){if(e.code===-32601)return l.debug(`Server advertised prompts but method not found`),{prompts:[]};throw e}}async getPrompt(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,n){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},void 0,n)}async cleanupResources(){let e=[];if(this.client)try{typeof this.client.close==`function`&&await this.client.close()}catch(t){let n=`Error closing client: ${t}`;l.warn(n),e.push(n)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){let n=`Error stopping connection manager: ${t}`;l.warn(n),e.push(n)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&l.warn(`Resource cleanup finished with ${e.length} issue(s)`)}},Due=class{static{a(this,`ConnectionManager`)}_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),l.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw Error(`Connection was not established`);return this._connection}async stop(){if(this._task&&this._abortController){l.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(e){e instanceof Error&&e.name===`AbortError`?l.debug(`${this.constructor.name} task aborted successfully`):l.warn(`Error stopping ${this.constructor.name} task: ${e}`)}}await this._donePromise,l.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(e=>this._readyResolver=e),this._donePromise=new Promise(e=>this._doneResolver=e),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){l.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),l.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(e){this._exception=e,l.error(`Error in ${this.constructor.name} task: ${e}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(e){l.warn(`Error closing connection in ${this.constructor.name}: ${e}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((e,t)=>{if(!this._abortController)return;let n=this._abortController.signal;if(n.aborted){e();return}let r=a(()=>{n.removeEventListener(`abort`,r),e()},`onAbort`);n.addEventListener(`abort`,r)})}},vO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),yO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=vO(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),bO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=vO(),n=yO(),r=vO();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=yO();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
438
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:K.string().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:K.string().optional().describe(`User's timezone in IANA format.`),userAgent:K.string().optional().describe(`Host application identifier.`),platform:K.union([K.literal(`web`),K.literal(`desktop`),K.literal(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:K.object({touch:K.boolean().optional().describe(`Whether the device supports touch input.`),hover:K.boolean().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:K.object({top:K.number().describe(`Top safe area inset in pixels.`),right:K.number().describe(`Right safe area inset in pixels.`),bottom:K.number().describe(`Bottom safe area inset in pixels.`),left:K.number().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();K.object({method:K.literal(`ui/notifications/host-context-changed`),params:tO.describe(`Partial context update containing only changed fields.`)}),K.object({method:K.literal(`ui/update-model-context`),params:K.object({content:K.array(Kg).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:K.record(K.string(),K.unknown().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),K.object({method:K.literal(`ui/initialize`),params:K.object({appInfo:ug.describe(`App identification (name and version).`),appCapabilities:sue.describe(`Features and capabilities this app provides.`),protocolVersion:K.string().describe(`Protocol version this app supports.`)})}),K.object({protocolVersion:K.string().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:ug.describe(`Host application identification and version.`),hostCapabilities:oue.describe(`Features and capabilities provided by the host.`),hostContext:tO.describe(`Rich context about the host environment.`)}).passthrough();var lue=`text/html;profile=mcp-app`,uue=`modulepreload`,due=function(e){return`/inspector/`+e},nO={},J=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=due(t,n),t in nO)return;nO[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:uue,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fue=`1.30.1-canary.2`;function rO(){return fue}a(rO,`getPackageVersion`);var iO=class{static{a(this,`BaseTelemetryEvent`)}},pue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`MCPAgentExecutionEvent`)}get name(){return`mcp_agent_execution`}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}};function aO(e,t){let n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),i=Array.from(e.registrations.resources.values()),a=Array.from(e.registrations.resourceTemplates.values()),o=i.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,uri:e.config.uri??null,mime_type:e.config.mimeType??null})),s=o.filter(e=>e.mime_type===`text/html+skybridge`),c=o.filter(e=>e.mime_type===`text/uri-list`||e.mime_type===`text/html`),l=o.filter(e=>e.mime_type===lue);return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,input_schema:e.config.schema?JSON.stringify(e.config.schema):null,output_schema:e.config.outputSchema?JSON.stringify(e.config.outputSchema):null})):null,resources:o.length>0?o:null,prompts:r.length>0?r.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null,args:e.config.args?JSON.stringify(e.config.args):null})):null,templates:a.length>0?a.map(e=>({name:e.config.name,title:e.config.title??null,description:e.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:s.length>0?s:null,appsSdkResourcesNumber:s.length,mcpUiResources:c.length>0?c:null,mcpUiResourcesNumber:c.length,mcpAppsResources:l.length>0?l:null,mcpAppsResourcesNumber:l.length}}a(aO,`createServerRunEventData`);var mue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerRunEvent`)}get name(){return`server_run`}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},hue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerInitializeEvent`)}get name(){return`server_initialize_call`}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},gue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerToolCallEvent`)}get name(){return`server_tool_call`}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},_ue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerResourceCallEvent`)}get name(){return`server_resource_call`}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},vue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerPromptCallEvent`)}get name(){return`server_prompt_call`}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},yue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ServerContextEvent`)}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},bue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`MCPClientInitEvent`)}get name(){return`mcpclient_init`}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},xue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ConnectorInitEvent`)}get name(){return`connector_init`}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},Sue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ClientAddServerEvent`)}get name(){return`client_add_server`}get properties(){let{serverName:e,serverConfig:t}=this.data,n=t.url;return{server_name:e,server_url_domain:n?this._extractHostname(n):null,transport:t.transport??null,has_auth:!!(t.authToken||t.authProvider)}}_extractHostname(e){try{return new URL(e).hostname}catch{return null}}},Cue=class extends iO{constructor(e){super(),this.data=e}static{a(this,`ClientRemoveServerEvent`)}get name(){return`client_remove_server`}get properties(){return{server_name:this.data.serverName}}};function oO(e){return e._llm_type||e.constructor.name.toLowerCase()}a(oO,`getModelProvider`);function sO(e){if(`_identifyingParams`in e){let t=e._identifyingParams;if(typeof t==`object`&&t){for(let e of[`model`,`modelName`,`model_name`,`modelId`,`model_id`,`deploymentName`,`deployment_name`])if(e in t)return String(t[e])}}return e.model||e.modelName||e.constructor.name}a(sO,`getModelName`);function wue(e){return[oO(e),sO(e)]}a(wue,`extractModelInfo`);function cO(){if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}a(cO,`generateUUID`);function lO(){if(typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}if(typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).substring(2,15)}a(lO,`secureRandomString`);var uO=`mcp_use_user_id`;function dO(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`&&typeof localStorage.removeItem==`function`}a(dO,`isLocalStorageFunctional`);function fO(){try{return typeof window<`u`&&typeof document<`u`?`browser`:`unknown`}catch{return`unknown`}}a(fO,`detectRuntimeEnvironment`);function pO(e){if(e===`browser`)try{if(dO())return localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`),`localStorage`}catch{}return`session-only`}a(pO,`getStorageCapability`);var mO=null;function hO(){return mO===null&&(mO=fO()),mO}a(hO,`getRuntimeEnvironment`);var gO=class e{static{a(this,`Telemetry`)}static instance=null;PROJECT_API_KEY=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`;HOST=`https://eu.i.posthog.com`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=hO(),this._storageCapability=pO(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;let e=this._checkTelemetryDisabled(),t=this._runtimeEnvironment!==`unknown`;e?(this._posthogBrowserClient=null,l.debug(`Telemetry disabled via localStorage`)):t?(l.debug(`Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable.`),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,l.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(dO())return localStorage.getItem(`MCP_USE_TELEMETRY_SOURCE`)}catch{}return null}_checkTelemetryDisabled(){return!!(typeof window<`u`&&window.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||dO()&&localStorage.getItem(`MCP_USE_ANONYMIZED_TELEMETRY`)===`false`)}async _initPostHogBrowser(){try{let e=await J(()=>import(`./module-BXKdgN2b.js`),[]),t=e.default||e.posthog;if(!t||typeof t.init!=`function`)throw Error(`posthog-js module did not export expected interface`);t.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:`localStorage`,autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:a(()=>{l.debug(`PostHog browser client initialized`)},`loaded`)}),this._posthogBrowserClient=t}catch(e){l.warn(`Failed to initialize PostHog browser telemetry: ${e}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e;try{dO()&&localStorage.setItem(`MCP_USE_TELEMETRY_SOURCE`,e)}catch{}l.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case`localStorage`:this._currUserId=this._getUserIdFromLocalStorage();break;default:try{this._currUserId=`session-${cO()}`}catch{this._currUserId=`session-${Date.now()}-${lO()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(!dO())throw Error(`localStorage is not available or not functional`);localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`);let e=localStorage.getItem(uO);if(!e){try{e=cO()}catch{e=`${Date.now()}-${lO()}`}localStorage.setItem(uO,e)}return e}catch(e){l.debug(`Failed to access localStorage for user ID: ${e}`);let t;try{t=`session-${cO()}`}catch{t=`session-${Date.now()}-${lO()}`}return t}}async capture(e){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;let t=this.userId,n={...e.properties};if(n.mcp_use_version=rO(),n.language=`typescript`,n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(e.name,{...n,distinct_id:t})}catch(t){l.debug(`Failed to track PostHog Browser event ${e.name}: ${t}`)}}async trackAgentExecution(e){if(!this.isEnabled)return;let t=new pue(e);await this.capture(t)}async trackServerRunFromServer(e,t){if(!this.isEnabled)return;let n=new mue(aO(e,t));await this.capture(n)}async trackServerInitialize(e){if(!this.isEnabled)return;let t=new hue(e);await this.capture(t)}async trackServerToolCall(e){if(!this.isEnabled)return;let t=new gue(e);await this.capture(t)}async trackServerResourceCall(e){if(!this.isEnabled)return;let t=new _ue(e);await this.capture(t)}async trackServerPromptCall(e){if(!this.isEnabled)return;let t=new vue(e);await this.capture(t)}async trackServerContext(e){if(!this.isEnabled)return;let t=new yue(e);await this.capture(t)}async trackMCPClientInit(e){if(!this.isEnabled)return;let t=new bue(e);await this.capture(t)}async trackConnectorInit(e){if(!this.isEnabled)return;let t=new xue(e);await this.capture(t)}async trackClientAddServer(e,t){if(!this.isEnabled)return;let n=new Sue({serverName:e,serverConfig:t});await this.capture(n)}async trackClientRemoveServer(e){if(!this.isEnabled)return;let t=new Cue({serverName:e});await this.capture(t)}async trackUseMcpConnection(e){this.isEnabled&&await this.capture({name:`usemcp_connection`,properties:{url_domain:new URL(e.url).hostname,transport_type:e.transportType,success:e.success,error_type:e.errorType??null,connection_time_ms:e.connectionTimeMs??null,has_oauth:e.hasOAuth,has_sampling:e.hasSampling,has_elicitation:e.hasElicitation}})}async trackUseMcpToolCall(e){this.isEnabled&&await this.capture({name:`usemcp_tool_call`,properties:{tool_name:e.toolName,success:e.success,error_type:e.errorType??null,execution_time_ms:e.executionTimeMs??null}})}async trackUseMcpResourceRead(e){this.isEnabled&&await this.capture({name:`usemcp_resource_read`,properties:{resource_uri_scheme:e.resourceUri.split(`:`)[0],success:e.success,error_type:e.errorType??null}})}identify(e,t){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(e,t)}catch(e){l.debug(`Failed to identify user: ${e}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(e){l.debug(`Failed to reset user: ${e}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(e){}},_O=gO;function Tue(e){_O.getInstance().setSource(e)}a(Tue,`setTelemetrySource`);var Eue=class{static{a(this,`BaseConnector`)}client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];constructor(e={}){let t={...e,onSampling:e.onSampling??e.samplingCallback,onElicitation:e.onElicitation??e.elicitationCallback};e.samplingCallback&&!e.onSampling&&l.warn(`[BaseConnector] The "samplingCallback" option is deprecated. Use "onSampling" instead.`),e.elicitationCallback&&!e.onElicitation&&console.warn(`[BaseConnector] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`),this.opts=t,t.roots&&(this.rootsCache=[...t.roots]),t.onNotification&&this.notificationHandlers.push(t.onNotification)}trackConnectorInit(e){let t=this.constructor.name;gO.getInstance().trackConnectorInit({connectorType:t,...e}).catch(e=>l.debug(`Failed to track connector init: ${e}`))}onNotification(e){this.notificationHandlers.push(e),this.client&&this.setupNotificationHandler()}setupNotificationHandler(){if(!this.client)return;let e=a(async e=>{for(let t of this.notificationHandlers)try{await t(e)}catch(e){l.error(`Error in notification handler:`,e)}},`forwardToUserHandlers`);this.client.fallbackNotificationHandler=async t=>{switch(t.method){case`notifications/tools/list_changed`:await this.refreshToolsCache();break;case`notifications/resources/list_changed`:await this.onResourcesListChanged();break;case`notifications/prompts/list_changed`:await this.onPromptsListChanged();break;default:break}await e(t)};let t=this.client._notificationHandlers;for(let n of[`notifications/progress`,`notifications/cancelled`]){let r=t.get(n);r&&t.set(n,async t=>{await r(t),await e(t)})}}async refreshToolsCache(){if(this.client)try{l.debug(`[Auto] Refreshing tools cache due to list_changed notification`),this.toolsCache=(await this.client.listTools()).tools??[],l.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(e){l.warn(`[Auto] Failed to refresh tools cache:`,e)}}async onResourcesListChanged(){l.debug(`[Auto] Resources list changed - clients should re-fetch if needed`)}async onPromptsListChanged(){l.debug(`[Auto] Prompts list changed - clients should re-fetch if needed`)}async setRoots(e){this.rootsCache=[...e],this.client&&(l.debug(`Sending roots/list_changed notification with ${e.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(l_,async(e,t)=>(l.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){l.debug(`setupSamplingHandler: No client available`);return}let e=this.opts.onSampling??this.opts.samplingCallback;if(!e){l.debug(`setupSamplingHandler: No sampling callback provided`);return}l.debug(`setupSamplingHandler: Setting up sampling request handler`),this.client.setRequestHandler(r_,async(t,n)=>(l.debug(`Server requested sampling, forwarding to callback`),await e(t.params))),l.debug(`setupSamplingHandler: Sampling handler registered successfully`)}setupElicitationHandler(){if(!this.client){l.debug(`setupElicitationHandler: No client available`);return}let e=this.opts.onElicitation??this.opts.elicitationCallback;if(!e){l.debug(`setupElicitationHandler: No elicitation callback provided`);return}l.debug(`setupElicitationHandler: Setting up elicitation request handler`),this.client.setRequestHandler(o_,async(t,n)=>(l.debug(`Server requested elicitation, forwarding to callback`),await e(t.params))),l.debug(`setupElicitationHandler: Elicitation handler registered successfully`)}async disconnect(){if(!this.connected){l.debug(`Not connected to MCP implementation`);return}l.debug(`Disconnecting from MCP implementation`),await this.cleanupResources(),this.connected=!1,l.debug(`Disconnected from MCP implementation`)}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw Error(`MCP client is not connected`);l.debug(`Caching server capabilities & tools`);let t=this.client.getServerCapabilities();this.capabilitiesCache=t||null;let n=this.client.getServerVersion();this.serverInfoCache=n||null;try{this.toolsCache=(await this.client.listTools(void 0,e)).tools??[],l.debug(`Fetched ${this.toolsCache.length} tools from server`)}catch(e){let t=e;t.code===-32601?l.debug(`Server does not implement tools/list, assuming no tools`):l.debug(`Failed to list tools, assuming empty:`,t.message),this.toolsCache=[]}return l.debug(`Server capabilities:`,t),l.debug(`Server info:`,n),t}get tools(){if(!this.toolsCache)throw Error(`MCP client is not initialized; call initialize() first`);return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}async callTool(e,t,n){if(!this.client)throw Error(`MCP client is not connected`);let r=n?{...n}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},l.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)),l.debug(`Calling tool '${e}' with args`,t);let i=await this.client.callTool({name:e,arguments:t},void 0,r);return l.debug(`Tool '${e}' returned`,i),i}async listTools(e){if(!this.client)throw Error(`MCP client is not connected`);l.debug(`[listTools] Fetching fresh tools from server...`);let t=await this.client.listTools(void 0,e),n=t.tools?[...t.tools]:[];return l.debug(`[listTools] Returned ${n.length} tools:`,n.map(e=>e.name)),n}async listResources(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Listing resources`,e?`with cursor: ${e}`:``),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.resources)return l.debug(`Server does not advertise resources capability, skipping`),{resources:[]};try{l.debug(`Listing all resources (with auto-pagination)`);let t=[],n;do{let r=await this.client.listResources({cursor:n},e);t.push(...r.resources||[]),n=r.nextCursor}while(n);return{resources:t}}catch(e){if(e.code===-32601)return l.debug(`Server advertised resources but method not found`),{resources:[]};throw e}}async listResourceTemplates(e){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Listing resource templates`),await this.client.listResourceTemplates(void 0,e)}async complete(e,t){if(!this.client)throw Error(`MCP client is not connected`);l.debug(`[complete] Requesting completions for:`,e.ref);let n=await this.client.complete(e,t);return l.debug(`[complete] Received ${n.completion.values.length} suggestions`),n}async readResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Reading resource ${e}`),await this.client.readResource({uri:e},t)}async subscribeToResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.prompts)return l.debug(`Server does not advertise prompts capability, skipping`),{prompts:[]};try{return l.debug(`Listing prompts`),await this.client.listPrompts()}catch(e){if(e.code===-32601)return l.debug(`Server advertised prompts but method not found`),{prompts:[]};throw e}}async getPrompt(e,t){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,n){if(!this.client)throw Error(`MCP client is not connected`);return l.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},void 0,n)}async cleanupResources(){let e=[];if(this.client)try{typeof this.client.close==`function`&&await this.client.close()}catch(t){let n=`Error closing client: ${t}`;l.warn(n),e.push(n)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){let n=`Error stopping connection manager: ${t}`;l.warn(n),e.push(n)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&l.warn(`Resource cleanup finished with ${e.length} issue(s)`)}},Due=class{static{a(this,`ConnectionManager`)}_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),l.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw Error(`Connection was not established`);return this._connection}async stop(){if(this._task&&this._abortController){l.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(e){e instanceof Error&&e.name===`AbortError`?l.debug(`${this.constructor.name} task aborted successfully`):l.warn(`Error stopping ${this.constructor.name} task: ${e}`)}}await this._donePromise,l.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(e=>this._readyResolver=e),this._donePromise=new Promise(e=>this._doneResolver=e),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){l.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),l.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(e){this._exception=e,l.error(`Error in ${this.constructor.name} task: ${e}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(e){l.warn(`Error closing connection in ${this.constructor.name}: ${e}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((e,t)=>{if(!this._abortController)return;let n=this._abortController.signal;if(n.aborted){e();return}let r=a(()=>{n.removeEventListener(`abort`,r),e()},`onAbort`);n.addEventListener(`abort`,r)})}},vO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),yO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=vO(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),bO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=vO(),n=yO(),r=vO();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return r.Name}});var i=yO();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
439
439
|
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),xO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=bO(),n=vO();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0?!0:(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),SO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t=bO();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),CO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=bO(),n=xO(),r=SO();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Oue=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=CO(),n=bO(),r=SO(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),wO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),TO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),EO=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=wO(),n=TO(),r=CO(),i=bO(),a=xO(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
440
440
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
441
441
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
@@ -449,7 +449,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
449
449
|
`&&r++}}return[t,n]}var kfe=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Dfe({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}},Afe={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Tk=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},jfe=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Vde(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Afe}async _authThenStart(){if(!this._authProvider)throw new pk(`No auth provider`);let e;try{e=await gk(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new pk;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=qO(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new Tk(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new kfe({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=ag.parse(JSON.parse(e.data));ng(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new pk(`No auth provider`);if(await gk(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new pk(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:$h(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Tk(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=vk(o);if(this._resourceMetadataUrl=t,this._scope=n,await gk(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new pk;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=vk(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new Tk(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await gk(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new pk;return this.send(e)}}throw new Tk(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),xae(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c)if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>ag.parse(e)):[ag.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new Tk(-1,`Unexpected content type: ${l}`);else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Tk(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}},Ek=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(Ok(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(Ok(this),t)}};function Mfe(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function Dk(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(Dk).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${Dk(e.cause)}`:e.message:`${e}`}function Ok(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var kk=e=>{throw TypeError(e)},Ak=(e,t,n)=>t.has(e)||kk(`Cannot `+n),jk=(e,t,n)=>(Ak(e,t,`read from private field`),n?n.call(e):t.get(e)),Mk=(e,t,n)=>t.has(e)?kk(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Nk=(e,t,n,r)=>(Ak(e,t,`write to private field`),t.set(e,n),n),Pk=(e,t,n)=>(Ak(e,t,`access private method`),n),Fk,Ik,Lk,Rk,zk,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,$k,eA,tA,nA,rA,iA=class extends EventTarget{constructor(e,t){super(),Mk(this,Jk),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Mk(this,Fk),Mk(this,Ik),Mk(this,Lk),Mk(this,Rk),Mk(this,zk),Mk(this,Bk),Mk(this,Vk),Mk(this,Hk,null),Mk(this,Uk),Mk(this,Wk),Mk(this,Gk,null),Mk(this,Kk,null),Mk(this,qk,null),Mk(this,Xk,async e=>{var t;jk(this,Wk).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){Pk(this,Jk,tA).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?Nk(this,Lk,new URL(e.url)):Nk(this,Lk,void 0),i!==200){Pk(this,Jk,tA).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){Pk(this,Jk,tA).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(jk(this,Fk)===this.CLOSED)return;Nk(this,Fk,this.OPEN);let o=new Event(`open`);if((t=jk(this,qk))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){Pk(this,Jk,tA).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&jk(this,Wk).feed(s.decode(t,{stream:!e})),e&&(l=!1,jk(this,Wk).reset(),Pk(this,Jk,nA).call(this))}while(l)}),Mk(this,Zk,e=>{Nk(this,Uk,void 0),!(e.name===`AbortError`||e.type===`aborted`)&&Pk(this,Jk,nA).call(this,Dk(e))}),Mk(this,$k,e=>{typeof e.id==`string`&&Nk(this,Hk,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:jk(this,Lk)?jk(this,Lk).origin:jk(this,Ik).origin,lastEventId:e.id||``});jk(this,Kk)&&(!e.event||e.event===`message`)&&jk(this,Kk).call(this,t),this.dispatchEvent(t)}),Mk(this,eA,e=>{Nk(this,Bk,e)}),Mk(this,rA,()=>{Nk(this,Vk,void 0),jk(this,Fk)===this.CONNECTING&&Pk(this,Jk,Yk).call(this)});try{if(e instanceof URL)Nk(this,Ik,e);else if(typeof e==`string`)Nk(this,Ik,new URL(e,Nfe()));else throw Error(`Invalid URL`)}catch{throw Mfe(`An invalid or illegal string was specified`)}Nk(this,Wk,Dfe({onEvent:jk(this,$k),onRetry:jk(this,eA)})),Nk(this,Fk,this.CONNECTING),Nk(this,Bk,3e3),Nk(this,zk,t?.fetch??globalThis.fetch),Nk(this,Rk,t?.withCredentials??!1),Pk(this,Jk,Yk).call(this)}get readyState(){return jk(this,Fk)}get url(){return jk(this,Ik).href}get withCredentials(){return jk(this,Rk)}get onerror(){return jk(this,Gk)}set onerror(e){Nk(this,Gk,e)}get onmessage(){return jk(this,Kk)}set onmessage(e){Nk(this,Kk,e)}get onopen(){return jk(this,qk)}set onopen(e){Nk(this,qk,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){jk(this,Vk)&&clearTimeout(jk(this,Vk)),jk(this,Fk)!==this.CLOSED&&(jk(this,Uk)&&jk(this,Uk).abort(),Nk(this,Fk,this.CLOSED),Nk(this,Uk,void 0))}};Fk=new WeakMap,Ik=new WeakMap,Lk=new WeakMap,Rk=new WeakMap,zk=new WeakMap,Bk=new WeakMap,Vk=new WeakMap,Hk=new WeakMap,Uk=new WeakMap,Wk=new WeakMap,Gk=new WeakMap,Kk=new WeakMap,qk=new WeakMap,Jk=new WeakSet,Yk=function(){Nk(this,Fk,this.CONNECTING),Nk(this,Uk,new AbortController),jk(this,zk)(jk(this,Ik),Pk(this,Jk,Qk).call(this)).then(jk(this,Xk)).catch(jk(this,Zk))},Xk=new WeakMap,Zk=new WeakMap,Qk=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...jk(this,Hk)?{"Last-Event-ID":jk(this,Hk)}:void 0},cache:`no-store`,signal:jk(this,Uk)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},$k=new WeakMap,eA=new WeakMap,tA=function(e,t){var n;jk(this,Fk)!==this.CLOSED&&Nk(this,Fk,this.CLOSED);let r=new Ek(`error`,{code:t,message:e});(n=jk(this,Gk))==null||n.call(this,r),this.dispatchEvent(r)},nA=function(e,t){var n;if(jk(this,Fk)===this.CLOSED)return;Nk(this,Fk,this.CONNECTING);let r=new Ek(`error`,{code:t,message:e});(n=jk(this,Gk))==null||n.call(this,r),this.dispatchEvent(r),Nk(this,Vk,setTimeout(jk(this,rA),jk(this,Bk)))},rA=new WeakMap,iA.CONNECTING=0,iA.OPEN=1,iA.CLOSED=2;function Nfe(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}var Pfe=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},Ffe=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Vde(t?.fetch,t?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new pk(`No auth provider`);let e;try{e=await gk(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new pk;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=qO(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((t,n)=>{this._eventSource=new iA(this._url.href,{...this._eventSourceInit,fetch:async(t,n)=>{let r=await this._commonHeaders();r.set(`Accept`,`text/event-stream`);let i=await e(t,{...n,headers:r});if(i.status===401&&i.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=vk(i);this._resourceMetadataUrl=e,this._scope=t}return i}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{if(e.code===401&&this._authProvider){this._authThenStart().then(t,n);return}let r=new Pfe(e.code,e.message,e);n(r),this.onerror?.(r)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,e=>{let r=e;try{if(this._endpoint=new URL(r.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){n(e),this.onerror?.(e),this.close();return}t()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=ag.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new pk(`No auth provider`);if(await gk(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new pk(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=vk(r);if(this._resourceMetadataUrl=t,this._scope=n,await gk(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new pk;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},Ife=class extends Due{static{a(this,`SseConnectionManager`)}url;opts;_transport=null;reinitializing=!1;constructor(e,t){super(),this.url=typeof e==`string`?new URL(e):e,this.opts=t}async establishConnection(){let e=new Ffe(this.url,this.opts),t=e.send.bind(e);return e.send=async n=>{let r=a(async e=>{if(Array.isArray(e))for(let n of e)await t(n);else await t(e)},`sendMessage`);try{await r(n)}catch(t){if(t?.code===404&&e.sessionId&&!this.reinitializing){l.warn(`[SSE] Session not found (404), re-initializing per MCP spec...`),this.reinitializing=!0;try{e.sessionId=void 0,await this.reinitialize(e),l.debug(`[SSE] Re-initialization successful, retrying request`),await r(n)}finally{this.reinitializing=!1}}else throw t}},this._transport=e,l.debug(`${this.constructor.name} connected successfully`),e}async reinitialize(e){l.debug(`[SSE] Re-initialization triggered`)}async closeConnection(e){if(this._transport)try{await this._transport.close()}catch(e){l.warn(`Error closing SSE transport: ${e}`)}finally{this._transport=null}}},aA=class extends Eue{static{a(this,`HttpConnector`)}baseUrl;headers;timeout;sseReadTimeout;customFetch;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;reconnectionOptions;transportType=null;streamableTransport=null;constructor(e,t={}){super(t);let n=e.replace(/\/$/,``);this.gatewayUrl=t.gatewayUrl,this.serverId=t.serverId,this.gatewayUrl?(this.baseUrl=this.gatewayUrl.replace(/\/$/,``),this.headers={...t.headers??{}},this.headers[`X-Target-URL`]=n,this.serverId&&(this.headers[`X-Server-Id`]=this.serverId)):(this.baseUrl=n,this.headers={...t.headers??{}}),t.authToken&&(this.headers.Authorization=`Bearer ${t.authToken}`),this.timeout=t.timeout??1e4,this.sseReadTimeout=t.sseReadTimeout??3e5,this.customFetch=t.fetch,this.clientInfo=t.clientInfo??{name:`http-connector`,version:`1.0.0`},this.preferSse=t.preferSse??!1,this.disableSseFallback=t.disableSseFallback??!1,this.reconnectionOptions=t.reconnectionOptions}buildClientOptions(){return{...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.onSampling?{sampling:{}}:{},...this.opts.onElicitation??this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}}}unwrapStreamableError(e){return e instanceof Tk?e:e instanceof Error&&e.cause instanceof Tk?e.cause:null}classifyStreamableHttpFailure(e){let t=`Unknown error`,n=!1,r,i=this.unwrapStreamableError(e);if(i)return n=i.code===401,r=i.code,i.code===400&&i.message.includes(`Missing session ID`)?(t=`Server requires session ID (FastMCP compatibility) - using SSE transport`,l.warn(`\u26A0\uFE0F ${t}`)):i.code===404||i.code===405?(t=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,l.debug(t)):(t=`Server returned ${i.code}: ${i.message}`,l.debug(t)),{fallbackReason:t,is401Error:n,httpStatusCode:r};if(e instanceof Error){let r=e.toString(),i=e.message||``;n=r.includes(`401`)||i.includes(`Unauthorized`),r.includes(`Missing session ID`)||r.includes(`Bad Request: Missing session ID`)||i.includes(`FastMCP session ID error`)?(t=`Server requires session ID (FastMCP compatibility) - using SSE transport`,l.warn(`\u26A0\uFE0F ${t}`)):r.includes(`405 Method Not Allowed`)||r.includes(`404 Not Found`)?(t=`Server doesn't support streamable HTTP (405/404)`,l.debug(t)):(t=`Streamable HTTP failed: ${e.message}`,l.debug(t))}return{fallbackReason:t,is401Error:n,httpStatusCode:r}}async connect(){if(this.connected){l.debug(`Already connected to MCP implementation`);return}let e=this.baseUrl;if(this.preferSse){l.debug(`Connecting to MCP implementation via HTTP/SSE: ${e}`),await this.connectWithSse(e);return}l.debug(`Connecting to MCP implementation via HTTP: ${e}`);try{l.debug(`🔄 Attempting streamable HTTP transport...`),await this.connectWithStreamableHttp(e),l.debug(`✅ Successfully connected via streamable HTTP`)}catch(t){l.debug(`Streamable HTTP connect failed`,t);let{fallbackReason:n,is401Error:r,httpStatusCode:i}=this.classifyStreamableHttpFailure(t);if(r){l.info(`Authentication required - skipping SSE fallback`),await this.cleanupResources();let e=Error(`Authentication required`);throw e.code=401,e}if(this.disableSseFallback)throw l.info(`SSE fallback disabled - failing connection`),await this.cleanupResources(),Error(`Streamable HTTP connection failed: ${n}`);l.debug(`🔄 Falling back to SSE transport...`);try{await this.connectWithSse(e)}catch(e){if(l.error(`Failed to connect with both transports:`),l.error(` Streamable HTTP: ${n}`),l.error(` SSE: ${e}`),await this.cleanupResources(),e?.message?.includes(`401`)||e?.message?.includes(`Unauthorized`)){let e=Error(`Authentication required`);throw e.code=401,e}let t=Error(`Could not connect to server with any available transport. Streamable HTTP: ${n}`);throw i!==void 0&&(Object.defineProperty(t,`code`,{value:i,writable:!1,enumerable:!0,configurable:!0}),l.debug(`Preserving HTTP status code ${i} in error for proxy fallback detection`)),t}}}async connectWithStreamableHttp(e){try{l.debug(`[HttpConnector] Connecting with Streamable HTTP`,{baseUrl:e,originalUrl:this.baseUrl,gatewayUrl:this.gatewayUrl||`none`,authProviderUrl:this.opts.authProvider?.serverUrl||`none`,headers:this.headers});let t=new jfe(new URL(e),{authProvider:this.opts.authProvider,fetch:this.customFetch,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2,...this.reconnectionOptions}}),n=t;if(this.opts.wrapTransport){let e=this.baseUrl;n=this.opts.wrapTransport(n,e)}let r=this.buildClientOptions();l.debug(`Creating Client with capabilities:`,JSON.stringify(r.capabilities,null,2)),this.client=new Bde(this.clientInfo,r),this.setupRootsHandler(),l.debug(`Roots handler registered before connect`);try{await this.client.connect(n,{timeout:this.timeout});let e=t.sessionId;e?l.debug(`Session ID obtained: ${e}`):l.warn(`Session ID not available after connect - this may cause issues with SSE stream`)}catch(e){if(e instanceof Error){let t=e.message||e.toString();if(t.includes(`Missing session ID`)||t.includes(`Bad Request: Missing session ID`)||t.includes(`Mcp-Session-Id header is required`)){let n=Error(`Session ID error: ${t}. The SDK should automatically extract session ID from initialize response.`);throw n.cause=e,n}}throw e}this.streamableTransport=t,this.connectionManager={stop:a(async()=>{if(this.streamableTransport)try{await this.streamableTransport.close()}catch(e){l.warn(`Error closing Streamable HTTP transport: ${e}`)}finally{this.streamableTransport=null}},`stop`)},this.connected=!0,this.transportType=`streamable-http`,this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),l.debug(`Successfully connected to MCP implementation via streamable HTTP: ${e}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(e){throw await this.cleanupResources(),e}}async connectWithSse(e){try{this.connectionManager=new Ife(e,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let t=await this.connectionManager.start();if(this.opts.wrapTransport){let e=this.baseUrl;t=this.opts.wrapTransport(t,e)}let n=this.buildClientOptions();l.debug(`Creating Client with capabilities (SSE):`,JSON.stringify(n.capabilities,null,2)),this.client=new Bde(this.clientInfo,n),this.setupRootsHandler(),l.debug(`Roots handler registered before connect (SSE)`),await this.client.connect(t),this.connected=!0,this.transportType=`sse`,this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),l.debug(`Successfully connected to MCP implementation via HTTP/SSE: ${e}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (sse)`})}catch(e){throw await this.cleanupResources(),e}}get publicIdentifier(){return{type:`http`,url:this.baseUrl,transport:this.transportType||`unknown`}}getTransportType(){return this.transportType}async cleanupResources(){if(this.streamableTransport)try{await this.streamableTransport.terminateSession()}catch(e){l.debug(`Error terminating Streamable HTTP session: ${e}`)}await super.cleanupResources()}};function oA(e,t){return{onSampling:e?.onSampling??e?.samplingCallback??t?.onSampling??t?.samplingCallback,onElicitation:e?.onElicitation??e?.elicitationCallback??t?.onElicitation??t?.elicitationCallback,onNotification:e?.onNotification??t?.onNotification}}a(oA,`resolveCallbacks`);function sA(){return{name:`mcp-use`,title:`mcp-use`,version:rO(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}}a(sA,`getDefaultClientInfo`);function cA(e){let t=sA();if(!e||typeof e!=`object`)return t;let n=e;return!n.name||!n.version?t:{...t,...n}}a(cA,`normalizeClientInfo`);function Lfe(e,t){let n=cA(e.clientInfo);if(`command`in e&&`args`in e)throw Error(`Stdio connector is not supported in this environment. Stdio connections require Node.js and are only available in the Node.js MCPClient.`);if(`url`in e){let r=e.transport||`http`;return new aA(e.url,{headers:e.headers,fetch:e.fetch,authToken:e.auth_token||e.authToken,authProvider:e.authProvider,preferSse:e.preferSse||r===`sse`,disableSseFallback:e.disableSseFallback,clientInfo:n,...t})}throw Error(`Cannot determine connector type from config`)}a(Lfe,`createConnectorFromConfig`);var Rfe=class{static{a(this,`MCPSession`)}connector;autoConnect;constructor(e,t=!0){this.connector=e,this.autoConnect=t}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(e,t){e===`notification`&&this.connector.onNotification(t)}async setRoots(e){return this.connector.setRoots(e)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(e){return this.connector.listTools(e)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(e,t={},n){return this.connector.callTool(e,t,n)}async listResources(e,t){return this.connector.listResources(e,t)}async listAllResources(e){return this.connector.listAllResources(e)}async listResourceTemplates(e){return this.connector.listResourceTemplates(e)}async complete(e,t){return this.connector.complete(e,t)}async readResource(e,t){return this.connector.readResource(e,t)}async subscribeToResource(e,t){return this.connector.subscribeToResource(e,t)}async unsubscribeFromResource(e,t){return this.connector.unsubscribeFromResource(e,t)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(e,t){return this.connector.getPrompt(e,t)}async request(e,t=null,n){return this.connector.request(e,t,n)}},zfe=class{static{a(this,`BaseMCPClient`)}config={};sessions={};activeSessions=[];constructor(e){e&&(this.config=e)}static fromDict(e){throw Error(`fromDict must be implemented by concrete class`)}addServer(e,t){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[e]=t,_O.getInstance().trackClientAddServer(e,t)}removeServer(e){this.config.mcpServers?.[e]&&(delete this.config.mcpServers[e],this.activeSessions=this.activeSessions.filter(t=>t!==e),_O.getInstance().trackClientRemoveServer(e))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(e){return this.config.mcpServers?.[e]}getConfig(){return this.config??{}}async createSession(e,t=!0){let n=this.config.mcpServers??{};if(Object.keys(n).length===0&&l.warn(`No MCP servers defined in config`),!n[e])throw Error(`Server '${e}' not found in config`);let r=new Rfe(await Promise.resolve(this.createConnectorFromConfig(n[e])));return t&&await r.initialize(),this.sessions[e]=r,this.activeSessions.includes(e)||this.activeSessions.push(e),r}async createAllSessions(e=!0){let t=this.config.mcpServers??{};Object.keys(t).length===0&&l.warn(`No MCP servers defined in config`);for(let n of Object.keys(t))await this.createSession(n,e);return this.sessions}getSession(e){return this.sessions[e]||null}requireSession(e){let t=this.sessions[e];if(!t)throw Error(`Session '${e}' not found. Available sessions: ${this.activeSessions.join(`, `)||`none`}`);return t}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(e=>[e,this.sessions[e]]))}async closeSession(e){let t=this.sessions[e];if(!t){l.warn(`No session exists for server ${e}, nothing to close`);return}try{l.debug(`Closing session for server ${e}`),await t.disconnect()}catch(t){l.error(`Error closing session for server '${e}': ${t}`)}finally{delete this.sessions[e],this.activeSessions=this.activeSessions.filter(t=>t!==e)}}async closeAllSessions(){let e=Object.keys(this.sessions),t=[];for(let n of e)try{l.debug(`Closing session for server ${n}`),await this.closeSession(n)}catch(e){let r=`Failed to close session for server '${n}': ${e}`;l.error(r),t.push(r)}t.length?l.error(`Encountered ${t.length} errors while closing sessions`):l.debug(`All sessions closed successfully`)}};function lA(e){let t=Object.keys(e.mcpServers??{});_O.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(e=>l.debug(`Failed to track BrowserMCPClient init: ${e}`))}a(lA,`trackBrowserClientInit`);var Bfe=class e extends zfe{static{a(this,`BrowserMCPClient`)}static getPackageVersion(){return rO()}constructor(e){super(e),lA(this.config)}static fromDict(t){return new e(t)}createConnectorFromConfig(e){let{url:t,headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:o,clientOptions:s,disableSseFallback:c,preferSse:u,timeout:d,sseReadTimeout:f,gatewayUrl:p,serverId:m,reconnectionOptions:h}=e;if(!t)throw Error(`Server URL is required`);let g=this.config,_=oA(e,g),v=cA(e.clientInfo??this.config.clientInfo),y={headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:o,clientOptions:s,onSampling:_.onSampling,onElicitation:_.onElicitation,onNotification:_.onNotification,disableSseFallback:c,preferSse:u,timeout:d,sseReadTimeout:f,clientInfo:v,gatewayUrl:p,serverId:m,reconnectionOptions:h};return l.debug(`[BrowserMCPClient] Connector options prepared (clientOptions: ${s?`provided`:`none`})`),new aA(t,y)}};function uA(e){let t=a(()=>{throw Error(`Invalid url to pass to open(): ${e}`)},`abort`),n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(dA).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}a(uA,`sanitizeUrl`);function dA([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}a(dA,`sanitizeParam`);var Vfe=class{static{a(this,`LocalStorageKVStore`)}get(e){return localStorage.getItem(e)}set(e,t){localStorage.setItem(e,t)}remove(e){localStorage.removeItem(e)}keys(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&e.push(n)}return e}},Hfe=class e{static{a(this,`OAuthSessionStore`)}serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;scope;store;_cachedAuthServerUrl=null;_cachedMetadata=null;_refreshPromise=null;constructor(t,n,r){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=e.hashString(t),this.clientName=n.clientName||`mcp-use`,this.clientUri=n.clientUri||(typeof window<`u`?window.location.origin:``),this.logoUri=n.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=uA(n.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.scope=n.scope,this.store=r}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}static hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}get redirectUrl(){return this.callbackUrl}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri,...this.scope?{scope:this.scope}:{}}}async tokens(){let e=this.getKey(`tokens`),t=await this.store.get(e);if(t)try{let e=JSON.parse(t);if(e.access_token&&e.refresh_token)try{let t=JSON.parse(atob(e.access_token.split(`.`)[1]));if(t.exp&&Date.now()>=(t.exp-30)*1e3){console.log(`[tokens] Access token expiring soon, refreshing...`);let t=await this._dedupedRefresh(e);if(t)return console.log(`[tokens] Refreshed successfully`),t}}catch{}return e}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),await this.store.remove(e);return}}async saveTokens(e){await this.store.set(this.getKey(`tokens`),JSON.stringify(e)),await this.store.remove(this.getKey(`code_verifier`)),await this.store.remove(this.getKey(`last_auth_url`))}async clientInformation(){let e=this.getKey(`client_info`),t=await this.store.get(e);if(t)try{let n=JSON.parse(t),r=Array.isArray(n.redirect_uris)?n.redirect_uris:[];if(!(r.length===0||r.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),await this.store.remove(e),await this.store.remove(this.getKey(`tokens`)),await this.store.remove(this.getKey(`last_auth_url`));return}return n}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),await this.store.remove(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);await this.store.set(t,JSON.stringify(e))}async saveCodeVerifier(e){await this.store.set(this.getKey(`code_verifier`),e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=await this.store.get(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async invalidateCredentials(e){switch(e){case`all`:await this.store.remove(this.getKey(`tokens`)),await this.store.remove(this.getKey(`client_info`)),await this.store.remove(this.getKey(`code_verifier`)),await this.store.remove(this.getKey(`last_auth_url`));break;case`client`:await this.store.remove(this.getKey(`client_info`));break;case`tokens`:await this.store.remove(this.getKey(`tokens`));break;case`verifier`:await this.store.remove(this.getKey(`code_verifier`));break;default:break}}async storeAuthorizationState(e,t={}){let n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,i=await this.store.get(this.getKey(`code_verifier`)),a={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,codeVerifier:i||void 0,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,...t.extraProviderOptions??{}},flowType:t.flowType,returnUrl:t.returnUrl};e.searchParams.set(`state`,n);let o=uA(e.toString());return await this.store.set(r,JSON.stringify(a)),await this.store.set(this.getKey(`last_auth_url`),o),o}async _refresh(e){try{if(!this._cachedAuthServerUrl||!this._cachedMetadata){let e=(await bk(this.serverUrl)).authorization_servers?.[0];if(!e)return null;let t=await Sk(e);if(!t)return null;this._cachedAuthServerUrl=e,this._cachedMetadata=t}let t=await this.clientInformation();if(!t)return null;let n=await Ck(this._cachedAuthServerUrl,{metadata:this._cachedMetadata,clientInformation:t,refreshToken:e.refresh_token});return await this.saveTokens(n),n}catch{return null}}async _dedupedRefresh(e){if(this._refreshPromise)return this._refreshPromise;this._refreshPromise=this._refresh(e);try{return await this._refreshPromise}finally{this._refreshPromise=null}}async forceRefresh(){let e=await this.store.get(this.getKey(`tokens`));if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return t.refresh_token?this._dedupedRefresh(t):null}};async function fA(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}a(fA,`serializeBody`);var pA=class{static{a(this,`BrowserOAuthClientProvider`)}serverUrl;staticClientInfo;session;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;_lastOriginalResource=null;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.session=new Hfe(e,t,new Vfe),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.staticClientInfo=t.staticClientInfo,this.onPopupWindow=t.onPopupWindow}get storageKeyPrefix(){return this.session.storageKeyPrefix}get serverUrlHash(){return this.session.serverUrlHash}get clientName(){return this.session.clientName}get clientUri(){return this.session.clientUri}get logoUri(){return this.session.logoUri}get callbackUrl(){return this.session.callbackUrl}get scope(){return this.session.scope}getKey(e){return this.session.getKey(e)}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn(`[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation`);return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn(`[BrowserOAuthProvider] Fetch interceptor already installed`);return}let e=this.oauthProxyUrl,t=this.connectionUrl,n=this.serverUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${e}`),window.fetch=async(i,a)=>{let o=typeof i==`string`?i:i instanceof URL?i.toString():i.url;if(!(o.includes(`/.well-known/`)||o.match(/\/(register|token|authorize)$/)))return await r(i,a);try{let t=new URL(o),n=new URL(e);if(t.origin===n.origin&&(t.pathname.startsWith(n.pathname)||o.includes(`/inspector/api/oauth`)))return await r(i,a)}catch{}try{let i=o.includes(`/.well-known/`),s=i?`${e}/metadata?url=${encodeURIComponent(o)}`:`${e}/proxy`;if(console.log(`[OAuth Proxy] Routing ${i?`metadata`:`request`} through: ${s}`),i){let e={...a?.headers?Object.fromEntries(new Headers(a.headers)):{}};t&&(e[`X-Connection-URL`]=t);let i=new URL(s);n&&i.searchParams.set(`mcp_url`,n);let o=await r(i.toString(),{...a,method:`GET`,headers:e});try{if((o.headers.get(`content-type`)||``).includes(`application/json`)){let e=await o.clone().json(),t=e&&typeof e==`object`&&typeof e._original_resource==`string`?e._original_resource:null;t&&(this._lastOriginalResource=t)}}catch{}return o}let c=a?.body?await fA(a.body):void 0,l=await(await r(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:o,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:c})})).json();return new Response(JSON.stringify(l.body),{status:l.status,statusText:l.statusText,headers:new Headers(l.headers)})}catch(e){return console.error(`[OAuth Proxy] Request failed, falling back to direct fetch:`,e),await r(i,a)}}}restoreFetch(){this.originalFetch&&=(console.log(`[BrowserOAuthProvider] Restoring original fetch`),window.fetch=this.originalFetch,void 0)}get redirectUrl(){return this.session.redirectUrl}get clientMetadata(){return this.session.clientMetadata}tokens(){return this.session.tokens()}saveTokens(e){return this.session.saveTokens(e)}async clientInformation(){return this.staticClientInfo?this.staticClientInfo:this.session.clientInformation()}async saveClientInformation(e){if(!this.staticClientInfo)return this.session.saveClientInformation(e)}codeVerifier(){return this.session.codeVerifier()}saveCodeVerifier(e){return this.session.saveCodeVerifier(e)}invalidateCredentials(e){return this.session.invalidateCredentials(e)}async prepareAuthorizationUrl(e){return this.rewriteResourceIfLocalProxy(e),this.session.storeAuthorizationState(e,{extraProviderOptions:{oauthProxyUrl:this.oauthProxyUrl,connectionUrl:this.connectionUrl,...this.staticClientInfo?{staticClientInfo:this.staticClientInfo}:{},...this.scope?{scope:this.scope}:{}},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0})}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}rewriteResourceIfLocalProxy(e){let t=e.searchParams.get(`resource`),n=!!(t&&(t.includes(`/inspector/api/proxy`)||t.includes(`/api/proxy`)||t.includes(`localhost:3000`))),r=!!(t&&this.connectionUrl&&t===this.connectionUrl),i=!!(t&&(this._lastOriginalResource||this.serverUrl)&&(r||n)),a=this._lastOriginalResource||this.serverUrl;i&&a&&e.searchParams.set(`resource`,a)}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?uA(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}},mA=null;function hA(){if(typeof window>`u`)return!1;let e=window.name;return typeof e==`string`&&e.startsWith(`mcp_auth_`)}a(hA,`isMcpAuthPopupWindow`);var Ufe=`mcp_auth_callback`;function gA(e,t){if(typeof BroadcastChannel>`u`)return;let n=null;try{n=new BroadcastChannel(Ufe),n.postMessage(e?{type:`mcp_auth_callback`,success:!0}:{type:`mcp_auth_callback`,success:!1,error:t??`Unknown error`})}catch(e){console.warn(`[mcp-callback] Failed to broadcast auth callback over BroadcastChannel:`,e)}finally{n&&setTimeout(()=>{try{n?.close()}catch{}},0)}}a(gA,`broadcastAuthCallback`);function _A(e,t,n=`success`){if(!(typeof document>`u`))try{document.body.innerHTML=``;let r=document.createElement(`div`);r.style.fontFamily=`sans-serif`,r.style.padding=`20px`;let i=document.createElement(`h1`);i.textContent=e,r.appendChild(i);let a=document.createElement(`p`);n===`error`&&(a.style.color=`red`,a.style.backgroundColor=`#ffebeb`,a.style.border=`1px solid red`,a.style.padding=`10px`,a.style.borderRadius=`4px`),a.textContent=t,r.appendChild(a);let o=document.createElement(`p`);o.textContent=`You can close this window or `;let s=document.createElement(`a`);s.href=`#`,s.textContent=`click here to close`,s.onclick=e=>(e.preventDefault(),window.close(),!1),o.appendChild(s),o.appendChild(document.createTextNode(`.`)),r.appendChild(o),document.body.appendChild(r)}catch{}}a(_A,`renderCloseWindowMessage`);function Wfe(){return mA||(mA=vA(),mA)}a(Wfe,`onMcpAuthorization`);async function vA(){let e=new URLSearchParams(window.location.search),t=e.get(`code`),n=e.get(`state`),r=e.get(`error`),i=e.get(`error_description`),o=`[mcp-callback]`;console.log(`${o} Handling callback...`,{code:t,state:n,error:r,errorDescription:i});let s=null,c=null,l=null;try{if(!n)throw Error(`State parameter not found or invalid in callback query parameters.`);console.log(`[mcp-callback] Looking for state: ${n}`),console.log(`[mcp-callback] All localStorage keys:`,Object.keys(localStorage));let e=`mcp:auth:state_${n}`;if(localStorage.getItem(e))l=e,console.log(`[mcp-callback] Found state with default key: ${e}`);else{let e=`:state_${n}`;for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n&&n.endsWith(e)){l=n,console.log(`[mcp-callback] Found state with dynamic key: ${n}`);break}}}if(!l){let e=Object.keys(localStorage).filter(e=>e.includes(`state`));throw console.log(`[mcp-callback] State keys in storage:`,e),Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`)}let u=localStorage.getItem(l);if(!u)throw Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(u)}catch{throw Error(`Failed to parse stored OAuth state.`)}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(l),Error(`OAuth state has expired. Please try initiating authentication again.`);if(r){console.log(`${o} OAuth error received: ${r} - ${i||`No description`}`);let e=c.flowType===`redirect`,t=window.opener&&!window.opener.closed,n=hA(),s=a(e=>{console.log(`${o} Returning to: ${e}`),localStorage.removeItem(l);let t=new URL(e);t.searchParams.set(`auth_error`,r),i&&t.searchParams.set(`auth_error_description`,i),window.location.href=t.toString()},`redirectWithError`);if(t){window.opener.postMessage({type:`mcp_auth_callback`,success:!1,error:`${r}${i?`: ${i}`:``}`},window.location.origin),localStorage.removeItem(l),window.close();return}if(c.returnUrl&&(e||!n)){s(c.returnUrl);return}if(n){gA(!1,`${r}${i?`: ${i}`:``}`),localStorage.removeItem(l),_A(`Authentication Error`,`${r}${i?`: ${i}`:``}`,`error`);try{window.close()}catch{}return}throw Error(`OAuth error: ${r}${i?` - ${i}`:``}`)}if(!t)throw Error(`Authorization code not found in callback query parameters.`);if(!c.providerOptions)throw Error(`Stored state is missing required provider options.`);let{serverUrl:d,...f}=c.providerOptions,p=f.connectionUrl,m=!!(p&&/run\.mcp-use\.com|mcp-use\.run/.test(p)),h=m?p:void 0,g=f.oauthProxyUrl,_=h;if(!g&&_)try{let e=new URL(window.location.href);if(e.pathname.includes(`/oauth/callback`)){let t=e.pathname.replace(/\/oauth\/callback.*$/,``);(!t||t===``)&&(/run\.mcp-use\.com|mcp-use\.run/.test(_)?console.log(`${o} Gateway connection detected; skipping default /inspector OAuth proxy inference`):(t=`/inspector`,console.log(`${o} Callback at root /oauth/callback, using /inspector as base path for OAuth proxy`))),t&&(g=`${e.origin}${t}/api/oauth`),console.log(`${o} Inferred OAuth proxy URL from callback: ${g}`)}}catch(e){console.warn(`${o} Could not infer OAuth proxy URL:`,e)}console.log(`${o} Re-instantiating provider for server: ${d}`),s=new pA(d,{...f,oauthProxyUrl:g,connectionUrl:_});let v=`${f.storageKeyPrefix}_${c.serverUrlHash}_code_verifier`,y=c.codeVerifier||localStorage.getItem(v);if(y)localStorage.setItem(v,y),localStorage.setItem(s.getKey(`code_verifier`),y);else throw Error(`[${f.storageKeyPrefix}] Code verifier missing for OAuth state ${n}. Please restart authentication.`);g&&(console.log(`${o} Installing fetch interceptor for token exchange (proxy: ${g})`),s.installFetchInterceptor()),console.log(`${o} Calling SDK auth() to exchange code...`);let b=m&&_?_:d;console.log(`${o} Using SDK serverUrl: ${b} (connectionUrl: ${_||`none`})`);let x=await gk(s,{serverUrl:b,authorizationCode:t});if(x===`AUTHORIZED`){console.log(`${o} Authorization successful via SDK auth().`);let e=c.flowType===`redirect`,t=hA();if(e&&c.returnUrl)console.log(`${o} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(l),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${o} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:`mcp_auth_callback`,success:!0},window.location.origin),localStorage.removeItem(l),window.close();else if(t){console.log(`${o} Popup flow complete but opener was lost; broadcasting success and rendering close-window message.`),gA(!0),localStorage.removeItem(l),_A(`Authentication Successful!`,`You're authenticated. You can close this window and return to the app.`);try{window.close()}catch{}}else if(c.returnUrl)console.log(`${o} Popup flow without opener (top-level nav). Returning to: ${c.returnUrl}`),localStorage.removeItem(l),window.location.href=c.returnUrl;else{console.warn(`${o} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(l);let e=window.location.pathname.split(`/`).filter(Boolean),t=e.length>0&&e[e.length-1]===`callback`?`/`+e.slice(0,-2).join(`/`):`/`;window.location.href=t||`/`}}else throw console.warn(`${o} SDK auth() returned unexpected status: ${x}`),Error(`Unexpected result from authentication library: ${x}`)}catch(e){console.error(`${o} Error during OAuth callback handling:`,e);let t=e instanceof Error?e.message:String(e);window.opener&&!window.opener.closed?window.opener.postMessage({type:`mcp_auth_callback`,success:!1,error:t},window.location.origin):hA()&&gA(!1,t);try{document.body.innerHTML=``;let n=document.createElement(`div`);n.style.fontFamily=`sans-serif`,n.style.padding=`20px`;let r=document.createElement(`h1`);r.textContent=`Authentication Error`,n.appendChild(r);let i=document.createElement(`p`);i.style.color=`red`,i.style.backgroundColor=`#ffebeb`,i.style.border=`1px solid red`,i.style.padding=`10px`,i.style.borderRadius=`4px`,i.textContent=t,n.appendChild(i);let a=document.createElement(`p`);a.textContent=`You can close this window or `;let o=document.createElement(`a`);if(o.href=`#`,o.textContent=`click here to close`,o.onclick=e=>(e.preventDefault(),window.close(),!1),a.appendChild(o),a.appendChild(document.createTextNode(`.`)),n.appendChild(a),e instanceof Error&&e.stack){let t=document.createElement(`pre`);t.style.fontSize=`0.8em`,t.style.color=`#555`,t.style.marginTop=`20px`,t.style.whiteSpace=`pre-wrap`,t.textContent=e.stack,n.appendChild(t)}document.body.appendChild(n)}catch(e){console.error(`${o} Could not display error in callback window:`,e)}l&&localStorage.removeItem(l),s&&localStorage.removeItem(s.getKey(`last_auth_url`))}}a(vA,`doOnMcpAuthorization`);async function yA(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=vk(r);return{resourceMetadataUrl:i,scope:a}}a(yA,`probeAuthParams`);function bA(e,t){if(!e)throw Error(t)}a(bA,`assert`);function xA(e){return e===`localhost`||e===`127.0.0.1`||e.startsWith(`127.`)||e.startsWith(`192.168.`)||e.startsWith(`10.`)||e.startsWith(`172.`)}a(xA,`isLocalServer`);function SA(e){let t=e.split(`.`),n=[];for(let e=0;e<t.length-1;e++)n.push(t.slice(e).join(`.`));return n}a(SA,`getSubdomainLevels`);function CA(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}a(CA,`blobToBase64`);async function wA(e){console.debug(`[favicon-detector] Starting favicon detection for:`,e);try{let t;if(t=e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e.includes(`://`)?e.split(`://`)[1].split(`/`)[0]:e.split(`/`)[0],console.debug(`[favicon-detector] Extracted domain:`,t),xA(t))return console.debug(`[favicon-detector] Skipping local server:`,t),null;let n=SA(t);console.debug(`[favicon-detector] Domains to try:`,n);for(let e of n)try{let t=`https://favicon.tools.mcp-use.com/${e}?response=json`;console.debug(`[favicon-detector] Attempting to fetch favicon metadata for:`,e,`from:`,t);let n=new AbortController,r=setTimeout(()=>n.abort(),2e3);try{let i=await fetch(t,{signal:n.signal});if(clearTimeout(r),!i.ok){console.debug(`[favicon-detector] Fetch failed for`,e,`with status:`,i.status);continue}let a=await i.json();console.debug(`[favicon-detector] Retrieved favicon metadata for:`,e,`source:`,a.source);let o=a.url.replace(/^http:\/\//,`https://`),s=await fetch(o);if(!s.ok){console.debug(`[favicon-detector] Failed to fetch favicon image for`,e,`status:`,s.status);continue}let c=await s.blob(),l=await CA(c);if(a.source===`default`){console.debug(`[favicon-detector] Found default favicon for:`,e,`skipping and continuing to search for non-default`);continue}return console.debug(`[favicon-detector] Successfully retrieved non-default favicon for:`,e,`source:`,a.source,`size:`,c.size,`bytes`),l}catch(t){clearTimeout(r),console.debug(`[favicon-detector] Fetch error for`,e,`:`,t instanceof Error?t.message:String(t));continue}}catch(t){console.debug(`[favicon-detector] Error processing domain`,e,`:`,t instanceof Error?t.message:String(t));continue}return console.debug(`[favicon-detector] No non-default favicon found for:`,e,`returning null to show gradient fallback`),null}catch(e){return console.warn(`[favicon-detector] Error detecting favicon:`,e),null}}a(wA,`detectFavicon`);function TA(e,t){let n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn(`[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.`),!t?.proxyAddress)return{url:e,headers:n};let r=new URL(t.proxyAddress),i=new URL(e);return{url:`${r.origin}${r.pathname}${i.pathname}${i.search}`,headers:{"X-Target-URL":e,...n}}}a(TA,`applyProxyConfig`);var EA=`inspector-server`;function DA(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}a(DA,`deriveOAuthClientConfigFromClientInfo`);function OA(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`oauth discovery failed`)||t.includes(`oauth-authorization-server`)||t.includes(`not valid json`)||t.includes(`404`)&&(t.includes(`openid-configuration`)||t.includes(`oauth-protected-resources`)||t.includes(`oauth-authorization-url`)||t.includes(`register`))||t.includes(`invalid oauth error response`)&&t.includes(`not found`)}a(OA,`isOAuthDiscoveryFailure`);function kA(e){if(!e)return;let t=new URL(e),n=t.pathname.replace(/\/proxy\/?$/,``);return`${t.origin}${n}/oauth`}a(kA,`deriveOAuthProxyUrl`);function AA(e){let t=kA(e.gatewayUrl),n=new pA(e.effectiveOAuthUrl,{storageKeyPrefix:e.storageKeyPrefix,clientName:e.oauthClientConfig.name,clientUri:e.oauthClientConfig.uri,logoUri:e.oauthClientConfig.logo_uri||`https://mcp-use.com/logo.png`,callbackUrl:e.callbackUrl,preventAutoAuth:e.preventAutoAuth,useRedirectFlow:e.useRedirectFlow,oauthProxyUrl:t,connectionUrl:e.gatewayUrl,onPopupWindow:e.onPopupWindow,staticClientInfo:e.staticClientInfo,scope:e.scope});return t&&e.installFetchInterceptor&&n.installFetchInterceptor(),{provider:n,oauthProxyUrl:t}}a(AA,`createBrowserOAuthProvider`);function jA(e){let t=null,n=Date.now(),r=e.healthCheckIntervalMs??1e4,i=e.healthCheckTimeoutMs??3e4;return t=setInterval(a(async()=>{if(!e.isMountedRef.current||e.stateRef.current!==`ready`){t&&=(clearInterval(t),null);return}try{let t=e.gatewayUrl||e.url;if(!t)return;let r=e.getAuthHeaders?await e.getAuthHeaders():{},i=await fetch(t,{method:`HEAD`,headers:{...e.allHeaders,...r},signal:AbortSignal.timeout(5e3)});if(i.ok||i.status<500)n=Date.now();else throw Error(`Server returned ${i.status}`)}catch{let r=Date.now()-n;r>i&&(e.addLog(`warn`,`Connection appears to be broken (no response for ${Math.round(r/1e3)}s), attempting to reconnect...`),t&&=(clearInterval(t),null),e.autoReconnectRef.current&&e.isMountedRef.current&&(e.setState(`discovering`),e.addLog(`info`,`Auto-reconnecting to MCP server...`),setTimeout(()=>{e.isMountedRef.current&&e.stateRef.current===`discovering`&&e.connect()},typeof e.autoReconnectRef.current==`number`?e.autoReconnectRef.current:e.defaultReconnectDelay)))}},`checkConnectionHealth`),r),()=>{t&&=(clearInterval(t),null)}}a(jA,`startConnectionHealthMonitoring`);var MA=3e3,Gfe=5e3;function NA(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?uA(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,clientConfig:o={},authProvider:s,headers:u,customHeaders:d,proxyConfig:f,autoProxyFallback:p=!0,debug:m=!1,logLevel:h,autoRetry:g=!1,autoReconnect:_=MA,reconnectionOptions:v,transportType:y=`auto`,preventAutoAuth:b=!0,useRedirectFlow:x=!1,onPopupWindow:S,timeout:C=3e4,sseReadTimeout:T=3e5,wrapTransport:E,fetch:D,clientOptions:O,onNotification:k,onSampling:A,samplingCallback:j,onElicitation:M,elicitationCallback:N,oauth:P}=e,F=P?.clientId?.trim()||void 0,I=P?.clientSecret?.trim()||void 0,L=P?.scope?.trim()||void 0,ee=(0,w.useMemo)(()=>F?{client_id:F,...I?{client_secret:I}:{}}:void 0,[F,I]),te=(0,w.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=c.get(e);return h?n.level=h:m&&(n.level=`debug`),n},[t,h,m]),ne=u??d??{};d&&!u&&te.warn(`[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.`);let re=A??j;j&&!A&&te.warn(`[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.`);let R=M??N;N&&!M&&l.warn(`[useMcp] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`);let z=(0,w.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:rO(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}),[]),B=(0,w.useMemo)(()=>e.clientInfo?{...z,...e.clientInfo}:z,[e.clientInfo,z]),ie=(0,w.useMemo)(()=>DA(B),[B]),ae=(0,w.useMemo)(()=>o&&Object.keys(o).length>0?(te.warn(`[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo.`),{...ie,...o}):ie,[o,ie]),oe=(0,w.useMemo)(()=>p?typeof p==`boolean`?{enabled:p,proxyAddress:`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:p.enabled!==!1,proxyAddress:p.proxyAddress||`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:!1,proxyAddress:void 0},[p]),se=(0,w.useMemo)(()=>_===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:_===!0?{enabled:!0,initialDelay:MA,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof _==`number`?{enabled:!0,initialDelay:_,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:_.enabled!==!1,initialDelay:_.initialDelay??MA,healthCheckInterval:_.healthCheckInterval??1e4,healthCheckTimeout:_.healthCheckTimeout??3e4},[_]),ce=(0,w.useRef)(!1),[le,ue]=(0,w.useState)(f);(0,w.useEffect)(()=>{ue(f)},[f]);let{gatewayUrl:de,proxyHeaders:fe}=(0,w.useMemo)(()=>{let e=TA(t||``,f);return{gatewayUrl:f?.proxyAddress,proxyHeaders:e.headers}},[t,f]),pe=(0,w.useMemo)(()=>t||``,[t]),me=(0,w.useMemo)(()=>({...fe,...ne}),[fe,ne]),[he,ge]=(0,w.useState)(`discovering`),[_e,ve]=(0,w.useState)([]),[ye,be]=(0,w.useState)([]),[xe,Se]=(0,w.useState)([]),[Ce,we]=(0,w.useState)([]),[Te,Ee]=(0,w.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[De,Oe]=(0,w.useState)(),[ke,Ae]=(0,w.useState)(void 0),[je,Me]=(0,w.useState)([]),[Ne,Pe]=(0,w.useState)(void 0),[Fe,Ie]=(0,w.useState)(void 0),Le=(0,w.useRef)(null),Re=(0,w.useRef)(s??null),ze=(0,w.useRef)(null),Be=(0,w.useRef)(!1),Ve=(0,w.useRef)(!0),He=(0,w.useRef)(0),Ue=(0,w.useRef)(null),We=(0,w.useRef)(!1),Ge=(0,w.useRef)(he),Ke=(0,w.useRef)(_),qe=(0,w.useRef)(null),Je=(0,w.useRef)(null),Ye=(0,w.useRef)(null);(0,w.useEffect)(()=>{Ge.current=he,Ke.current=_},[he,_]),(0,w.useEffect)(()=>{Re.current=s??null},[s]);let V=(0,w.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t,i=`[useMcp] ${r}`;switch(e){case`error`:te.error(i);break;case`warn`:te.warn(i);break;case`info`:te.info(i);break;case`debug`:te.debug(i);break;default:te.info(i)}Ve.current&&Me(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[te]),Xe=(0,w.useCallback)(async(e=!1)=>{if(e||V(`info`,`Disconnecting...`),Be.current=!1,Ue.current&&clearTimeout(Ue.current),Ue.current=null,Le.current)try{let e=EA,t=Le.current.getSession(e);t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await Le.current.closeSession(e)}catch(t){e||V(`warn`,`Error closing session:`,t)}Le.current=null,Ve.current&&!e&&(ge(`discovering`),ve([]),be([]),Se([]),we([]),Ae(void 0),Pe(void 0))},[V]),Ze=(0,w.useCallback)((e,n)=>{V(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=oe.enabled&&!le?.proxyAddress,a=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),o=r===400;if(i&&(a||o||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return V(`info`,`Direct connection failed with ${a?`CORS error`:o?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),Le.current=null,s||(Re.current=null),V(`debug`,`Cleared client and auth provider for proxy fallback`),ue({proxyAddress:oe.proxyAddress}),Ve.current&&ge(`discovering`),setTimeout(()=>{Ve.current&&Je.current?.()},1e3),!0;if(Ve.current){V(`info`,`Setting state to FAILED:`,e),ge(`failed`),Ae(e);let t=Re.current?.getLastAttemptedAuthUrl?.();t&&(Pe(t),V(`info`,`Manual authentication URL may be available.`,t))}return Be.current=!1,t&&_O.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Re.current,hasSampling:!!re,hasElicitation:!!R}).catch(()=>{}),!1},[V,t,y,re,R,oe,le,s]),Qe=(0,w.useCallback)(async()=>{if(!n||!t){V(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(Be.current){V(`debug`,`Connection attempt already in progress.`);return}if(!Ve.current){V(`debug`,`Connect called after unmount, aborting.`);return}if(Be.current=!0,He.current+=1,Ae(void 0),Pe(void 0),qe.current=null,ge(`discovering`),V(`info`,`Connecting attempt #${He.current} to ${t}...`),!Re.current){let{provider:e,oauthProxyUrl:t}=AA({effectiveOAuthUrl:pe,storageKeyPrefix:i,oauthClientConfig:ae,callbackUrl:r,preventAutoAuth:b,useRedirectFlow:x,gatewayUrl:de,onPopupWindow:S,installFetchInterceptor:!0,staticClientInfo:ee,scope:L});Re.current=e,t&&V(`debug`,`OAuth proxy URL derived from gateway: ${t}`),V(`debug`,`BrowserOAuthClientProvider initialized with URL: ${pe}, proxy: ${t?`enabled`:`disabled`}, gateway: ${de?`enabled`:`disabled`}`)}Le.current?V(`debug`,`BrowserMCPClient already exists, reusing.`):(Le.current=new Bfe,V(`debug`,`BrowserMCPClient initialized in connect.`));let e=a(async n=>{if(!Ve.current)return V(`debug`,`Connection attempt aborted - component unmounted`),`failed`;V(`info`,`Attempting connection with transport: ${n}`),V(`debug`,`Client ref status at start of tryConnectWithTransport: ${Le.current?`initialized`:`NULL`}`);try{let e=EA,r={url:t,transport:n===`sse`?`http`:n,timeout:C,sseReadTimeout:T,disableSseFallback:y===`http`,preferSse:n===`sse`,clientInfo:B,...D&&{fetch:D},...O&&{clientOptions:O},...v?{reconnectionOptions:v}:_===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(de&&(r.gatewayUrl=de,V(`debug`,`Using proxy gateway: ${de} for target: ${t}`)),me&&Object.keys(me).length>0&&(r.headers=me),!Le.current){if(!Ve.current)return V(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw V(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}Le.current.addServer(e,{...r,authProvider:Re.current,onSampling:re,onElicitation:R,wrapTransport:E?n=>(V(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),E(n,t)):void 0});let i=await Le.current.createSession(e,!1);if(!Ve.current)return V(`debug`,`Connection aborted after session creation - component unmounted`),`failed`;if(i.on(`notification`,e=>{V(`debug`,`Notification received:`,e.method,e),k?.(e),e.method===`notifications/tools/list_changed`?(V(`info`,`Tools list changed, auto-refreshing...`),ot().catch(e=>{V(`warn`,`Auto-refresh tools failed:`,e)})):e.method===`notifications/resources/list_changed`?(V(`info`,`Resources list changed, auto-refreshing...`),st().catch(e=>V(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(V(`info`,`Prompts list changed, auto-refreshing...`),ct().catch(e=>V(`warn`,`Auto-refresh prompts failed:`,e)))}),await i.initialize(),!Ve.current)return V(`debug`,`Connection completed but component unmounted, aborting`),`failed`;if(V(`info`,`✅ Successfully connected to MCP server`),V(`info`,`Server info:`,i.connector.serverInfo),V(`info`,`Server capabilities:`,i.connector.serverCapabilities),!Ve.current)return V(`debug`,`Skipping state update - component unmounted`),`failed`;ge(`ready`),qe.current=n,se.enabled&&se.healthCheckInterval!==!1&&(i._healthCheckCleanup=jA({gatewayUrl:de,url:t,allHeaders:me,getAuthHeaders:a(async()=>{try{let e=await Re.current?.tokens?.();if(e?.access_token){let t=e.token_type||`bearer`;return{Authorization:`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.access_token}`}}}catch{}return{}},`getAuthHeaders`),isMountedRef:Ve,stateRef:Ge,autoReconnectRef:Ke,setState:ge,addLog:V,connect:Qe,defaultReconnectDelay:se.initialDelay,healthCheckIntervalMs:se.healthCheckInterval,healthCheckTimeoutMs:se.healthCheckTimeout})),_O.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Re.current,hasSampling:!!re,hasElicitation:!!R}).catch(()=>{}),ve(i.connector.tools||[]);let o=await i.connector.listAllResources();if(!Ve.current)return V(`debug`,`Connection aborted after listing resources - component unmounted`),`failed`;be(o.resources||[]);let s=await i.connector.listPrompts();if(!Ve.current)return V(`debug`,`Connection aborted after listing prompts - component unmounted`),`failed`;if(we(s.prompts||[]),i.connector.serverCapabilities?.resourceTemplates){let e=await i.connector.listResourceTemplates();if(!Ve.current)return V(`debug`,`Connection aborted after listing resource templates - component unmounted`),`failed`;Se(e.resourceTemplates||[])}else Se([]);let c=i.connector.serverInfo,l=i.connector.serverCapabilities;if(c){if(V(`debug`,`Server info:`,c),!Ve.current)return V(`debug`,`Skipping state update - component unmounted`),`failed`;Ee(c),ze.current=(async()=>{try{let e=c.icons;if(e&&Array.isArray(e)&&e.length>0){let t=e[0].src||e[0].url;if(t){V(`info`,`Server provided icon:`,t);let e=await(await fetch(t)).blob(),n=await new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)});return Ve.current&&(Ee(e=>e?{...e,icon:n}:void 0),V(`debug`,`Server icon converted to base64`)),n}}if(t){let e=await wA(t);if(!Ve.current)return V(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(e)return Ee(t=>t?{...t,icon:e}:void 0),V(`debug`,`Favicon detected and added to serverInfo`),e}return null}catch(e){return V(`debug`,`Icon loading failed (non-critical):`,e),null}})()}if(l){if(V(`debug`,`Server capabilities:`,l),!Ve.current)return V(`debug`,`Skipping state update - component unmounted`),`failed`;Oe(l)}if(Re.current){let e=await Re.current.tokens?.();if(!Ve.current)return V(`debug`,`Connection aborted after token fetch for auth tokens - component unmounted`),`failed`;if(e?.access_token){let t=e.expires_in?Date.now()+e.expires_in*1e3:void 0;if(!Ve.current)return V(`debug`,`Skipping state update - component unmounted`),`failed`;Ie({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope})}}return`success`}catch(r){let i=r,a=i?.message||String(r),o=OA(r),s=i.code===401||a.includes(`401`)||a.includes(`Unauthorized`);if(o&&ne&&Object.keys(ne).length>0)return Ze(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(o&&(!ne||Object.keys(ne).length===0))return Ze(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(s){if(o)return Ze(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(Re.current)if(V(`info`,`Authentication required. OAuth provider available.`),b){if(V(`info`,`Waiting for user to initiate authentication flow...`),Ve.current){ge(`pending_auth`);let e=Re.current?.getLastAttemptedAuthUrl?.();e&&(Pe(e),V(`info`,`Retrieved stored auth URL for manual authentication`))}return Be.current=!1,`auth_redirect`}else{V(`info`,`Triggering automatic OAuth authentication flow...`);try{let{resourceMetadataUrl:r,scope:i}=await yA(t);if(await gk(Re.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i}})===`REDIRECT`){let e=await Re.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await gk(Re.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i},authorizationCode:e})}return V(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return Ze(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return ne&&Object.keys(ne).length>0?(Ze(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(Ze(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return Ze(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},`tryConnectWithTransport`),o=`failed`;if(y===`sse`)V(`debug`,`Using SSE-only transport mode`),o=await e(`sse`);else if(y===`http`)V(`debug`,`Using HTTP-only transport mode`),o=await e(`http`);else{V(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);t===`fallback`&&Ve.current&&Ge.current!==`authenticating`?(V(`info`,`HTTP failed, attempting SSE fallback...`),o=await e(`sse`)):o=t}(o===`success`||o===`failed`||o===`auth_redirect`)&&(Be.current=!1),V(`debug`,`Connection sequence finished with status: ${o}`)},[V,Ze,Xe,t,i,r,ae.name,ae.version,ae.uri,ae.logo_uri,ee,L,ne,y,b,x,S,n,C,T,B,de,me,pe]);(0,w.useEffect)(()=>{Je.current=Qe,Ye.current=Ze},[Qe,Ze]);let $e=(0,w.useCallback)(async(e,t,n)=>{if(Ge.current!==`ready`||!Le.current)throw Error(`MCP client is not ready (current state: ${he}). Cannot call tool "${e}".`);V(`info`,`Calling tool: ${e}`,t);let r=Date.now();try{let i=EA,a=Le.current.getSession(i);if(!a)throw Error(`No active session found`);let o=await a.connector.callTool(e,t||{},n);return V(`info`,`Tool "${e}" call successful:`,o),_O.getInstance().trackUseMcpToolCall({toolName:e,success:!0,executionTimeMs:Date.now()-r}).catch(()=>{}),o}catch(t){throw V(`error`,`Tool "${e}" call failed:`,t),_O.getInstance().trackUseMcpToolCall({toolName:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`,executionTimeMs:Date.now()-r}).catch(()=>{}),t}},[he]),et=(0,w.useCallback)(()=>{Ge.current===`failed`?(V(`info`,`Retry requested...`),Je.current?.()):V(`warn`,`Retry called but state is not 'failed' (state: ${Ge.current}). Ignoring.`)},[V]),tt=(0,w.useCallback)(async()=>{V(`info`,`Manual authentication requested...`);let e=Ge.current;if(e===`failed`)V(`info`,`Attempting to reconnect and authenticate via retry...`),et();else if(e===`pending_auth`){V(`info`,`Proceeding with authentication from pending state...`);try{if(bA(Re.current,`Auth Provider not available for manual auth`),bA(t,`Server URL is required for authentication`),s){V(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t),n=e.origin+e.pathname.replace(/\/+$/,``);await gk(Re.current,{serverUrl:n}),Je.current?.();return}V(`info`,`Cleared ${Re.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),ge(`authenticating`);let{provider:e,oauthProxyUrl:n}=AA({effectiveOAuthUrl:pe,storageKeyPrefix:i,oauthClientConfig:ae,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,gatewayUrl:de,onPopupWindow:S,installFetchInterceptor:!de,staticClientInfo:ee,scope:L});n&&!de?V(`info`,`Installed OAuth fetch interceptor for manual auth`):n&&de&&V(`info`,`Using MCP gateway proxy for OAuth (no fetch interceptor needed)`),Re.current=e,V(`info`,`Triggering fresh OAuth authorization...`);let a=new URL(t),o=a.origin+a.pathname.replace(/\/+$/,``);try{await gk(e,{serverUrl:o}),V(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){V(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let c=e.getLastAttemptedAuthUrl?.();c&&(Pe(c),V(`info`,`Updated auth URL for fallback:`,c))}catch(e){if(!Ve.current)return;ge(`pending_auth`),V(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){V(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Re.current?.getLastAttemptedAuthUrl?.();e&&!Ne&&(Pe(e),V(`info`,`Manual authentication URL retrieved:`,e))}else V(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[V,et,Ne,t,x,S,i,ae.name,ae.uri,ae.logo_uri,ee,L,r,B,s]),nt=(0,w.useCallback)(()=>{Re.current?.clearStorage?(V(`info`,`Cleared ${Re.current.clearStorage()} item(s) from localStorage for ${t}.`),Pe(void 0),Xe()):V(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,V,Xe]),rt=(0,w.useCallback)(async()=>{if(Ge.current!==`ready`||!Le.current)throw Error(`MCP client is not ready (current state: ${he}). Cannot list resources.`);V(`info`,`Listing resources`);try{let e=EA,t=Le.current.getSession(e);if(!t)throw Error(`No active session found`);be((await t.connector.listAllResources()).resources||[]),V(`info`,`Resources listed successfully`)}catch(e){throw V(`error`,`List resources failed:`,e),e}},[he]),it=(0,w.useCallback)(async e=>{if(Ge.current!==`ready`||!Le.current)throw Error(`MCP client is not ready (current state: ${he}). Cannot read resource.`);V(`info`,`Reading resource: ${e}`);try{let t=EA,n=Le.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.connector.readResource(e);return V(`info`,`Resource read successful:`,r),_O.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!0}).catch(()=>{}),r}catch(t){throw V(`error`,`Resource read failed:`,t),_O.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`}).catch(()=>{}),t}},[he]),at=(0,w.useCallback)(async()=>{if(Ge.current!==`ready`||!Le.current)throw Error(`MCP client is not ready (current state: ${he}). Cannot list prompts.`);V(`info`,`Listing prompts`);try{let e=EA,t=Le.current.getSession(e);if(!t)throw Error(`No active session found`);we((await t.connector.listPrompts()).prompts||[]),V(`info`,`Prompts listed successfully`)}catch(e){throw V(`error`,`List prompts failed:`,e),e}},[he]),ot=(0,w.useCallback)(async()=>{if(Ge.current!==`ready`||!Le.current){V(`debug`,`Cannot refresh tools - client not ready. State:`,Ge.current);return}V(`debug`,`Refreshing tools list`);try{let e=EA,t=Le.current.getSession(e);if(!t){V(`warn`,`No active session found for tools refresh`);return}V(`debug`,`Calling listTools...`);let n=await t.connector.listTools();V(`debug`,`listTools returned:`,n?.length,`tools`),ve(n||[]),V(`info`,`Tools list refreshed successfully`)}catch(e){V(`error`,`Failed to refresh tools:`,e)}},[V]),st=(0,w.useCallback)(async()=>{if(Ge.current!==`ready`||!Le.current){V(`debug`,`Cannot refresh resources - client not ready`);return}V(`debug`,`Refreshing resources list`);try{let e=EA,t=Le.current.getSession(e);if(!t){V(`warn`,`No active session found for resources refresh`);return}be((await t.connector.listAllResources()).resources||[]),V(`info`,`Resources list refreshed successfully`)}catch(e){V(`warn`,`Failed to refresh resources:`,e)}},[V]),ct=(0,w.useCallback)(async()=>{if(Ge.current!==`ready`||!Le.current){V(`debug`,`Cannot refresh prompts - client not ready`);return}V(`debug`,`Refreshing prompts list`);try{let e=EA,t=Le.current.getSession(e);if(!t){V(`warn`,`No active session found for prompts refresh`);return}we((await t.connector.listPrompts()).prompts||[]),V(`info`,`Prompts list refreshed successfully`)}catch(e){V(`warn`,`Failed to refresh prompts:`,e)}},[V]),lt=(0,w.useCallback)(async()=>{if(Ge.current!==`ready`||!Le.current){V(`debug`,`Cannot refresh resource templates - client not ready`);return}V(`debug`,`Refreshing resource templates list`);try{let e=EA,t=Le.current.getSession(e);if(!t)throw Error(`No active session found`);let n=await t.connector.listResourceTemplates();Ve.current&&(Se(n.resourceTemplates||[]),V(`info`,`Resource templates refreshed: ${n.resourceTemplates?.length||0} templates`))}catch(e){throw V(`error`,`Failed to refresh resource templates:`,e),e}},[V]),ut=(0,w.useCallback)(async()=>{V(`info`,`Refreshing all lists (tools, resources, resource templates, prompts)`),await Promise.all([ot(),st(),lt(),ct()])},[ot,st,lt,ct,V]),dt=(0,w.useCallback)(async(e,t)=>{if(Ge.current!==`ready`||!Le.current)throw Error(`MCP client is not ready (current state: ${he}). Cannot get prompt.`);V(`info`,`Getting prompt: ${e}`,t);try{let n=EA,r=Le.current.getSession(n);if(!r)throw Error(`No active session found`);let i=await r.connector.getPrompt(e,t||{});return V(`info`,`Prompt "${e}" retrieved successfully:`,i),i}catch(t){throw V(`error`,`Prompt "${e}" retrieval failed:`,t),t}},[he,V]),ft=(0,w.useCallback)(async e=>{if(Ge.current!==`ready`||!Le.current)throw Error(`MCP client is not ready (current state: ${he}). Cannot request completion.`);V(`info`,`Requesting completions for ${e.ref.type===`ref/prompt`?`prompt`:`resource template`} "${e.ref.type===`ref/prompt`?e.ref.name:e.ref.uri}"`);try{let t=EA,n=Le.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.complete(e);return V(`info`,`Received ${r.completion.values.length} completion suggestions`),r}catch(e){throw V(`error`,`Completion request failed:`,e),e}},[he,V]);(0,w.useEffect)(()=>{let e=a((e,t)=>{V(`info`,`Received auth callback via ${t}.`,e),Ue.current&&clearTimeout(Ue.current),Ue.current=null,e?.success?(V(`info`,`Authentication successful via popup. Reconnecting client...`),Be.current&&V(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),Be.current=!1,setTimeout(()=>{Ve.current&&(V(`debug`,`Initiating reconnection after successful auth callback.`),Je.current?.())},100)):Ye.current?.(`Authentication failed in callback: ${e?.error||`Unknown reason.`}`)},`handleCallbackPayload`),t=a(t=>{t.origin===window.location.origin&&t.data?.type===`mcp_auth_callback`&&e(t.data,`postMessage`)},`messageHandler`);window.addEventListener(`message`,t),V(`debug`,`Auth callback message listener added.`);let n=null,r=a(t=>{t.data?.type===`mcp_auth_callback`&&e(t.data,`BroadcastChannel`)},`broadcastHandler`);if(typeof BroadcastChannel<`u`)try{n=new BroadcastChannel(`mcp_auth_callback`),n.addEventListener(`message`,r),V(`debug`,`Auth callback BroadcastChannel listener added.`)}catch(e){V(`warn`,`Failed to open auth callback BroadcastChannel; lost-opener popups will not reach this client.`,e),n=null}return()=>{if(window.removeEventListener(`message`,t),V(`debug`,`Auth callback message listener removed.`),n){try{n.removeEventListener(`message`,r),n.close()}catch{}V(`debug`,`Auth callback BroadcastChannel listener removed.`)}Ue.current&&clearTimeout(Ue.current)}},[V]),(0,w.useEffect)(()=>{ce.current=!1,ue(f)},[t,f]),(0,w.useEffect)(()=>{if(Ve.current=!0,!n||!t)return V(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),ge(`discovering`),()=>{Ve.current=!1};if(V(`debug`,`useMcp mounted, initiating connection.`),He.current=0,s)Re.current=s,V(`debug`,`Using externally provided authProvider`);else if(!Re.current||Re.current.serverUrl!==pe){let{provider:e,oauthProxyUrl:t}=AA({effectiveOAuthUrl:pe,storageKeyPrefix:i,oauthClientConfig:ae,callbackUrl:r,preventAutoAuth:b,useRedirectFlow:x,gatewayUrl:de,onPopupWindow:S,installFetchInterceptor:!0,staticClientInfo:ee,scope:L});Re.current=e,t&&V(`debug`,`OAuth proxy URL derived from gateway: ${t}`),V(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${pe}, proxy: ${t?`enabled`:`disabled`}, gateway: ${de?`enabled`:`disabled`}`)}return Qe(),()=>{if(Ve.current=!1,V(`debug`,`useMcp unmounting, disconnecting.`),Re.current?.restoreFetch?.(),(Ge.current===`authenticating`||Ge.current===`pending_auth`)&&Re.current)try{let e=Re.current.clearStorage?.()??0;e>0&&V(`debug`,`Cleared ${e} OAuth state item(s) during unmount to prevent corruption`)}catch(e){V(`debug`,`Error clearing OAuth state during unmount:`,e)}Xe(!0)}},[t,n,i,r,ae.name,ae.version,ae.uri,ae.logo_uri,ee,L,x,B,pe,f,s]);let pt=(0,w.useRef)(et),mt=(0,w.useRef)(V);(0,w.useEffect)(()=>{pt.current=et,mt.current=V},[et,V]),(0,w.useEffect)(()=>{let e=null;if(he===`failed`&&g&&He.current>0){if(!We.current){We.current=!0;let t=typeof g==`number`?g:Gfe;mt.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{We.current=!1,Ve.current&&Ge.current===`failed`&&pt.current()},t)}}else he!==`failed`&&(We.current=!1);return()=>{e&&(clearTimeout(e),We.current=!1)}},[he,g]);let ht=(0,w.useCallback)(async()=>Ge.current===`ready`?Te?.icon?Te.icon:ze.current?(V(`debug`,`Waiting for icon to finish loading...`),await ze.current):(V(`debug`,`No icon available and no loading in progress`),null):(V(`warn`,`Cannot ensure icon loaded - not connected`),null),[Te,V]);return{state:he,name:Te?.name||t||``,tools:_e,resources:ye,resourceTemplates:xe,prompts:Ce,serverInfo:Te,capabilities:De,error:ke,log:je,authUrl:Ne,authTokens:Fe,client:Le.current,callTool:$e,readResource:it,listResources:rt,listPrompts:at,getPrompt:dt,complete:ft,refreshTools:ot,refreshResources:st,refreshResourceTemplates:lt,refreshPrompts:ct,refreshAll:ut,retry:et,disconnect:Xe,authenticate:tt,clearStorage:nt,ensureIconLoaded:ht}}a(NA,`useMcp`);var PA=`__model_context`,FA=new Map;function IA(e){FA.set(e.id,e),zA()}a(IA,`setNode`);function LA(e){FA.delete(e),zA()}a(LA,`removeNode`);var RA=!1;function zA(){RA||(RA=!0,queueMicrotask(BA))}a(zA,`scheduleFlush`);function BA(){RA=!1,WA(VA())}a(BA,`flush`);function VA(){let e=new Map;for(let t of FA.values()){let n=t.parentId??null;e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let t of e.values())t.sort((e,t)=>e.id.localeCompare(t.id));let t=[];function n(r,i){let a=e.get(r);if(a)for(let e of a)e.content.trim()&&t.push(`${` `.repeat(i)}- ${e.content.trim()}`),n(e.id,i+1)}return a(n,`traverseTree`),n(null,0),t.join(`
|
|
450
450
|
`)}a(VA,`buildDescriptionString`);var HA=null;function UA(e){return HA=e,e(VA()),()=>{HA===e&&(HA=null)}}a(UA,`registerModelContextFlush`);function WA(e){HA?.(e)}a(WA,`notifyHost`);var GA=(0,w.createContext)(null);function Kfe({content:e,children:t}){let n=(0,w.useContext)(GA),r=(0,w.useId)();return(0,w.useEffect)(()=>(e.trim()&&IA({id:r,parentId:n,content:e}),()=>{LA(r)}),[r,n,e]),t==null?null:w.createElement(GA.Provider,{value:r},t)}a(Kfe,`ModelContext`);var qfe=c.get(`ErrorBoundary`),Jfe=class extends w.Component{static{a(this,`ErrorBoundary`)}constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){qfe.error(`Widget Error:`,e,t),this.props.onError?.(e,t)}render(){return this.state.hasError&&this.state.error?this.props.fallback===void 0?w.createElement(`div`,{className:`p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100`},w.createElement(`h3`,{className:`font-bold mb-2`},`Widget Error`),w.createElement(`pre`,{className:`text-sm whitespace-pre-wrap`},this.state.error.message)):typeof this.props.fallback==`function`?this.props.fallback(this.state.error):this.props.fallback:this.props.children}};function KA(e,t){return{jsonrpc:`2.0`,method:e,...t&&{params:t}}}a(KA,`createNotification`);function qA(e,t,n){return{jsonrpc:`2.0`,id:e,method:t,...n&&{params:n}}}a(qA,`createRequest`);var Yfe={POLL_INTERVAL:100,MAX_TIMEOUT:5e3,MAX_HEIGHT:600,LOCALE:`en`},JA={REQUEST_TIMEOUT:3e4,APP_NAME:`mcp-use-widget`,APP_VERSION:`1.0.0`,PROTOCOL_VERSION:`2025-06-18`},Xfe=class{static{a(this,`McpAppsBridge`)}connected=!1;connectPromise=null;requestId=1;pendingRequests=new Map;listeners=new Set;toolInput=null;partialToolInput=null;toolOutput=null;toolResponseMetadata=null;hostContext=null;hostInfo=null;hostCapabilities=null;initialized=!1;toolInputHandlers=new Set;toolInputPartialHandlers=new Set;toolResultHandlers=new Set;hostContextHandlers=new Set;constructor(){if(typeof window>`u`)return;let e=a(e=>{let t=e.data;if(!(!t||t.jsonrpc!==`2.0`)){if(`result`in t||`error`in t){let e=t;if(e.id!==null&&e.id!==void 0){let t=this.pendingRequests.get(e.id);t&&(this.pendingRequests.delete(e.id),`error`in e&&e.error?t.reject(Error(e.error.message)):t.resolve(e.result))}return}`method`in t&&!(`id`in t)&&this.handleNotification(t)}},`handleMessage`);window.addEventListener(`message`,e),this.listeners.add(e),this.interceptConsole()}interceptConsole(){if(typeof window>`u`||typeof console>`u`)return;let e={log:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)},t={log:`info`,warn:`warning`,error:`error`,info:`info`,debug:`debug`},n=a((e,t=new WeakSet)=>{if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(e instanceof Response)return{__type:`Response`,status:e.status,statusText:e.statusText,ok:e.ok,url:e.url,headers:Object.fromEntries(e.headers.entries())};if(e instanceof Request)return{__type:`Request`,method:e.method,url:e.url,headers:Object.fromEntries(e.headers.entries())};if(e instanceof Error)return{__type:`Error`,name:e.name,message:e.message,stack:e.stack};if(e instanceof Event)return{__type:`Event`,type:e.type,target:e.target?.constructor?.name};if(typeof HTMLElement<`u`&&e instanceof HTMLElement)return{__type:`HTMLElement`,tagName:e.tagName,id:e.id,className:e.className};if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;if(Array.isArray(e))return t.add(e),e.map(e=>n(e,t));try{t.add(e);let r={};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i))try{r[i]=n(e[i],t)}catch{r[i]=`[Unserializable]`}return r}catch{return`[Object]`}},`serializeForPostMessage`),r=a((r,i)=>{try{let e=i.map(e=>n(e));this.sendNotification(`notifications/message`,{level:t[r]||`info`,logger:`console`,data:e.length===1?e[0]:e})}catch(t){e.warn(`[MCP Apps Bridge] Failed to forward console message:`,t)}},`sendLog`);console.log=(...t)=>{r(`log`,t),e.log(...t)},console.warn=(...t)=>{r(`warn`,t),e.warn(...t)},console.error=(...t)=>{r(`error`,t),e.error(...t)},console.info=(...t)=>{r(`info`,t),e.info(...t)},console.debug=(...t)=>{r(`debug`,t),e.debug(...t)}}handleNotification(e){switch(console.log(`[MCP Apps Bridge] Received notification:`,e.method,e.params),e.method){case`ui/notifications/tool-input`:{let t=e.params;console.log(`[MCP Apps Bridge] Tool input received:`,t.arguments),this.toolInput=t.arguments,this.toolInputHandlers.forEach(e=>e(t.arguments));break}case`ui/notifications/tool-input-partial`:{let t=e.params;console.log(`[MCP Apps Bridge] Partial tool input received:`,t.arguments),this.partialToolInput=t.arguments,this.toolInputPartialHandlers.forEach(e=>e(t.arguments));break}case`ui/notifications/tool-result`:{let t=e.params,n=t.structuredContent||this.parseTextContent(t),r=t._meta||null;this.toolOutput=n,this.toolResponseMetadata=r,this.partialToolInput=null,this.toolResultHandlers.forEach(e=>e(n));break}case`ui/notifications/host-context-changed`:{let t=e.params;console.log(`[MCP Apps Bridge] Host context changed:`,t),this.hostContext={...this.hostContext,...t},console.log(`[MCP Apps Bridge] Merged hostContext:`,this.hostContext),console.log(`[MCP Apps Bridge] Calling handlers:`,this.hostContextHandlers.size),this.hostContextHandlers.forEach(e=>e(this.hostContext));break}case`ui/notifications/initialized`:this.initialized=!0;break;default:break}}parseTextContent(e){if(e.content&&Array.isArray(e.content)){for(let t of e.content)if(t.type===`text`&&t.text)try{let e=JSON.parse(t.text);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{}}return{}}sendRequest(e,t){if(typeof window>`u`||!window.parent)return Promise.reject(Error(`Not in iframe context`));let n=this.requestId++,r=qA(n,e,t);return new Promise((t,i)=>{this.pendingRequests.set(n,{resolve:t,reject:i}),window.parent.postMessage(r,`*`),setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),i(Error(`Request timeout: ${e}`)))},JA.REQUEST_TIMEOUT)})}sendNotification(e,t){if(typeof window>`u`||!window.parent)return;let n=KA(e,t);window.parent.postMessage(n,`*`)}async connect(){if(!this.connected){if(typeof window>`u`||window===window.parent){console.log(`[MCP Apps Bridge] Not in iframe, skipping connection`);return}return this.connectPromise||(this.connectPromise=this.doConnect(),this.connectPromise.catch(()=>{this.connectPromise=null})),this.connectPromise}}async doConnect(){console.log(`[MCP Apps Bridge] Connecting to MCP Apps host...`);try{let e=await this.sendRequest(`ui/initialize`,{appCapabilities:{},appInfo:{name:JA.APP_NAME,version:JA.APP_VERSION},protocolVersion:JA.PROTOCOL_VERSION});console.log(`[MCP Apps Bridge] Initialize result:`,e),e.hostContext&&(this.hostContext=e.hostContext,console.log(`[MCP Apps Bridge] Host context:`,this.hostContext)),e.hostInfo&&(this.hostInfo=e.hostInfo),e.hostCapabilities&&(this.hostCapabilities=e.hostCapabilities),this.sendNotification(`ui/notifications/initialized`,{}),this.connected=!0,console.log(`[MCP Apps Bridge] Successfully connected`)}catch(e){throw console.error(`[MCP Apps Bridge] Failed to connect:`,e),e}}isConnected(){return this.connected}getToolInput(){return this.toolInput}getPartialToolInput(){return this.partialToolInput}getToolOutput(){return this.toolOutput}getToolResponseMetadata(){return this.toolResponseMetadata}getHostContext(){return this.hostContext}getHostInfo(){return this.hostInfo}getHostCapabilities(){return this.hostCapabilities}onToolInput(e){return this.toolInputHandlers.add(e),()=>this.toolInputHandlers.delete(e)}onToolInputPartial(e){return this.toolInputPartialHandlers.add(e),()=>this.toolInputPartialHandlers.delete(e)}onToolResult(e){return this.toolResultHandlers.add(e),()=>this.toolResultHandlers.delete(e)}onHostContextChange(e){return this.hostContextHandlers.add(e),()=>this.hostContextHandlers.delete(e)}async callTool(e,t){return this.sendRequest(`tools/call`,{name:e,arguments:t})}async sendMessage(e){let t=Array.isArray(e)?e:[e];await this.sendRequest(`ui/message`,{role:`user`,content:t})}async openLink(e){await this.sendRequest(`ui/open-link`,{url:e})}async requestDisplayMode(e){return await this.sendRequest(`ui/request-display-mode`,{mode:e})}async updateModelContext(e){await this.sendRequest(`ui/update-model-context`,e)}sendSizeChanged(e){this.sendNotification(`ui/notifications/size-changed`,e)}disconnect(){this.listeners.forEach(e=>{typeof window<`u`&&window.removeEventListener(`message`,e)}),this.listeners.clear(),this.pendingRequests.clear(),this.toolInputHandlers.clear(),this.toolInputPartialHandlers.clear(),this.toolResultHandlers.clear(),this.hostContextHandlers.clear(),this.connected=!1,this.connectPromise=null}},YA=null;function XA(){return YA||=new Xfe,YA}a(XA,`getMcpAppsBridge`);function ZA(e){if(e&&typeof e==`object`&&`result`in e)return e;let t=e?.content||[],n=e?.structuredContent||{},r=t.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
|
|
451
451
|
`);return{content:t,structuredContent:n,isError:e?.isError??!1,result:r,_meta:e?._meta}}a(ZA,`normalizeCallToolResponse`);var QA=`openai:set_globals`;function $A(e){return(0,w.useSyncExternalStore)(t=>{let n=typeof window<`u`&&window.openai?window.openai[e]:void 0,r=a(r=>{let i=r.detail.globals[e];i!==void 0&&i!==n&&(n=i,t())},`handleSetGlobal`);return typeof window<`u`&&window.addEventListener(QA,r),()=>{typeof window<`u`&&window.removeEventListener(QA,r)}},()=>typeof window<`u`&&window.openai?window.openai[e]:void 0)}a($A,`useOpenAiGlobal`);function ej(e){let[t,n]=(0,w.useState)(()=>typeof window<`u`&&!!window.openai),[r,i]=(0,w.useState)(!1),[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(null),[u,d]=(0,w.useState)(null),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(null),[g,_]=(0,w.useState)(null),[v,y]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(typeof window<`u`&&window.openai){n(!0);return}let e=setInterval(()=>{typeof window<`u`&&window.openai&&(n(!0),clearInterval(e))},100),t=a(()=>{typeof window<`u`&&window.openai&&(n(!0),clearInterval(e))},`handleSetGlobals`);typeof window<`u`&&window.addEventListener(QA,t);let r=setTimeout(()=>{clearInterval(e),typeof window<`u`&&window.removeEventListener(QA,t)},5e3);return()=>{clearInterval(e),clearTimeout(r),typeof window<`u`&&window.removeEventListener(QA,t)}},[]),(0,w.useEffect)(()=>{if(typeof window>`u`||window.openai||window===window.parent)return;let e=XA();e.connect().then(()=>{i(!0);let t=e.getToolInput(),n=e.getToolOutput(),r=e.getToolResponseMetadata(),a=e.getHostContext(),o=e.getPartialToolInput();t&&s(t),n&&l(n),r&&d(r),o&&p(o),a&&h(a);let c=e.getHostInfo(),u=e.getHostCapabilities();c&&_(c),u&&y(u)}).catch(e=>{console.warn(`[useWidget] Failed to connect to MCP Apps host:`,e)});let t=e.onToolInput(e=>{s(e)}),n=e.onToolInputPartial(e=>{p(e)}),r=e.onToolResult(t=>{l(t),d(e.getToolResponseMetadata()),p(null)}),a=e.onHostContextChange(e=>{console.log(`[useWidget] Host context change received:`,e),h(e)});return()=>{t(),n(),r(),a()}},[]);let b=(0,w.useMemo)(()=>t?`openai`:r?`mcp-apps`:`mcp-ui`,[t,r]),x=typeof window<`u`?window.location.search:``,S=(0,w.useMemo)(()=>{let e=new URLSearchParams(x);return e.has(`mcpUseParams`)?JSON.parse(e.get(`mcpUseParams`)):{toolInput:{},toolOutput:{},toolId:``}},[x]),C=$A(`toolInput`),T=$A(`toolOutput`),E=$A(`toolResponseMetadata`),D=$A(`widgetState`),O=$A(`theme`),k=$A(`displayMode`),A=$A(`safeArea`),j=$A(`maxHeight`),M=$A(`userAgent`),N=$A(`locale`),P=(0,w.useMemo)(()=>b===`openai`?C:b===`mcp-apps`?o:S.toolInput,[b,C,o,S.toolInput]),F=(0,w.useMemo)(()=>{if(b===`openai`){let e=T;return e&&e.structuredContent&&typeof e.structuredContent==`object`?e.structuredContent:T}return b===`mcp-apps`?c:S.toolOutput},[b,T,c,S.toolOutput]),I=(0,w.useMemo)(()=>{let t=P||{},n=e||{},r;if(b===`openai`&&T){let e=T;r=e.structuredContent&&typeof e.structuredContent==`object`?e.structuredContent:e}else b===`mcp-apps`&&c?r=c:b===`mcp-ui`&&S.toolOutput&&(r=S.toolOutput);return{...n,...t,...r||{}}},[b,P,T,c,S.toolOutput,e]),L=(0,w.useMemo)(()=>{if(b===`openai`)return O;if(b===`mcp-apps`&&m)return m.theme},[b,O,m]),ee=(0,w.useMemo)(()=>{if(b===`openai`)return k;if(b===`mcp-apps`&&m)return m.displayMode},[b,k,m]),te=(0,w.useMemo)(()=>{if(b===`openai`)return A;if(b===`mcp-apps`&&m?.safeAreaInsets)return{insets:m.safeAreaInsets}},[b,A,m]),ne=(0,w.useMemo)(()=>{if(b===`openai`)return j;if(b===`mcp-apps`&&m?.containerDimensions)return m.containerDimensions.maxHeight},[b,j,m]),re=(0,w.useMemo)(()=>{if(b!==`openai`&&b===`mcp-apps`&&m?.containerDimensions)return m.containerDimensions.maxWidth},[b,m]),R=(0,w.useMemo)(()=>{if(b===`openai`)return M;if(b===`mcp-apps`&&m)return{device:{type:m.platform===`mobile`?`mobile`:`desktop`},capabilities:{hover:m.deviceCapabilities?.hover??!1,touch:m.deviceCapabilities?.touch??!1}}},[b,M,m]),z=(0,w.useMemo)(()=>{if(b===`openai`)return N;if(b===`mcp-apps`&&m)return m.locale},[b,N,m]),B=(0,w.useMemo)(()=>{if(b===`openai`)return typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0;if(b===`mcp-apps`&&m)return m.timeZone},[b,m]),ie=(0,w.useMemo)(()=>typeof window<`u`&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,``):``,[]),[ae,oe]=(0,w.useState)(null);(0,w.useEffect)(()=>{D!==void 0&&oe(D)},[D]);let se=(0,w.useRef)(b);se.current=b;let ce=(0,w.useRef)(ae);ce.current=ae,(0,w.useEffect)(()=>UA(e=>{let t=se.current;if(t===`mcp-apps`){let t=XA();t.isConnected()&&t.updateModelContext({structuredContent:{[PA]:e},content:[{type:`text`,text:e}]}).catch(e=>{console.warn(`[ModelContext] Failed to update model context:`,e)});return}if(t===`openai`&&window.openai?.setWidgetState){let t=window.openai.widgetState??ce.current??{};window.openai.setWidgetState({...t,[PA]:e}).catch(e=>{console.warn(`[ModelContext] Failed to set widget state:`,e)})}}),[]);let le=(0,w.useCallback)(async(e,t)=>{if(b===`mcp-apps`)return ZA(await XA().callTool(e,t));if(!window.openai?.callTool)throw Error(`window.openai.callTool is not available`);return ZA(await window.openai.callTool(e,t))},[b]),ue=(0,w.useCallback)(async e=>{let t=typeof e==`string`?[{type:`text`,text:e}]:e;if(b===`mcp-apps`){await XA().sendMessage(t);return}if(!window.openai?.sendFollowUpMessage)throw Error(`window.openai.sendFollowUpMessage is not available`);let n=typeof e==`string`?e:t.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
452
|
-
`);return window.openai.sendFollowUpMessage({prompt:n})},[b]),de=(0,w.useCallback)(e=>{if(b===`mcp-apps`){XA().openLink(e).catch(e=>{console.error(`Failed to open link:`,e)});return}if(!window.openai?.openExternal)throw Error(`window.openai.openExternal is not available`);window.openai.openExternal({href:e})},[b]),fe=(0,w.useCallback)(async e=>{if(b===`mcp-apps`)return await XA().requestDisplayMode(e);if(!window.openai?.requestDisplayMode)throw Error(`window.openai.requestDisplayMode is not available`);return window.openai.requestDisplayMode({mode:e})},[b]),pe=(0,w.useCallback)(async e=>{if(b===`mcp-apps`){let t=typeof e==`function`?e(ae):e;oe(t);let n=XA(),r=t;n.updateModelContext({structuredContent:r,content:[{type:`text`,text:JSON.stringify(Object.fromEntries(Object.entries(r).filter(([e])=>e!==PA)))}]}).catch(e=>{console.warn(`[useWidget] Failed to update model context:`,e)});return}if(!window.openai?.setWidgetState)throw Error(`window.openai.setWidgetState is not available`);let t=typeof e==`function`?e(D===void 0?ae:D):e,n=(window.openai.widgetState??{})[PA];return oe(t),window.openai.setWidgetState(n===void 0?t:{...t,[PA]:n})},[b,D,ae]),me=(0,w.useMemo)(()=>b===`openai`?T===null&&E===null:b===`mcp-apps`?c===null:b===`mcp-ui`?typeof window<`u`&&window!==window.parent&&!S.toolId?!0:F==null:!1,[b,T,E,c,F,S.toolId]),he=(0,w.useMemo)(()=>b===`mcp-apps`&&f?f:null,[b,f]),ge=(0,w.useMemo)(()=>b===`mcp-apps`?f!==null:!1,[b,f]);return{props:I,toolInput:P||{},output:F??null,metadata:b===`mcp-apps`?u??null:E??null,state:ae?Object.fromEntries(Object.entries(ae).filter(([e])=>e!==PA)):null,setState:pe,theme:L||`light`,displayMode:ee||`inline`,safeArea:te||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:ne||600,maxWidth:re,userAgent:R||{device:{type:`desktop`},capabilities:{hover:!0,touch:!1}},locale:z||Yfe.LOCALE,timeZone:B||(typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:`UTC`),mcp_url:ie,callTool:le,sendFollowUpMessage:ue,openExternal:de,requestDisplayMode:fe,isAvailable:t||r,isPending:me,partialToolInput:he,isStreaming:ge,hostInfo:g??void 0,hostCapabilities:v??void 0}}a(ej,`useWidget`);function Zfe(e){let{props:t}=ej(e);return t}a(Zfe,`useWidgetProps`);function Qfe(){let{theme:e}=ej();return e}a(Qfe,`useWidgetTheme`);function $fe(e){let{state:t,setState:n}=ej();return(0,w.useEffect)(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}a($fe,`useWidgetState`);var epe=a(({children:e,colorScheme:t=!1})=>{let{theme:n,isAvailable:r}=ej(),[i,o]=(0,w.useState)(()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);(0,w.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=a(e=>{o(e.matches?`dark`:`light`)},`handleChange`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let s=r?n:i;return(0,w.useLayoutEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(s===`dark`?`dark`:`light`),e.setAttribute(`data-theme`,s===`dark`?`dark`:`light`),t?e.style.colorScheme=s===`dark`?`dark`:`light`:e.style.colorScheme=``},[s,t]),w.createElement(w.Fragment,null,e)},`ThemeProvider`);function tj({children:e,className:t=``,position:n=`top-right`,attachTo:r,showLabels:i=!0,debugger:o=!1,viewControls:s=!1}){let{props:c,output:l,metadata:u,state:d,theme:f,displayMode:p,safeArea:m,maxHeight:h,userAgent:g,locale:_,isAvailable:v,callTool:y,sendFollowUpMessage:b,openExternal:x,requestDisplayMode:S,setState:C}=ej(),[T,E]=(0,w.useState)(!1),[D,O]=(0,w.useState)(!1),k=(0,w.useRef)(null),A=(0,w.useRef)(null),[j,M]=(0,w.useState)([]),[N,P]=(0,w.useState)(``),[F,I]=(0,w.useState)(`get-my-city`),[L,ee]=(0,w.useState)(`{}`),[te,ne]=(0,w.useState)(`Test follow-up message`),[re,R]=(0,w.useState)(`https://mcp-use.com/docs`),z=p===`fullscreen`&&v,B=p===`pip`&&v,ie=typeof window<`u`&&window.location.pathname.includes(`/inspector/api/`);(0,w.useEffect)(()=>{let e=setTimeout(()=>{if(typeof window<`u`&&window.openai)try{M(Object.keys(window.openai))}catch{M([])}else M([])},100);return()=>{clearTimeout(e)}},[]);let ae=f===`dark`,oe=a(()=>{let e=[`absolute`,`z-[1000]`,`flex`,`gap-2`,`transition-opacity`,`duration-200`,`ease-in-out`,T?`opacity-100`:`opacity-0`,T?`pointer-events-auto`:`pointer-events-none`];switch(n){case`top-left`:return[...e,`top-4`,`left-4`];case`top-center`:return[...e,`top-4`,`left-1/2`,`-translate-x-1/2`];case`top-right`:return[...e,`top-4`,`right-4`];case`center-left`:return[...e,`top-1/2`,`left-4`,`-translate-y-1/2`];case`center-right`:return[...e,`top-1/2`,`right-4`,`-translate-y-1/2`];case`bottom-left`:return[...e,`bottom-4`,`left-4`];case`bottom-center`:return[...e,`bottom-4`,`left-1/2`,`-translate-x-1/2`];case`bottom-right`:return[...e,`bottom-4`,`right-4`];default:return[...e,`top-4`,`right-4`]}},`getPositionClasses`),se=a(()=>{let e=m?.insets?.top?Math.max(16,m.insets.top+8):16,t=m?.insets?.right?Math.max(16,m.insets.right+8):16,r=m?.insets?.bottom?Math.max(16,m.insets.bottom+8):16,i=m?.insets?.left?Math.max(16,m.insets.left+8):16,a={};switch(n){case`top-left`:a.top=`${e}px`,a.left=`${i}px`;break;case`top-center`:a.top=`${e}px`;break;case`top-right`:a.top=`${e}px`,a.right=`${t}px`;break;case`center-left`:a.left=`${i}px`;break;case`center-right`:a.right=`${t}px`;break;case`bottom-left`:a.bottom=`${r}px`,a.left=`${i}px`;break;case`bottom-center`:a.bottom=`${r}px`;break;case`bottom-right`:a.bottom=`${r}px`,a.right=`${t}px`;break;default:a.top=`${e}px`,a.right=`${t}px`;break}return a},`getPositionOffsetStyles`);(0,w.useEffect)(()=>{if(!r)return;let e=a(()=>E(!0),`handleMouseEnter`),t=a(()=>E(!1),`handleMouseLeave`);return r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),()=>{r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t)}},[r]),(0,w.useEffect)(()=>{if(!D)return;let e=a(e=>{A.current&&!A.current.contains(e.target)&&O(!1)},`handleClickOutside`);return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[D]),(0,w.useEffect)(()=>(D?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[D]);let ce=a(()=>{O(!D)},`handleToggleOverlay`),le=a(async()=>{try{P(`Calling tool...`);let e=await y(F,L.trim()?JSON.parse(L):{});P(`Success: ${JSON.stringify(e,null,2)}`)}catch(e){P(`Error: ${e.message}`)}},`handleCallTool`),ue=a(async()=>{try{P(`Sending follow-up message...`),await b(te),P(`Follow-up message sent successfully`)}catch(e){P(`Error: ${e.message}`)}},`handleSendFollowUpMessage`),de=a(()=>{try{x(re),P(`Opened external link: ${re}`)}catch(e){P(`Error: ${e.message}`)}},`handleOpenExternal`),fe=a(async e=>{try{P(`Requesting display mode: ${e}...`),P(`Display mode granted: ${(await S(e)).mode}`)}catch(e){P(`Error: ${e.message}`)}},`handleRequestDisplayMode`),pe=a(async()=>{try{let e=d?{...d,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};P(`Setting state...`),await C(e),P(`State updated: ${JSON.stringify(e,null,2)}`)}catch(e){P(`Error: ${e.message}`)}},`handleSetState`),me=a(async()=>{try{await S(`fullscreen`)}catch(e){console.error(`Failed to go fullscreen:`,e)}},`handleFullscreen`),he=a(async()=>{try{await S(`pip`)}catch(e){console.error(`Failed to go pip:`,e)}},`handlePip`),ge=a(()=>{let e=[`absolute`,`px-2`,`py-1`,`bg-black/90`,`text-white`,`rounded`,`text-xs`,`whitespace-nowrap`,`pointer-events-none`,`transition-opacity`,`duration-200`,`ease-in-out`];switch(n){case`top-right`:return[...e,`top-full`,`right-0`,`mt-2`];case`top-left`:return[...e,`top-full`,`left-0`,`mt-2`];case`top-center`:return[...e,`top-full`,`left-1/2`,`-translate-x-1/2`,`mt-2`];case`bottom-right`:return[...e,`bottom-full`,`right-0`,`mb-2`];case`bottom-left`:return[...e,`bottom-full`,`left-0`,`mb-2`];case`bottom-center`:return[...e,`bottom-full`,`left-1/2`,`-translate-x-1/2`,`mb-2`];case`center-left`:return[...e,`left-full`,`top-1/2`,`-translate-y-1/2`,`ml-2`];case`center-right`:return[...e,`right-full`,`top-1/2`,`-translate-y-1/2`,`mr-2`];default:return[...e,`top-full`,`right-0`,`mt-2`]}},`getTooltipClasses`),_e=a(({onClick:e,label:t,children:n})=>{let[r,a]=(0,w.useState)(!1),o=ge();return w.createElement(`button`,{className:`p-2 ${ae?`bg-white/10 hover:bg-white/20`:`bg-black/70 hover:bg-black/90`} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${ae?`shadow-[0_2px_8px_rgba(0,0,0,0.3)]`:`shadow-[0_2px_8px_rgba(0,0,0,0.2)]`} relative`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:e,"aria-label":t},w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`block`},n),i&&w.createElement(`span`,{className:`${o.join(` `)} ${r?`opacity-100`:`opacity-0`}`},t))},`IconButton`),ve=a(e=>{if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)},`formatValue`),ye=a(e=>e?`${e.device?.type||`unknown`}`:`N/A`,`formatUserAgent`),be=a(e=>{if(!e?.insets)return`N/A`;let{top:t,bottom:n,left:r,right:i}=e.insets;return`T:${t} B:${n} L:${r} R:${i}`},`formatSafeArea`);return w.createElement(w.Fragment,null,w.createElement(`div`,{ref:k,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&E(!0),onMouseLeave:()=>!r&&E(!1)},w.createElement(`div`,{className:oe().join(` `),style:se()},!ie&&w.createElement(w.Fragment,null,!z&&!B&&w.createElement(w.Fragment,null,(s===!0||s===`fullscreen`)&&w.createElement(_e,{onClick:me,label:`Fullscreen`},w.createElement(`path`,{d:`M15 3h6v6`}),w.createElement(`path`,{d:`m21 3-7 7`}),w.createElement(`path`,{d:`m3 21 7-7`}),w.createElement(`path`,{d:`M9 21H3v-6`})),(s===!0||s===`pip`)&&w.createElement(_e,{onClick:he,label:`Picture in Picture`},w.createElement(`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`}),w.createElement(`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`}))),o&&w.createElement(_e,{onClick:ce,label:`Debug Info`},w.createElement(`path`,{d:`M12 20v-9`}),w.createElement(`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`}),w.createElement(`path`,{d:`M14.12 3.88 16 2`}),w.createElement(`path`,{d:`M21 21a4 4 0 0 0-3.81-4`}),w.createElement(`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`}),w.createElement(`path`,{d:`M22 13h-4`}),w.createElement(`path`,{d:`M3 21a4 4 0 0 1 3.81-4`}),w.createElement(`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`}),w.createElement(`path`,{d:`M6 13H2`}),w.createElement(`path`,{d:`m8 2 1.88 1.88`}),w.createElement(`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`})))),e),D&&o&&w.createElement(`div`,{ref:A,className:`fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4`,onClick:e=>{e.target===A.current&&O(!1)}},w.createElement(`button`,{onClick:()=>O(!1),className:`absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none`,"aria-label":`Close`},`×`),w.createElement(`div`,{className:`max-w-[1200px] mx-auto pt-10`},w.createElement(`h1`,{className:`text-lg font-bold mb-4 border-b border-gray-700 pb-2`},`Debug Info`),w.createElement(`table`,{className:`w-full border-collapse border-spacing-0`},w.createElement(`tbody`,null,w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Props`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(c))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Output`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(l))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Metadata`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(u))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`State`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(d))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Theme`),w.createElement(`td`,{className:`p-2`},f)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Display Mode`),w.createElement(`td`,{className:`p-2`},p)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Locale`),w.createElement(`td`,{className:`p-2`},_)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Max Height`),w.createElement(`td`,{className:`p-2`},h,`px`)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`User Agent`),w.createElement(`td`,{className:`p-2`},ye(g))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Safe Area`),w.createElement(`td`,{className:`p-2`},be(m))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`API Available`),w.createElement(`td`,{className:`p-2`},v?`Yes`:`No`)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`window.openai Keys`),w.createElement(`td`,{className:`p-2`},j.length>0?j.join(`, `):`N/A`)))),w.createElement(`h2`,{className:`text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2`},`Actions`),w.createElement(`div`,{className:`flex flex-col gap-3`},w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),placeholder:`Tool name`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]`}),w.createElement(`input`,{type:`text`,value:L,onChange:e=>ee(e.target.value),placeholder:`{"key": "value"}`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),w.createElement(`button`,{onClick:le,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Call Tool`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`input`,{type:`text`,value:te,onChange:e=>ne(e.target.value),placeholder:`Follow-up message`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),w.createElement(`button`,{onClick:ue,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Send Follow-Up`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`input`,{type:`text`,value:re,onChange:e=>R(e.target.value),placeholder:`External URL`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),w.createElement(`button`,{onClick:de,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Open Link`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`span`,{className:`w-[150px] text-xs`},`Display Mode:`),w.createElement(`button`,{onClick:()=>fe(`inline`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Inline`),w.createElement(`button`,{onClick:()=>fe(`pip`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`PiP`),w.createElement(`button`,{onClick:()=>fe(`fullscreen`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Fullscreen`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`button`,{onClick:pe,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Set State (Add Timestamp)`)),N&&w.createElement(`div`,{className:`mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto`},w.createElement(`div`,{className:`font-bold mb-1 text-gray-400`},`Result:`),N,w.createElement(`button`,{onClick:()=>P(``),className:`mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]`},`Clear`))))))}a(tj,`WidgetControls`);var tpe=150,npe=5;function rpe({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!0,colorScheme:i=!1}){let[a,o]=(0,w.useState)(null),s=(0,w.useRef)(0),c=(0,w.useRef)(null),l=(0,w.useRef)(!1),u=(0,w.useCallback)(e=>{if(!(typeof window>`u`)){if(l.current=!0,window.openai?.notifyIntrinsicHeight){window.openai.notifyIntrinsicHeight(e).then(()=>{l.current=!1}).catch(e=>{l.current=!1,console.error(`[McpUseProvider] Failed to notify intrinsic height (ChatGPT):`,e)});return}try{XA().sendSizeChanged({height:e}),console.log(`[McpUseProvider] Sent size-changed notification:`,e),l.current=!1}catch(e){l.current=!1,console.error(`[McpUseProvider] Failed to notify size change (MCP Apps):`,e)}}},[]),d=(0,w.useCallback)(e=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{Math.abs(e-s.current)>=npe&&e>0&&(s.current=e,u(e))},tpe)},[u]);(0,w.useEffect)(()=>{if(!r){console.log(`[McpUseProvider] autoSize is disabled`);return}if(!a){console.log(`[McpUseProvider] No container element found for autoSize`);return}if(typeof ResizeObserver>`u`){console.log(`[McpUseProvider] ResizeObserver not available`);return}console.log(`[McpUseProvider] Setting up ResizeObserver for autoSize`);let e=new ResizeObserver(e=>{if(l.current){console.log(`[McpUseProvider] Skipping resize - notification in progress`);return}for(let t of e){let e=t.contentRect.height,n=t.target.scrollHeight,r=Math.max(e,n);console.log(`[McpUseProvider] ResizeObserver fired:`,{height:e,scrollHeight:n,intrinsicHeight:r}),d(r)}});e.observe(a);let t=Math.max(a.offsetHeight,a.scrollHeight);return console.log(`[McpUseProvider] Initial height measurement:`,t),t>0&&d(t),()=>{console.log(`[McpUseProvider] Cleaning up ResizeObserver`),e.disconnect(),c.current&&=(clearTimeout(c.current),null),l.current=!1}},[r,a,d]);let f=e;return f=w.createElement(Jfe,null,f),(t||n)&&(f=w.createElement(tj,{debugger:t,viewControls:n},f)),f=w.createElement(epe,{colorScheme:i},f),r&&(f=w.createElement(`div`,{ref:o,style:{width:`100%`,minHeight:0}},f)),w.createElement(w.StrictMode,null,f)}a(rpe,`McpUseProvider`);function ipe(){let e=(0,w.useMemo)(()=>typeof window>`u`?!1:typeof window.openai?.uploadFile==`function`&&typeof window.openai?.getFileDownloadUrl==`function`,[]);return{isSupported:e,upload:(0,w.useMemo)(()=>async(t,n={})=>{if(!e)throw Error("[useFiles] File upload is not supported in this host. Check `isSupported` before calling `upload`. File operations are only available in the ChatGPT Apps SDK environment.");let r=await window.openai.uploadFile(t),{modelVisible:i=!0}=n;if(i&&window.openai?.setWidgetState){let e=window.openai.widgetState??{},t=[...e.imageIds??[],r.fileId];window.openai.setWidgetState({...e,imageIds:t}).catch(e=>{console.warn(`[useFiles] Failed to track imageId:`,e)})}return r},[e]),getDownloadUrl:(0,w.useMemo)(()=>async t=>{if(!e)throw Error("[useFiles] File download is not supported in this host. Check `isSupported` before calling `getDownloadUrl`. File operations are only available in the ChatGPT Apps SDK environment.");return window.openai.getFileDownloadUrl(t)},[e])}}a(ipe,`useFiles`);function nj(e){let[{status:t,data:n,error:r},i]=(0,w.useState)({status:`idle`,data:void 0,error:void 0}),o=(0,w.useRef)(0),s=a(async t=>{let n=++o.current;i({status:`pending`,data:void 0,error:void 0});try{let r;if(typeof window<`u`)if(window.openai?.callTool)r=await window.openai.callTool(e,t);else if(window!==window.parent)r=await XA().callTool(e,t);else throw Error(`No tool calling interface available`);else throw Error(`useCallTool can only be used in browser environment`);let a=ZA(r);return n===o.current&&i({status:`success`,data:a,error:void 0}),a}catch(e){throw n===o.current&&i({status:`error`,data:void 0,error:e}),e}},`execute`),c=(0,w.useCallback)((e=>s(e===void 0?null:e)),[e]),l=(0,w.useCallback)(((e,t)=>{let n;e&&typeof e==`object`&&(`onSuccess`in e||`onError`in e||`onSettled`in e)?(n=null,t=e):n=e===void 0?null:e,s(n).then(e=>{t?.onSuccess?.(e,n),t?.onSettled?.(e,void 0,n)}).catch(e=>{t?.onError?.(e,n),t?.onSettled?.(void 0,e,n)})}),[e]);return{status:t,data:n,error:r,isIdle:t===`idle`,isPending:t===`pending`,isSuccess:t===`success`,isError:t===`error`,callTool:l,callToolAsync:c}}a(nj,`useCallTool`);function ape(){return{useCallTool:a(e=>nj(e),`useCallTool`),useToolInfo:a(()=>ej(),`useToolInfo`)}}a(ape,`generateHelpers`);var rj=c.get(`McpClientProvider`),ij=(0,w.createContext)(null),aj=500;function oj({id:e,options:t,defaultCallbackUrl:n,defaultProxyConfig:r,defaultAutoProxyFallback:i,clientInfo:a,cachedMetadata:o,onUpdate:s,rpcWrapTransport:c,onGlobalSamplingRequest:l,onGlobalElicitationRequest:u}){let{name:d,onSamplingRequest:f,onElicitationRequest:p,onNotificationReceived:m,wrapTransport:h}=t,g=(0,w.useMemo)(()=>{let{name:e,onSamplingRequest:s,onElicitationRequest:c,onNotificationReceived:l,wrapTransport:u,...d}=t;return{...d,callbackUrl:d.callbackUrl||n,proxyConfig:d.proxyConfig||r,autoProxyFallback:d.autoProxyFallback===void 0?i:d.autoProxyFallback,clientInfo:d.clientInfo?a?{...a,...d.clientInfo}:d.clientInfo:a,_initialServerInfo:o}},[t,r,i,a,o]),_=(0,w.useMemo)(()=>{if(!(!c&&!h))return t=>{let n=t;return c&&(n=c(n,e)),h&&(n=h(n,e)),n}},[c,h,e]),[v,y]=(0,w.useState)([]),[b,x]=(0,w.useState)([]),S=(0,w.useRef)(0),[C,T]=(0,w.useState)([]),E=(0,w.useRef)(0),D=(0,w.useCallback)(e=>{y(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),O=(0,w.useCallback)(()=>{y(e=>e.map(e=>({...e,read:!0})))},[]),k=(0,w.useCallback)(()=>{y([])},[]),A=(0,w.useCallback)(e=>{let t={id:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,method:e.method,params:e.params,timestamp:Date.now(),read:!1};y(e=>{let n=[t,...e];return n.length>aj?n.slice(0,aj):n}),m?.(t)},[m]),j=(0,w.useCallback)((e,t)=>{x(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),M=(0,w.useCallback)((e,t)=>{x(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected sampling request`)),n.filter(t=>t.id!==e)):n})},[]),N=(0,w.useCallback)(async t=>new Promise((n,r)=>{let i={id:`sampling-${S.current++}`,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:d||e},a={...i,resolve:n,reject:r};x(e=>[...e,a]),f?.(i),l?.(i,e,d||e,j,M)}),[e,d,f,l,j,M]),P=(0,w.useCallback)((e,t)=>{T(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),F=(0,w.useCallback)((e,t)=>{T(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected elicitation request`)),n.filter(t=>t.id!==e)):n})},[]),I=(0,w.useCallback)(async t=>new Promise((n,r)=>{let i={id:`elicitation-${E.current++}`,request:t,timestamp:Date.now(),serverName:d||e},a={...i,resolve:n,reject:r};T(e=>[...e,a]),p?.(i),u?.(i,e,d||e,P,F)}),[e,d,p,u,P,F]),L=NA({...g,onNotification:A,onSampling:N,onElicitation:I,wrapTransport:_}),ee=(0,w.useMemo)(()=>b.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[b]),te=(0,w.useMemo)(()=>C.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[C]),ne=(0,w.useMemo)(()=>v.filter(e=>!e.read).length,[v]),re=(0,w.useMemo)(()=>JSON.stringify(L.tools.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,_meta:e._meta})).sort((e,t)=>e.name.localeCompare(t.name))),[L.tools,e]),R=(0,w.useMemo)(()=>JSON.stringify(L.resources.map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})).sort((e,t)=>e.uri.localeCompare(t.uri))),[L.resources]),z=(0,w.useMemo)(()=>JSON.stringify(L.prompts.map(e=>({name:e.name,description:e.description,arguments:e.arguments})).sort((e,t)=>e.name.localeCompare(t.name))),[L.prompts]),B=(0,w.useRef)(s),ie=(0,w.useRef)(null),ae=(0,w.useRef)({tools:``,resources:``,prompts:``});return(0,w.useEffect)(()=>{B.current=s},[s]),(0,w.useEffect)(()=>{let n={...L,id:e,url:t.url||``,name:d||e,notifications:v,unreadNotificationCount:ne,markNotificationRead:D,markAllNotificationsRead:O,clearNotifications:k,pendingSamplingRequests:ee,approveSampling:j,rejectSampling:M,pendingElicitationRequests:te,approveElicitation:P,rejectElicitation:F},r=ie.current,i=ae.current,a=i.tools!==re,o=i.resources!==R,s=i.prompts!==z;!r||r.name!==n.name||r.state!==n.state||r.error!==n.error||r.authUrl!==n.authUrl||a||o||s||r.serverInfo!==n.serverInfo||r.capabilities!==n.capabilities||r.notifications.length!==n.notifications.length||r.unreadNotificationCount!==n.unreadNotificationCount||r.pendingSamplingRequests.length!==n.pendingSamplingRequests.length||r.pendingElicitationRequests.length!==n.pendingElicitationRequests.length||!r.client?(ie.current=n,ae.current={tools:re,resources:R,prompts:z},B.current(n)):rj.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,d,t.url,L.state,L.error,L.authUrl,re,R,z,L.serverInfo,L.capabilities,v.length,ne,ee.length,te.length,D,O,k,j,M,P,F]),null}a(oj,`McpServerWrapper`);function sj({children:e,mcpServers:t,defaultCallbackUrl:n,defaultProxyConfig:r,defaultAutoProxyFallback:i=!0,clientInfo:o,storageProvider:s,enableRpcLogging:c=!1,onServerAdded:l,onServerRemoved:u,onServerStateChange:d,onSamplingRequest:f,onElicitationRequest:p}){let[m,h]=(0,w.useState)([]),[g,_]=(0,w.useState)([]),[v,y]=(0,w.useState)(!1),b=(0,w.useRef)([]);(0,w.useEffect)(()=>{b.current=g},[g]);let x=(0,w.useRef)({}),[S,C]=(0,w.useState)(void 0),[T,E]=(0,w.useState)(!1);(0,w.useEffect)(()=>{if(!c||typeof window>`u`){C(void 0),E(!0);return}J(()=>import(`./rpc-logger-TPNV75J4-DSV4wgJB.js`).then(e=>{rj.debug(`[McpClientProvider] RPC logger loaded`),C(()=>e.wrapTransportForLogging),E(!0)}),__vite__mapDeps([0,1])).catch(e=>{rj.error(`[McpClientProvider] Failed to load RPC logger:`,e),C(void 0),E(!0)})},[c]),(0,w.useEffect)(()=>{if(!T){rj.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}a(async()=>{if(rj.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!s,`mcpServers:`,t),!s){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));rj.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),h(e)}y(!0);return}try{let e=await Promise.resolve(s.getServers());if(rj.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),s.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(s.getServerMetadata(e))]),n=await Promise.all(t);x.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),rj.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(x.current).length,`servers`)}catch(e){rj.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));rj.debug(`[McpClientProvider] Total servers after merge:`,r.length),h(r),y(!0)}catch(e){rj.error(`[McpClientProvider] Failed to load from storage:`,e),t&&h(Object.entries(t).map(([e,t])=>({id:e,options:t}))),y(!0)}},`loadServers`)()},[s,t,T]),(0,w.useEffect)(()=>{!s||!v||a(async()=>{try{let e=m.reduce((e,t)=>(e[t.id]=t.options,e),{});await Promise.resolve(s.setServers(e))}catch(e){rj.error(`[McpClientProvider] Failed to save to storage:`,e)}},`saveServers`)()},[m,s,v]);let D=(0,w.useCallback)(e=>{rj.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];_(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return rj.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>l?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,o=i.serverInfo!==e.serverInfo;if(rj.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),i.name===e.name&&i.url===e.url&&i.state===e.state&&i.tools===e.tools&&i.resources===e.resources&&i.prompts===e.prompts&&i.error===e.error&&i.serverInfo===e.serverInfo&&i.client===e.client&&i.notifications===e.notifications&&i.unreadNotificationCount===e.unreadNotificationCount&&i.pendingSamplingRequests.length===e.pendingSamplingRequests.length&&i.pendingElicitationRequests.length===e.pendingElicitationRequests.length)return rj.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(rj.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>d?.(e.id,e.state)),o&&e.serverInfo&&s?.setServerMetadata){let t={name:e.serverInfo.name,version:e.serverInfo.version,title:e.serverInfo.title,websiteUrl:e.serverInfo.websiteUrl,icons:e.serverInfo.icons,icon:e.serverInfo.icon};x.current[e.id]=t,Promise.resolve(s.setServerMetadata(e.id,t)).catch(e=>{rj.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let c=[...n];return c[r]=e,c}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[l,d,s]),O=(0,w.useCallback)((e,t)=>{h(n=>n.find(t=>t.id===e)?n:(rj.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),k=(0,w.useCallback)(e=>{let t=b.current.find(t=>t.id===e);_(t=>t.filter(t=>t.id!==e)),h(t=>t.filter(t=>t.id!==e)),t?.disconnect&&t.disconnect(),t?.clearStorage&&t.clearStorage(),u?.(e)},[u]),A=(0,w.useCallback)(async(e,t)=>new Promise(n=>{let r=m.find(t=>t.id===e);if(!r){rj.warn(`[McpClientProvider] Cannot update server "${e}" - not found`),n();return}let i={...r.options,...t,_updateVersion:(r.options._updateVersion||0)+1},a=b.current.find(t=>t.id===e);_(t=>t.filter(t=>t.id!==e)),h(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r}),a?.disconnect&&a.disconnect(),a?.clearStorage&&a.clearStorage()}),[m]),j=(0,w.useCallback)(async(e,t)=>new Promise(n=>{let r=m.find(t=>t.id===e);if(!r){rj.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`),n();return}let i={...r.options,...t};_(n=>n.map(n=>n.id===e?{...n,name:t.name}:n)),h(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[m]),M=(0,w.useCallback)(e=>g.find(t=>t.id===e),[g]),N=(0,w.useMemo)(()=>({servers:g,addServer:O,removeServer:k,updateServerMetadata:j,updateServer:A,getServer:M,storageLoaded:v}),[g,O,k,j,A,M,v]),{capabilities:P,...F}=o||{},I=(0,w.useMemo)(()=>Object.keys(F).length?F:void 0,[o]),L=(0,w.useMemo)(()=>m.map(e=>({id:e.id,options:P?{...e.options,clientOptions:{...e.options.clientOptions,capabilities:{...P,...e.options.clientOptions?.capabilities}}}:e.options})),[m,P]);return w.createElement(ij.Provider,{value:N},e,L.map(e=>w.createElement(oj,{key:`${e.id}-v${e.options._updateVersion||0}`,id:e.id,options:e.options,defaultCallbackUrl:n,defaultProxyConfig:r,defaultAutoProxyFallback:i,clientInfo:I,cachedMetadata:x.current[e.id],onUpdate:D,rpcWrapTransport:S,onGlobalSamplingRequest:f,onGlobalElicitationRequest:p})))}a(sj,`McpClientProvider`);function cj(){let e=(0,w.useContext)(ij);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}a(cj,`useMcpClient`);function ope(e){let{getServer:t}=cj();return t(e)}a(ope,`useMcpServer`);var spe=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}static{a(this,`LocalStorageProvider`)}metadataKey;getServers(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load servers:`,e),{}}}setServers(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save servers:`,e)}}setServer(e,t){let n=this.getServers();n[e]=t,this.setServers(n)}removeServer(e){let t=this.getServers();delete t[e],this.setServers(t),this.removeServerMetadata(e)}clear(){try{localStorage.removeItem(this.storageKey),localStorage.removeItem(this.metadataKey)}catch(e){console.error(`[LocalStorageProvider] Failed to clear:`,e)}}getAllMetadata(){try{let e=localStorage.getItem(this.metadataKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load metadata:`,e),{}}}setAllMetadata(e){try{localStorage.setItem(this.metadataKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save metadata:`,e)}}getServerMetadata(e){return this.getAllMetadata()[e]}setServerMetadata(e,t){let n=this.getAllMetadata();n[e]={...t,cachedAt:Date.now()},this.setAllMetadata(n)}removeServerMetadata(e){let t=this.getAllMetadata();delete t[e],this.setAllMetadata(t)}};(class{static{a(this,`MemoryStorageProvider`)}storage={};metadata={};getServers(){return{...this.storage}}setServers(e){this.storage={...e}}setServer(e,t){this.storage[e]=t}removeServer(e){delete this.storage[e],this.removeServerMetadata(e)}clear(){this.storage={},this.metadata={}}getServerMetadata(e){return this.metadata[e]}setServerMetadata(e,t){this.metadata[e]={...t,cachedAt:Date.now()}}removeServerMetadata(e){delete this.metadata[e]}});async function lj(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);if(t.value=e,t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0`,document.body.appendChild(t),t.focus(),t.select(),!document.execCommand(`copy`))throw Error(`execCommand copy failed`);document.body.removeChild(t)}function uj(e,t,n){let r=e.trim(),i=t.trim(),a=n.trim();if(!(!r&&!a))return{...r?{clientId:r}:{},...r&&i?{clientSecret:i}:{},...a?{scope:a}:{}}}function dj(e){try{let t=localStorage.getItem(`mcp-inspector-connections`);return t&&JSON.parse(t)[e]||null}catch{return null}}function cpe(e){let t=e.proxyConfig?.headers||e.proxyConfig?.customHeaders||e.headers||e.customHeaders||{};return Object.fromEntries(Object.entries(t).filter(([e,t])=>e&&t).map(([e,t])=>[e,String(t)]).sort(([e],[t])=>e.localeCompare(t)))}function fj(e){let t=e.url?.trim()||``;return{url:t,name:e.name?.trim()||t,transportType:e.transportType||`http`,proxyAddress:e.proxyConfig?.proxyAddress?.trim()||``,headers:cpe(e),oauthClientId:e.oauth?.clientId?.trim()||``,oauthClientSecret:e.oauth?.clientSecret?.trim()||``,oauthScope:e.oauth?.scope?.trim()||``}}function pj(e,t){let n=fj(e),r=fj(t);return n.url===r.url&&n.transportType===r.transportType&&n.proxyAddress===r.proxyAddress&&JSON.stringify(n.headers)===JSON.stringify(r.headers)&&n.oauthClientId===r.oauthClientId&&n.oauthClientSecret===r.oauthClientSecret&&n.oauthScope===r.oauthScope&&n.name!==r.name}function mj(e){let t=e.name?.trim(),n=e.url?.trim();return t?t===n?``:t:``}function hj(e){return mj(e)||e.serverInfo?.title?.trim()||e.serverInfo?.name?.trim()||e.name?.trim()||e.url?.trim()||`Unknown server`}var gj=`popstate`;function _j(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function lpe(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return xj(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Sj(t)}return dpe(t,n,null,e)}function vj(e,t){if(e===!1||e==null)throw Error(t)}function yj(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function upe(){return Math.random().toString(36).substring(2,10)}function bj(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function xj(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?Cj(t):t,state:n,key:t&&t.key||r||upe(),mask:i}}function Sj({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function Cj(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function dpe(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=_j(e)?e:xj(h.location,e,t);n&&n(r,e),l=u()+1;let d=bj(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=_j(e)?e:xj(h.location,e,t);n&&n(r,e),l=u();let i=bj(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return fpe(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(gj,d),c=e,()=>{i.removeEventListener(gj,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function fpe(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),vj(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Sj(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}function wj(e,t,n=`/`){return ppe(e,t,n,!1)}function ppe(e,t,n,r,i){let a=kj((typeof t==`string`?Cj(t):t).pathname||`/`,n);if(a==null)return null;let o=i??hpe(e),s=null,c=Dpe(a);for(let e=0;s==null&&e<o.length;++e)s=Tpe(o[e],c,r);return s}function mpe(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function hpe(e){let t=Tj(e);return gpe(t),t}function Tj(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;vj(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Fj([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(vj(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Tj(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Cpe(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Ej(e.path))a(e,t,!0,n)}),t}function Ej(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Ej(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function gpe(e){e.sort((e,t)=>e.score===t.score?wpe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var _pe=/^:[\w-]+$/,vpe=3,ype=2,bpe=1,xpe=10,Spe=-2,Dj=e=>e===`*`;function Cpe(e,t){let n=e.split(`/`),r=n.length;return n.some(Dj)&&(r+=Spe),t&&(r+=ype),n.filter(e=>!Dj(e)).reduce((e,t)=>e+(_pe.test(t)?vpe:t===``?bpe:xpe),r)}function wpe(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Tpe(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=Oj({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=Oj({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Fj([a,u.pathname]),pathnameBase:jpe(Fj([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Fj([a,u.pathnameBase]))}return o}function Oj(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Epe(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Epe(e,t=!1,n=!0){yj(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Dpe(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return yj(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function kj(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Ope=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function kpe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?Cj(e):e,a;return n?(n=Pj(n),a=n.startsWith(`/`)?Aj(n.substring(1),`/`):Aj(n,t)):a=t,{pathname:a,search:Mpe(r),hash:Npe(i)}}function Aj(e,t){let n=Ij(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function jj(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ape(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Mj(e){let t=Ape(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Nj(e,t,n,r=!1){let i;typeof e==`string`?i=Cj(e):(i={...e},vj(!i.pathname||!i.pathname.includes(`?`),jj(`?`,`pathname`,`search`,i)),vj(!i.pathname||!i.pathname.includes(`#`),jj(`#`,`pathname`,`hash`,i)),vj(!i.search||!i.search.includes(`#`),jj(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=kpe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Pj=e=>e.replace(/\/\/+/g,`/`),Fj=e=>Pj(e.join(`/`)),Ij=e=>e.replace(/\/+$/,``),jpe=e=>Ij(e).replace(/^\/*/,`/`),Mpe=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Npe=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ppe=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Fpe(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ipe(e){return Fj(e.map(e=>e.route.path).filter(Boolean))||`/`}var Lj=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Rj(e,t){let n=e;if(typeof n!=`string`||!Ope.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Lj)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=kj(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{yj(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var zj=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(zj);var Lpe=[`GET`,...zj];new Set(Lpe);var Bj=w.createContext(null);Bj.displayName=`DataRouter`;var Vj=w.createContext(null);Vj.displayName=`DataRouterState`;var Hj=w.createContext(!1);function Rpe(){return w.useContext(Hj)}var Uj=w.createContext({isTransitioning:!1});Uj.displayName=`ViewTransition`;var zpe=w.createContext(new Map);zpe.displayName=`Fetchers`;var Bpe=w.createContext(null);Bpe.displayName=`Await`;var Wj=w.createContext(null);Wj.displayName=`Navigation`;var Gj=w.createContext(null);Gj.displayName=`Location`;var Kj=w.createContext({outlet:null,matches:[],isDataRoute:!1});Kj.displayName=`Route`;var qj=w.createContext(null);qj.displayName=`RouteError`;var Jj=`REACT_ROUTER_ERROR`,Vpe=`REDIRECT`,Hpe=`ROUTE_ERROR_RESPONSE`;function Upe(e){if(e.startsWith(`${Jj}:${Vpe}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Wpe(e){if(e.startsWith(`${Jj}:${Hpe}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ppe(t.status,t.statusText,t.data)}catch{}}function Gpe(e,{relative:t}={}){vj(Yj(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=w.useContext(Wj),{hash:i,pathname:a,search:o}=$j(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Fj([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Yj(){return w.useContext(Gj)!=null}function Xj(){return vj(Yj(),`useLocation() may be used only in the context of a <Router> component.`),w.useContext(Gj).location}var Kpe=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Zj(e){w.useContext(Wj).static||w.useLayoutEffect(e)}function Qj(){let{isDataRoute:e}=w.useContext(Kj);return e?ome():qpe()}function qpe(){vj(Yj(),`useNavigate() may be used only in the context of a <Router> component.`);let e=w.useContext(Bj),{basename:t,navigator:n}=w.useContext(Wj),{matches:r}=w.useContext(Kj),{pathname:i}=Xj(),a=JSON.stringify(Mj(r)),o=w.useRef(!1);return Zj(()=>{o.current=!0}),w.useCallback((r,s={})=>{if(yj(o.current,Kpe),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Nj(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Fj([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}w.createContext(null);function Jpe(){let{matches:e}=w.useContext(Kj);return e[e.length-1]?.params??{}}function $j(e,{relative:t}={}){let{matches:n}=w.useContext(Kj),{pathname:r}=Xj(),i=JSON.stringify(Mj(n));return w.useMemo(()=>Nj(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ype(e,t){return eM(e,t)}function eM(e,t,n){vj(Yj(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=w.useContext(Wj),{matches:i}=w.useContext(Kj),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;cM(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
452
|
+
`);return window.openai.sendFollowUpMessage({prompt:n})},[b]),de=(0,w.useCallback)(e=>{if(b===`mcp-apps`){XA().openLink(e).catch(e=>{console.error(`Failed to open link:`,e)});return}if(!window.openai?.openExternal)throw Error(`window.openai.openExternal is not available`);window.openai.openExternal({href:e})},[b]),fe=(0,w.useCallback)(async e=>{if(b===`mcp-apps`)return await XA().requestDisplayMode(e);if(!window.openai?.requestDisplayMode)throw Error(`window.openai.requestDisplayMode is not available`);return window.openai.requestDisplayMode({mode:e})},[b]),pe=(0,w.useCallback)(async e=>{if(b===`mcp-apps`){let t=typeof e==`function`?e(ae):e;oe(t);let n=XA(),r=t;n.updateModelContext({structuredContent:r,content:[{type:`text`,text:JSON.stringify(Object.fromEntries(Object.entries(r).filter(([e])=>e!==PA)))}]}).catch(e=>{console.warn(`[useWidget] Failed to update model context:`,e)});return}if(!window.openai?.setWidgetState)throw Error(`window.openai.setWidgetState is not available`);let t=typeof e==`function`?e(D===void 0?ae:D):e,n=(window.openai.widgetState??{})[PA];return oe(t),window.openai.setWidgetState(n===void 0?t:{...t,[PA]:n})},[b,D,ae]),me=(0,w.useMemo)(()=>b===`openai`?T===null&&E===null:b===`mcp-apps`?c===null:b===`mcp-ui`?typeof window<`u`&&window!==window.parent&&!S.toolId?!0:F==null:!1,[b,T,E,c,F,S.toolId]),he=(0,w.useMemo)(()=>b===`mcp-apps`&&f?f:null,[b,f]),ge=(0,w.useMemo)(()=>b===`mcp-apps`?f!==null:!1,[b,f]);return{props:I,toolInput:P||{},output:F??null,metadata:b===`mcp-apps`?u??null:E??null,state:ae?Object.fromEntries(Object.entries(ae).filter(([e])=>e!==PA)):null,setState:pe,theme:L||`light`,displayMode:ee||`inline`,safeArea:te||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:ne||600,maxWidth:re,userAgent:R||{device:{type:`desktop`},capabilities:{hover:!0,touch:!1}},locale:z||Yfe.LOCALE,timeZone:B||(typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:`UTC`),mcp_url:ie,callTool:le,sendFollowUpMessage:ue,openExternal:de,requestDisplayMode:fe,isAvailable:t||r,isPending:me,partialToolInput:he,isStreaming:ge,hostInfo:g??void 0,hostCapabilities:v??void 0}}a(ej,`useWidget`);function Zfe(e){let{props:t}=ej(e);return t}a(Zfe,`useWidgetProps`);function Qfe(){let{theme:e}=ej();return e}a(Qfe,`useWidgetTheme`);function $fe(e){let{state:t,setState:n}=ej();return(0,w.useEffect)(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}a($fe,`useWidgetState`);var epe=a(({children:e,colorScheme:t=!1})=>{let{theme:n,isAvailable:r}=ej(),[i,o]=(0,w.useState)(()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);(0,w.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=a(e=>{o(e.matches?`dark`:`light`)},`handleChange`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let s=r?n:i;return(0,w.useLayoutEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(s===`dark`?`dark`:`light`),e.setAttribute(`data-theme`,s===`dark`?`dark`:`light`),t?e.style.colorScheme=s===`dark`?`dark`:`light`:e.style.colorScheme=``},[s,t]),w.createElement(w.Fragment,null,e)},`ThemeProvider`);function tj({children:e,className:t=``,position:n=`top-right`,attachTo:r,showLabels:i=!0,debugger:o=!1,viewControls:s=!1}){let{props:c,output:l,metadata:u,state:d,theme:f,displayMode:p,safeArea:m,maxHeight:h,userAgent:g,locale:_,isAvailable:v,callTool:y,sendFollowUpMessage:b,openExternal:x,requestDisplayMode:S,setState:C}=ej(),[T,E]=(0,w.useState)(!1),[D,O]=(0,w.useState)(!1),k=(0,w.useRef)(null),A=(0,w.useRef)(null),[j,M]=(0,w.useState)([]),[N,P]=(0,w.useState)(``),[F,I]=(0,w.useState)(`get-my-city`),[L,ee]=(0,w.useState)(`{}`),[te,ne]=(0,w.useState)(`Test follow-up message`),[re,R]=(0,w.useState)(`https://mcp-use.com/docs`),z=p===`fullscreen`&&v,B=p===`pip`&&v,ie=typeof window<`u`&&window.location.pathname.includes(`/inspector/api/`);(0,w.useEffect)(()=>{let e=setTimeout(()=>{if(typeof window<`u`&&window.openai)try{M(Object.keys(window.openai))}catch{M([])}else M([])},100);return()=>{clearTimeout(e)}},[]);let ae=f===`dark`,oe=a(()=>{let e=[`absolute`,`z-[1000]`,`flex`,`gap-2`,`transition-opacity`,`duration-200`,`ease-in-out`,T?`opacity-100`:`opacity-0`,T?`pointer-events-auto`:`pointer-events-none`];switch(n){case`top-left`:return[...e,`top-4`,`left-4`];case`top-center`:return[...e,`top-4`,`left-1/2`,`-translate-x-1/2`];case`top-right`:return[...e,`top-4`,`right-4`];case`center-left`:return[...e,`top-1/2`,`left-4`,`-translate-y-1/2`];case`center-right`:return[...e,`top-1/2`,`right-4`,`-translate-y-1/2`];case`bottom-left`:return[...e,`bottom-4`,`left-4`];case`bottom-center`:return[...e,`bottom-4`,`left-1/2`,`-translate-x-1/2`];case`bottom-right`:return[...e,`bottom-4`,`right-4`];default:return[...e,`top-4`,`right-4`]}},`getPositionClasses`),se=a(()=>{let e=m?.insets?.top?Math.max(16,m.insets.top+8):16,t=m?.insets?.right?Math.max(16,m.insets.right+8):16,r=m?.insets?.bottom?Math.max(16,m.insets.bottom+8):16,i=m?.insets?.left?Math.max(16,m.insets.left+8):16,a={};switch(n){case`top-left`:a.top=`${e}px`,a.left=`${i}px`;break;case`top-center`:a.top=`${e}px`;break;case`top-right`:a.top=`${e}px`,a.right=`${t}px`;break;case`center-left`:a.left=`${i}px`;break;case`center-right`:a.right=`${t}px`;break;case`bottom-left`:a.bottom=`${r}px`,a.left=`${i}px`;break;case`bottom-center`:a.bottom=`${r}px`;break;case`bottom-right`:a.bottom=`${r}px`,a.right=`${t}px`;break;default:a.top=`${e}px`,a.right=`${t}px`;break}return a},`getPositionOffsetStyles`);(0,w.useEffect)(()=>{if(!r)return;let e=a(()=>E(!0),`handleMouseEnter`),t=a(()=>E(!1),`handleMouseLeave`);return r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),()=>{r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t)}},[r]),(0,w.useEffect)(()=>{if(!D)return;let e=a(e=>{A.current&&!A.current.contains(e.target)&&O(!1)},`handleClickOutside`);return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[D]),(0,w.useEffect)(()=>(D?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[D]);let ce=a(()=>{O(!D)},`handleToggleOverlay`),le=a(async()=>{try{P(`Calling tool...`);let e=await y(F,L.trim()?JSON.parse(L):{});P(`Success: ${JSON.stringify(e,null,2)}`)}catch(e){P(`Error: ${e.message}`)}},`handleCallTool`),ue=a(async()=>{try{P(`Sending follow-up message...`),await b(te),P(`Follow-up message sent successfully`)}catch(e){P(`Error: ${e.message}`)}},`handleSendFollowUpMessage`),de=a(()=>{try{x(re),P(`Opened external link: ${re}`)}catch(e){P(`Error: ${e.message}`)}},`handleOpenExternal`),fe=a(async e=>{try{P(`Requesting display mode: ${e}...`),P(`Display mode granted: ${(await S(e)).mode}`)}catch(e){P(`Error: ${e.message}`)}},`handleRequestDisplayMode`),pe=a(async()=>{try{let e=d?{...d,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};P(`Setting state...`),await C(e),P(`State updated: ${JSON.stringify(e,null,2)}`)}catch(e){P(`Error: ${e.message}`)}},`handleSetState`),me=a(async()=>{try{await S(`fullscreen`)}catch(e){console.error(`Failed to go fullscreen:`,e)}},`handleFullscreen`),he=a(async()=>{try{await S(`pip`)}catch(e){console.error(`Failed to go pip:`,e)}},`handlePip`),ge=a(()=>{let e=[`absolute`,`px-2`,`py-1`,`bg-black/90`,`text-white`,`rounded`,`text-xs`,`whitespace-nowrap`,`pointer-events-none`,`transition-opacity`,`duration-200`,`ease-in-out`];switch(n){case`top-right`:return[...e,`top-full`,`right-0`,`mt-2`];case`top-left`:return[...e,`top-full`,`left-0`,`mt-2`];case`top-center`:return[...e,`top-full`,`left-1/2`,`-translate-x-1/2`,`mt-2`];case`bottom-right`:return[...e,`bottom-full`,`right-0`,`mb-2`];case`bottom-left`:return[...e,`bottom-full`,`left-0`,`mb-2`];case`bottom-center`:return[...e,`bottom-full`,`left-1/2`,`-translate-x-1/2`,`mb-2`];case`center-left`:return[...e,`left-full`,`top-1/2`,`-translate-y-1/2`,`ml-2`];case`center-right`:return[...e,`right-full`,`top-1/2`,`-translate-y-1/2`,`mr-2`];default:return[...e,`top-full`,`right-0`,`mt-2`]}},`getTooltipClasses`),_e=a(({onClick:e,label:t,children:n})=>{let[r,a]=(0,w.useState)(!1),o=ge();return w.createElement(`button`,{className:`p-2 ${ae?`bg-white/10 hover:bg-white/20`:`bg-black/70 hover:bg-black/90`} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${ae?`shadow-[0_2px_8px_rgba(0,0,0,0.3)]`:`shadow-[0_2px_8px_rgba(0,0,0,0.2)]`} relative`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:e,"aria-label":t},w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`block`},n),i&&w.createElement(`span`,{className:`${o.join(` `)} ${r?`opacity-100`:`opacity-0`}`},t))},`IconButton`),ve=a(e=>{if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)},`formatValue`),ye=a(e=>e?`${e.device?.type||`unknown`}`:`N/A`,`formatUserAgent`),be=a(e=>{if(!e?.insets)return`N/A`;let{top:t,bottom:n,left:r,right:i}=e.insets;return`T:${t} B:${n} L:${r} R:${i}`},`formatSafeArea`);return w.createElement(w.Fragment,null,w.createElement(`div`,{ref:k,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&E(!0),onMouseLeave:()=>!r&&E(!1)},w.createElement(`div`,{className:oe().join(` `),style:se()},!ie&&w.createElement(w.Fragment,null,!z&&!B&&w.createElement(w.Fragment,null,(s===!0||s===`fullscreen`)&&w.createElement(_e,{onClick:me,label:`Fullscreen`},w.createElement(`path`,{d:`M15 3h6v6`}),w.createElement(`path`,{d:`m21 3-7 7`}),w.createElement(`path`,{d:`m3 21 7-7`}),w.createElement(`path`,{d:`M9 21H3v-6`})),(s===!0||s===`pip`)&&w.createElement(_e,{onClick:he,label:`Picture in Picture`},w.createElement(`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`}),w.createElement(`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`}))),o&&w.createElement(_e,{onClick:ce,label:`Debug Info`},w.createElement(`path`,{d:`M12 20v-9`}),w.createElement(`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`}),w.createElement(`path`,{d:`M14.12 3.88 16 2`}),w.createElement(`path`,{d:`M21 21a4 4 0 0 0-3.81-4`}),w.createElement(`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`}),w.createElement(`path`,{d:`M22 13h-4`}),w.createElement(`path`,{d:`M3 21a4 4 0 0 1 3.81-4`}),w.createElement(`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`}),w.createElement(`path`,{d:`M6 13H2`}),w.createElement(`path`,{d:`m8 2 1.88 1.88`}),w.createElement(`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`})))),e),D&&o&&w.createElement(`div`,{ref:A,className:`fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4`,onClick:e=>{e.target===A.current&&O(!1)}},w.createElement(`button`,{onClick:()=>O(!1),className:`absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none`,"aria-label":`Close`},`×`),w.createElement(`div`,{className:`max-w-[1200px] mx-auto pt-10`},w.createElement(`h1`,{className:`text-lg font-bold mb-4 border-b border-gray-700 pb-2`},`Debug Info`),w.createElement(`table`,{className:`w-full border-collapse border-spacing-0`},w.createElement(`tbody`,null,w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Props`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(c))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Output`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(l))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Metadata`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(u))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`State`),w.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},ve(d))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Theme`),w.createElement(`td`,{className:`p-2`},f)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Display Mode`),w.createElement(`td`,{className:`p-2`},p)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Locale`),w.createElement(`td`,{className:`p-2`},_)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Max Height`),w.createElement(`td`,{className:`p-2`},h,`px`)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`User Agent`),w.createElement(`td`,{className:`p-2`},ye(g))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Safe Area`),w.createElement(`td`,{className:`p-2`},be(m))),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`API Available`),w.createElement(`td`,{className:`p-2`},v?`Yes`:`No`)),w.createElement(`tr`,{className:`border-b border-gray-700`},w.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`window.openai Keys`),w.createElement(`td`,{className:`p-2`},j.length>0?j.join(`, `):`N/A`)))),w.createElement(`h2`,{className:`text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2`},`Actions`),w.createElement(`div`,{className:`flex flex-col gap-3`},w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),placeholder:`Tool name`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]`}),w.createElement(`input`,{type:`text`,value:L,onChange:e=>ee(e.target.value),placeholder:`{"key": "value"}`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),w.createElement(`button`,{onClick:le,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Call Tool`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`input`,{type:`text`,value:te,onChange:e=>ne(e.target.value),placeholder:`Follow-up message`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),w.createElement(`button`,{onClick:ue,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Send Follow-Up`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`input`,{type:`text`,value:re,onChange:e=>R(e.target.value),placeholder:`External URL`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),w.createElement(`button`,{onClick:de,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Open Link`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`span`,{className:`w-[150px] text-xs`},`Display Mode:`),w.createElement(`button`,{onClick:()=>fe(`inline`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Inline`),w.createElement(`button`,{onClick:()=>fe(`pip`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`PiP`),w.createElement(`button`,{onClick:()=>fe(`fullscreen`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Fullscreen`)),w.createElement(`div`,{className:`flex gap-2 items-center`},w.createElement(`button`,{onClick:pe,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Set State (Add Timestamp)`)),N&&w.createElement(`div`,{className:`mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto`},w.createElement(`div`,{className:`font-bold mb-1 text-gray-400`},`Result:`),N,w.createElement(`button`,{onClick:()=>P(``),className:`mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]`},`Clear`))))))}a(tj,`WidgetControls`);var tpe=150,npe=5;function rpe({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!0,colorScheme:i=!1}){let[a,o]=(0,w.useState)(null),s=(0,w.useRef)(0),c=(0,w.useRef)(null),l=(0,w.useRef)(!1),u=(0,w.useCallback)(e=>{if(!(typeof window>`u`)){if(l.current=!0,window.openai?.notifyIntrinsicHeight){window.openai.notifyIntrinsicHeight(e).then(()=>{l.current=!1}).catch(e=>{l.current=!1,console.error(`[McpUseProvider] Failed to notify intrinsic height (ChatGPT):`,e)});return}try{XA().sendSizeChanged({height:e}),console.log(`[McpUseProvider] Sent size-changed notification:`,e),l.current=!1}catch(e){l.current=!1,console.error(`[McpUseProvider] Failed to notify size change (MCP Apps):`,e)}}},[]),d=(0,w.useCallback)(e=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{let t=Math.abs(e-s.current);(e===0||t>=npe)&&(s.current=e,u(e))},tpe)},[u]);(0,w.useEffect)(()=>{if(!r){console.log(`[McpUseProvider] autoSize is disabled`);return}if(!a){console.log(`[McpUseProvider] No container element found for autoSize`);return}if(typeof ResizeObserver>`u`){console.log(`[McpUseProvider] ResizeObserver not available`);return}console.log(`[McpUseProvider] Setting up ResizeObserver for autoSize`);let e=new ResizeObserver(e=>{if(l.current){console.log(`[McpUseProvider] Skipping resize - notification in progress`);return}for(let t of e){let e=t.contentRect.height,n=t.target.scrollHeight,r=Math.max(e,n);console.log(`[McpUseProvider] ResizeObserver fired:`,{height:e,scrollHeight:n,intrinsicHeight:r}),d(r)}});e.observe(a);let t=Math.max(a.offsetHeight,a.scrollHeight);return console.log(`[McpUseProvider] Initial height measurement:`,t),t>0&&d(t),()=>{console.log(`[McpUseProvider] Cleaning up ResizeObserver`),e.disconnect(),c.current&&=(clearTimeout(c.current),null),l.current=!1}},[r,a,d]);let f=e;return f=w.createElement(Jfe,null,f),(t||n)&&(f=w.createElement(tj,{debugger:t,viewControls:n},f)),f=w.createElement(epe,{colorScheme:i},f),r&&(f=w.createElement(`div`,{ref:o,style:{width:`100%`,minHeight:0}},f)),w.createElement(w.StrictMode,null,f)}a(rpe,`McpUseProvider`);function ipe(){let e=(0,w.useMemo)(()=>typeof window>`u`?!1:typeof window.openai?.uploadFile==`function`&&typeof window.openai?.getFileDownloadUrl==`function`,[]);return{isSupported:e,upload:(0,w.useMemo)(()=>async(t,n={})=>{if(!e)throw Error("[useFiles] File upload is not supported in this host. Check `isSupported` before calling `upload`. File operations are only available in the ChatGPT Apps SDK environment.");let r=await window.openai.uploadFile(t),{modelVisible:i=!0}=n;if(i&&window.openai?.setWidgetState){let e=window.openai.widgetState??{},t=[...e.imageIds??[],r.fileId];window.openai.setWidgetState({...e,imageIds:t}).catch(e=>{console.warn(`[useFiles] Failed to track imageId:`,e)})}return r},[e]),getDownloadUrl:(0,w.useMemo)(()=>async t=>{if(!e)throw Error("[useFiles] File download is not supported in this host. Check `isSupported` before calling `getDownloadUrl`. File operations are only available in the ChatGPT Apps SDK environment.");return window.openai.getFileDownloadUrl(t)},[e])}}a(ipe,`useFiles`);function nj(e){let[{status:t,data:n,error:r},i]=(0,w.useState)({status:`idle`,data:void 0,error:void 0}),o=(0,w.useRef)(0),s=a(async t=>{let n=++o.current;i({status:`pending`,data:void 0,error:void 0});try{let r;if(typeof window<`u`)if(window.openai?.callTool)r=await window.openai.callTool(e,t);else if(window!==window.parent)r=await XA().callTool(e,t);else throw Error(`No tool calling interface available`);else throw Error(`useCallTool can only be used in browser environment`);let a=ZA(r);return n===o.current&&i({status:`success`,data:a,error:void 0}),a}catch(e){throw n===o.current&&i({status:`error`,data:void 0,error:e}),e}},`execute`),c=(0,w.useCallback)((e=>s(e===void 0?null:e)),[e]),l=(0,w.useCallback)(((e,t)=>{let n;e&&typeof e==`object`&&(`onSuccess`in e||`onError`in e||`onSettled`in e)?(n=null,t=e):n=e===void 0?null:e,s(n).then(e=>{t?.onSuccess?.(e,n),t?.onSettled?.(e,void 0,n)}).catch(e=>{t?.onError?.(e,n),t?.onSettled?.(void 0,e,n)})}),[e]);return{status:t,data:n,error:r,isIdle:t===`idle`,isPending:t===`pending`,isSuccess:t===`success`,isError:t===`error`,callTool:l,callToolAsync:c}}a(nj,`useCallTool`);function ape(){return{useCallTool:a(e=>nj(e),`useCallTool`),useToolInfo:a(()=>ej(),`useToolInfo`)}}a(ape,`generateHelpers`);var rj=c.get(`McpClientProvider`),ij=(0,w.createContext)(null),aj=500;function oj({id:e,options:t,defaultCallbackUrl:n,defaultProxyConfig:r,defaultAutoProxyFallback:i,clientInfo:a,cachedMetadata:o,onUpdate:s,rpcWrapTransport:c,onGlobalSamplingRequest:l,onGlobalElicitationRequest:u}){let{name:d,onSamplingRequest:f,onElicitationRequest:p,onNotificationReceived:m,wrapTransport:h}=t,g=(0,w.useMemo)(()=>{let{name:e,onSamplingRequest:s,onElicitationRequest:c,onNotificationReceived:l,wrapTransport:u,...d}=t;return{...d,callbackUrl:d.callbackUrl||n,proxyConfig:d.proxyConfig||r,autoProxyFallback:d.autoProxyFallback===void 0?i:d.autoProxyFallback,clientInfo:d.clientInfo?a?{...a,...d.clientInfo}:d.clientInfo:a,_initialServerInfo:o}},[t,r,i,a,o]),_=(0,w.useMemo)(()=>{if(!(!c&&!h))return t=>{let n=t;return c&&(n=c(n,e)),h&&(n=h(n,e)),n}},[c,h,e]),[v,y]=(0,w.useState)([]),[b,x]=(0,w.useState)([]),S=(0,w.useRef)(0),[C,T]=(0,w.useState)([]),E=(0,w.useRef)(0),D=(0,w.useCallback)(e=>{y(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),O=(0,w.useCallback)(()=>{y(e=>e.map(e=>({...e,read:!0})))},[]),k=(0,w.useCallback)(()=>{y([])},[]),A=(0,w.useCallback)(e=>{let t={id:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,method:e.method,params:e.params,timestamp:Date.now(),read:!1};y(e=>{let n=[t,...e];return n.length>aj?n.slice(0,aj):n}),m?.(t)},[m]),j=(0,w.useCallback)((e,t)=>{x(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),M=(0,w.useCallback)((e,t)=>{x(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected sampling request`)),n.filter(t=>t.id!==e)):n})},[]),N=(0,w.useCallback)(async t=>new Promise((n,r)=>{let i={id:`sampling-${S.current++}`,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:d||e},a={...i,resolve:n,reject:r};x(e=>[...e,a]),f?.(i),l?.(i,e,d||e,j,M)}),[e,d,f,l,j,M]),P=(0,w.useCallback)((e,t)=>{T(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),F=(0,w.useCallback)((e,t)=>{T(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected elicitation request`)),n.filter(t=>t.id!==e)):n})},[]),I=(0,w.useCallback)(async t=>new Promise((n,r)=>{let i={id:`elicitation-${E.current++}`,request:t,timestamp:Date.now(),serverName:d||e},a={...i,resolve:n,reject:r};T(e=>[...e,a]),p?.(i),u?.(i,e,d||e,P,F)}),[e,d,p,u,P,F]),L=NA({...g,onNotification:A,onSampling:N,onElicitation:I,wrapTransport:_}),ee=(0,w.useMemo)(()=>b.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[b]),te=(0,w.useMemo)(()=>C.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[C]),ne=(0,w.useMemo)(()=>v.filter(e=>!e.read).length,[v]),re=(0,w.useMemo)(()=>JSON.stringify(L.tools.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,_meta:e._meta})).sort((e,t)=>e.name.localeCompare(t.name))),[L.tools,e]),R=(0,w.useMemo)(()=>JSON.stringify(L.resources.map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})).sort((e,t)=>e.uri.localeCompare(t.uri))),[L.resources]),z=(0,w.useMemo)(()=>JSON.stringify(L.prompts.map(e=>({name:e.name,description:e.description,arguments:e.arguments})).sort((e,t)=>e.name.localeCompare(t.name))),[L.prompts]),B=(0,w.useRef)(s),ie=(0,w.useRef)(null),ae=(0,w.useRef)({tools:``,resources:``,prompts:``});return(0,w.useEffect)(()=>{B.current=s},[s]),(0,w.useEffect)(()=>{let n={...L,id:e,url:t.url||``,name:d||e,notifications:v,unreadNotificationCount:ne,markNotificationRead:D,markAllNotificationsRead:O,clearNotifications:k,pendingSamplingRequests:ee,approveSampling:j,rejectSampling:M,pendingElicitationRequests:te,approveElicitation:P,rejectElicitation:F},r=ie.current,i=ae.current,a=i.tools!==re,o=i.resources!==R,s=i.prompts!==z;!r||r.name!==n.name||r.state!==n.state||r.error!==n.error||r.authUrl!==n.authUrl||a||o||s||r.serverInfo!==n.serverInfo||r.capabilities!==n.capabilities||r.notifications.length!==n.notifications.length||r.unreadNotificationCount!==n.unreadNotificationCount||r.pendingSamplingRequests.length!==n.pendingSamplingRequests.length||r.pendingElicitationRequests.length!==n.pendingElicitationRequests.length||!r.client?(ie.current=n,ae.current={tools:re,resources:R,prompts:z},B.current(n)):rj.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,d,t.url,L.state,L.error,L.authUrl,re,R,z,L.serverInfo,L.capabilities,v.length,ne,ee.length,te.length,D,O,k,j,M,P,F]),null}a(oj,`McpServerWrapper`);function sj({children:e,mcpServers:t,defaultCallbackUrl:n,defaultProxyConfig:r,defaultAutoProxyFallback:i=!0,clientInfo:o,storageProvider:s,enableRpcLogging:c=!1,onServerAdded:l,onServerRemoved:u,onServerStateChange:d,onSamplingRequest:f,onElicitationRequest:p}){let[m,h]=(0,w.useState)([]),[g,_]=(0,w.useState)([]),[v,y]=(0,w.useState)(!1),b=(0,w.useRef)([]);(0,w.useEffect)(()=>{b.current=g},[g]);let x=(0,w.useRef)({}),[S,C]=(0,w.useState)(void 0),[T,E]=(0,w.useState)(!1);(0,w.useEffect)(()=>{if(!c||typeof window>`u`){C(void 0),E(!0);return}J(()=>import(`./rpc-logger-TPNV75J4-DSV4wgJB.js`).then(e=>{rj.debug(`[McpClientProvider] RPC logger loaded`),C(()=>e.wrapTransportForLogging),E(!0)}),__vite__mapDeps([0,1])).catch(e=>{rj.error(`[McpClientProvider] Failed to load RPC logger:`,e),C(void 0),E(!0)})},[c]),(0,w.useEffect)(()=>{if(!T){rj.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}a(async()=>{if(rj.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!s,`mcpServers:`,t),!s){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));rj.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),h(e)}y(!0);return}try{let e=await Promise.resolve(s.getServers());if(rj.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),s.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(s.getServerMetadata(e))]),n=await Promise.all(t);x.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),rj.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(x.current).length,`servers`)}catch(e){rj.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));rj.debug(`[McpClientProvider] Total servers after merge:`,r.length),h(r),y(!0)}catch(e){rj.error(`[McpClientProvider] Failed to load from storage:`,e),t&&h(Object.entries(t).map(([e,t])=>({id:e,options:t}))),y(!0)}},`loadServers`)()},[s,t,T]),(0,w.useEffect)(()=>{!s||!v||a(async()=>{try{let e=m.reduce((e,t)=>(e[t.id]=t.options,e),{});await Promise.resolve(s.setServers(e))}catch(e){rj.error(`[McpClientProvider] Failed to save to storage:`,e)}},`saveServers`)()},[m,s,v]);let D=(0,w.useCallback)(e=>{rj.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];_(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return rj.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>l?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,o=i.serverInfo!==e.serverInfo;if(rj.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),i.name===e.name&&i.url===e.url&&i.state===e.state&&i.tools===e.tools&&i.resources===e.resources&&i.prompts===e.prompts&&i.error===e.error&&i.serverInfo===e.serverInfo&&i.client===e.client&&i.notifications===e.notifications&&i.unreadNotificationCount===e.unreadNotificationCount&&i.pendingSamplingRequests.length===e.pendingSamplingRequests.length&&i.pendingElicitationRequests.length===e.pendingElicitationRequests.length)return rj.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(rj.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>d?.(e.id,e.state)),o&&e.serverInfo&&s?.setServerMetadata){let t={name:e.serverInfo.name,version:e.serverInfo.version,title:e.serverInfo.title,websiteUrl:e.serverInfo.websiteUrl,icons:e.serverInfo.icons,icon:e.serverInfo.icon};x.current[e.id]=t,Promise.resolve(s.setServerMetadata(e.id,t)).catch(e=>{rj.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let c=[...n];return c[r]=e,c}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[l,d,s]),O=(0,w.useCallback)((e,t)=>{h(n=>n.find(t=>t.id===e)?n:(rj.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),k=(0,w.useCallback)(e=>{let t=b.current.find(t=>t.id===e);_(t=>t.filter(t=>t.id!==e)),h(t=>t.filter(t=>t.id!==e)),t?.disconnect&&t.disconnect(),t?.clearStorage&&t.clearStorage(),u?.(e)},[u]),A=(0,w.useCallback)(async(e,t)=>new Promise(n=>{let r=m.find(t=>t.id===e);if(!r){rj.warn(`[McpClientProvider] Cannot update server "${e}" - not found`),n();return}let i={...r.options,...t,_updateVersion:(r.options._updateVersion||0)+1},a=b.current.find(t=>t.id===e);_(t=>t.filter(t=>t.id!==e)),h(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r}),a?.disconnect&&a.disconnect(),a?.clearStorage&&a.clearStorage()}),[m]),j=(0,w.useCallback)(async(e,t)=>new Promise(n=>{let r=m.find(t=>t.id===e);if(!r){rj.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`),n();return}let i={...r.options,...t};_(n=>n.map(n=>n.id===e?{...n,name:t.name}:n)),h(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[m]),M=(0,w.useCallback)(e=>g.find(t=>t.id===e),[g]),N=(0,w.useMemo)(()=>({servers:g,addServer:O,removeServer:k,updateServerMetadata:j,updateServer:A,getServer:M,storageLoaded:v}),[g,O,k,j,A,M,v]),{capabilities:P,...F}=o||{},I=(0,w.useMemo)(()=>Object.keys(F).length?F:void 0,[o]),L=(0,w.useMemo)(()=>m.map(e=>({id:e.id,options:P?{...e.options,clientOptions:{...e.options.clientOptions,capabilities:{...P,...e.options.clientOptions?.capabilities}}}:e.options})),[m,P]);return w.createElement(ij.Provider,{value:N},e,L.map(e=>w.createElement(oj,{key:`${e.id}-v${e.options._updateVersion||0}`,id:e.id,options:e.options,defaultCallbackUrl:n,defaultProxyConfig:r,defaultAutoProxyFallback:i,clientInfo:I,cachedMetadata:x.current[e.id],onUpdate:D,rpcWrapTransport:S,onGlobalSamplingRequest:f,onGlobalElicitationRequest:p})))}a(sj,`McpClientProvider`);function cj(){let e=(0,w.useContext)(ij);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}a(cj,`useMcpClient`);function ope(e){let{getServer:t}=cj();return t(e)}a(ope,`useMcpServer`);var spe=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}static{a(this,`LocalStorageProvider`)}metadataKey;getServers(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load servers:`,e),{}}}setServers(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save servers:`,e)}}setServer(e,t){let n=this.getServers();n[e]=t,this.setServers(n)}removeServer(e){let t=this.getServers();delete t[e],this.setServers(t),this.removeServerMetadata(e)}clear(){try{localStorage.removeItem(this.storageKey),localStorage.removeItem(this.metadataKey)}catch(e){console.error(`[LocalStorageProvider] Failed to clear:`,e)}}getAllMetadata(){try{let e=localStorage.getItem(this.metadataKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load metadata:`,e),{}}}setAllMetadata(e){try{localStorage.setItem(this.metadataKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save metadata:`,e)}}getServerMetadata(e){return this.getAllMetadata()[e]}setServerMetadata(e,t){let n=this.getAllMetadata();n[e]={...t,cachedAt:Date.now()},this.setAllMetadata(n)}removeServerMetadata(e){let t=this.getAllMetadata();delete t[e],this.setAllMetadata(t)}};(class{static{a(this,`MemoryStorageProvider`)}storage={};metadata={};getServers(){return{...this.storage}}setServers(e){this.storage={...e}}setServer(e,t){this.storage[e]=t}removeServer(e){delete this.storage[e],this.removeServerMetadata(e)}clear(){this.storage={},this.metadata={}}getServerMetadata(e){return this.metadata[e]}setServerMetadata(e,t){this.metadata[e]={...t,cachedAt:Date.now()}}removeServerMetadata(e){delete this.metadata[e]}});async function lj(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);if(t.value=e,t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0`,document.body.appendChild(t),t.focus(),t.select(),!document.execCommand(`copy`))throw Error(`execCommand copy failed`);document.body.removeChild(t)}function uj(e,t,n){let r=e.trim(),i=t.trim(),a=n.trim();if(!(!r&&!a))return{...r?{clientId:r}:{},...r&&i?{clientSecret:i}:{},...a?{scope:a}:{}}}function dj(e){try{let t=localStorage.getItem(`mcp-inspector-connections`);return t&&JSON.parse(t)[e]||null}catch{return null}}function cpe(e){let t=e.proxyConfig?.headers||e.proxyConfig?.customHeaders||e.headers||e.customHeaders||{};return Object.fromEntries(Object.entries(t).filter(([e,t])=>e&&t).map(([e,t])=>[e,String(t)]).sort(([e],[t])=>e.localeCompare(t)))}function fj(e){let t=e.url?.trim()||``;return{url:t,name:e.name?.trim()||t,transportType:e.transportType||`http`,proxyAddress:e.proxyConfig?.proxyAddress?.trim()||``,headers:cpe(e),oauthClientId:e.oauth?.clientId?.trim()||``,oauthClientSecret:e.oauth?.clientSecret?.trim()||``,oauthScope:e.oauth?.scope?.trim()||``}}function pj(e,t){let n=fj(e),r=fj(t);return n.url===r.url&&n.transportType===r.transportType&&n.proxyAddress===r.proxyAddress&&JSON.stringify(n.headers)===JSON.stringify(r.headers)&&n.oauthClientId===r.oauthClientId&&n.oauthClientSecret===r.oauthClientSecret&&n.oauthScope===r.oauthScope&&n.name!==r.name}function mj(e){let t=e.name?.trim(),n=e.url?.trim();return t?t===n?``:t:``}function hj(e){return mj(e)||e.serverInfo?.title?.trim()||e.serverInfo?.name?.trim()||e.name?.trim()||e.url?.trim()||`Unknown server`}var gj=`popstate`;function _j(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function lpe(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return xj(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Sj(t)}return dpe(t,n,null,e)}function vj(e,t){if(e===!1||e==null)throw Error(t)}function yj(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function upe(){return Math.random().toString(36).substring(2,10)}function bj(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function xj(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?Cj(t):t,state:n,key:t&&t.key||r||upe(),mask:i}}function Sj({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function Cj(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function dpe(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=_j(e)?e:xj(h.location,e,t);n&&n(r,e),l=u()+1;let d=bj(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=_j(e)?e:xj(h.location,e,t);n&&n(r,e),l=u();let i=bj(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return fpe(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(gj,d),c=e,()=>{i.removeEventListener(gj,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function fpe(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),vj(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Sj(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}function wj(e,t,n=`/`){return ppe(e,t,n,!1)}function ppe(e,t,n,r,i){let a=kj((typeof t==`string`?Cj(t):t).pathname||`/`,n);if(a==null)return null;let o=i??hpe(e),s=null,c=Dpe(a);for(let e=0;s==null&&e<o.length;++e)s=Tpe(o[e],c,r);return s}function mpe(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function hpe(e){let t=Tj(e);return gpe(t),t}function Tj(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;vj(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Fj([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(vj(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Tj(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Cpe(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Ej(e.path))a(e,t,!0,n)}),t}function Ej(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Ej(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function gpe(e){e.sort((e,t)=>e.score===t.score?wpe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var _pe=/^:[\w-]+$/,vpe=3,ype=2,bpe=1,xpe=10,Spe=-2,Dj=e=>e===`*`;function Cpe(e,t){let n=e.split(`/`),r=n.length;return n.some(Dj)&&(r+=Spe),t&&(r+=ype),n.filter(e=>!Dj(e)).reduce((e,t)=>e+(_pe.test(t)?vpe:t===``?bpe:xpe),r)}function wpe(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Tpe(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=Oj({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=Oj({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Fj([a,u.pathname]),pathnameBase:jpe(Fj([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Fj([a,u.pathnameBase]))}return o}function Oj(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Epe(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Epe(e,t=!1,n=!0){yj(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Dpe(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return yj(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function kj(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Ope=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function kpe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?Cj(e):e,a;return n?(n=Pj(n),a=n.startsWith(`/`)?Aj(n.substring(1),`/`):Aj(n,t)):a=t,{pathname:a,search:Mpe(r),hash:Npe(i)}}function Aj(e,t){let n=Ij(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function jj(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ape(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Mj(e){let t=Ape(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Nj(e,t,n,r=!1){let i;typeof e==`string`?i=Cj(e):(i={...e},vj(!i.pathname||!i.pathname.includes(`?`),jj(`?`,`pathname`,`search`,i)),vj(!i.pathname||!i.pathname.includes(`#`),jj(`#`,`pathname`,`hash`,i)),vj(!i.search||!i.search.includes(`#`),jj(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=kpe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Pj=e=>e.replace(/\/\/+/g,`/`),Fj=e=>Pj(e.join(`/`)),Ij=e=>e.replace(/\/+$/,``),jpe=e=>Ij(e).replace(/^\/*/,`/`),Mpe=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Npe=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ppe=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Fpe(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ipe(e){return Fj(e.map(e=>e.route.path).filter(Boolean))||`/`}var Lj=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Rj(e,t){let n=e;if(typeof n!=`string`||!Ope.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Lj)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=kj(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{yj(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var zj=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(zj);var Lpe=[`GET`,...zj];new Set(Lpe);var Bj=w.createContext(null);Bj.displayName=`DataRouter`;var Vj=w.createContext(null);Vj.displayName=`DataRouterState`;var Hj=w.createContext(!1);function Rpe(){return w.useContext(Hj)}var Uj=w.createContext({isTransitioning:!1});Uj.displayName=`ViewTransition`;var zpe=w.createContext(new Map);zpe.displayName=`Fetchers`;var Bpe=w.createContext(null);Bpe.displayName=`Await`;var Wj=w.createContext(null);Wj.displayName=`Navigation`;var Gj=w.createContext(null);Gj.displayName=`Location`;var Kj=w.createContext({outlet:null,matches:[],isDataRoute:!1});Kj.displayName=`Route`;var qj=w.createContext(null);qj.displayName=`RouteError`;var Jj=`REACT_ROUTER_ERROR`,Vpe=`REDIRECT`,Hpe=`ROUTE_ERROR_RESPONSE`;function Upe(e){if(e.startsWith(`${Jj}:${Vpe}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Wpe(e){if(e.startsWith(`${Jj}:${Hpe}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ppe(t.status,t.statusText,t.data)}catch{}}function Gpe(e,{relative:t}={}){vj(Yj(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=w.useContext(Wj),{hash:i,pathname:a,search:o}=$j(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Fj([n,a])),r.createHref({pathname:s,search:o,hash:i})}function Yj(){return w.useContext(Gj)!=null}function Xj(){return vj(Yj(),`useLocation() may be used only in the context of a <Router> component.`),w.useContext(Gj).location}var Kpe=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Zj(e){w.useContext(Wj).static||w.useLayoutEffect(e)}function Qj(){let{isDataRoute:e}=w.useContext(Kj);return e?ome():qpe()}function qpe(){vj(Yj(),`useNavigate() may be used only in the context of a <Router> component.`);let e=w.useContext(Bj),{basename:t,navigator:n}=w.useContext(Wj),{matches:r}=w.useContext(Kj),{pathname:i}=Xj(),a=JSON.stringify(Mj(r)),o=w.useRef(!1);return Zj(()=>{o.current=!0}),w.useCallback((r,s={})=>{if(yj(o.current,Kpe),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Nj(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Fj([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}w.createContext(null);function Jpe(){let{matches:e}=w.useContext(Kj);return e[e.length-1]?.params??{}}function $j(e,{relative:t}={}){let{matches:n}=w.useContext(Kj),{pathname:r}=Xj(),i=JSON.stringify(Mj(n));return w.useMemo(()=>Nj(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ype(e,t){return eM(e,t)}function eM(e,t,n){vj(Yj(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=w.useContext(Wj),{matches:i}=w.useContext(Kj),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;cM(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
453
453
|
|
|
454
454
|
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=Xj(),d;if(t){let e=typeof t==`string`?Cj(t):t;vj(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):wj(e,{pathname:p});yj(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),yj(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=eme(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:Fj([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:Fj([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?w.createElement(Gj.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function Xpe(){let e=ame(),t=Fpe(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=w.createElement(w.Fragment,null,w.createElement(`p`,null,`💿 Hey developer 👋`),w.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,w.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,w.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),w.createElement(w.Fragment,null,w.createElement(`h2`,null,`Unexpected Application Error!`),w.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?w.createElement(`pre`,{style:i},n):null,o)}var Zpe=w.createElement(Xpe,null),tM=class extends w.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Wpe(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:w.createElement(Kj.Provider,{value:this.props.routeContext},w.createElement(qj.Provider,{value:e,children:this.props.component}));return this.context?w.createElement(Qpe,{error:e},t):t}};tM.contextType=Hj;var nM=new WeakMap;function Qpe({children:e,error:t}){let{basename:n}=w.useContext(Wj);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Upe(t.digest);if(e){let r=nM.get(t);if(r)throw r;let i=Rj(e.location,n);if(Lj&&!nM.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw nM.set(t,n),n}return w.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function $pe({routeContext:e,match:t,children:n}){let r=w.useContext(Bj);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),w.createElement(Kj.Provider,{value:e},n)}function eme(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);vj(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Ipe(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||Zpe,o&&(s<0&&c===0?(cM(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?w.createElement(n.route.Component,null):n.route.element?n.route.element:e,w.createElement($pe,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?w.createElement(tM,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function rM(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function tme(e){let t=w.useContext(Bj);return vj(t,rM(e)),t}function iM(e){let t=w.useContext(Vj);return vj(t,rM(e)),t}function nme(e){let t=w.useContext(Kj);return vj(t,rM(e)),t}function aM(e){let t=nme(e),n=t.matches[t.matches.length-1];return vj(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function rme(){return aM(`useRouteId`)}function ime(){let e=iM(`useNavigation`);return w.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function oM(){let{matches:e,loaderData:t}=iM(`useMatches`);return w.useMemo(()=>e.map(e=>mpe(e,t)),[e,t])}function ame(){let e=w.useContext(qj),t=iM(`useRouteError`),n=aM(`useRouteError`);return e===void 0?t.errors?.[n]:e}function ome(){let{router:e}=tme(`useNavigate`),t=aM(`useNavigate`),n=w.useRef(!1);return Zj(()=>{n.current=!0}),w.useCallback(async(r,i={})=>{yj(n.current,Kpe),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var sM={};function cM(e,t,n){!t&&!sM[e]&&(sM[e]=!0,yj(!1,n))}w.useOptimistic,w.memo(sme);function sme({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return eM(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function lM(e){vj(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function uM({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){vj(!Yj(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=w.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=Cj(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=w.useMemo(()=>{let e=kj(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return yj(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:w.createElement(Wj.Provider,{value:c},w.createElement(Gj.Provider,{children:t,value:h}))}function cme({children:e,location:t}){return Ype(dM(e),t)}w.Component;function dM(e,t=[]){let n=[];return w.Children.forEach(e,(e,r)=>{if(!w.isValidElement(e))return;let i=[...t,r];if(e.type===w.Fragment){n.push.apply(n,dM(e.props.children,i));return}vj(e.type===lM,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),vj(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=dM(e.props.children,i)),n.push(a)}),n}var fM=`get`,pM=`application/x-www-form-urlencoded`;function mM(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function lme(e){return mM(e)&&e.tagName.toLowerCase()===`button`}function ume(e){return mM(e)&&e.tagName.toLowerCase()===`form`}function dme(e){return mM(e)&&e.tagName.toLowerCase()===`input`}function fme(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function pme(e,t){return e.button===0&&(!t||t===`_self`)&&!fme(e)}function hM(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function mme(e,t){let n=hM(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var gM=null;function hme(){if(gM===null)try{new FormData(document.createElement(`form`),0),gM=!1}catch{gM=!0}return gM}var gme=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function _M(e){return e!=null&&!gme.has(e)?(yj(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${pM}"`),null):e}function _me(e,t){let n,r,i,a,o;if(ume(e)){let o=e.getAttribute(`action`);r=o?kj(o,t):null,n=e.getAttribute(`method`)||fM,i=_M(e.getAttribute(`enctype`))||pM,a=new FormData(e)}else if(lme(e)||dme(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?kj(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||fM,i=_M(e.getAttribute(`formenctype`))||_M(o.getAttribute(`enctype`))||pM,a=new FormData(o,e),!hme()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(mM(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=fM,r=null,i=pM,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var vme={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},yme=/[&><\u2028\u2029]/g;function vM(e){return e.replace(yme,e=>vme[e])}function yM(e,t){if(e===!1||e==null)throw Error(t)}function bM(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&kj(i.pathname,t)===`/`?i.pathname=`${Ij(t)}/_root.${r}`:i.pathname=`${Ij(i.pathname)}.${r}`,i}async function bme(e,t){if(e.id in t)return t[e.id];try{let n=await J(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function xme(e){return e!=null&&typeof e.page==`string`}function Sme(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Cme(e,t,n){return Dme((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await bme(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Sme).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function xM(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function wme(e,t,{includeHydrateFallback:n}={}){return Tme(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Tme(e){return[...new Set(e)]}function Eme(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Dme(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!xme(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Eme(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function SM(){let e=w.useContext(Bj);return yM(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Ome(){let e=w.useContext(Vj);return yM(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var CM=w.createContext(void 0);CM.displayName=`FrameworkContext`;function wM(){let e=w.useContext(CM);return yM(e,`You must render this element inside a <HydratedRouter> element`),e}function kme(e,t){let n=w.useContext(CM),[r,i]=w.useState(!1),[a,o]=w.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=w.useRef(null);w.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),w.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:TM(s,p),onBlur:TM(c,m),onMouseEnter:TM(l,p),onMouseLeave:TM(u,m),onTouchStart:TM(d,p)}]:[a,f,{}]:[!1,f,{}]}function TM(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ame({page:e,...t}){let n=Rpe(),{router:r}=SM(),i=w.useMemo(()=>wj(r.routes,e,r.basename),[r.routes,e,r.basename]);return i?n?w.createElement(Mme,{page:e,matches:i,...t}):w.createElement(Nme,{page:e,matches:i,...t}):null}function jme(e){let{manifest:t,routeModules:n}=wM(),[r,i]=w.useState([]);return w.useEffect(()=>{let r=!1;return Cme(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Mme({page:e,matches:t,...n}){let r=Xj(),{future:i}=wM(),{basename:a}=SM(),o=w.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=bM(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return w.createElement(w.Fragment,null,o.map(e=>w.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function Nme({page:e,matches:t,...n}){let r=Xj(),{future:i,manifest:a,routeModules:o}=wM(),{basename:s}=SM(),{loaderData:c,matches:l}=Ome(),u=w.useMemo(()=>xM(e,t,l,a,r,`data`),[e,t,l,a,r]),d=w.useMemo(()=>xM(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=w.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=bM(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=w.useMemo(()=>wme(d,a),[d,a]),m=jme(d);return w.createElement(w.Fragment,null,f.map(e=>w.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>w.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>w.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Pme(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}w.Component;var Fme=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Fme&&(window.__reactRouterVersion=`7.16.0`)}catch{}function Ime({basename:e,children:t,useTransitions:n,window:r}){let i=w.useRef();i.current??=lpe({window:r,v5Compat:!0});let a=i.current,[o,s]=w.useState({action:a.action,location:a.location}),c=w.useCallback(e=>{n===!1?s(e):w.startTransition(()=>s(e))},[n]);return w.useLayoutEffect(()=>a.listen(c),[a,c]),w.createElement(uM,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,useTransitions:n})}function Lme({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=w.useState({action:n.action,location:n.location}),o=w.useCallback(e=>{r===!1?a(e):w.startTransition(()=>a(e))},[r]);return w.useLayoutEffect(()=>n.listen(o),[n,o]),w.createElement(uM,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}Lme.displayName=`unstable_HistoryRouter`;var EM=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,DM=w.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:_}=w.useContext(Wj),v=typeof l==`string`&&EM.test(l),y=Rj(l,h);l=y.to;let b=Gpe(l,{relative:r}),x=Xj(),S=null;if(o){let e=Nj(o,[],x.mask?x.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:Fj([h,e.pathname])),S=g.createHref(e)}let[C,T,E]=kme(n,p),D=Hme(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:_});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(y.isExternal||i),A=w.createElement(`a`,{...p,...E,href:(k?S:void 0)||y.absoluteURL||b,onClick:k?O:e,ref:Pme(m,T),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return C&&!v?w.createElement(w.Fragment,null,A,w.createElement(Ame,{page:b})):A});DM.displayName=`Link`;var Rme=w.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=$j(a,{relative:c.relative}),d=Xj(),f=w.useContext(Vj),{navigator:p,basename:m}=w.useContext(Wj),h=f!=null&&Yme(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=kj(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),S={isActive:b,isPending:x,isTransitioning:h},C=b?e:void 0,T;T=typeof n==`function`?n(S):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(S):i;return w.createElement(DM,{...c,"aria-current":C,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(S):s)});Rme.displayName=`NavLink`;var zme=w.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=fM,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=w.useContext(Wj),g=Gme(),_=Kme(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&EM.test(s);return w.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?w.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});zme.displayName=`Form`;function Bme({getKey:e,storageKey:t,...n}){let r=w.useContext(CM),{basename:i}=w.useContext(Wj),a=Xj(),o=oM();qme({getKey:e,storageKey:t});let s=w.useMemo(()=>{if(!r||!e)return null;let t=NM(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return w.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${vM(JSON.stringify(t||jM))}, ${vM(JSON.stringify(s))})`}})}Bme.displayName=`ScrollRestoration`;function OM(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kM(e){let t=w.useContext(Bj);return vj(t,OM(e)),t}function Vme(e){let t=w.useContext(Vj);return vj(t,OM(e)),t}function Hme(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=Qj(),d=Xj(),f=$j(e,{relative:o});return w.useCallback(p=>{if(pme(p,t)){p.preventDefault();let t=n===void 0?Sj(d)===Sj(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?w.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function AM(e){yj(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=w.useRef(hM(e)),n=w.useRef(!1),r=Xj(),i=w.useMemo(()=>mme(r.search,n.current?null:t.current),[r.search]),a=Qj();return[i,w.useCallback((e,t)=>{let r=hM(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Ume=0,Wme=()=>`__${String(++Ume)}__`;function Gme(){let{router:e}=kM(`useSubmit`),{basename:t}=w.useContext(Wj),n=rme(),r=e.fetch,i=e.navigate;return w.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=_me(e,t);a.navigate===!1?await r(a.fetcherKey||Wme(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Kme(e,{relative:t}={}){let{basename:n}=w.useContext(Wj),r=w.useContext(Kj);vj(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...$j(e||`.`,{relative:t})},o=Xj();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:Fj([n,a.pathname])),Sj(a)}var jM=`react-router-scroll-positions`,MM={};function NM(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:kj(e.pathname,n)||e.pathname},t)),i??=e.key,i}function qme({getKey:e,storageKey:t}={}){let{router:n}=kM(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Vme(`useScrollRestoration`),{basename:a}=w.useContext(Wj),o=Xj(),s=oM(),c=ime();w.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Jme(w.useCallback(()=>{if(c.state===`idle`){let t=NM(o,s,a,e);MM[t]=window.scrollY}try{sessionStorage.setItem(t||jM,JSON.stringify(MM))}catch(e){yj(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(w.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||jM);e&&(MM=JSON.parse(e))}catch{}},[t]),w.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(MM,()=>window.scrollY,e?(t,n)=>NM(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),w.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{yj(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Jme(e,t){let{capture:n}=t||{};w.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Yme(e,{relative:t}={}){let n=w.useContext(Uj);vj(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=kM(`useViewTransitionState`),i=$j(e,{relative:t});if(!n.isTransitioning)return!1;let a=kj(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=kj(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Oj(i.pathname,o)!=null||Oj(i.pathname,a)!=null}function Xme(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var Zme=e=>{switch(e){case`success`:return ehe;case`info`:return nhe;case`warning`:return the;case`error`:return rhe;default:return null}},Qme=Array(12).fill(0),$me=({visible:e,className:t})=>w.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},w.createElement(`div`,{className:`sonner-spinner`},Qme.map((e,t)=>w.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),ehe=w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},w.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),the=w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},w.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),nhe=w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},w.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),rhe=w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},w.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ihe=w.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},w.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),w.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),ahe=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},PM=1,FM=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:PM++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],w.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(she(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!w.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!w.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!w.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!w.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||PM++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},ohe=(e,t)=>{let n=t?.id||PM++;return FM.addToast({title:e,...t,id:n}),n},she=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,IM=Object.assign(ohe,{success:FM.success,info:FM.info,warning:FM.warning,error:FM.error,custom:FM.custom,message:FM.message,promise:FM.promise,dismiss:FM.dismiss,loading:FM.loading},{getHistory:()=>FM.toasts,getToasts:()=>FM.getActiveToasts()});Xme(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function LM(e){return e.label!==void 0}var che=3,lhe=`24px`,uhe=`16px`,RM=4e3,dhe=356,fhe=14,phe=45,mhe=200;function zM(...e){return e.filter(Boolean).join(` `)}function hhe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var ghe=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=w.useState(null),[k,A]=w.useState(null),[j,M]=w.useState(!1),[N,P]=w.useState(!1),[F,I]=w.useState(!1),[L,ee]=w.useState(!1),[te,ne]=w.useState(!1),[re,R]=w.useState(0),[z,B]=w.useState(0),ie=w.useRef(n.duration||y||RM),ae=w.useRef(null),oe=w.useRef(null),se=c===0,ce=c+1<=o,le=n.type,ue=n.dismissible!==!1,de=n.className||``,fe=n.descriptionClassName||``,pe=w.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),me=w.useMemo(()=>n.closeButton??p,[n.closeButton,p]),he=w.useMemo(()=>n.duration||y||RM,[n.duration,y]),ge=w.useRef(0),_e=w.useRef(0),ve=w.useRef(0),ye=w.useRef(null),[be,xe]=b.split(`-`),Se=w.useMemo(()=>s.reduce((e,t,n)=>n>=pe?e:e+t.height,0),[s,pe]),Ce=ahe(),we=n.invert||t,Te=le===`loading`;_e.current=w.useMemo(()=>pe*x+Se,[pe,Se]),w.useEffect(()=>{ie.current=he},[he]),w.useEffect(()=>{M(!0)},[]),w.useEffect(()=>{let e=oe.current;if(e){let t=e.getBoundingClientRect().height;return B(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),w.useLayoutEffect(()=>{if(!j)return;let e=oe.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,B(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let Ee=w.useCallback(()=>{P(!0),R(_e.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},mhe)},[n,d,a,_e]);w.useEffect(()=>{if(n.promise&&le===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||Ce?(()=>{if(ve.current<ge.current){let e=new Date().getTime()-ge.current;ie.current-=e}ve.current=new Date().getTime()})():ie.current!==1/0&&(ge.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),Ee()},ie.current)),()=>clearTimeout(e)},[u,i,n,le,Ce,Ee]),w.useEffect(()=>{n.delete&&(Ee(),n.onDismiss==null||n.onDismiss.call(n,n))},[Ee,n.delete]);function De(){return T?.loading?w.createElement(`div`,{className:zM(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":le===`loading`},T.loading):w.createElement($me,{className:zM(C?.loader,n?.classNames?.loader),visible:le===`loading`})}let Oe=n.icon||T?.[le]||Zme(le);return w.createElement(`li`,{tabIndex:0,ref:oe,className:zM(_,de,C?.toast,n?.classNames?.toast,C?.default,C?.[le],n?.classNames?.[le]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":te,"data-removed":N,"data-visible":ce,"data-y-position":be,"data-x-position":xe,"data-index":c,"data-front":se,"data-swiping":F,"data-dismissible":ue,"data-type":le,"data-invert":we,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||S&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?re:_e.current}px`,"--initial-height":S?`auto`:`${z}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),ye.current=null},onPointerDown:e=>{e.button!==2&&(Te||!ue||(ae.current=new Date,R(_e.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),ye.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!ue)return;ye.current=null;let e=Number(oe.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(oe.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-ae.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=phe||a>.11){R(_e.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),Ee(),ee(!0);return}else{var o,s;(o=oe.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=oe.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}ne(!1),I(!1),O(null)},onPointerMove:t=>{var n,r;if(!ye.current||!ue||window.getSelection()?.toString().length>0)return;let i=t.clientY-ye.current.y,a=t.clientX-ye.current.x,o=e.swipeDirections??hhe(b);!D&&(Math.abs(a)>1||Math.abs(i)>1)&&O(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(D===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&ne(!0),(n=oe.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=oe.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},me&&!n.jsx&&le!==`loading`?w.createElement(`button`,{"aria-label":E,"data-disabled":Te,"data-close-button":!0,onClick:Te||!ue?()=>{}:()=>{Ee(),n.onDismiss==null||n.onDismiss.call(n,n)},className:zM(C?.closeButton,n?.classNames?.closeButton)},T?.close??ihe):null,(le||n.icon||n.promise)&&n.icon!==null&&(T?.[le]!==null||n.icon)?w.createElement(`div`,{"data-icon":``,className:zM(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||De():null,n.type===`loading`?null:Oe):null,w.createElement(`div`,{"data-content":``,className:zM(C?.content,n?.classNames?.content)},w.createElement(`div`,{"data-title":``,className:zM(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?w.createElement(`div`,{"data-description":``,className:zM(v,fe,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),w.isValidElement(n.cancel)?n.cancel:n.cancel&&LM(n.cancel)?w.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{LM(n.cancel)&&ue&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),Ee())},className:zM(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,w.isValidElement(n.action)?n.action:n.action&&LM(n.action)?w.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{LM(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&Ee())},className:zM(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function BM(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function _he(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?uhe:lhe;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var vhe=w.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=che,toastOptions:g,dir:_=BM(),gap:v=fhe,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=w.useState([]),C=w.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),T=w.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[E,D]=w.useState([]),[O,k]=w.useState(!1),[A,j]=w.useState(!1),[M,N]=w.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=w.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=w.useRef(null),L=w.useRef(!1),ee=w.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||FM.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return w.useEffect(()=>FM.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Bt.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),w.useEffect(()=>{if(d!==`system`){N(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?N(`dark`):N(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{N(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{N(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),w.useEffect(()=>{x.length<=1&&k(!1)},[x]),w.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=P.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===P.current||P.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),w.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),w.createElement(`section`,{ref:t,"aria-label":`${b} ${F}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?w.createElement(`ol`,{key:t,dir:_===`auto`?BM():_,tabIndex:-1,ref:P,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${dhe}px`,"--gap":`${v}px`,...m,..._he(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>w.createElement(ghe,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:C.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:v,expanded:O,swipeDirections:e.swipeDirections}))):null}))}),VM=`__mcpUseInspectorReconnect`;function HM(e){if(!e||typeof e!=`string`)return console.warn(`[useAutoConnect] parseAutoConnectParam: invalid param`,e),null;let t=e.trim();if((t.startsWith(`{`)||t.startsWith(`[`))&&t.endsWith(`/`)&&(t=t.replace(/\/+$/,``)),t.startsWith(`http://`)||t.startsWith(`https://`))return console.log(`[useAutoConnect] parseAutoConnectParam: treating as plain URL:`,t),{url:t,name:`Auto-connected Server`,transportType:`http`,connectionType:`Direct`};try{let e=JSON.parse(t);if(console.log(`[useAutoConnect] parseAutoConnectParam: parsed JSON:`,e),e&&typeof e==`object`&&!Array.isArray(e))if(e.url&&typeof e.url==`string`){let t=e.url.trim();if((t.startsWith(`{`)||t.startsWith(`[`))&&t.length>2)try{let e=JSON.parse(t);e&&typeof e==`object`&&e.url&&typeof e.url==`string`?(t=e.url.trim(),console.log(`[useAutoConnect] parseAutoConnectParam: extracted URL from nested JSON:`,t)):console.warn(`[useAutoConnect] parseAutoConnectParam: url field is JSON but doesn't contain a url:`,e)}catch(e){console.warn(`[useAutoConnect] parseAutoConnectParam: url field looks like JSON but failed to parse, using as-is:`,e)}return!t.startsWith(`http://`)&&!t.startsWith(`https://`)?(console.error(`[useAutoConnect] parseAutoConnectParam: extracted URL is not a valid HTTP(S) URL:`,t),null):(console.log(`[useAutoConnect] parseAutoConnectParam: extracted URL:`,t),{url:t,name:e.name||`Auto-connected Server`,transportType:e.transportType===`sse`?`sse`:`http`,connectionType:e.connectionType===`Via Proxy`?`Via Proxy`:`Direct`,customHeaders:e.customHeaders||{},requestTimeout:e.requestTimeout,resetTimeoutOnProgress:e.resetTimeoutOnProgress,maxTotalTimeout:e.maxTotalTimeout,auth:e.auth})}else return console.warn(`[useAutoConnect] parseAutoConnectParam: parsed object missing or invalid url field:`,e),null;else return typeof e==`string`&&(e.startsWith(`http://`)||e.startsWith(`https://`))?(console.log(`[useAutoConnect] parseAutoConnectParam: JSON parsed to URL string:`,e),{url:e,name:`Auto-connected Server`,transportType:`http`,connectionType:`Direct`}):(console.warn(`[useAutoConnect] parseAutoConnectParam: parsed value is not a valid object:`,e),null)}catch(e){return console.error(`[useAutoConnect] parseAutoConnectParam: Failed to parse as JSON and not a valid URL:`,e,`Param:`,t),null}}function yhe({connections:e,addConnection:t,removeConnection:n,configLoaded:r,embedded:i=!1}){let a=Qj(),[o,s]=(0,w.useState)(!1),[c,l]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),f=(0,w.useCallback)(e=>{let{url:n,name:r,transportType:a,connectionType:o,customHeaders:s,auth:c}=e;console.log(`[useAutoConnect] Config received:`,e),console.log(`[useAutoConnect] Custom headers before auth:`,s),console.log(`[useAutoConnect] Auth config:`,c);let l={...s};if(c?.access_token){let e=c.token_type||`bearer`;if(l.Authorization=`${e.charAt(0).toUpperCase()+e.slice(1)} ${c.access_token}`,console.log(`[useAutoConnect] Added Authorization header:`,l.Authorization),typeof window<`u`&&!i){let e=`mcp:auth:${n}`,t={access_token:c.access_token,token_type:c.token_type||`bearer`,expires_at:c.expires_at,refresh_token:c.refresh_token,scope:c.scope||``};try{localStorage.setItem(e,JSON.stringify(t)),console.log(`[useAutoConnect] Pre-stored OAuth tokens for ${n}`)}catch(e){console.error(`[useAutoConnect] Failed to store OAuth tokens:`,e)}}}console.log(`[useAutoConnect] Final custom headers:`,l);let u;try{let e=new URL(n).origin,t=window.location.origin;t!==e&&(u=`${t}/inspector/api/proxy`)}catch{u=`${window.location.origin}/inspector/api/proxy`}let d={...u?{proxyAddress:u}:{},...Object.keys(l).length>0&&{headers:l}};console.warn(`[useAutoConnect] Attempting connection (${o}):`,{url:n,transportType:a,proxyConfig:d}),t(n,r,d,a)},[t]),p=(0,w.useCallback)(t=>{let n=e.find(e=>e.url===t.url);if(n)if(n.state===`ready`){console.warn(`[useAutoConnect] Connection already ready, navigating to server`);let e=new URLSearchParams(window.location.search),t=e.get(`tunnelUrl`),r=e.get(`tab`),i=e.get(`openTunnelPopover`),o=new URLSearchParams;o.set(`server`,n.id),t&&o.set(`tunnelUrl`,t),r&&o.set(`tab`,r),i&&o.set(`openTunnelPopover`,i),a(`/?${o.toString()}`)}else console.warn(`[useAutoConnect] Connection exists, waiting for ready state`),l(t),s(!0);else l(t),s(!0),f(t)},[e,a,f]);return(0,w.useEffect)(()=>{if(u)return;let e=()=>{if(typeof sessionStorage>`u`)return!1;try{let e=sessionStorage.getItem(VM);if(!e)return!1;let t=JSON.parse(e);return sessionStorage.removeItem(VM),!t?.url||!t.transportType?!1:(p(t),!0)}catch{try{sessionStorage.removeItem(VM)}catch{}return!1}};if(i){if(e()){d(!0);return}let t=new URLSearchParams(window.location.search).get(`autoConnect`);if(t){try{t=decodeURIComponent(t)}catch{}console.log(`[useAutoConnect] Raw autoConnect param:`,t);let e=HM(t);console.log(`[useAutoConnect] Parsed config:`,e),e&&p(e),d(!0);return}d(!0);return}if(r!==!0)return;if(e()){d(!0);return}let t=new URLSearchParams(window.location.search).get(`autoConnect`);if(t)try{t=decodeURIComponent(t)}catch{}if(t){let e=HM(t);e&&p(e),d(!0);return}fetch(`/inspector/config.json`).then(e=>e.json()).then(e=>{if(d(!0),e.autoConnectUrl){let t=HM(e.autoConnectUrl);t&&p(t)}}).catch(()=>d(!0))},[u,r,p,i]),(0,w.useEffect)(()=>{if(!c)return;let t=e.find(e=>e.url===c.url);if(t?.state===`ready`){console.warn(`[useAutoConnect] Connection succeeded, navigating to server`);let e=new URLSearchParams(window.location.search),n=e.get(`tunnelUrl`),r=e.get(`tab`),i=e.get(`openTunnelPopover`),o=new URLSearchParams;o.set(`server`,t.id),n&&o.set(`tunnelUrl`,n),r&&o.set(`tab`,r),i&&o.set(`openTunnelPopover`,i),a(`/?${o.toString()}`),setTimeout(()=>{l(null),s(!1)},100);return}if(t?.state===`pending_auth`||t?.state===`authenticating`){console.warn(`[useAutoConnect] Connection requires authentication, clearing loading overlay`),setTimeout(()=>{s(!1)},100);return}t?.state===`failed`&&(console.warn(`[useAutoConnect] Connection failed after all retries`),IM.error(`Cannot connect to server. Please check the URL and try again.`),queueMicrotask(()=>{s(!1),l(null)}))},[e,c,a]),(0,w.useEffect)(()=>{if(o&&e.length>0&&!c&&e.some(e=>e.state===`ready`||e.state===`failed`||e.state===`pending_auth`)){let e=setTimeout(()=>s(!1),500);return()=>clearTimeout(e)}},[o,e,c]),(0,w.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>{o&&(console.warn(`[useAutoConnect] Auto-connect timeout - clearing loading state`),s(!1),l(null))},3e4);return()=>clearTimeout(e)},[o]),{isAutoConnecting:o,autoConnectUrl:c?.url||null}}var UM=`Dialog`,[WM,GM]=Nt(UM),[bhe,KM]=WM(UM),qM=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=w.useRef(null),c=w.useRef(null),[l,u]=Lt({prop:r,defaultProp:i??!1,onChange:a,caller:UM});return(0,S.jsx)(bhe,{scope:t,triggerRef:s,contentRef:c,contentId:In(),titleId:In(),descriptionId:In(),open:l,onOpenChange:u,onOpenToggle:w.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};qM.displayName=UM;var JM=`DialogTrigger`,YM=w.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=KM(JM,n),a=D(t,i.triggerRef);return(0,S.jsx)(Jt.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":uN(i.open),...r,ref:a,onClick:jt(e.onClick,i.onOpenToggle)})});YM.displayName=JM;var XM=`DialogPortal`,[xhe,ZM]=WM(XM,{forceMount:void 0}),QM=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=KM(XM,t);return(0,S.jsx)(xhe,{scope:t,forceMount:n,children:w.Children.map(r,e=>(0,S.jsx)(ka,{present:n||a.open,children:(0,S.jsx)(Da,{asChild:!0,container:i,children:e})}))})};QM.displayName=XM;var $M=`DialogOverlay`,eN=w.forwardRef((e,t)=>{let n=ZM($M,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=KM($M,e.__scopeDialog);return a.modal?(0,S.jsx)(ka,{present:r||a.open,children:(0,S.jsx)(Che,{...i,ref:t})}):null});eN.displayName=$M;var She=Vt(`DialogOverlay.RemoveScroll`),Che=w.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=KM($M,n);return(0,S.jsx)(vs,{as:She,allowPinchZoom:!0,shards:[i.contentRef],children:(0,S.jsx)(Jt.div,{"data-state":uN(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),tN=`DialogContent`,nN=w.forwardRef((e,t)=>{let n=ZM(tN,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=KM(tN,e.__scopeDialog);return(0,S.jsx)(ka,{present:r||a.open,children:a.modal?(0,S.jsx)(whe,{...i,ref:t}):(0,S.jsx)(The,{...i,ref:t})})});nN.displayName=tN;var whe=w.forwardRef((e,t)=>{let n=KM(tN,e.__scopeDialog),r=w.useRef(null),i=D(t,n.contentRef,r);return w.useEffect(()=>{let e=r.current;if(e)return co(e)},[]),(0,S.jsx)(rN,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:jt(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:jt(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:jt(e.onFocusOutside,e=>e.preventDefault())})}),The=w.forwardRef((e,t)=>{let n=KM(tN,e.__scopeDialog),r=w.useRef(!1),i=w.useRef(!1);return(0,S.jsx)(rN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),rN=w.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=KM(tN,n),c=w.useRef(null),l=D(t,c);return gn(),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Sn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,S.jsx)(cn,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":uN(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Dhe,{titleId:s.titleId}),(0,S.jsx)(khe,{contentRef:c,descriptionId:s.descriptionId})]})]})}),iN=`DialogTitle`,aN=w.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=KM(iN,n);return(0,S.jsx)(Jt.h2,{id:i.titleId,...r,ref:t})});aN.displayName=iN;var oN=`DialogDescription`,sN=w.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=KM(oN,n);return(0,S.jsx)(Jt.p,{id:i.descriptionId,...r,ref:t})});sN.displayName=oN;var cN=`DialogClose`,lN=w.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=KM(cN,n);return(0,S.jsx)(Jt.button,{type:`button`,...r,ref:t,onClick:jt(e.onClick,()=>i.onOpenChange(!1))})});lN.displayName=cN;function uN(e){return e?`open`:`closed`}var dN=`DialogTitleWarning`,[Ehe,fN]=Mt(dN,{contentName:tN,titleName:iN,docsSlug:`dialog`}),Dhe=({titleId:e})=>{let t=fN(dN),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
455
455
|
|
|
@@ -634,7 +634,7 @@ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Rec
|
|
|
634
634
|
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Rje=Q.object({method:Q.literal(`ui/open-link`),params:Q.object({url:Q.string().describe(`URL to open in the host's browser`)})});Q.object({isError:Q.boolean().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),Q.object({isError:Q.boolean().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();var zje=Q.object({method:Q.literal(`ui/notifications/sandbox-proxy-ready`),params:Q.object({})}),T7=Q.object({connectDomains:Q.array(Q.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).`),resourceDomains:Q.array(Q.string()).optional().describe(`Origins for static resources (scripts, images, styles, fonts).`),frameDomains:Q.array(Q.string()).optional().describe(`Origins for nested iframes (frame-src directive).`),baseUriDomains:Q.array(Q.string()).optional().describe(`Allowed base URIs for the document (base-uri directive).`)}),E7=Q.object({camera:Q.object({}).optional().describe("Request camera access (Permission Policy `camera` feature)."),microphone:Q.object({}).optional().describe("Request microphone access (Permission Policy `microphone` feature)."),geolocation:Q.object({}).optional().describe("Request geolocation access (Permission Policy `geolocation` feature)."),clipboardWrite:Q.object({}).optional().describe("Request clipboard write access (Permission Policy `clipboard-write` feature).")}),Bje=Q.object({method:Q.literal(`ui/notifications/size-changed`),params:Q.object({width:Q.number().optional().describe(`New width in pixels.`),height:Q.number().optional().describe(`New height in pixels.`)})});Q.object({method:Q.literal(`ui/notifications/tool-input`),params:Q.object({arguments:Q.record(Q.string(),Q.unknown().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),Q.object({method:Q.literal(`ui/notifications/tool-input-partial`),params:Q.object({arguments:Q.record(Q.string(),Q.unknown().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),Q.object({method:Q.literal(`ui/notifications/tool-cancelled`),params:Q.object({reason:Q.string().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var Vje=Q.object({fonts:Q.string().optional()}),Hje=Q.object({variables:Lje.optional().describe(`CSS variables for theming the app.`),css:Vje.optional().describe(`CSS blocks that apps can inject.`)});Q.object({method:Q.literal(`ui/resource-teardown`),params:Q.object({})});var Uje=Q.record(Q.string(),Q.unknown()),Wje=Q.object({text:Q.object({}).optional().describe(`Host supports text content blocks.`),image:Q.object({}).optional().describe(`Host supports image content blocks.`),audio:Q.object({}).optional().describe(`Host supports audio content blocks.`),resource:Q.object({}).optional().describe(`Host supports resource content blocks.`),resourceLink:Q.object({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:Q.object({}).optional().describe(`Host supports structured content.`)}),Gje=Q.object({experimental:Q.object({}).optional().describe(`Experimental features (structure TBD).`),openLinks:Q.object({}).optional().describe(`Host supports opening external URLs.`),serverTools:Q.object({listChanged:Q.boolean().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:Q.object({listChanged:Q.boolean().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:Q.object({}).optional().describe(`Host accepts log messages.`),sandbox:Q.object({permissions:E7.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:T7.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:Wje.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:Wje.optional().describe(`Host supports receiving content messages (ui/message) from the view.`)}),Kje=Q.object({experimental:Q.object({}).optional().describe(`Experimental features (structure TBD).`),tools:Q.object({listChanged:Q.boolean().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:Q.array(w7).optional().describe(`Display modes the app supports.`)}),qje=Q.object({method:Q.literal(`ui/notifications/initialized`),params:Q.object({}).optional()});Q.object({csp:T7.optional().describe(`Content Security Policy configuration.`),permissions:E7.optional().describe(`Sandbox permissions requested by the UI.`),domain:Q.string().optional().describe(`Dedicated origin for view sandbox.`),prefersBorder:Q.boolean().optional().describe(`Visual boundary preference - true if UI prefers a visible border.`)});var Jje=Q.object({method:Q.literal(`ui/request-display-mode`),params:Q.object({mode:w7.describe(`The display mode being requested.`)})});Q.object({mode:w7.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var Yje=Q.union([Q.literal(`model`),Q.literal(`app`)]).describe(`Tool visibility scope - who can access the tool.`);Q.object({resourceUri:Q.string().optional(),visibility:Q.array(Yje).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
635
635
|
- "model": Tool visible to and callable by the agent
|
|
636
636
|
- "app": Tool callable by the app from this server only`)}),Q.object({mimeTypes:Q.array(Q.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Xje=Q.object({method:Q.literal(`ui/message`),params:Q.object({role:Q.literal(`user`).describe(`Message role, currently only "user" is supported.`),content:Q.array(Kg).describe(`Message content blocks (text, image, etc.).`)})});Q.object({method:Q.literal(`ui/notifications/sandbox-resource-ready`),params:Q.object({html:Q.string().describe(`HTML content to load into the inner iframe.`),sandbox:Q.string().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:T7.optional().describe(`CSP configuration from resource metadata.`),permissions:E7.optional().describe(`Sandbox permissions from resource metadata.`)})}),Q.object({method:Q.literal(`ui/notifications/tool-result`),params:Zg.describe(`Standard MCP tool execution result.`)});var Zje=Q.object({toolInfo:Q.object({id:Zh.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Yg.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Fje.optional().describe(`Current color theme preference.`),styles:Hje.optional().describe(`Style configuration for theming the app.`),displayMode:w7.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:Q.array(w7).optional().describe(`Display modes the host supports.`),containerDimensions:Q.union([Q.object({height:Q.number().describe(`Fixed container height in pixels.`)}),Q.object({maxHeight:Q.union([Q.number(),Q.undefined()]).optional().describe(`Maximum container height in pixels.`)})]).and(Q.union([Q.object({width:Q.number().describe(`Fixed container width in pixels.`)}),Q.object({maxWidth:Q.union([Q.number(),Q.undefined()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
637
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:Q.string().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:Q.string().optional().describe(`User's timezone in IANA format.`),userAgent:Q.string().optional().describe(`Host application identifier.`),platform:Q.union([Q.literal(`web`),Q.literal(`desktop`),Q.literal(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Q.object({touch:Q.boolean().optional().describe(`Whether the device supports touch input.`),hover:Q.boolean().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Q.object({top:Q.number().describe(`Top safe area inset in pixels.`),right:Q.number().describe(`Right safe area inset in pixels.`),bottom:Q.number().describe(`Bottom safe area inset in pixels.`),left:Q.number().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();Q.object({method:Q.literal(`ui/notifications/host-context-changed`),params:Zje.describe(`Partial context update containing only changed fields.`)});var Qje=Q.object({method:Q.literal(`ui/update-model-context`),params:Q.object({content:Q.array(Kg).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:Q.record(Q.string(),Q.unknown().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),$je=Q.object({method:Q.literal(`ui/initialize`),params:Q.object({appInfo:ug.describe(`App identification (name and version).`),appCapabilities:Kje.describe(`Features and capabilities this app provides.`),protocolVersion:Q.string().describe(`Protocol version this app supports.`)})});Q.object({protocolVersion:Q.string().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:ug.describe(`Host application identification and version.`),hostCapabilities:Gje.describe(`Features and capabilities provided by the host.`),hostContext:Zje.describe(`Rich context about the host environment.`)}).passthrough();var eMe=[OQ],tMe=class extends m_{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._capabilities=n,this._hostContext=r?.hostContext||{},this.setRequestHandler($je,e=>this._oninitialize(e)),this.setRequestHandler(pg,(e,t)=>(this.onping?.(e.params,t),{})),this.setRequestHandler(Jje,e=>({mode:this._hostContext.displayMode??`inline`}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;set onsizechange(e){this.setNotificationHandler(Bje,t=>e(t.params))}set onsandboxready(e){this.setNotificationHandler(zje,t=>e(t.params))}set oninitialized(e){this.setNotificationHandler(qje,t=>e(t.params))}set onmessage(e){this.setRequestHandler(Xje,async(t,n)=>e(t.params,n))}set onopenlink(e){this.setRequestHandler(Rje,async(t,n)=>e(t.params,n))}set onrequestdisplaymode(e){this.setRequestHandler(Jje,async(t,n)=>e(t.params,n))}set onloggingmessage(e){this.setNotificationHandler(t_,async t=>{e(t.params)})}set onupdatemodelcontext(e){this.setRequestHandler(Qje,async(t,n)=>e(t.params,n))}set oncalltool(e){this.setRequestHandler(Qg,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}set onlistresources(e){this.setRequestHandler(Ng,async(t,n)=>e(t.params,n))}set onlistresourcetemplates(e){this.setRequestHandler(Fg,async(t,n)=>e(t.params,n))}set onreadresource(e){this.setRequestHandler(Rg,async(t,n)=>e(t.params,n))}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}set onlistprompts(e){this.setRequestHandler(Vg,async(t,n)=>e(t.params,n))}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:eMe.includes(t)?t:OQ,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];nMe(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},Uje,t)}sendResourceTeardown=this.teardownResource;async connect(e){if(this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},Zg,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler($g,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},Pg,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},Ig,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},zg,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(Bg,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},Hg,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(Jg,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function nMe(e,t){return JSON.stringify(e)===JSON.stringify(t)}var rMe=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){this.listeners.get(e)?.forEach(e=>{try{e(...t)}catch(e){console.error(`Error in event listener:`,e)}})}},iMe=new class{emitter=new rMe;bufferByServer=new Map;publish(e){let t=this.bufferByServer.get(e.serverId)??[];t.push(e),t.length>1e3&&t.shift(),this.bufferByServer.set(e.serverId,t),this.emitter.emit(`event`,e)}subscribe(e,t){let n=new Set(e),r=e=>{(n.size===0||n.has(e.serverId))&&t(e)};return this.emitter.on(`event`,r),()=>this.emitter.off(`event`,r)}getBuffer(e,t){let n=new Set(e),r=[];for(let[e,t]of this.bufferByServer.entries())n.size>0&&!n.has(e)||r.push(...t);return r.sort((e,t)=>t.timestamp.localeCompare(e.timestamp)),t===0?[]:!Number.isFinite(t)||t<0?r:r.slice(0,t)}clear(e){if(e&&e.length>0){let t=new Set(e);for(let e of t)this.bufferByServer.delete(e)}else this.bufferByServer.clear()}},aMe=new class{listeners=new Set;publish(e){this.listeners.forEach(t=>{try{t(e)}catch(e){console.error(`[ConsoleLogBus] Error in listener:`,e)}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}},D7=`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox`,O7={API_ENDPOINTS:{WIDGET_STORE:`/inspector/api/mcp-apps/widget/store`,WIDGET_CONTENT:e=>`/inspector/api/mcp-apps/widget-content/${e}`},VERSION:`0.16.2`,TIMEOUTS:{TOOL_CALL:6e5,ANIMATION:300},DIMENSIONS:{PIP_WIDTH:768,PIP_MAX_WIDTH:700,PIP_HEIGHT:400,DEFAULT_HEIGHT:400}},oMe=[{value:`en-US`,label:`English (US)`},{value:`en-GB`,label:`English (UK)`},{value:`en-CA`,label:`English (Canada)`},{value:`en-AU`,label:`English (Australia)`},{value:`en-IN`,label:`English (India)`},{value:`es-ES`,label:`Spanish (Spain)`},{value:`es-MX`,label:`Spanish (Mexico)`},{value:`es-AR`,label:`Spanish (Argentina)`},{value:`es-CO`,label:`Spanish (Colombia)`},{value:`fr-FR`,label:`French (France)`},{value:`fr-CA`,label:`French (Canada)`},{value:`fr-BE`,label:`French (Belgium)`},{value:`fr-CH`,label:`French (Switzerland)`},{value:`de-DE`,label:`German (Germany)`},{value:`de-AT`,label:`German (Austria)`},{value:`de-CH`,label:`German (Switzerland)`},{value:`pt-BR`,label:`Portuguese (Brazil)`},{value:`pt-PT`,label:`Portuguese (Portugal)`},{value:`zh-CN`,label:`Chinese (Simplified, China)`},{value:`zh-TW`,label:`Chinese (Traditional, Taiwan)`},{value:`zh-HK`,label:`Chinese (Traditional, Hong Kong)`},{value:`ja-JP`,label:`Japanese (Japan)`},{value:`ko-KR`,label:`Korean (Korea)`},{value:`ar-SA`,label:`Arabic (Saudi Arabia)`},{value:`ar-EG`,label:`Arabic (Egypt)`},{value:`hi-IN`,label:`Hindi (India)`},{value:`ru-RU`,label:`Russian (Russia)`},{value:`it-IT`,label:`Italian (Italy)`},{value:`nl-NL`,label:`Dutch (Netherlands)`},{value:`nl-BE`,label:`Dutch (Belgium)`},{value:`pl-PL`,label:`Polish (Poland)`},{value:`sv-SE`,label:`Swedish (Sweden)`},{value:`no-NO`,label:`Norwegian (Norway)`},{value:`da-DK`,label:`Danish (Denmark)`},{value:`fi-FI`,label:`Finnish (Finland)`},{value:`tr-TR`,label:`Turkish (Turkey)`},{value:`el-GR`,label:`Greek (Greece)`},{value:`cs-CZ`,label:`Czech (Czech Republic)`},{value:`hu-HU`,label:`Hungarian (Hungary)`},{value:`ro-RO`,label:`Romanian (Romania)`},{value:`th-TH`,label:`Thai (Thailand)`},{value:`vi-VN`,label:`Vietnamese (Vietnam)`},{value:`id-ID`,label:`Indonesian (Indonesia)`},{value:`ms-MY`,label:`Malay (Malaysia)`},{value:`tl-PH`,label:`Tagalog (Philippines)`},{value:`he-IL`,label:`Hebrew (Israel)`},{value:`uk-UA`,label:`Ukrainian (Ukraine)`},{value:`bg-BG`,label:`Bulgarian (Bulgaria)`},{value:`hr-HR`,label:`Croatian (Croatia)`},{value:`sk-SK`,label:`Slovak (Slovakia)`},{value:`sl-SI`,label:`Slovenian (Slovenia)`},{value:`sr-RS`,label:`Serbian (Serbia)`},{value:`bn-BD`,label:`Bengali (Bangladesh)`},{value:`ta-IN`,label:`Tamil (India)`},{value:`te-IN`,label:`Telugu (India)`},{value:`mr-IN`,label:`Marathi (India)`},{value:`ur-PK`,label:`Urdu (Pakistan)`},{value:`fa-IR`,label:`Persian (Iran)`},{value:`sw-KE`,label:`Swahili (Kenya)`}];function sMe(){return Intl.supportedValuesOf(`timeZone`).map(e=>({value:e,label:e.replace(/_/g,` `)}))}var cMe=sMe();function lMe(e,t){return(0,w.useMemo)(()=>e===`custom`?{maxWidth:t.width,maxHeight:t.height}:{maxWidth:CQ[e].width,maxHeight:CQ[e].height},[e,t])}function uMe({theme:e,displayMode:t,maxWidth:n,maxHeight:r,playground:i,deviceType:a,toolCallId:o,toolName:s,toolInput:c,toolOutput:l,toolMetadata:u,tool:d}){return(0,w.useMemo)(()=>({theme:e,displayMode:t,availableDisplayModes:[`inline`,`pip`,`fullscreen`],containerDimensions:{maxHeight:r,maxWidth:n},locale:i.locale,timeZone:i.timeZone,platform:a===`mobile`?`mobile`:`web`,userAgent:`mcp-use-inspector/0.16.2`,deviceCapabilities:i.capabilities,safeAreaInsets:i.safeAreaInsets,styles:{variables:{}},toolInfo:d?{id:o,tool:d}:void 0}),[e,t,r,n,i.locale,i.timeZone,i.capabilities,i.safeAreaInsets,a,o,s,c,l,u,d])}function dMe(){let[e,t]=(0,w.useState)(0),n=(0,w.useRef)(!1);return{sandboxGeneration:e,onSandboxMount:(0,w.useCallback)(()=>n.current?(t(e=>e+1),!0):(n.current=!0,!1),[])}}var fMe=`w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background`,pMe=fMe,mMe=`fixed inset-0 z-[100] ${fMe}`,hMe=[`fixed top-4 left-1/2 -translate-x-1/2 z-[100]`,`rounded-3xl w-full min-w-[300px] h-[400px]`,`shadow-2xl border overflow-hidden`,`bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,`flex flex-col`].join(` `),k7=`data-mcp-widget-fullscreen`,A7=`data-mcp-widget-display-mode`;function gMe(e){return e?mMe:pMe}function _Me(e){(0,w.useEffect)(()=>{if(!(typeof document>`u`)){if(e===`pip`||e===`fullscreen`)return document.documentElement.setAttribute(A7,e),e===`fullscreen`?document.documentElement.setAttribute(k7,``):document.documentElement.removeAttribute(k7),()=>{document.documentElement.removeAttribute(A7),document.documentElement.removeAttribute(k7)};document.documentElement.removeAttribute(A7),document.documentElement.removeAttribute(k7)}},[e])}function vMe({containerRef:e,displayMode:t,setDisplayMode:n}){let[r,i]=(0,w.useState)(!1),a=t===`fullscreen`,o=t===`pip`;return _Me(t),(0,w.useEffect)(()=>{let e=()=>{!document.fullscreenElement&&t===`fullscreen`&&(i(!1),n(`inline`))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[t,n]),{handleDisplayModeChange:(0,w.useCallback)(async t=>{if(t===`fullscreen`){try{await e.current?.requestFullscreen(),i(!1)}catch{i(!0)}n(`fullscreen`);return}try{document.fullscreenElement&&await document.exitFullscreen()}catch{}i(!1),n(t)},[e,n]),fullscreenShellClassName:a?gMe(r):void 0,pipShellClassName:o?hMe:void 0,isFullscreen:a,isPip:o}}function yMe({title:e,onClose:t,className:n,testId:r}){return(0,S.jsxs)(`div`,{className:H(`shrink-0 z-50 flex w-full items-center justify-between px-4 py-3`,`bg-background/80 backdrop-blur-md border-b border-border`,`supports-[backdrop-filter]:bg-background/60`,n),children:[(0,S.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,S.jsx)(`span`,{className:`text-sm font-semibold text-foreground/80`,children:`MCP Inspector`})}),(0,S.jsx)(`div`,{className:`flex-1 text-center`,children:(0,S.jsx)(`h2`,{className:`text-sm font-medium text-foreground truncate max-w-md mx-auto`,children:e})}),(0,S.jsx)(`div`,{className:`flex items-center`,children:(0,S.jsxs)(`button`,{"data-testid":r,onClick:t,className:H(`flex items-center gap-2 px-3 py-1.5 rounded-md`,`text-sm font-medium`,`bg-background/50 hover:bg-background/80`,`border border-border hover:border-border/80`,`transition-colors`,`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`),"aria-label":`Exit Fullscreen`,children:[(0,S.jsx)(Fp,{className:`w-4 h-4`}),(0,S.jsx)(`span`,{className:`hidden sm:inline`,children:`Exit Fullscreen`})]})})]})}var bMe=(0,w.forwardRef)(function({html:e,sandbox:t=D7,csp:n,permissions:r,permissive:i,onProxyReady:a,onLoad:o,onSandboxMount:s,onMessage:c,className:l,style:u,title:d=`Sandboxed Content`},f){let p=(0,w.useRef)(null),[m,h]=(0,w.useState)(!1);(0,w.useEffect)(()=>{s?.()},[s]);let[g]=(0,w.useState)(()=>{let e=window.location.hostname,t=window.location.port,n=window.location.protocol,r=window.__MCP_SANDBOX_ORIGIN__;if(r)return`${r}/inspector/api/mcp-apps/sandbox-proxy?v=${Date.now()}`;let i,a=window.__MCP_DEV_MODE__===!0;i=e===`localhost`||e===`127.0.0.1`||a?e:e.startsWith(`dev.`)?`sandbox-inspector.dev.${e.slice(4)}`:e.startsWith(`inspector.`)?`sandbox-${e}`:`sandbox-inspector.${e}`;let o=t?`:${t}`:``;return`${n}//${i}${o}/inspector/api/mcp-apps/sandbox-proxy?v=${Date.now()}`}),_=(0,w.useMemo)(()=>{try{return new URL(g).origin}catch{return`*`}},[g]);(0,w.useImperativeHandle)(f,()=>({postMessage:e=>{p.current?.contentWindow?.postMessage(e,_)},getIframeElement:()=>p.current}),[_]);let v=(0,w.useCallback)(e=>{if(!(e.origin!==_&&_!==`*`)&&e.source===p.current?.contentWindow){if(e.data?.method===`ui/notifications/sandbox-proxy-ready`||e.data?.type===`sandbox-proxy-ready`){console.log(`[SandboxedIframe] Sandbox proxy ready`),h(!0),a?.();return}c(e)}},[_,a,c]);return(0,w.useEffect)(()=>(window.addEventListener(`message`,v),()=>window.removeEventListener(`message`,v)),[v]),(0,w.useEffect)(()=>{!m||!e||!p.current?.contentWindow||p.current.contentWindow.postMessage({jsonrpc:`2.0`,method:`ui/notifications/sandbox-resource-ready`,params:{html:e,sandbox:t,csp:n,permissions:r,permissive:i}},_)},[m,e,t,n,r,i,_]),(0,S.jsx)(`iframe`,{ref:p,src:g,className:l,style:u,title:d,sandbox:t,allow:`web-share`,onLoad:o})});function j7({children:e,className:t,noWrapper:n}){return n?e:(0,S.jsx)(`div`,{className:H(`bg-zinc-100 flex flex-1 items-center justify-center dark:bg-zinc-900 bg-[radial-gradient(circle,_rgba(0,0,0,0.2)_1px,_transparent_1px)] dark:bg-[radial-gradient(circle,_rgba(255,255,255,0.2)_1px,_transparent_1px)] bg-[length:32px_32px]`,t),children:e})}function xMe(e){let t=e=>e.replace(/['"<>;]/g,``).trim(),n=(e.connectDomains||[]).map(t).filter(Boolean),r=(e.resourceDomains||[]).map(t).filter(Boolean),i=(e.frameDomains||[]).map(t).filter(Boolean),a=(e.baseUriDomains||[]).map(t).filter(Boolean),o=n.length>0?n.join(` `):`'none'`,s=r.length>0?[`data:`,`blob:`,...r].join(` `):`data: blob:`,c=i.length>0?i.join(` `):`'none'`,l=a.length>0?a.join(` `):`'none'`;return[`default-src 'none'`,`script-src 'unsafe-inline' ${s}`,`style-src 'unsafe-inline' ${s}`,`img-src ${s}`,`font-src ${s}`,`media-src ${s}`,`connect-src ${o}`,`frame-src ${c}`,`object-src 'none'`,`base-uri ${l}`].join(`; `)}function SMe({serverId:e,toolCallId:t,toolName:n,toolInput:r,toolOutput:i,toolMetadata:a,invoking:o,invoked:s,partialToolInput:c,resourceUri:l,readResource:u,onSendFollowUp:d,className:f,displayMode:p,onDisplayModeChange:m,noWrapper:h,customProps:g,cancelled:_,onRerun:v,onReady:y,chromeless:b,inlineWidthOverride:x}){let C=(0,w.useRef)(null),T=(0,w.useRef)(null),{resolvedTheme:E}=LP(),{servers:D}=cj(),O=D.find(t=>t.id===e),{playground:k,addWidget:A,removeWidget:j,addCspViolation:M,setWidgetModelContext:N,setWidgetDeclaredCsp:P}=SQ(),[F,I]=(0,w.useState)(0),[L,ee]=(0,w.useState)(null),[te,ne]=(0,w.useState)(null),[re,R]=(0,w.useState)(!1),[z,B]=(0,w.useState)(!0),ie=(0,w.useRef)(!1),ae=(0,w.useRef)(null),oe=(0,w.useRef)(null),se=(0,w.useRef)(null),ce=(0,w.useRef)(0),le=(0,w.useRef)(void 0),ue=(0,w.useRef)(r),de=(0,w.useRef)(i),fe=(0,w.useRef)(g),pe=(0,w.useRef)(u),me=(0,w.useRef)(O),he=(0,w.useRef)(null);ue.current=r,de.current=i,fe.current=g,pe.current=u,me.current=O;let[ge,_e]=(0,w.useState)(void 0),[ve,ye]=(0,w.useState)(void 0),[be,xe]=(0,w.useState)(!1),[Se,Ce]=(0,w.useState)(`inline`),we=p??Se,Te=(0,w.useRef)(null),Ee=(0,w.useRef)(p),De=(0,w.useCallback)(e=>{p!==void 0&&(Ee.current=e),m?m(e):Ce(e)},[m,p]),{sandboxGeneration:Oe,onSandboxMount:ke}=dMe(),Ae=(0,w.useCallback)(()=>{ke()&&ie.current&&(B(!0),R(!1))},[ke]),{handleDisplayModeChange:je,fullscreenShellClassName:Me,pipShellClassName:Ne,isFullscreen:Pe,isPip:Fe}=vMe({containerRef:Te,displayMode:we,setDisplayMode:De}),Ie=(0,w.useRef)(je);Ie.current=je;let Le=(0,w.useRef)(we);Le.current=we,(0,w.useEffect)(()=>{p!==void 0&&Ee.current!==p&&(Ee.current=p,Ie.current(p))},[p]);let[Re,ze]=(0,w.useState)(O7.DIMENSIONS.DEFAULT_HEIGHT),Be=k.cspMode,Ve=k.deviceType,He=k.customViewport,{maxWidth:Ue,maxHeight:We}=lMe(Ve,He),Ge=x??(Ve===`mobile`?Ue:768),Ke=uMe({theme:E,displayMode:we,maxWidth:Ue,maxHeight:We,playground:k,deviceType:Ve,toolCallId:t,toolName:n,toolInput:r,toolOutput:i,toolMetadata:a,tool:(0,w.useMemo)(()=>{if(O?.tools)return O.tools.find(e=>e.name===n)},[O,n])});(0,w.useEffect)(()=>{ie.current=!1,V.current=!1},[t,l]),(0,w.useEffect)(()=>{(async()=>{try{let o=await u(l),s=o?.contents?.[0],c=s?.mimeType,d=s?._meta,f=(O?.resources?.find(e=>e.uri===l))?._meta?.ui,p=d?.ui,m=f||p?{...f,...p}:void 0,h=m?.csp;if(!h&&a?.[`openai/widgetCSP`]){let e=a[`openai/widgetCSP`],t={};Array.isArray(e.connect_domains)&&(t.connectDomains=e.connect_domains),Array.isArray(e.resource_domains)&&(t.resourceDomains=e.resource_domains),Array.isArray(e.frame_domains)&&(t.frameDomains=e.frame_domains),Array.isArray(e.base_uri_domains)&&(t.baseUriDomains=e.base_uri_domains),Array.isArray(e.script_directives)&&(t.scriptDirectives=e.script_directives),Object.keys(t).length>0&&(h=t)}let g=m?.permissions,_=m?.prefersBorder??!1,v=await fetch(O7.API_ENDPOINTS.WIDGET_STORE,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({serverId:e,uri:l,toolInput:r,toolOutput:i,toolId:t,toolName:n,theme:E,protocol:`mcp-apps`,cspMode:Be,resourceData:o,mimeType:c,mcpAppsCsp:h,mcpAppsPermissions:g})});if(!v.ok)throw Error(`Failed to store widget: ${v.statusText}`);let y=O7.API_ENDPOINTS.WIDGET_CONTENT(t),b=await fetch(`${y}?csp_mode=${Be}`);if(!b.ok){let e=await b.json().catch(()=>({}));throw Error(e.error||`Failed to fetch widget: ${b.statusText}`)}let{html:x,csp:S,permissions:C,mimeTypeWarning:w,mimeTypeValid:T}=await b.json();if(!T){ee(w||`Invalid MIME type - SEP-1865 requires "text/html;profile=mcp-app"`);return}ne(x),R(!1),ie.current||B(!0),_e(S),ye(C),xe(_),A(t,{toolName:n,protocol:`mcp-apps`,hostContext:Ke});let D=S??h,k=D&&typeof D==`object`?{connectDomains:D.connectDomains,resourceDomains:D.resourceDomains,frameDomains:D.frameDomains,baseUriDomains:D.baseUriDomains}:void 0,j;Be===`permissive`?j=[`default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:`,`script-src * 'unsafe-inline' 'unsafe-eval' data: blob:`,`style-src * 'unsafe-inline' data: blob:`,`img-src * data: blob: https: http:`,`media-src * data: blob: https: http:`,`font-src * data: blob: https: http:`,`connect-src * data: blob: https: http: ws: wss: about:`,`frame-src * data: blob: https: http: about:`,`object-src * data: blob:`,`base-uri *`,`form-action *`].join(`; `):k&&(j=xMe(k)),P(t,k,j)}catch(e){ee(e instanceof Error?e.message:`Failed to prepare widget`)}})()},[e,l,t,n]);let qe=(0,w.useRef)(Be);(0,w.useEffect)(()=>{qe.current!==Be&&(qe.current=Be,ie.current&&v&&v())},[Be,v]),(0,w.useEffect)(()=>{if(F<=1)return;let e=!1;return(async()=>{try{let t=await u(l);if(e)return;let n=t?.contents?.[0]?._meta?.ui;n&&`prefersBorder`in n&&xe(n.prefersBorder??!1)}catch{}})(),()=>{e=!0}},[F,l,u]),(0,w.useEffect)(()=>{if(!te||!C.current)return;let e=C.current.getIframeElement();if(!e?.contentWindow)return;ce.current=0,ae.current=null,oe.current=null,se.current=null,I(0);let n={sessionId:void 0,async start(){},async send(e){C.current?.postMessage(e),iMe.publish({serverId:`widget-${t}`,direction:`send`,timestamp:new Date().toISOString(),message:e})},async close(){},onmessage:void 0,onerror:void 0,onclose:void 0},r=new tMe(null,{name:`mcp-use-inspector`,version:`0.16.2`},{openLinks:{},serverTools:{},serverResources:{},logging:{},sandbox:{csp:Be===`permissive`?void 0:ge,permissions:ve}},{hostContext:Ke});r.oninitialized=()=>{let e=Date.now();if(ce.current>0&&e-ce.current<2e3){clearTimeout(le.current),le.current=setTimeout(()=>{let e=fe.current,t={};if(e)for(let[n,r]of Object.entries(e))if(typeof r==`string`&&(r.trim().startsWith(`[`)||r.trim().startsWith(`{`)))try{t[n]=JSON.parse(r)}catch{t[n]=r}else t[n]=r;let n={...ue.current,...t};r.sendToolInput({arguments:n});let i=de.current;i&&r.sendToolResult(i)},300);return}ce.current=e,I(e=>e+1)},r.onmessage=async({content:e})=>(e.length>0&&d&&d(e),{}),r.onopenlink=async({url:e})=>(e&&window.open(e,`_blank`,`noopener,noreferrer`),{}),r.oncalltool=async({name:e,arguments:t})=>{let n=me.current;if(!n)throw Error(`Server connection not available`);try{return await n.callTool(e,t||{},{timeout:O7.TIMEOUTS.TOOL_CALL,resetTimeoutOnProgress:!0})}catch(e){throw r.sendToolCancelled({reason:e instanceof Error?e.message:String(e)}),e}},r.onreadresource=async({uri:e})=>(await pe.current(e)).contents||[],r.onlistresources=async()=>{let e=me.current;if(!e)throw Error(`Server connection not available`);return{resources:e.resources}},r.onrequestdisplaymode=async({mode:e})=>{let t=e??`inline`;return await Ie.current(t),{mode:t}},r.onupdatemodelcontext=async({content:e,structuredContent:n})=>{N(t,{content:e,structuredContent:n});try{localStorage.setItem(`mcp-use:widget-state:${t}`,JSON.stringify(n))}catch{}return{}},r.onloggingmessage=async({level:e,logger:n,data:r})=>{if(aMe.publish({level:e,args:Array.isArray(r)?r:[r],timestamp:new Date().toISOString(),url:l}),e===`error`&&typeof window<`u`&&window.parent!==window){let e=typeof r==`string`?r:typeof r?.message==`string`?String(r.message):`MCP Apps runtime error`,n=typeof r?.stack==`string`?String(r.stack):void 0;window.parent.postMessage({type:`mcp-inspector:widget:error`,source:`mcp-apps:logging`,message:e,stack:n,timestamp:Date.now(),toolId:t,url:l},`*`)}return{}},r.onsizechange=({height:t})=>{if(Le.current!==`inline`)return;let n=e;if(!n||t===void 0)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`,a=t;i&&(a+=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth));let o={height:`${n.offsetHeight}px`},s={height:`${a}px`};n.style.height=`${a}px`,ze(a),n.animate([o,s],{duration:300,easing:`ease-out`})},T.current=r;let i=!0;r.connect(n).catch(e=>{i&&ee(e instanceof Error?e.message:`Failed to connect MCP App`)});let a=e=>{let r=C.current?.getIframeElement();if(!r?.contentWindow)return;let i=new URL(r.src).origin;if(e.origin===i&&e.source===r.contentWindow){if(e.data?.type===`iframe-console-log`){if(e.data.level===`error`&&typeof window<`u`&&window.parent!==window){let n=(Array.isArray(e.data.args)?e.data.args:[])[0],r=typeof n==`string`?n:typeof n?.message==`string`?n.message:`MCP Apps iframe runtime error`,i=typeof n?.error?.stack==`string`?n.error.stack:typeof n?.stack==`string`?n.stack:void 0;window.parent.postMessage({type:`mcp-inspector:widget:error`,source:`mcp-apps:iframe-console:error`,message:r,stack:i,timestamp:Date.now(),toolId:t,url:typeof e.data.url==`string`?e.data.url:l},`*`)}return}iMe.publish({serverId:`widget-${t}`,direction:`receive`,timestamp:new Date().toISOString(),message:e.data}),n.onmessage&&e.data&&n.onmessage(e.data)}};return window.addEventListener(`message`,a),()=>{ce.current=0,clearTimeout(le.current),i=!1,window.removeEventListener(`message`,a),r&&(async()=>{try{await Promise.race([r.teardownResource({}),new Promise((e,t)=>setTimeout(()=>t(Error(`teardown timeout`)),2e3))])}catch{}finally{r.close().catch(()=>{})}})(),T.current=null,he.current=null,j(t)}},[te,C,t,Oe]),(0,w.useEffect)(()=>{let e=T.current;if(!e||F===0)return;let t=JSON.stringify(Ke);he.current!==t&&(he.current=t,e.setHostContext(Ke))},[Ke,F]),(0,w.useEffect)(()=>{let e=T.current;!e||F===0||!c||e.sendToolInputPartial({arguments:c})},[F,c]),(0,w.useEffect)(()=>{let e=T.current;if(!e||F===0)return;let n={};if(g)for(let[e,t]of Object.entries(g))if(typeof t==`string`&&(t.trim().startsWith(`[`)||t.trim().startsWith(`{`)))try{n[e]=JSON.parse(t)}catch{n[e]=t}else n[e]=t;let i={...r,...n},a=JSON.stringify(i),o=`${t}:${F}`;if(!(ae.current===o&&oe.current===a))if(c){let t=requestAnimationFrame(()=>{e.sendToolInput({arguments:i}),ae.current=o,oe.current=a});return()=>cancelAnimationFrame(t)}else e.sendToolInput({arguments:i}),ae.current=o,oe.current=a},[F,r,g,t,c]),(0,w.useEffect)(()=>{let e=T.current;if(!(!e||F===0)&&i){let t=JSON.stringify({content:i?.structuredContent??i,customProps:g??null});if(se.current===t)return;se.current=t;let n=i;if(g&&Object.keys(g).length>0){let t={};for(let[e,n]of Object.entries(g))if(typeof n==`string`&&(n.trim().startsWith(`[`)||n.trim().startsWith(`{`)))try{t[e]=JSON.parse(n)}catch{t[e]=n}else t[e]=n;e.sendToolResult({...n,structuredContent:t})}else e.sendToolResult(n)}},[F,i,t,g]),(0,w.useEffect)(()=>{let e=T.current;!e||F===0||!_||e.sendToolCancelled({reason:`Cancelled by user`})},[_,F]);let Je=(0,w.useCallback)(e=>{if(e.data?.type!==`mcp-apps:csp-violation`)return;let{directive:n,blockedUri:r,sourceFile:i,lineNumber:a,columnNumber:o,effectiveDirective:s,originalPolicy:c,timestamp:l}=e.data;M(t,{directive:n,effectiveDirective:s,blockedUri:r,sourceFile:i,lineNumber:a,columnNumber:o,originalPolicy:c,timestamp:l||Date.now()}),console.warn(`[MCP Apps CSP Violation] ${n}: Blocked ${r}`,i?`at ${i}:${a}:${o}`:``)},[t,M]),Ye=F>0||re&&!ie.current,V=(0,w.useRef)(!1);if((0,w.useEffect)(()=>{V.current||F>0&&(V.current=!0,y?.())},[F,y]),(0,w.useEffect)(()=>{if(!Ye||!z)return;let e=setTimeout(()=>{B(!1),ie.current=!0},300);return()=>clearTimeout(e)},[Ye,z]),L)return(0,S.jsx)(j7,{className:f,noWrapper:h,children:(0,S.jsx)(`div`,{className:`border border-red-200/50 dark:border-red-800/50 bg-red-50/30 dark:bg-red-950/20 rounded-lg p-4`,children:(0,S.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:[`Failed to load MCP App: `,L]})})});if(!te)return(0,S.jsx)(j7,{className:f,noWrapper:h,children:(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,S.jsx)(Vq,{className:`size-5`})})});let Xe=Me||Ne||`flex group flex-1 items-center justify-center`,Ze={height:Pe||Fe?`100%`:`${Re}px`,width:`100%`,maxWidth:we===`inline`?`${Ge}px`:`100%`,transition:Pe||Fe?void 0:`height 300ms ease-out`},Qe=(0,S.jsxs)(`div`,{ref:Te,className:Xe,style:Fe?{maxWidth:O7.DIMENSIONS.PIP_MAX_WIDTH}:void 0,children:[Pe&&!b&&(0,S.jsx)(yMe,{title:n,onClose:()=>je(`inline`),testId:`debugger-exit-fullscreen-button`}),Fe&&(0,S.jsx)(`button`,{"data-testid":`debugger-exit-pip-button`,onClick:()=>je(`inline`),className:`absolute left-2 top-2 z-30 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 hover:bg-background border border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors cursor-pointer`,"aria-label":`Close PiP mode`,title:`Close PiP mode`,children:(0,S.jsx)(Fp,{className:`w-4 h-4`})}),(0,S.jsxs)(`div`,{className:H(`relative w-full min-h-0`,Pe||Fe?`flex flex-1 flex-col`:`flex flex-1 justify-center items-center`,!Fe&&!Pe&&(o||s)&&`pt-8`),children:[z&&(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full z-10`,children:(0,S.jsx)(Vq,{className:`size-5`})}),(0,S.jsxs)(`div`,{className:H(`relative w-full`,Pe||Fe?`h-full min-h-0 flex-1`:`h-full`),style:Pe||Fe?void 0:{maxWidth:Ze.maxWidth},children:[(0,S.jsx)(`div`,{className:`absolute -top-8 left-2 z-10 h-full`,children:!Fe&&!Pe&&(o||s)&&(0,S.jsxs)(`div`,{className:`whitespace-nowrap`,children:[o&&!i&&(0,S.jsx)(NY,{className:`text-xs `,children:o}),s&&!!i&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s})]})}),(0,S.jsx)(bMe,{ref:C,html:te,sandbox:D7,csp:ge,permissions:ve,permissive:Be===`permissive`,onSandboxMount:Ae,onLoad:()=>R(!0),onMessage:Je,title:`MCP App: ${n}`,className:H(we===`inline`&&`w-full`,we===`fullscreen`&&`w-full h-full rounded-none`,we===`pip`&&`w-full h-full`,we!==`fullscreen`&&be&&`rounded-lg`,`overflow-hidden`,be&&`border border-zinc-200 dark:border-zinc-700`),style:Ze}),` `]})]})]});return(0,S.jsx)(j7,{className:f,noWrapper:h,children:Fe&&typeof document<`u`?(0,Bt.createPortal)(Qe,document.body):Qe})}function CMe(e,t){for(let n of[`serverId`,`toolCallId`,`toolName`,`resourceUri`,`displayMode`,`cancelled`,`noWrapper`])if(e[n]!==t[n])return!1;return!(e.toolInput!==t.toolInput||e.toolOutput!==t.toolOutput||e.toolMetadata!==t.toolMetadata||e.partialToolInput!==t.partialToolInput||e.customProps!==t.customProps||e.readResource!==t.readResource||e.onSendFollowUp!==t.onSendFollowUp||e.onRerun!==t.onRerun||e.onReady!==t.onReady||e.chromeless!==t.chromeless||e.inlineWidthOverride!==t.inlineWidthOverride||e.onDisplayModeChange!==t.onDisplayModeChange||e.className!==t.className||e.serverBaseUrl!==t.serverBaseUrl||e.invoking!==t.invoking||e.invoked!==t.invoked)}var M7=(0,w.memo)(SMe,CMe),wMe=`
|
|
637
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:Q.string().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:Q.string().optional().describe(`User's timezone in IANA format.`),userAgent:Q.string().optional().describe(`Host application identifier.`),platform:Q.union([Q.literal(`web`),Q.literal(`desktop`),Q.literal(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Q.object({touch:Q.boolean().optional().describe(`Whether the device supports touch input.`),hover:Q.boolean().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Q.object({top:Q.number().describe(`Top safe area inset in pixels.`),right:Q.number().describe(`Right safe area inset in pixels.`),bottom:Q.number().describe(`Bottom safe area inset in pixels.`),left:Q.number().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();Q.object({method:Q.literal(`ui/notifications/host-context-changed`),params:Zje.describe(`Partial context update containing only changed fields.`)});var Qje=Q.object({method:Q.literal(`ui/update-model-context`),params:Q.object({content:Q.array(Kg).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:Q.record(Q.string(),Q.unknown().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),$je=Q.object({method:Q.literal(`ui/initialize`),params:Q.object({appInfo:ug.describe(`App identification (name and version).`),appCapabilities:Kje.describe(`Features and capabilities this app provides.`),protocolVersion:Q.string().describe(`Protocol version this app supports.`)})});Q.object({protocolVersion:Q.string().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:ug.describe(`Host application identification and version.`),hostCapabilities:Gje.describe(`Features and capabilities provided by the host.`),hostContext:Zje.describe(`Rich context about the host environment.`)}).passthrough();var eMe=[OQ],tMe=class extends m_{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._capabilities=n,this._hostContext=r?.hostContext||{},this.setRequestHandler($je,e=>this._oninitialize(e)),this.setRequestHandler(pg,(e,t)=>(this.onping?.(e.params,t),{})),this.setRequestHandler(Jje,e=>({mode:this._hostContext.displayMode??`inline`}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;set onsizechange(e){this.setNotificationHandler(Bje,t=>e(t.params))}set onsandboxready(e){this.setNotificationHandler(zje,t=>e(t.params))}set oninitialized(e){this.setNotificationHandler(qje,t=>e(t.params))}set onmessage(e){this.setRequestHandler(Xje,async(t,n)=>e(t.params,n))}set onopenlink(e){this.setRequestHandler(Rje,async(t,n)=>e(t.params,n))}set onrequestdisplaymode(e){this.setRequestHandler(Jje,async(t,n)=>e(t.params,n))}set onloggingmessage(e){this.setNotificationHandler(t_,async t=>{e(t.params)})}set onupdatemodelcontext(e){this.setRequestHandler(Qje,async(t,n)=>e(t.params,n))}set oncalltool(e){this.setRequestHandler(Qg,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}set onlistresources(e){this.setRequestHandler(Ng,async(t,n)=>e(t.params,n))}set onlistresourcetemplates(e){this.setRequestHandler(Fg,async(t,n)=>e(t.params,n))}set onreadresource(e){this.setRequestHandler(Rg,async(t,n)=>e(t.params,n))}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}set onlistprompts(e){this.setRequestHandler(Vg,async(t,n)=>e(t.params,n))}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:eMe.includes(t)?t:OQ,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];nMe(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},Uje,t)}sendResourceTeardown=this.teardownResource;async connect(e){if(this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},Zg,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler($g,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},Pg,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},Ig,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},zg,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(Bg,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},Hg,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(Jg,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function nMe(e,t){return JSON.stringify(e)===JSON.stringify(t)}var rMe=class{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){this.listeners.get(e)?.forEach(e=>{try{e(...t)}catch(e){console.error(`Error in event listener:`,e)}})}},iMe=new class{emitter=new rMe;bufferByServer=new Map;publish(e){let t=this.bufferByServer.get(e.serverId)??[];t.push(e),t.length>1e3&&t.shift(),this.bufferByServer.set(e.serverId,t),this.emitter.emit(`event`,e)}subscribe(e,t){let n=new Set(e),r=e=>{(n.size===0||n.has(e.serverId))&&t(e)};return this.emitter.on(`event`,r),()=>this.emitter.off(`event`,r)}getBuffer(e,t){let n=new Set(e),r=[];for(let[e,t]of this.bufferByServer.entries())n.size>0&&!n.has(e)||r.push(...t);return r.sort((e,t)=>t.timestamp.localeCompare(e.timestamp)),t===0?[]:!Number.isFinite(t)||t<0?r:r.slice(0,t)}clear(e){if(e&&e.length>0){let t=new Set(e);for(let e of t)this.bufferByServer.delete(e)}else this.bufferByServer.clear()}},aMe=new class{listeners=new Set;publish(e){this.listeners.forEach(t=>{try{t(e)}catch(e){console.error(`[ConsoleLogBus] Error in listener:`,e)}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}},D7=`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox`,O7={API_ENDPOINTS:{WIDGET_STORE:`/inspector/api/mcp-apps/widget/store`,WIDGET_CONTENT:e=>`/inspector/api/mcp-apps/widget-content/${e}`},VERSION:`0.16.2`,TIMEOUTS:{TOOL_CALL:6e5,ANIMATION:300},DIMENSIONS:{PIP_WIDTH:768,PIP_MAX_WIDTH:700,PIP_HEIGHT:400,DEFAULT_HEIGHT:400}},oMe=[{value:`en-US`,label:`English (US)`},{value:`en-GB`,label:`English (UK)`},{value:`en-CA`,label:`English (Canada)`},{value:`en-AU`,label:`English (Australia)`},{value:`en-IN`,label:`English (India)`},{value:`es-ES`,label:`Spanish (Spain)`},{value:`es-MX`,label:`Spanish (Mexico)`},{value:`es-AR`,label:`Spanish (Argentina)`},{value:`es-CO`,label:`Spanish (Colombia)`},{value:`fr-FR`,label:`French (France)`},{value:`fr-CA`,label:`French (Canada)`},{value:`fr-BE`,label:`French (Belgium)`},{value:`fr-CH`,label:`French (Switzerland)`},{value:`de-DE`,label:`German (Germany)`},{value:`de-AT`,label:`German (Austria)`},{value:`de-CH`,label:`German (Switzerland)`},{value:`pt-BR`,label:`Portuguese (Brazil)`},{value:`pt-PT`,label:`Portuguese (Portugal)`},{value:`zh-CN`,label:`Chinese (Simplified, China)`},{value:`zh-TW`,label:`Chinese (Traditional, Taiwan)`},{value:`zh-HK`,label:`Chinese (Traditional, Hong Kong)`},{value:`ja-JP`,label:`Japanese (Japan)`},{value:`ko-KR`,label:`Korean (Korea)`},{value:`ar-SA`,label:`Arabic (Saudi Arabia)`},{value:`ar-EG`,label:`Arabic (Egypt)`},{value:`hi-IN`,label:`Hindi (India)`},{value:`ru-RU`,label:`Russian (Russia)`},{value:`it-IT`,label:`Italian (Italy)`},{value:`nl-NL`,label:`Dutch (Netherlands)`},{value:`nl-BE`,label:`Dutch (Belgium)`},{value:`pl-PL`,label:`Polish (Poland)`},{value:`sv-SE`,label:`Swedish (Sweden)`},{value:`no-NO`,label:`Norwegian (Norway)`},{value:`da-DK`,label:`Danish (Denmark)`},{value:`fi-FI`,label:`Finnish (Finland)`},{value:`tr-TR`,label:`Turkish (Turkey)`},{value:`el-GR`,label:`Greek (Greece)`},{value:`cs-CZ`,label:`Czech (Czech Republic)`},{value:`hu-HU`,label:`Hungarian (Hungary)`},{value:`ro-RO`,label:`Romanian (Romania)`},{value:`th-TH`,label:`Thai (Thailand)`},{value:`vi-VN`,label:`Vietnamese (Vietnam)`},{value:`id-ID`,label:`Indonesian (Indonesia)`},{value:`ms-MY`,label:`Malay (Malaysia)`},{value:`tl-PH`,label:`Tagalog (Philippines)`},{value:`he-IL`,label:`Hebrew (Israel)`},{value:`uk-UA`,label:`Ukrainian (Ukraine)`},{value:`bg-BG`,label:`Bulgarian (Bulgaria)`},{value:`hr-HR`,label:`Croatian (Croatia)`},{value:`sk-SK`,label:`Slovak (Slovakia)`},{value:`sl-SI`,label:`Slovenian (Slovenia)`},{value:`sr-RS`,label:`Serbian (Serbia)`},{value:`bn-BD`,label:`Bengali (Bangladesh)`},{value:`ta-IN`,label:`Tamil (India)`},{value:`te-IN`,label:`Telugu (India)`},{value:`mr-IN`,label:`Marathi (India)`},{value:`ur-PK`,label:`Urdu (Pakistan)`},{value:`fa-IR`,label:`Persian (Iran)`},{value:`sw-KE`,label:`Swahili (Kenya)`}];function sMe(){return Intl.supportedValuesOf(`timeZone`).map(e=>({value:e,label:e.replace(/_/g,` `)}))}var cMe=sMe();function lMe(e,t){return(0,w.useMemo)(()=>e===`custom`?{maxWidth:t.width,maxHeight:t.height}:{maxWidth:CQ[e].width,maxHeight:CQ[e].height},[e,t])}function uMe({theme:e,displayMode:t,maxWidth:n,maxHeight:r,playground:i,deviceType:a,toolCallId:o,toolName:s,toolInput:c,toolOutput:l,toolMetadata:u,tool:d}){return(0,w.useMemo)(()=>({theme:e,displayMode:t,availableDisplayModes:[`inline`,`pip`,`fullscreen`],containerDimensions:{maxHeight:r,maxWidth:n},locale:i.locale,timeZone:i.timeZone,platform:a===`mobile`?`mobile`:`web`,userAgent:`mcp-use-inspector/0.16.2`,deviceCapabilities:i.capabilities,safeAreaInsets:i.safeAreaInsets,styles:{variables:{}},toolInfo:d?{id:o,tool:d}:void 0}),[e,t,r,n,i.locale,i.timeZone,i.capabilities,i.safeAreaInsets,a,o,s,c,l,u,d])}function dMe(){let[e,t]=(0,w.useState)(0),n=(0,w.useRef)(!1);return{sandboxGeneration:e,onSandboxMount:(0,w.useCallback)(()=>n.current?(t(e=>e+1),!0):(n.current=!0,!1),[])}}var fMe=`w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background`,pMe=fMe,mMe=`fixed inset-0 z-[100] ${fMe}`,hMe=[`fixed top-4 left-1/2 -translate-x-1/2 z-[100]`,`rounded-3xl w-full min-w-[300px] h-[400px]`,`shadow-2xl border overflow-hidden`,`bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80`,`flex flex-col`].join(` `),k7=`data-mcp-widget-fullscreen`,A7=`data-mcp-widget-display-mode`;function gMe(e){return e?mMe:pMe}function _Me(e){(0,w.useEffect)(()=>{if(!(typeof document>`u`)){if(e===`pip`||e===`fullscreen`)return document.documentElement.setAttribute(A7,e),e===`fullscreen`?document.documentElement.setAttribute(k7,``):document.documentElement.removeAttribute(k7),()=>{document.documentElement.removeAttribute(A7),document.documentElement.removeAttribute(k7)};document.documentElement.removeAttribute(A7),document.documentElement.removeAttribute(k7)}},[e])}function vMe({containerRef:e,displayMode:t,setDisplayMode:n}){let[r,i]=(0,w.useState)(!1),a=t===`fullscreen`,o=t===`pip`;return _Me(t),(0,w.useEffect)(()=>{let e=()=>{!document.fullscreenElement&&t===`fullscreen`&&(i(!1),n(`inline`))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[t,n]),{handleDisplayModeChange:(0,w.useCallback)(async t=>{if(t===`fullscreen`){try{await e.current?.requestFullscreen(),i(!1)}catch{i(!0)}n(`fullscreen`);return}try{document.fullscreenElement&&await document.exitFullscreen()}catch{}i(!1),n(t)},[e,n]),fullscreenShellClassName:a?gMe(r):void 0,pipShellClassName:o?hMe:void 0,isFullscreen:a,isPip:o}}function yMe({title:e,onClose:t,className:n,testId:r}){return(0,S.jsxs)(`div`,{className:H(`shrink-0 z-50 flex w-full items-center justify-between px-4 py-3`,`bg-background/80 backdrop-blur-md border-b border-border`,`supports-[backdrop-filter]:bg-background/60`,n),children:[(0,S.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,S.jsx)(`span`,{className:`text-sm font-semibold text-foreground/80`,children:`MCP Inspector`})}),(0,S.jsx)(`div`,{className:`flex-1 text-center`,children:(0,S.jsx)(`h2`,{className:`text-sm font-medium text-foreground truncate max-w-md mx-auto`,children:e})}),(0,S.jsx)(`div`,{className:`flex items-center`,children:(0,S.jsxs)(`button`,{"data-testid":r,onClick:t,className:H(`flex items-center gap-2 px-3 py-1.5 rounded-md`,`text-sm font-medium`,`bg-background/50 hover:bg-background/80`,`border border-border hover:border-border/80`,`transition-colors`,`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`),"aria-label":`Exit Fullscreen`,children:[(0,S.jsx)(Fp,{className:`w-4 h-4`}),(0,S.jsx)(`span`,{className:`hidden sm:inline`,children:`Exit Fullscreen`})]})})]})}var bMe=(0,w.forwardRef)(function({html:e,sandbox:t=D7,csp:n,permissions:r,permissive:i,onProxyReady:a,onLoad:o,onSandboxMount:s,onMessage:c,className:l,style:u,title:d=`Sandboxed Content`},f){let p=(0,w.useRef)(null),[m,h]=(0,w.useState)(!1);(0,w.useEffect)(()=>{s?.()},[s]);let[g]=(0,w.useState)(()=>{let e=window.location.hostname,t=window.location.port,n=window.location.protocol,r=window.__MCP_SANDBOX_ORIGIN__;if(r)return`${r}/inspector/api/mcp-apps/sandbox-proxy?v=${Date.now()}`;let i,a=window.__MCP_DEV_MODE__===!0;i=e===`localhost`||e===`127.0.0.1`||a?e:e.startsWith(`dev.`)?`sandbox-inspector.dev.${e.slice(4)}`:e.startsWith(`inspector.`)?`sandbox-${e}`:`sandbox-inspector.${e}`;let o=t?`:${t}`:``;return`${n}//${i}${o}/inspector/api/mcp-apps/sandbox-proxy?v=${Date.now()}`}),_=(0,w.useMemo)(()=>{try{return new URL(g).origin}catch{return`*`}},[g]);(0,w.useImperativeHandle)(f,()=>({postMessage:e=>{p.current?.contentWindow?.postMessage(e,_)},getIframeElement:()=>p.current}),[_]);let v=(0,w.useCallback)(e=>{if(!(e.origin!==_&&_!==`*`)&&e.source===p.current?.contentWindow){if(e.data?.method===`ui/notifications/sandbox-proxy-ready`||e.data?.type===`sandbox-proxy-ready`){console.log(`[SandboxedIframe] Sandbox proxy ready`),h(!0),a?.();return}c(e)}},[_,a,c]);return(0,w.useEffect)(()=>(window.addEventListener(`message`,v),()=>window.removeEventListener(`message`,v)),[v]),(0,w.useEffect)(()=>{!m||!e||!p.current?.contentWindow||p.current.contentWindow.postMessage({jsonrpc:`2.0`,method:`ui/notifications/sandbox-resource-ready`,params:{html:e,sandbox:t,csp:n,permissions:r,permissive:i}},_)},[m,e,t,n,r,i,_]),(0,S.jsx)(`iframe`,{ref:p,src:g,className:l,style:u,title:d,sandbox:t,allow:`web-share`,onLoad:o})});function j7({children:e,className:t,noWrapper:n}){return n?e:(0,S.jsx)(`div`,{className:H(`bg-zinc-100 flex flex-1 items-center justify-center dark:bg-zinc-900 bg-[radial-gradient(circle,_rgba(0,0,0,0.2)_1px,_transparent_1px)] dark:bg-[radial-gradient(circle,_rgba(255,255,255,0.2)_1px,_transparent_1px)] bg-[length:32px_32px]`,t),children:e})}function xMe(e){let t=e=>e.replace(/['"<>;]/g,``).trim(),n=(e.connectDomains||[]).map(t).filter(Boolean),r=(e.resourceDomains||[]).map(t).filter(Boolean),i=(e.frameDomains||[]).map(t).filter(Boolean),a=(e.baseUriDomains||[]).map(t).filter(Boolean),o=n.length>0?n.join(` `):`'none'`,s=r.length>0?[`data:`,`blob:`,...r].join(` `):`data: blob:`,c=i.length>0?i.join(` `):`'none'`,l=a.length>0?a.join(` `):`'none'`;return[`default-src 'none'`,`script-src 'unsafe-inline' ${s}`,`style-src 'unsafe-inline' ${s}`,`img-src ${s}`,`font-src ${s}`,`media-src ${s}`,`connect-src ${o}`,`frame-src ${c}`,`object-src 'none'`,`base-uri ${l}`].join(`; `)}function SMe({serverId:e,toolCallId:t,toolName:n,toolInput:r,toolOutput:i,toolMetadata:a,invoking:o,invoked:s,partialToolInput:c,resourceUri:l,readResource:u,onSendFollowUp:d,className:f,displayMode:p,onDisplayModeChange:m,noWrapper:h,customProps:g,cancelled:_,onRerun:v,onReady:y,chromeless:b,inlineWidthOverride:x}){let C=(0,w.useRef)(null),T=(0,w.useRef)(null),{resolvedTheme:E}=LP(),{servers:D}=cj(),O=D.find(t=>t.id===e),{playground:k,addWidget:A,removeWidget:j,addCspViolation:M,setWidgetModelContext:N,setWidgetDeclaredCsp:P}=SQ(),[F,I]=(0,w.useState)(0),[L,ee]=(0,w.useState)(null),[te,ne]=(0,w.useState)(null),[re,R]=(0,w.useState)(!1),[z,B]=(0,w.useState)(!0),ie=(0,w.useRef)(!1),ae=(0,w.useRef)(null),oe=(0,w.useRef)(null),se=(0,w.useRef)(null),ce=(0,w.useRef)(0),le=(0,w.useRef)(void 0),ue=(0,w.useRef)(r),de=(0,w.useRef)(i),fe=(0,w.useRef)(g),pe=(0,w.useRef)(u),me=(0,w.useRef)(O),he=(0,w.useRef)(null);ue.current=r,de.current=i,fe.current=g,pe.current=u,me.current=O;let[ge,_e]=(0,w.useState)(void 0),[ve,ye]=(0,w.useState)(void 0),[be,xe]=(0,w.useState)(!1),[Se,Ce]=(0,w.useState)(`inline`),we=p??Se,Te=(0,w.useRef)(null),Ee=(0,w.useRef)(p),De=(0,w.useCallback)(e=>{p!==void 0&&(Ee.current=e),m?m(e):Ce(e)},[m,p]),{sandboxGeneration:Oe,onSandboxMount:ke}=dMe(),Ae=(0,w.useCallback)(()=>{ke()&&ie.current&&(B(!0),R(!1))},[ke]),{handleDisplayModeChange:je,fullscreenShellClassName:Me,pipShellClassName:Ne,isFullscreen:Pe,isPip:Fe}=vMe({containerRef:Te,displayMode:we,setDisplayMode:De}),Ie=(0,w.useRef)(je);Ie.current=je;let Le=(0,w.useRef)(we);Le.current=we,(0,w.useEffect)(()=>{p!==void 0&&Ee.current!==p&&(Ee.current=p,Ie.current(p))},[p]);let[Re,ze]=(0,w.useState)(O7.DIMENSIONS.DEFAULT_HEIGHT),Be=k.cspMode,Ve=k.deviceType,He=k.customViewport,{maxWidth:Ue,maxHeight:We}=lMe(Ve,He),Ge=x??(Ve===`mobile`?Ue:768),Ke=uMe({theme:E,displayMode:we,maxWidth:Ue,maxHeight:We,playground:k,deviceType:Ve,toolCallId:t,toolName:n,toolInput:r,toolOutput:i,toolMetadata:a,tool:(0,w.useMemo)(()=>{if(O?.tools)return O.tools.find(e=>e.name===n)},[O,n])});(0,w.useEffect)(()=>{ie.current=!1,V.current=!1},[t,l]),(0,w.useEffect)(()=>{(async()=>{try{let o=await u(l),s=o?.contents?.[0],c=s?.mimeType,d=s?._meta,f=(O?.resources?.find(e=>e.uri===l))?._meta?.ui,p=d?.ui,m=f||p?{...f,...p}:void 0,h=m?.csp;if(!h&&a?.[`openai/widgetCSP`]){let e=a[`openai/widgetCSP`],t={};Array.isArray(e.connect_domains)&&(t.connectDomains=e.connect_domains),Array.isArray(e.resource_domains)&&(t.resourceDomains=e.resource_domains),Array.isArray(e.frame_domains)&&(t.frameDomains=e.frame_domains),Array.isArray(e.base_uri_domains)&&(t.baseUriDomains=e.base_uri_domains),Array.isArray(e.script_directives)&&(t.scriptDirectives=e.script_directives),Object.keys(t).length>0&&(h=t)}let g=m?.permissions,_=m?.prefersBorder??!1,v=await fetch(O7.API_ENDPOINTS.WIDGET_STORE,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({serverId:e,uri:l,toolInput:r,toolOutput:i,toolId:t,toolName:n,theme:E,protocol:`mcp-apps`,cspMode:Be,resourceData:o,mimeType:c,mcpAppsCsp:h,mcpAppsPermissions:g})});if(!v.ok)throw Error(`Failed to store widget: ${v.statusText}`);let y=O7.API_ENDPOINTS.WIDGET_CONTENT(t),b=await fetch(`${y}?csp_mode=${Be}`);if(!b.ok){let e=await b.json().catch(()=>({}));throw Error(e.error||`Failed to fetch widget: ${b.statusText}`)}let{html:x,csp:S,permissions:C,mimeTypeWarning:w,mimeTypeValid:T}=await b.json();if(!T){ee(w||`Invalid MIME type - SEP-1865 requires "text/html;profile=mcp-app"`);return}ne(x),R(!1),ie.current||B(!0),_e(S),ye(C),xe(_),A(t,{toolName:n,protocol:`mcp-apps`,hostContext:Ke});let D=S??h,k=D&&typeof D==`object`?{connectDomains:D.connectDomains,resourceDomains:D.resourceDomains,frameDomains:D.frameDomains,baseUriDomains:D.baseUriDomains}:void 0,j;Be===`permissive`?j=[`default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:`,`script-src * 'unsafe-inline' 'unsafe-eval' data: blob:`,`style-src * 'unsafe-inline' data: blob:`,`img-src * data: blob: https: http:`,`media-src * data: blob: https: http:`,`font-src * data: blob: https: http:`,`connect-src * data: blob: https: http: ws: wss: about:`,`frame-src * data: blob: https: http: about:`,`object-src * data: blob:`,`base-uri *`,`form-action *`].join(`; `):k&&(j=xMe(k)),P(t,k,j)}catch(e){ee(e instanceof Error?e.message:`Failed to prepare widget`)}})()},[e,l,t,n]);let qe=(0,w.useRef)(Be);(0,w.useEffect)(()=>{qe.current!==Be&&(qe.current=Be,ie.current&&v&&v())},[Be,v]),(0,w.useEffect)(()=>{if(F<=1)return;let e=!1;return(async()=>{try{let t=await u(l);if(e)return;let n=t?.contents?.[0]?._meta?.ui;n&&`prefersBorder`in n&&xe(n.prefersBorder??!1)}catch{}})(),()=>{e=!0}},[F,l,u]),(0,w.useEffect)(()=>{if(!te||!C.current)return;let e=C.current.getIframeElement();if(!e?.contentWindow)return;ce.current=0,ae.current=null,oe.current=null,se.current=null,I(0);let n={sessionId:void 0,async start(){},async send(e){C.current?.postMessage(e),iMe.publish({serverId:`widget-${t}`,direction:`send`,timestamp:new Date().toISOString(),message:e})},async close(){},onmessage:void 0,onerror:void 0,onclose:void 0},r=new tMe(null,{name:`mcp-use-inspector`,version:`0.16.2`},{openLinks:{},serverTools:{},serverResources:{},logging:{},sandbox:{csp:Be===`permissive`?void 0:ge,permissions:ve}},{hostContext:Ke});r.oninitialized=()=>{let e=Date.now();if(ce.current>0&&e-ce.current<2e3){clearTimeout(le.current),le.current=setTimeout(()=>{let e=fe.current,t={};if(e)for(let[n,r]of Object.entries(e))if(typeof r==`string`&&(r.trim().startsWith(`[`)||r.trim().startsWith(`{`)))try{t[n]=JSON.parse(r)}catch{t[n]=r}else t[n]=r;let n={...ue.current,...t};r.sendToolInput({arguments:n});let i=de.current;i&&r.sendToolResult(i)},300);return}ce.current=e,I(e=>e+1)},r.onmessage=async({content:e})=>(e.length>0&&d&&d(e),{}),r.onopenlink=async({url:e})=>(e&&window.open(e,`_blank`,`noopener,noreferrer`),{}),r.oncalltool=async({name:e,arguments:t})=>{let n=me.current;if(!n)throw Error(`Server connection not available`);try{return await n.callTool(e,t||{},{timeout:O7.TIMEOUTS.TOOL_CALL,resetTimeoutOnProgress:!0})}catch(e){throw r.sendToolCancelled({reason:e instanceof Error?e.message:String(e)}),e}},r.onreadresource=async({uri:e})=>(await pe.current(e)).contents||[],r.onlistresources=async()=>{let e=me.current;if(!e)throw Error(`Server connection not available`);return{resources:e.resources}},r.onrequestdisplaymode=async({mode:e})=>{let t=e??`inline`;return await Ie.current(t),{mode:t}},r.onupdatemodelcontext=async({content:e,structuredContent:n})=>{N(t,{content:e,structuredContent:n});try{localStorage.setItem(`mcp-use:widget-state:${t}`,JSON.stringify(n))}catch{}return{}},r.onloggingmessage=async({level:e,logger:n,data:r})=>{if(aMe.publish({level:e,args:Array.isArray(r)?r:[r],timestamp:new Date().toISOString(),url:l}),e===`error`&&typeof window<`u`&&window.parent!==window){let e=typeof r==`string`?r:typeof r?.message==`string`?String(r.message):`MCP Apps runtime error`,n=typeof r?.stack==`string`?String(r.stack):void 0;window.parent.postMessage({type:`mcp-inspector:widget:error`,source:`mcp-apps:logging`,message:e,stack:n,timestamp:Date.now(),toolId:t,url:l},`*`)}return{}},r.onsizechange=({height:t})=>{if(Le.current!==`inline`)return;let n=e;if(!n||t===void 0)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`,a=t;i&&(a+=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth));let o={height:`${n.offsetHeight}px`},s={height:`${a}px`};n.style.height=`${a}px`,ze(a),n.animate([o,s],{duration:300,easing:`ease-out`})},T.current=r;let i=!0;r.connect(n).catch(e=>{i&&ee(e instanceof Error?e.message:`Failed to connect MCP App`)});let a=e=>{let r=C.current?.getIframeElement();if(!r?.contentWindow)return;let i=new URL(r.src).origin;if(e.origin===i&&e.source===r.contentWindow){if(e.data?.type===`iframe-console-log`){if(e.data.level===`error`&&typeof window<`u`&&window.parent!==window){let n=(Array.isArray(e.data.args)?e.data.args:[])[0],r=typeof n==`string`?n:typeof n?.message==`string`?n.message:`MCP Apps iframe runtime error`,i=typeof n?.error?.stack==`string`?n.error.stack:typeof n?.stack==`string`?n.stack:void 0;window.parent.postMessage({type:`mcp-inspector:widget:error`,source:`mcp-apps:iframe-console:error`,message:r,stack:i,timestamp:Date.now(),toolId:t,url:typeof e.data.url==`string`?e.data.url:l},`*`)}return}iMe.publish({serverId:`widget-${t}`,direction:`receive`,timestamp:new Date().toISOString(),message:e.data}),n.onmessage&&e.data&&n.onmessage(e.data)}};return window.addEventListener(`message`,a),()=>{ce.current=0,clearTimeout(le.current),i=!1,window.removeEventListener(`message`,a),r&&(async()=>{try{await Promise.race([r.teardownResource({}),new Promise((e,t)=>setTimeout(()=>t(Error(`teardown timeout`)),2e3))])}catch{}finally{r.close().catch(()=>{})}})(),T.current=null,he.current=null,j(t)}},[te,C,t,Oe]),(0,w.useEffect)(()=>{let e=T.current;if(!e||F===0)return;let t=JSON.stringify(Ke);he.current!==t&&(he.current=t,e.setHostContext(Ke))},[Ke,F]),(0,w.useEffect)(()=>{let e=T.current;!e||F===0||!c||e.sendToolInputPartial({arguments:c})},[F,c]),(0,w.useEffect)(()=>{let e=T.current;if(!e||F===0)return;let n={};if(g)for(let[e,t]of Object.entries(g))if(typeof t==`string`&&(t.trim().startsWith(`[`)||t.trim().startsWith(`{`)))try{n[e]=JSON.parse(t)}catch{n[e]=t}else n[e]=t;let i={...r,...n},a=JSON.stringify(i),o=`${t}:${F}`;if(!(ae.current===o&&oe.current===a))if(c){let t=requestAnimationFrame(()=>{e.sendToolInput({arguments:i}),ae.current=o,oe.current=a});return()=>cancelAnimationFrame(t)}else e.sendToolInput({arguments:i}),ae.current=o,oe.current=a},[F,r,g,t,c]),(0,w.useEffect)(()=>{let e=T.current;if(!(!e||F===0)&&i){let t=JSON.stringify({content:i?.structuredContent??i,customProps:g??null});if(se.current===t)return;se.current=t;let n=i;if(g&&Object.keys(g).length>0){let t={};for(let[e,n]of Object.entries(g))if(typeof n==`string`&&(n.trim().startsWith(`[`)||n.trim().startsWith(`{`)))try{t[e]=JSON.parse(n)}catch{t[e]=n}else t[e]=n;e.sendToolResult({...n,structuredContent:t})}else e.sendToolResult(n)}},[F,i,t,g]),(0,w.useEffect)(()=>{let e=T.current;!e||F===0||!_||e.sendToolCancelled({reason:`Cancelled by user`})},[_,F]);let Je=(0,w.useCallback)(e=>{if(e.data?.type!==`mcp-apps:csp-violation`)return;let{directive:n,blockedUri:r,sourceFile:i,lineNumber:a,columnNumber:o,effectiveDirective:s,originalPolicy:c,timestamp:l}=e.data;M(t,{directive:n,effectiveDirective:s,blockedUri:r,sourceFile:i,lineNumber:a,columnNumber:o,originalPolicy:c,timestamp:l||Date.now()}),console.warn(`[MCP Apps CSP Violation] ${n}: Blocked ${r}`,i?`at ${i}:${a}:${o}`:``)},[t,M]),Ye=F>0||re&&!ie.current,V=(0,w.useRef)(!1);if((0,w.useEffect)(()=>{V.current||F>0&&(V.current=!0,y?.())},[F,y]),(0,w.useEffect)(()=>{if(!Ye||!z)return;let e=setTimeout(()=>{B(!1),ie.current=!0},300);return()=>clearTimeout(e)},[Ye,z]),L)return(0,S.jsx)(j7,{className:f,noWrapper:h,children:(0,S.jsx)(`div`,{className:`border border-red-200/50 dark:border-red-800/50 bg-red-50/30 dark:bg-red-950/20 rounded-lg p-4`,children:(0,S.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:[`Failed to load MCP App: `,L]})})});if(!te)return(0,S.jsx)(j7,{className:f,noWrapper:h,children:(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,S.jsx)(Vq,{className:`size-5`})})});let Xe=Me||Ne||`flex group flex-1 items-center justify-center`,Ze={height:Pe||Fe?`100%`:`${Re}px`,width:`100%`,maxWidth:we===`inline`?`${Ge}px`:`100%`,transition:Pe||Fe?void 0:`height 300ms ease-out`},Qe=(0,S.jsxs)(`div`,{ref:Te,className:Xe,style:Fe?{maxWidth:O7.DIMENSIONS.PIP_MAX_WIDTH}:void 0,children:[Pe&&!b&&(0,S.jsx)(yMe,{title:n,onClose:()=>je(`inline`),testId:`debugger-exit-fullscreen-button`}),Fe&&(0,S.jsx)(`button`,{"data-testid":`debugger-exit-pip-button`,onClick:()=>je(`inline`),className:`absolute left-2 top-2 z-30 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 hover:bg-background border border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors cursor-pointer`,"aria-label":`Close PiP mode`,title:`Close PiP mode`,children:(0,S.jsx)(Fp,{className:`w-4 h-4`})}),(0,S.jsxs)(`div`,{className:H(`relative w-full min-h-0`,Pe||Fe?`flex flex-1 flex-col`:`flex flex-1 justify-center items-center`,!Fe&&!Pe&&(o||s)&&`pt-8`),children:[z&&(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full z-10`,children:(0,S.jsx)(Vq,{className:`size-5`})}),(0,S.jsxs)(`div`,{className:H(`relative w-full`,Pe||Fe?`h-full min-h-0 flex-1`:`h-full`),style:Pe||Fe?void 0:{maxWidth:Ze.maxWidth},children:[!Fe&&!Pe&&(o||s)&&(0,S.jsxs)(`div`,{className:`absolute -top-8 left-2 z-10 whitespace-nowrap pointer-events-none`,children:[o&&!i&&(0,S.jsx)(NY,{className:`text-xs `,children:o}),s&&!!i&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s})]}),(0,S.jsx)(bMe,{ref:C,html:te,sandbox:D7,csp:ge,permissions:ve,permissive:Be===`permissive`,onSandboxMount:Ae,onLoad:()=>R(!0),onMessage:Je,title:`MCP App: ${n}`,className:H(we===`inline`&&`w-full`,we===`fullscreen`&&`w-full h-full rounded-none`,we===`pip`&&`w-full h-full`,we!==`fullscreen`&&be&&`rounded-lg`,`overflow-hidden`,be&&`border border-zinc-200 dark:border-zinc-700`),style:Ze}),` `]})]})]});return(0,S.jsx)(j7,{className:f,noWrapper:h,children:Fe&&typeof document<`u`?(0,Bt.createPortal)(Qe,document.body):Qe})}function CMe(e,t){for(let n of[`serverId`,`toolCallId`,`toolName`,`resourceUri`,`displayMode`,`cancelled`,`noWrapper`])if(e[n]!==t[n])return!1;return!(e.toolInput!==t.toolInput||e.toolOutput!==t.toolOutput||e.toolMetadata!==t.toolMetadata||e.partialToolInput!==t.partialToolInput||e.customProps!==t.customProps||e.readResource!==t.readResource||e.onSendFollowUp!==t.onSendFollowUp||e.onRerun!==t.onRerun||e.onReady!==t.onReady||e.chromeless!==t.chromeless||e.inlineWidthOverride!==t.inlineWidthOverride||e.onDisplayModeChange!==t.onDisplayModeChange||e.className!==t.className||e.serverBaseUrl!==t.serverBaseUrl||e.invoking!==t.invoking||e.invoked!==t.invoked)}var M7=(0,w.memo)(SMe,CMe),wMe=`
|
|
638
638
|
(function() {
|
|
639
639
|
'use strict';
|
|
640
640
|
|
|
@@ -791,7 +791,7 @@ Example format: {"theme": "dark", "width": "400", "title": "My Widget"}`},{role:
|
|
|
791
791
|
|
|
792
792
|
Based on this information, suggest 3-5 common customizable properties like theme, dimensions, colors, titles, or configuration options that would be useful for this type of resource. Keep it simple and practical.`}],{text:l}=await B7({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:c});try{let e=INe(l);if(e)return Object.entries(e).map(([e,t])=>({key:e,value:typeof t==`object`&&t?JSON.stringify(t):String(t)}));let t=l.split(`
|
|
793
793
|
`),n=[];for(let e of t){let t=e.match(/^\s*["']?(\w+)["']?\s*[:=]\s*["']?(.+?)["']?\s*,?\s*$/);t&&n.push({key:t[1].trim(),value:t[2].trim().replace(/^["']|["']$/g,``)})}if(n.length>0)return n;throw Error(`Could not parse props from LLM response`)}catch(e){throw console.error(`[usePropsLLM] Failed to parse LLM response:`,e),Error(`Failed to parse props from LLM response: ${l.slice(0,100)}...`)}},[e]),isAvailable:e!==null}}function RNe(e,t){if(!e?.$ref)return e;let n=e.$ref;if(n.startsWith(`#/`)){let r=n.substring(2).split(`/`),i=t;for(let t of r)if(i&&typeof i==`object`&&t in i)i=i[t];else return console.warn(`Could not resolve $ref: ${n}`),e;return i}return e}function zNe(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>e.type!==`null`);if(n)return{...RNe(n,t),nullable:!0}}return e}function BNe(e){return Array.isArray(e.enum)?e.enum:null}function VNe({name:e,schema:t,value:n,onChange:r,required:i=!1,disabled:a=!1,rootSchema:o}){let s=o||t,c=zNe(t,s);c=RNe(c,s);let l=BNe(c),u=c.type===`string`&&l!==null,d=c;return d.type===`object`||d.type===`array`?(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(AN,{htmlFor:e,className:`text-sm font-medium`,children:[e,i&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,S.jsx)(mY,{id:e,value:n,onChange:e=>r(e.target.value),placeholder:d?.description||d?.default?JSON.stringify(d.default,null,2):`Enter ${e}`,className:`min-h-[100px]`,disabled:a}),d?.description&&(0,S.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d.description})]}):u&&l?(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(AN,{htmlFor:e,className:`text-sm font-medium`,children:[e,i&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,S.jsxs)(SP,{value:n||``,onValueChange:r,disabled:a,children:[(0,S.jsx)(wP,{id:e,className:`w-full`,children:(0,S.jsx)(CP,{placeholder:d.description||`Select an option`})}),(0,S.jsx)(TP,{children:l.map((e,t)=>(0,S.jsx)(EP,{value:e,children:d.enumNames?.[t]||e},e))})]}),d.description&&(0,S.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d.description})]}):(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(AN,{htmlFor:e,className:`text-sm font-medium`,children:[e,i&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,S.jsx)(DN,{id:e,value:n,onChange:e=>r(e.target.value),placeholder:d?.description||(d?.default===void 0?`Enter ${e}`:String(d.default)),type:d.type===`number`?`number`:`text`,disabled:a}),d?.description&&(0,S.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d.description})]})}function HNe({open:e,onOpenChange:t,onSave:n,existingPresets:r,resource:i,resourceAnnotations:a,llmConfig:o,editingPreset:s}){let c=(0,w.useMemo)(()=>{let e=e=>{if(!e)return null;if(e.type===`object`&&e.properties)return e;let t=e?.def?.shape??e?._def?.shape;if(t&&typeof t==`object`){let e={},n=[],r=e=>({ZodString:`string`,string:`string`,ZodNumber:`number`,number:`number`,ZodBoolean:`boolean`,boolean:`boolean`,ZodArray:`array`,array:`array`,ZodObject:`object`,object:`object`})[e]||`string`,i=e=>e?.typeName??e?.type??``,a=e=>{let t=e?._def??e?.def??{},n=e,a=i(t);for(;a===`ZodOptional`||a===`ZodDefault`||a===`ZodNullable`;)n=t.innerType??n,a=i(n?._def??n?.def??{});let o=r(a);if(o===`array`){let e=n?._def?.type??n?.def?.element??n?.element;if(e){let t=e._def??e.def??{};if(r(i(t))===`object`){let n=t.shape??e._def?.shape??e.def?.shape??{};return{type:`array`,items:{type:`object`,properties:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{type:r(i(t?._def??t?.def??{}))}]))}}}}return{type:`array`}}return{type:o}};for(let[r,o]of Object.entries(t)){let t=o,s=t?._def??t?.def??{},c=i(s),l=c===`ZodOptional`||c===`ZodDefault`||c===`ZodNullable`,u=a(t);e[r]={type:u.type,...u.items&&{items:u.items},description:t?.description??s.description},l||n.push(r)}if(Object.keys(e).length>0)return{type:`object`,properties:e,required:n.length>0?n:void 0}}return null},t=a;if(t?.[`mcp-use/propsSchema`])return e(t[`mcp-use/propsSchema`]);let n=i.annotations;return n?.[`mcp-use/propsSchema`]?e(n[`mcp-use/propsSchema`]):null},[a,i.annotations,i.uri,i.name]),l=!!c,[u,d]=(0,w.useState)(``),[f,p]=(0,w.useState)({}),[m,h]=(0,w.useState)([{id:crypto.randomUUID(),key:``,value:``}]),[g,_]=(0,w.useState)(!1),[v,y]=(0,w.useState)(null),{generateProps:b,isAvailable:x}=LNe({llmConfig:o});(0,w.useEffect)(()=>{if(e){if(s)if(d(s.name),l)p(s.props);else{let e=Object.entries(s.props).map(([e,t])=>({id:crypto.randomUUID(),key:e,value:t}));h(e.length>0?e:[{id:crypto.randomUUID(),key:``,value:``}])}else d(``),l?p({}):h([{id:crypto.randomUUID(),key:``,value:``}]);y(null)}},[e,s,l]);let C=()=>{h([...m,{id:crypto.randomUUID(),key:``,value:``}])},T=e=>{m.length>1&&h(m.filter(t=>t.id!==e))},E=(e,t,n)=>{h(m.map(r=>r.id===e?{...r,[t]:n}:r))};return(0,S.jsx)(xN,{open:e,onOpenChange:t,children:(0,S.jsxs)(CN,{className:`sm:max-w-[600px] max-h-[80vh] flex flex-col`,"data-testid":`props-config-dialog`,children:[(0,S.jsxs)(wN,{children:[(0,S.jsx)(TN,{children:s?`Edit Preset`:`Create Props Preset`}),(0,S.jsxs)(EN,{children:[`Configure props for `,i.name||i.uri,`. You can manually add key-value pairs or generate them with AI.`]})]}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-4 py-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(AN,{htmlFor:`preset-name`,children:`Preset Name`}),(0,S.jsx)(DN,{id:`preset-name`,"data-testid":`props-config-preset-name`,value:u,onChange:e=>d(e.target.value),placeholder:`e.g., Dark Theme, Production Config`,disabled:g})]}),(0,S.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(AN,{className:`text-sm font-medium`,children:`Generate with AI`}),x&&(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Using `,o?.provider,` (`,o?.model,`)`]})]}),x?(0,S.jsx)(U,{onClick:async()=>{if(!x){IM.error(`LLM not configured`,{description:`Please configure LLM in the Chat tab first.`});return}_(!0),y(null);try{let e=await b({resource:i,resourceAnnotations:a,propsSchema:l?c:void 0});if(l){let t={};for(let n of e)c.properties?.[n.key]&&(t[n.key]=n.value);p(t)}else h(e.map(e=>({id:crypto.randomUUID(),key:e.key,value:e.value})));IM.success(`Props generated successfully`,{description:`Generated ${e.length} prop(s) using ${o?.provider}`})}catch(e){let t=e instanceof Error?e.message:`Failed to generate props`;y(t),IM.error(`LLM Generation Failed`,{description:t})}finally{_(!1)}},disabled:g,size:`sm`,variant:`outline`,className:`w-full`,"data-testid":`props-config-generate-llm-button`,children:g?(0,S.jsxs)(`span`,{"data-testid":`props-config-generating`,className:`flex items-center gap-2`,children:[(0,S.jsx)(Zf,{className:`h-4 w-4 mr-2 animate-spin`}),`Generating...`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Cp,{className:`h-4 w-4 mr-2`}),`Generate Props with LLM`]})}):(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`LLM not configured. Please configure LLM in the Chat tab to use this feature.`}),v&&(0,S.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`props-config-error`,children:v})]}),(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsx)(AN,{className:`text-sm font-medium`,children:`Props`}),l?(0,S.jsx)(`div`,{className:`space-y-4`,children:Object.entries(c.properties||{}).map(([e,t])=>(0,S.jsx)(VNe,{name:e,schema:t,value:f[e]||``,onChange:t=>p(n=>({...n,[e]:t})),required:c.required?.includes(e),disabled:g,rootSchema:c},e))}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,S.jsxs)(U,{onClick:C,size:`sm`,variant:`ghost`,disabled:g,"data-testid":`props-config-add-prop`,children:[(0,S.jsx)(lp,{className:`h-4 w-4 mr-1`}),`Add Prop`]})}),m.map((e,t)=>(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,S.jsx)(DN,{placeholder:`Key`,value:e.key,onChange:t=>E(e.id,`key`,t.target.value),disabled:g,"data-testid":`props-config-key-${t}`}),(0,S.jsx)(DN,{placeholder:`Value`,value:e.value,onChange:t=>E(e.id,`value`,t.target.value),disabled:g,"data-testid":`props-config-value-${t}`})]}),(0,S.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>T(e.id),disabled:m.length===1||g,className:`h-9 w-9 p-0`,"data-testid":`props-config-remove-${t}`,children:(0,S.jsx)(Mp,{className:`h-4 w-4 text-muted-foreground`})})]},e.id))]})]})]}),(0,S.jsxs)(Mhe,{children:[(0,S.jsx)(U,{variant:`outline`,onClick:()=>t(!1),disabled:g,"data-testid":`props-config-cancel-button`,children:`Cancel`}),(0,S.jsxs)(U,{onClick:()=>{if(!u.trim()){IM.error(`Preset name required`,{description:`Please enter a name for this preset.`});return}if(r.find(e=>e.name.toLowerCase()===u.toLowerCase()&&e.id!==s?.id)){IM.error(`Duplicate preset name`,{description:`A preset with this name already exists.`});return}let e;if(l)e={...f};else{e={};for(let t of m)t.key.trim()&&(e[t.key.trim()]=t.value)}if(Object.keys(e).length===0){IM.error(`No props defined`,{description:`Please add at least one prop with a key.`});return}let i={id:s?.id||crypto.randomUUID(),name:u.trim(),props:e};n(i),t(!1),IM.success(s?`Preset updated`:`Preset created`,{description:`Preset "${i.name}" saved successfully.`})},disabled:g,"data-testid":`props-config-save-button`,children:[s?`Update`:`Create`,` Preset`]})]})]})})}function UNe({value:e,onChange:t}){let n=(n,r)=>{let i=parseInt(r,10);isNaN(i)||t({...e,[n]:i})};return(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Top`}),(0,S.jsx)(DN,{type:`number`,min:`0`,value:e.top,onChange:e=>n(`top`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-top`})]}),(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Right`}),(0,S.jsx)(DN,{type:`number`,min:`0`,value:e.right,onChange:e=>n(`right`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-right`})]}),(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Bottom`}),(0,S.jsx)(DN,{type:`number`,min:`0`,value:e.bottom,onChange:e=>n(`bottom`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-bottom`})]}),(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Left`}),(0,S.jsx)(DN,{type:`number`,min:`0`,value:e.left,onChange:e=>n(`left`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-left`})]})]})}var V7=`__no_props__`,H7=`__tool_props__`,WNe=`__create_preset__`;function GNe(e,t){let n=new Set(t?.connectDomains??[]),r=new Set(t?.resourceDomains??[]),i=new Set(t?.frameDomains??[]),a=new Set([`script-src`,`style-src`,`img-src`,`font-src`,`media-src`]);for(let t of e){let e=(t.blockedUri||``).trim();if(!e||e===`(inline)`||e.startsWith(`blob:`)||e.startsWith(`data:`))continue;let o=null;try{o=new URL(e).origin}catch{continue}if(!o)continue;let s=(t.effectiveDirective||t.directive||``).toLowerCase();s===`connect-src`?(n.add(o),o.startsWith(`http://`)?n.add(o.replace(`http://`,`ws://`)):o.startsWith(`https://`)&&n.add(o.replace(`https://`,`wss://`))):a.has(s)?r.add(o):s===`frame-src`&&i.add(o)}let o={connectDomains:Array.from(n).sort(),resourceDomains:Array.from(r).sort()};return i.size>0&&(o.frameDomains=Array.from(i).sort()),o}var KNe=`https://raw.githubusercontent.com/modelcontextprotocol/ext-apps/bcfffb6585ea4fb1e3a9da39fb8911b83399fa71/specification/2026-01-26/apps.mdx`,qNe=`https://mcp-use.com/docs/typescript/server/csp`;function JNe(e,t,n,r){let i=[`Fix the Content Security Policy (CSP) for this MCP Apps widget. The widget has CSP violations that block network requests and resources.`,``,`**References:**`,`- MCP Apps CSP spec: ${KNe}`,`- mcp-use CSP docs: ${qNe}`,``];if(i.push(`**Current declared CSP:**`),e?(i.push(`connectDomains: ${JSON.stringify(e.connectDomains??[])}`),i.push(`resourceDomains: ${JSON.stringify(e.resourceDomains??[])}`),i.push(`frameDomains: ${JSON.stringify(e.frameDomains??[])}`),i.push(`baseUriDomains: ${JSON.stringify(e.baseUriDomains??[])}`)):i.push(`No CSP declared.`),i.push(``),t&&(i.push(`**Effective policy (originalPolicy):**`),i.push("```"),i.push(t),i.push("```"),i.push(``)),n.length>0){i.push(`**Blocked requests (${n.length}):**`);for(let e of n){let t=e.effectiveDirective||e.directive,n=e.blockedUri||`(inline)`;i.push(`- ${t}: ${n}`)}i.push(``)}return r?(i.push(`**Apply this CSP config to fix the violations:**`),i.push(`Add these domains to the widget's CSP metadata (appsSdkMetadata["openai/widgetCSP"] or resource _meta.ui.csp). Use camelCase for MCP Apps (connectDomains, resourceDomains) or snake_case for OpenAI format (connect_domains, resource_domains).`),i.push(``),i.push("```json"),i.push(JSON.stringify({connectDomains:r.connectDomains,resourceDomains:r.resourceDomains,...r.frameDomains?.length?{frameDomains:r.frameDomains}:{}},null,2)),i.push("```")):i.push(`No blocked requests - no fix needed.`),i.join(`
|
|
794
|
-
`)}function U7({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:r,resourceUri:i,toolInput:a,resourceAnnotations:o,llmConfig:s,resource:c,onPropsChange:l,requiredProps:u,protocol:d=`mcp-apps`,onUpdateGlobals:f}){let{resolvedTheme:p,setTheme:m}=LP(),{playground:h,updatePlaygroundSettings:g,widgets:_,clearCspViolations:v}=SQ(),y=_.get(n),b=y?.cspViolations??[],x=y?.declaredCsp,C=y?.effectivePolicy,T=b.length>0?GNe(b,x):null,E=b.length>0?JNe(x,C,b,T):``,D=e===`fullscreen`,O=e===`pip`,k=d===`apps-sdk`,{presets:A,activePresetId:j,savePreset:M,deletePreset:N,setActivePreset:P,getActiveProps:F}=DMe(i),[I,L]=(0,w.useState)(!1),ee=!!u?.length&&!j,[te,ne]=(0,w.useState)(()=>ee);(0,w.useEffect)(()=>{ee&&ne(!0)},[ee]);let[re,R]=(0,w.useState)(null),[z,B]=(0,w.useState)(!1),[ie,ae]=(0,w.useState)(!1),[oe,se]=(0,w.useState)(!1),[ce,le]=(0,w.useState)(!1),[ue,de]=(0,w.useState)(!0),[fe,pe]=(0,w.useState)(!0),[me,he]=(0,w.useState)(!0),ge=(0,w.useCallback)(()=>r===`tool`&&a?H7:V7,[r,a]),[_e,ve]=(0,w.useState)(ge());(0,w.useEffect)(()=>{j&&r!==`tool`?ve(j):_e!==V7&&_e!==H7&&ve(ge())},[j,_e,ge,r]),(0,w.useEffect)(()=>{l&&(_e===V7||_e===H7?l(null):j&&l(F()))},[_e,j,a,F,l]);let ye=e=>{if(e===WNe){R(null),L(!0);return}e===V7||e===H7?(P(null),ve(e)):(P(e),ve(e))},be=e=>{M(e),P(e.id),ve(e.id)},xe=(e,t)=>{t.stopPropagation();let n=A.find(t=>t.id===e);n&&(N(e),IM.success(`Preset deleted`,{description:`Preset "${n.name}" has been deleted.`}))},Se=(e,t)=>{t.stopPropagation(),R(e),L(!0)};return(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!D&&!O&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-fullscreen-button`,variant:`outline`,size:`sm`,className:`bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>t(`fullscreen`),children:(0,S.jsx)(Qf,{className:`size-4`})})}),(0,S.jsx)(jd,{children:`Enter fullscreen mode`})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-pip-button`,variant:`outline`,size:`sm`,className:`bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>t(`pip`),children:(0,S.jsx)(sp,{className:`size-4`})})}),(0,S.jsx)(jd,{children:`Picture-in-picture`})]})]}),(0,S.jsxs)(xN,{open:z,onOpenChange:B,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-device-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(()=>{switch(h.deviceType){case`mobile`:return(0,S.jsx)(Sp,{className:`size-3`});case`tablet`:return(0,S.jsx)(Ap,{className:`size-3`});default:return(0,S.jsx)(rp,{className:`size-3`})}})()})})}),(0,S.jsxs)(jd,{children:[`Device: `,h.deviceType]})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[300px]`,"data-testid":`debugger-device-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Device Type`})}),(0,S.jsx)(`div`,{className:`space-y-2`,children:[{value:`desktop`,label:`Desktop`,icon:rp},{value:`mobile`,label:`Mobile`,icon:Sp},{value:`tablet`,label:`Tablet`,icon:Ap}].map(e=>{let t=e.icon;return(0,S.jsxs)(U,{"data-testid":`debugger-device-option-${e.value}`,variant:h.deviceType===e.value?`default`:`outline`,className:`w-full justify-start`,onClick:()=>{g({deviceType:e.value}),k&&f&&f({userAgent:{device:{type:e.value},capabilities:h.capabilities}}),B(!1)},children:[(0,S.jsx)(t,{className:`size-4 mr-2`}),e.label]},e.value)})})]})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-theme-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>{let e=p===`dark`?`light`:`dark`;m(e),f&&f({theme:e})},children:p===`dark`?(0,S.jsx)(ip,{className:`size-3.5`}):(0,S.jsx)(kp,{className:`size-3.5`})})}),(0,S.jsxs)(jd,{children:[`Theme: `,p===`dark`?`Dark`:`Light`]})]}),(0,S.jsxs)(xN,{open:ie,onOpenChange:ae,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-locale-button`,variant:`outline`,size:`sm`,className:`h-8 min-w-[50px] px-2 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(0,S.jsx)(`span`,{className:`text-xs font-mono`,children:h.locale})})})}),(0,S.jsx)(jd,{children:`Locale`})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[400px]`,"data-testid":`debugger-locale-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Select Locale`})}),(0,S.jsxs)(MJ,{children:[(0,S.jsx)(NJ,{placeholder:`Search locales...`,"data-testid":`debugger-locale-search`}),(0,S.jsxs)(PJ,{children:[(0,S.jsx)(FJ,{children:`No locale found.`}),(0,S.jsx)(IJ,{children:oMe.map(e=>(0,S.jsx)(LJ,{value:e.value,"data-testid":`debugger-locale-option-${e.value}`,onSelect:()=>{g({locale:e.value}),k&&f&&f({locale:e.value}),ae(!1)},children:e.label},e.value))})]})]})]})]}),!k&&(0,S.jsxs)(xN,{open:oe,onOpenChange:se,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-timezone-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(0,S.jsx)(Df,{className:`size-3.5`})})})}),(0,S.jsxs)(jd,{children:[`Timezone: `,h.timeZone]})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[400px]`,"data-testid":`debugger-timezone-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Select Timezone`})}),(0,S.jsxs)(MJ,{children:[(0,S.jsx)(NJ,{placeholder:`Search timezones...`,"data-testid":`debugger-timezone-search`}),(0,S.jsxs)(PJ,{children:[(0,S.jsx)(FJ,{children:`No timezone found.`}),(0,S.jsx)(IJ,{children:cMe.map(e=>(0,S.jsx)(LJ,{value:e.value,"data-testid":`debugger-timezone-option-${e.value.replace(/\//g,`-`)}`,onSelect:()=>{g({timeZone:e.value}),se(!1)},children:e.label},e.value))})]})]})]})]}),(0,S.jsxs)(xN,{open:ce,onOpenChange:le,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsxs)(U,{"data-testid":`debugger-csp-button`,variant:`outline`,size:`sm`,className:`relative h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:[h.cspMode===`permissive`?(0,S.jsx)(bp,{className:`size-3.5`}):(0,S.jsx)(yp,{className:`size-3.5`}),b.length>0&&(0,S.jsx)(`span`,{className:`absolute -top-1.5 -right-1.5 flex h-4 min-w-4 items-center justify-center rounded-full px-0.5 text-[9px] font-bold text-white leading-none ${h.cspMode===`permissive`?`bg-yellow-500`:`bg-red-500`}`,children:b.length>99?`99+`:b.length})]})})}),(0,S.jsxs)(jd,{children:[`CSP:`,` `,h.cspMode===`permissive`?`Permissive`:`Declared`,b.length>0&&` · ${b.length} ${h.cspMode===`permissive`?`would be blocked`:`blocked`}`]})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[520px] max-h-[85vh] overflow-y-auto`,"data-testid":`debugger-csp-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`CSP Mode`})}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(U,{"data-testid":`debugger-csp-option-permissive`,variant:h.cspMode===`permissive`?`default`:`outline`,className:`w-full justify-start`,onClick:()=>{g({cspMode:`permissive`}),le(!1)},children:[(0,S.jsx)(bp,{className:`size-4 mr-2`}),(0,S.jsx)(`div`,{className:`flex flex-col items-start`,children:(0,S.jsx)(`span`,{children:`Permissive`})})]}),(0,S.jsxs)(U,{"data-testid":`debugger-csp-option-widget-declared`,variant:h.cspMode===`widget-declared`?`default`:`outline`,className:`w-full justify-start`,onClick:()=>{g({cspMode:`widget-declared`}),le(!1)},children:[(0,S.jsx)(yp,{className:`size-4 mr-2`}),(0,S.jsx)(`div`,{className:`flex flex-col items-start`,children:(0,S.jsx)(`span`,{children:`Widget-Declared`})})]})]}),(0,S.jsxs)(`div`,{className:`mt-3 border border-zinc-200 dark:border-zinc-700 rounded-md overflow-hidden`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-medium bg-zinc-50 dark:bg-zinc-900/50 hover:bg-zinc-100 dark:hover:bg-zinc-800/50 transition-colors`,onClick:()=>de(e=>!e),children:[ue?(0,S.jsx)(yf,{className:`size-3.5 shrink-0`}):(0,S.jsx)(xf,{className:`size-3.5 shrink-0`}),`Current declared CSP`]}),ue&&(0,S.jsx)(`div`,{className:`px-3 pb-3 pt-0 space-y-1.5 text-xs`,children:x?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`connectDomains:`}),` `,x.connectDomains?.length?JSON.stringify(x.connectDomains):`Not declared`]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`resourceDomains:`}),` `,x.resourceDomains?.length?JSON.stringify(x.resourceDomains):`Not declared`]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`frameDomains:`}),` `,x.frameDomains?.length?JSON.stringify(x.frameDomains):`Not declared`]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`baseUriDomains:`}),` `,x.baseUriDomains?.length?JSON.stringify(x.baseUriDomains):`Not declared`]})]}):(0,S.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:h.cspMode===`permissive`?`Widget-declared (would apply in Widget-Declared mode)`:`No CSP declared`})})]}),(0,S.jsxs)(`div`,{className:`mt-3 border border-zinc-200 dark:border-zinc-700 rounded-md overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 bg-zinc-50 dark:bg-zinc-900/50 hover:bg-zinc-100 dark:hover:bg-zinc-800/50 transition-colors`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`flex-1 flex items-center gap-2 text-left text-sm font-medium min-w-0`,onClick:()=>pe(e=>!e),children:[fe?(0,S.jsx)(yf,{className:`size-3.5 shrink-0`}):(0,S.jsx)(xf,{className:`size-3.5 shrink-0`}),`originalPolicy`]}),C&&(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,onClick:async e=>{e.stopPropagation();try{await lj(C),IM.success(`Policy copied to clipboard`)}catch{IM.error(`Failed to copy`)}},"aria-label":`Copy policy`,children:(0,S.jsx)(jf,{className:`size-3.5`})})}),(0,S.jsx)(jd,{children:`Copy policy`})]})]}),fe&&(0,S.jsx)(`div`,{className:`px-3 pb-3 pt-0`,children:C?(0,S.jsx)(`pre`,{className:`text-[11px] font-mono text-zinc-600 dark:text-zinc-400 whitespace-pre-wrap break-all bg-zinc-50 dark:bg-zinc-900 p-2 rounded border border-zinc-100 dark:border-zinc-800`,children:C}):(0,S.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400 text-xs`,children:`No policy data yet (load widget in Widget-Declared mode)`})})]}),b.length>-1&&(0,S.jsxs)(`div`,{className:`mt-3 border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 bg-amber-50 dark:bg-amber-950/30 hover:bg-amber-100 dark:hover:bg-amber-900/30 transition-colors`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`flex-1 flex items-center gap-2 text-left text-sm font-medium min-w-0 text-amber-800 dark:text-amber-200`,onClick:()=>he(e=>!e),children:[me?(0,S.jsx)(yf,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}):(0,S.jsx)(xf,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),`Prompt for Agents`]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-amber-600 dark:text-amber-400 hover:bg-amber-200/50 dark:hover:bg-amber-800/30`,onClick:async e=>{e.stopPropagation();try{await lj(E),IM.success(`Prompt copied to clipboard`)}catch{IM.error(`Failed to copy`)}},"aria-label":`Copy prompt for agents`,children:(0,S.jsx)(jf,{className:`size-3.5`})})}),(0,S.jsx)(jd,{children:`Copy prompt for agents`})]})]}),me&&(0,S.jsx)(`div`,{className:`px-3 pb-3 pt-0`,children:(0,S.jsx)(`pre`,{className:`text-[11px] font-mono text-zinc-600 dark:text-zinc-400 whitespace-pre-wrap bg-zinc-50 dark:bg-zinc-900 p-2 rounded border border-zinc-100 dark:border-zinc-800 overflow-x-auto max-h-48 overflow-y-auto`,"data-testid":`debugger-csp-prompt-for-agents`,children:E})})]}),b.length>0&&(0,S.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-xs font-semibold uppercase tracking-wide ${h.cspMode===`permissive`?`text-yellow-600 dark:text-yellow-400`:`text-red-600 dark:text-red-400`}`,children:[b.length,` `,h.cspMode===`permissive`?`would-be-blocked`:`blocked`,` `,`request`,b.length===1?``:`s`]}),(0,S.jsx)(`button`,{className:`text-xs text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200 underline`,onClick:()=>v(n),children:`Clear`})]}),(0,S.jsx)(`div`,{className:`max-h-56 overflow-y-auto space-y-1 rounded border border-zinc-200 dark:border-zinc-700 bg-zinc-50 dark:bg-zinc-900 p-2`,children:b.map((e,t)=>(0,S.jsxs)(`div`,{className:`flex flex-col gap-0.5 py-1 border-b border-zinc-100 dark:border-zinc-800 last:border-0`,children:[(0,S.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,S.jsx)(`span`,{className:`shrink-0 rounded bg-red-100 dark:bg-red-900/40 px-1 py-0.5 text-[10px] font-mono font-semibold text-red-700 dark:text-red-300`,children:e.effectiveDirective||e.directive})}),(0,S.jsx)(`span`,{className:`text-[11px] font-mono text-zinc-600 dark:text-zinc-400 break-all leading-snug`,children:e.blockedUri||`(inline)`})]},t))})]})]})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-touch-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${h.capabilities.touch?`border-blue-500 dark:border-blue-400`:``}`,onClick:()=>{let e={...h.capabilities,touch:!h.capabilities.touch};g({capabilities:e}),k&&f&&f({userAgent:{device:{type:h.deviceType},capabilities:e}})},children:(0,S.jsx)(up,{className:`size-3.5 ${h.capabilities.touch?`text-blue-600 dark:text-blue-400`:``}`})})}),(0,S.jsxs)(jd,{children:[`Touch: `,h.capabilities.touch?`Enabled`:`Disabled`]})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-hover-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${h.capabilities.hover?`border-blue-500 dark:border-blue-400`:``}`,onClick:()=>{let e={...h.capabilities,hover:!h.capabilities.hover};g({capabilities:e}),k&&f&&f({userAgent:{device:{type:h.deviceType},capabilities:e}})},children:(0,S.jsx)(ap,{className:`size-3.5 ${h.capabilities.hover?`text-blue-600 dark:text-blue-400`:``}`})})}),(0,S.jsxs)(jd,{children:[`Hover: `,h.capabilities.hover?`Enabled`:`Disabled`]})]}),(0,S.jsxs)(eY,{children:[(0,S.jsx)(tY,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-safe-area-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(0,S.jsx)(Tp,{className:`size-3.5`})})}),(0,S.jsx)(nY,{className:`w-64 p-3`,"data-testid":`debugger-safe-area-dialog`,children:(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-xs font-medium`,children:`Safe Area Insets`}),(0,S.jsx)(UNe,{value:h.safeAreaInsets,onChange:e=>{g({safeAreaInsets:e}),k&&f&&f({safeArea:{insets:e}})}})]})})]}),r===`tool`?(0,S.jsxs)(xN,{children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,"data-testid":`debugger-props-button`,children:(0,S.jsx)(mf,{className:`size-3.5`})})})}),(0,S.jsx)(jd,{children:`View Tool Props`})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[600px]`,"data-testid":`debugger-props-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Tool Props`})}),(0,S.jsx)(`div`,{className:`overflow-auto max-h-[60vh] rounded-md bg-gray-50 dark:bg-zinc-900 border border-gray-200 dark:border-zinc-700 p-3`,children:(0,S.jsx)(BV,{data:a??{},filename:`tool-props.json`})})]})]}):(0,S.jsxs)(eY,{open:te,onOpenChange:ne,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(tY,{asChild:!0,children:(0,S.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${ee?`bg-amber-50 dark:bg-amber-950/40 border-amber-300 dark:border-amber-700 hover:bg-amber-100 dark:hover:bg-amber-900/50 animate-pulse`:`bg-white/90 dark:bg-zinc-900/90 hover:bg-white dark:hover:bg-zinc-900`}`,"data-testid":`debugger-props-button`,children:(0,S.jsx)(mf,{className:`size-3.5 ${ee?`text-amber-500`:``}`})})})}),(0,S.jsxs)(jd,{children:[`Props:`,` `,_e===V7?`No Props`:_e===H7?`Tool Props`:A.find(e=>e.id===_e)?.name||`Custom`]})]}),(0,S.jsxs)(nY,{className:`w-64 p-2`,"data-testid":`debugger-props-popover`,children:[ee&&(0,S.jsxs)(`div`,{className:`mb-2 rounded-md border border-amber-200 dark:border-amber-800/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-amber-700 dark:text-amber-300 mb-0.5`,children:`Props required to render this widget:`}),(0,S.jsx)(`p`,{className:`text-xs font-mono text-amber-600 dark:text-amber-400`,children:u.join(`, `)}),(0,S.jsx)(`p`,{className:`text-xs text-amber-500 dark:text-amber-400 mt-1`,children:`Create a preset below to set them.`})]}),(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(U,{variant:_e===V7?`secondary`:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:()=>ye(V7),"data-testid":`debugger-props-no-props`,children:`No Props`}),A.map(e=>(0,S.jsxs)(`div`,{className:`relative group flex items-center`,children:[(0,S.jsx)(U,{variant:_e===e.id?`secondary`:`ghost`,size:`sm`,className:`w-full justify-start pr-14`,onClick:()=>ye(e.id),"data-testid":`debugger-props-preset-${e.id}`,children:e.name}),(0,S.jsxs)(`div`,{className:`absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:t=>Se(e,t),"data-testid":`debugger-props-edit-${e.id}`,children:(0,S.jsx)(vp,{className:`h-3 w-3`})}),(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:t=>xe(e.id,t),"data-testid":`debugger-props-delete-${e.id}`,children:(0,S.jsx)(Mp,{className:`h-3 w-3 text-destructive`})})]})]},e.id)),(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start text-primary`,onClick:()=>ye(WNe),"data-testid":`debugger-props-create-preset`,children:`+ Create Preset...`})]})]})]}),(0,S.jsx)(LMe,{iframeId:n,enabled:!0}),c&&(0,S.jsx)(HNe,{open:I,onOpenChange:L,onSave:be,existingPresets:A,resource:c,resourceAnnotations:o,llmConfig:s||null,editingPreset:re})]})}function YNe({children:e,className:t,noWrapper:n}){return n?e:(0,S.jsx)(`div`,{className:H(`bg-zinc-100 dark:bg-zinc-900 bg-[radial-gradient(circle,_rgba(0,0,0,0.2)_1px,_transparent_1px)] dark:bg-[radial-gradient(circle,_rgba(255,255,255,0.2)_1px,_transparent_1px)] bg-[length:32px_32px]`,t),children:e})}function XNe({componentUrl:e,toolName:t,toolArgs:n,toolResult:r,serverId:i,readResource:a,className:o,noWrapper:s=!1,showConsole:c=!0,customProps:l,serverBaseUrl:u,invoking:d,invoked:f,onUpdateGlobals:p}){let m=(0,w.useRef)(null),h=(0,w.useRef)(null),[g,_]=(0,w.useState)(!1),[v,y]=(0,w.useState)(!0),b=(0,w.useRef)(!1),[x,C]=(0,w.useState)(null),[T,E]=(0,w.useState)(null),[D,O]=(0,w.useState)(400),k=(0,w.useRef)(0),A=(0,w.useRef)(0),j=(0,w.useRef)(!1),[M,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(`inline`),[I,L]=(0,w.useState)(!1),[ee,te]=(0,w.useState)(!1),[ne,re]=(0,w.useState)(!1),[R,z]=(0,w.useState)(null),[B,ie]=(0,w.useState)(null),ae=(0,w.useRef)(null),oe=(0,w.useRef)(null),se=(0,w.useRef)(null),ce=(0,w.useRef)(!1),le=(0,w.useRef)(null),ue=(0,w.useRef)(`tool-${Date.now()}-${Math.random().toString(36).substring(7)}`).current,de=(0,w.useRef)(!1),{servers:fe}=cj(),pe=fe.find(e=>e.id===i),me=(0,w.useRef)(pe);me.current=pe;let he=u??pe?.url,{resolvedTheme:ge}=LP(),{playground:_e,addWidget:ve,addCspViolation:ye}=SQ(),be=(0,w.useRef)(n),xe=(0,w.useRef)(r),Se=(0,w.useRef)(a),Ce=(0,w.useRef)(he),we=(0,w.useRef)(ge),Te=(0,w.useRef)(l);(0,w.useEffect)(()=>{be.current=n,xe.current=r,Se.current=a,Ce.current=he,we.current=ge,Te.current=l}),(0,w.useEffect)(()=>{let n=!1;return(async()=>{let r=xe.current,a=Se.current,o=we.current,s=_e;console.log(`[OpenAIComponentRenderer] Storing widget data with playground:`,{locale:s.locale,deviceType:s.deviceType});try{let c=r?r.structuredContent??{}:null,l=await a(e);if(n)return;let u=null;r?._meta?.[`openai/widgetCSP`]?u=r._meta[`openai/widgetCSP`]:l?.contents?.[0]?._meta?.[`openai/widgetCSP`]&&(u=l.contents[0]._meta[`openai/widgetCSP`]);let d=be.current,f=Te.current,p={...d||{},...f||{}},m={serverId:i,uri:e,toolInput:p,toolOutput:c,toolResponseMetadata:null,resourceData:l,toolId:ue,widgetCSP:u,theme:o,playground:{locale:s.locale,deviceType:s.deviceType,capabilities:s.capabilities,safeAreaInsets:s.safeAreaInsets}},h=await fetch(`/inspector/api/resources/widget/store`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(m)});if(!h.ok){let e=await h.json().catch(()=>({error:`Unknown error`}));throw Error(`Failed to store widget data: ${e.error||h.statusText}`)}if(n)return;z(p),ie(c),re(!1),de.current||(de.current=!0,E(`/inspector/api/resources/widget-content/${ue}?t=${Date.now()}`),ve(ue,{toolName:t,protocol:`chatgpt-app`})),L(!0)}catch(e){if(n)return;console.error(`Error storing widget data:`,e),C(e instanceof Error?e.message:`Failed to prepare widget`)}})(),()=>{n=!0}},[e,i,ue,l,JSON.stringify(n),r]);let Ee=(0,w.useCallback)(e=>{if(se.current={...se.current||{},...e},!m.current?.contentWindow){p&&p(e);return}ce.current||(ce.current=!0,queueMicrotask(()=>{ce.current=!1;let e=se.current;if(se.current=null,!e)return;let t=()=>{if(oe.current!==null)return;let e=0,t=()=>{let n=m.current?.contentWindow,r=ae.current;if(!n||!r){oe.current=null;return}if(n.openai){ae.current=null,oe.current=null,Ee(r);return}if(e+=1,e>=60){oe.current=null;return}oe.current=window.requestAnimationFrame(t)};oe.current=window.requestAnimationFrame(t)};try{let n=m.current?.contentWindow,r=m.current?.contentDocument;if(!n)return;if(e.theme!==void 0&&r){let t=r.documentElement;t.setAttribute(`data-theme`,e.theme),t.style.colorScheme=e.theme,t.classList.remove(`light`,`dark`),t.classList.add(e.theme)}if(n.openai){if(!(e.locale!==void 0||e.safeArea!==void 0||e.userAgent!==void 0||e.maxHeight!==void 0||e.toolOutput!==void 0||e.toolResponseMetadata!==void 0)){let t=e.theme===void 0||n.openai.theme===e.theme,r=e.displayMode===void 0||n.openai.displayMode===e.displayMode;if(t&&r)return}e.displayMode!==void 0&&(n.openai.displayMode=e.displayMode),e.theme!==void 0&&(n.openai.theme=e.theme),e.maxHeight!==void 0&&(n.openai.maxHeight=e.maxHeight),e.locale!==void 0&&(n.openai.locale=e.locale),e.safeArea!==void 0&&(n.openai.safeArea=e.safeArea),e.userAgent!==void 0&&(n.openai.userAgent=e.userAgent),e.toolOutput!==void 0&&(n.openai.toolOutput=e.toolOutput),e.toolResponseMetadata!==void 0&&(n.openai.toolResponseMetadata=e.toolResponseMetadata);try{let e=new n.CustomEvent(`openai:set_globals`,{detail:{globals:{...n.openai}}});n.dispatchEvent(e)}catch{n.postMessage({type:`openai:globalsChanged`,updates:e},`*`)}}else ae.current={...ae.current||{},...e},t();p&&p(e)}catch{let t=m.current?.contentWindow;t&&t.postMessage({type:`openai:globalsChanged`,updates:e},`*`),p&&p(e)}}))},[p]);(0,w.useEffect)(()=>()=>{oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)},[]),(0,w.useEffect)(()=>{if(!r||!g||!m.current?.contentWindow)return;let e=r?.structuredContent||r,t=r?._meta||null,n=JSON.stringify(e);le.current!==n&&(le.current=n,Ee({toolOutput:e,toolResponseMetadata:t}))},[r,g,Ee]);let{handleDisplayModeChange:De,fullscreenShellClassName:Oe,pipShellClassName:ke,isPip:Ae}=vMe({containerRef:h,displayMode:P,setDisplayMode:(0,w.useCallback)(e=>{F(e),Ee({displayMode:e})},[Ee])}),je=(0,w.useRef)(0),[Me,Ne]=(0,w.useState)(0),Pe=(0,w.useCallback)(e=>{m.current=e,e&&(je.current+=1,je.current>1&&(Ne(e=>e+1),b.current&&(y(!0),_(!1))))},[]),Fe=(0,w.useRef)(De);Fe.current=De;let Ie=(0,w.useRef)(null);if((0,w.useEffect)(()=>{if(!T)return;let e=Ie.current!==T;Ie.current=T,e&&(_(!1),b.current||y(!0)),C(null);let t=!1,n=async e=>{let t=m.current;if(!(!t||e.source!==t.contentWindow)){if(e.data?.type===`iframe-console-log`){if(e.data.level===`error`){let t=(Array.isArray(e.data.args)?e.data.args:[])[0],n=typeof t==`string`?t:typeof t?.message==`string`?t.message:`Widget runtime error`,r=typeof t?.error?.stack==`string`?t.error.stack:typeof t?.stack==`string`?t.stack:void 0;typeof window<`u`&&window.parent!==window&&window.parent.postMessage({type:`mcp-inspector:widget:error`,source:`iframe-console:error`,message:n,stack:r,timestamp:Date.now(),url:typeof e.data.url==`string`?e.data.url:void 0,toolId:ue},`*`)}return}if(e.data?.type===`mcp-inspector:getWidgetState`){try{let t=m.current?.contentWindow;t?.openai?.widgetState!==void 0&&m.current?.contentWindow?.postMessage({type:`mcp-inspector:widgetStateResponse`,toolId:e.data.toolId,state:t.openai.widgetState},`*`)}catch{}return}switch(e.data.type){case`openai:csp-violation`:ye(ue,{directive:e.data.directive,effectiveDirective:e.data.effectiveDirective,blockedUri:e.data.blockedUri,sourceFile:e.data.sourceFile,lineNumber:e.data.lineNumber,columnNumber:e.data.columnNumber,timestamp:e.data.timestamp||Date.now()});break;case`openai:setWidgetState`:break;case`openai:callTool`:try{let t=me.current;if(!t)throw Error(`Server connection not available`);let{toolName:n,params:r,requestId:i}=e.data,a=await t.callTool(n,r||{},{timeout:6e5,resetTimeoutOnProgress:!0}),o;o=a&&typeof a==`object`?Array.isArray(a.contents)?{content:a.contents.map(e=>typeof e==`string`?{type:`text`,text:e}:e.type===`text`&&e.text?{type:`text`,text:e.text}:e.type===`image`&&e.data?{type:`image`,image_url:{url:e.data}}:{type:`text`,text:JSON.stringify(e)})}:{content:[{type:`text`,text:typeof a==`string`?a:JSON.stringify(a)}]}:{content:[{type:`text`,text:String(a)}]},m.current?.contentWindow?.postMessage({type:`openai:callTool:response`,requestId:i,result:o},`*`)}catch(t){console.error(`[OpenAIComponentRenderer] Tool call error:`,t),m.current?.contentWindow?.postMessage({type:`openai:callTool:response`,requestId:e.data.requestId,error:t instanceof Error?t.message:String(t)},`*`)}break;case`openai:sendFollowup`:try{let{message:t}=e.data,n=typeof t==`string`?t:t?.prompt||t;if(!n){console.warn(`[OpenAIComponentRenderer] No prompt in followup message`);return}let r=new window.CustomEvent(`mcp-inspector:widget-followup`,{detail:{prompt:n,serverId:i}});window.dispatchEvent(r);try{let e=JSON.parse(localStorage.getItem(`mcp-inspector-pending-followups`)||`[]`);e.push({prompt:n,serverId:i,timestamp:Date.now()}),localStorage.setItem(`mcp-inspector-pending-followups`,JSON.stringify(e.slice(-10)))}catch{}}catch(e){console.error(`[OpenAIComponentRenderer] Failed to send followup:`,e)}break;case`openai:requestDisplayMode`:try{let{mode:t}=e.data;t&&[`inline`,`pip`,`fullscreen`].includes(t)&&await Fe.current(t)}catch(e){console.error(`[OpenAIComponentRenderer] Failed to change display mode:`,e)}break;case`openai:notifyIntrinsicHeight`:try{let{height:t}=e.data;if(typeof t==`number`&&t>0){let e=t;if(P===`fullscreen`||P===`pip`){let n=typeof window<`u`?window.innerHeight:t;e=Math.min(t,n)}(t!==A.current||e!==D)&&(A.current=t,k.current=e,j.current=!0,O(e))}}catch(e){console.error(`[OpenAIComponentRenderer] Failed to handle intrinsic height notification:`,e)}break;default:break}}};window.addEventListener(`message`,n);let r=()=>{if(!t){if(t=!0,_(!0),C(null),m.current)try{let e=!!m.current.contentDocument;e&&I?TMe(m.current):e||L(!1)}catch{L(!1)}ge&&setTimeout(()=>{Ee({theme:ge})},50)}},a=()=>{C(`Failed to load component`)},o=m.current;return o?.addEventListener(`load`,r),o?.addEventListener(`error`,a),o&&(o.contentDocument?.readyState===`complete`||o.contentDocument?.readyState===`interactive`)&&(o.contentDocument?.querySelectorAll(`script`).length??0)>0&&r(),()=>{window.removeEventListener(`message`,n),o?.removeEventListener(`load`,r),o?.removeEventListener(`error`,a)}},[T,I,i,Ee,ne,Me]),(0,w.useEffect)(()=>{if(g){if(!I){Ee({theme:ge});return}try{if(!m.current?.contentDocument)return;let e=m.current.contentDocument.documentElement;e.setAttribute(`data-theme`,ge),e.style.colorScheme=ge,e.classList.remove(`light`,`dark`),e.classList.add(ge)}catch{}Ee({theme:ge})}},[ge,g,I,Ee]),(0,w.useEffect)(()=>{!g||!v||(y(!1),b.current=!0)},[g,v]),(0,w.useEffect)(()=>{if(!T||!I)return;let e=()=>{if(j.current)return;let e=m.current;try{let t=e?.contentWindow?.document?.body;if(!e||!t)return;let n=t.scrollHeight||0,r=typeof window<`u`?window.innerHeight:n,i=Math.min(n,r);i>0&&i!==k.current&&(k.current=i,O(i))}catch{}},t,n=()=>{e(),t=window.requestAnimationFrame(n)};return n(),window.addEventListener(`resize`,e),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,e)}},[T,I]),(0,w.useEffect)(()=>{let e=()=>{let e=h.current;if(!e)return;let t=e.clientHeight;N(t>D)};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[D]),(0,w.useEffect)(()=>{if(T&&ge&&g){let e=setTimeout(()=>{Ee({theme:ge})},0);return()=>clearTimeout(e)}},[ge,T,g,Ee]),x)return(0,S.jsx)(`div`,{className:o,children:(0,S.jsx)(`div`,{className:`bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4`,children:(0,S.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:[`Failed to load component: `,x]})})});if(!T)return(0,S.jsx)(YNe,{className:o,noWrapper:s,children:(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,S.jsx)(Vq,{className:`size-5`})})});let Le=(0,S.jsxs)(`div`,{ref:h,className:H(`w-full h-full flex flex-col min-h-0`,P===`fullscreen`?`items-stretch justify-stretch`:H(`justify-center items-center`,M&&`items-center`),Oe,ke),style:Ae?{maxWidth:O7.DIMENSIONS.PIP_MAX_WIDTH}:void 0,onMouseEnter:()=>Ae&&te(!0),onMouseLeave:()=>Ae&&te(!1),children:[P===`fullscreen`&&(0,S.jsx)(yMe,{title:t,onClose:()=>De(`inline`)}),Ae&&(0,S.jsx)(`button`,{onClick:()=>De(`inline`),className:H(`absolute top-2 right-2 z-50`,`flex items-center justify-center`,`w-8 h-8 rounded-full`,`bg-background/90 hover:bg-background`,`border border-border`,`shadow-lg`,`transition-opacity duration-200`,`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,ee?`opacity-100`:`opacity-0`),"aria-label":`Exit Picture in Picture`,children:(0,S.jsx)(Fp,{className:`w-4 h-4 text-foreground`})}),(0,S.jsx)(`div`,{className:H(`relative w-full min-h-0`,P===`fullscreen`||P===`pip`?`flex flex-1 flex-col`:H(`flex flex-1 justify-center items-center`,M&&`items-center`),P===`inline`&&(d||f)&&`pt-8`),children:(0,S.jsxs)(`div`,{className:H(`relative w-full`,P===`fullscreen`||P===`pip`?`h-full min-h-0 flex-1`:`max-w-[768px]`),children:[P===`inline`&&(d||f)&&(0,S.jsxs)(`div`,{className:`absolute -top-8 left-2 z-10 whitespace-nowrap`,children:[d&&!r&&(0,S.jsx)(NY,{className:`text-xs`,children:d}),f&&r&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f})]}),(0,S.jsx)(`iframe`,{ref:Pe,src:T,className:H(P===`inline`&&`w-full`,P===`fullscreen`&&`w-full h-full rounded-none`,P===`pip`&&`w-full h-full rounded-lg`),style:{height:P===`fullscreen`||P===`pip`?`100%`:`${D}px`},sandbox:D7,title:`OpenAI Component: ${t}`,allow:`web-share`})]})})]});return(0,S.jsxs)(YNe,{className:o,noWrapper:s,children:[!Ae&&v&&(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full z-0`,children:(0,S.jsx)(Vq,{className:`size-5`})}),c&&I&&!Ae&&P!==`fullscreen`&&(0,S.jsx)(`div`,{className:`absolute top-2 right-2 z-30 flex items-center gap-2`,children:(0,S.jsx)(U7,{displayMode:P,onDisplayModeChange:De,toolCallId:ue,propsContext:`tool`,resourceUri:e,toolInput:R,resourceAnnotations:void 0,llmConfig:null,resource:null,onPropsChange:void 0,protocol:`apps-sdk`,onUpdateGlobals:Ee})}),Ae&&typeof document<`u`?(0,S.jsxs)(S.Fragment,{children:[v&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-[99] flex items-center justify-center bg-background/40`,children:(0,S.jsx)(Vq,{className:`size-5`})}),(0,Bt.createPortal)(Le,document.body)]}):Le]})}function ZNe(e,t){for(let n of[`componentUrl`,`toolName`,`serverId`,`toolArgs`,`toolResult`,`readResource`,`className`])if(e[n]!==t[n])return!1;return!(e.invoking!==t.invoking||e.invoked!==t.invoked)}var W7=(0,w.memo)(XNe,ZNe),QNe=(0,w.memo)(({resource:e})=>{if(!e.uri?.startsWith(`ui://`))return null;let t=(0,w.useMemo)(()=>{if(e.text)return e.text;if(e.blob)try{return atob(e.blob)}catch{return null}return null},[e.text,e.blob]);return t?(0,S.jsx)(`div`,{className:`my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card`,children:(0,S.jsx)(`iframe`,{srcDoc:t,sandbox:`allow-scripts allow-forms allow-popups`,title:e.uri??`MCP UI Resource`,style:{width:`100%`,height:`100%`,border:`none`,overflow:`auto`}})}):null});function $Ne({widgetId:e}){let{getWidget:t}=SQ(),n=t(e)?.modelContext;if(!n?.content?.length&&!n?.structuredContent)return null;let r=n.content?.map(e=>e.text).join(` `)??JSON.stringify(n.structuredContent).slice(0,80);return(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1`,children:[(0,S.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0`}),(0,S.jsx)(`span`,{className:`font-medium`,children:`State synced to model`}),(0,S.jsx)(`span`,{className:`truncate opacity-60 max-w-[300px]`,children:r})]})}function ePe({toolName:e,toolArgs:t,result:n,serverId:r,readResource:i,toolMeta:a,onSendFollowUp:o,serverBaseUrl:s,partialToolArgs:c,cancelled:l}){let{playground:u}=SQ(),[d,f]=(0,w.useState)(null),p=(0,w.useRef)(null),m=(0,w.useMemo)(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),h=(0,w.useMemo)(()=>{if(!n)return null;if(typeof n==`string`)try{return JSON.parse(n)}catch(e){return console.error(`[ToolResultRenderer] Failed to parse result:`,e),n}return n},[n]),g=(0,w.useMemo)(()=>JSON.stringify(a),[a]),_=(0,w.useMemo)(()=>TQ(a,h),[g,h]),v=(0,w.useMemo)(()=>wQ(a),[g]),y=(0,w.useMemo)(()=>_?_===`both`?u.selectedProtocol?u.selectedProtocol:`mcp-apps`:_:null,[_,u.selectedProtocol]),b=(0,w.useMemo)(()=>y===`mcp-apps`,[y]),x=(0,w.useMemo)(()=>y===`chatgpt-app`,[y]),C=(0,w.useMemo)(()=>!!(h?.content&&Array.isArray(h.content)&&h.content.some(e=>e.type===`resource`&&e.resource?.uri?.startsWith(`ui://`)&&e.resource?.mimeType===`text/html+skybridge`)),[h]),T=(0,w.useMemo)(()=>C&&h.content.find(e=>e.type===`resource`&&e.resource?.uri?.startsWith(`ui://`)&&e.resource?.mimeType===`text/html+skybridge`)?.resource||null,[C,h]),E=(0,w.useMemo)(()=>t,[e,h]),D=(0,w.useMemo)(()=>h,[e,h]),O=(0,w.useMemo)(()=>v&&y?EQ(y,a):b?a?.ui?.resourceUri||null:x&&a?.[`openai/outputTemplate`]||null,[v,y,b,x,g]);(0,w.useEffect)(()=>{if(T){f(T),p.current=T.uri||null;return}O&&p.current===O||(O!==p.current&&f(null),O&&i&&(p.current=O,i(O).then(e=>{e?.contents&&Array.isArray(e.contents)&&e.contents.length>0&&f(e.contents[0])}).catch(e=>{console.error(`[ToolResultRenderer] Failed to fetch resource:`,e),p.current=null})))},[T,O,y,i]);let k=a?.[`openai/toolInvocation/invoking`],A=a?.[`openai/toolInvocation/invoked`];if(v&&d&&r&&i)return(0,S.jsxs)(`div`,{className:`my-4`,children:[y===`mcp-apps`&&(0,S.jsx)(M7,{serverId:r,toolCallId:m,toolName:e,toolInput:E,toolOutput:D,toolMetadata:a,invoking:k,invoked:A,partialToolInput:c,resourceUri:d.uri,readResource:i,noWrapper:!0,onSendFollowUp:o,serverBaseUrl:s,cancelled:l}),y===`chatgpt-app`&&(0,S.jsx)(W7,{componentUrl:d.uri,toolName:e,toolArgs:E,toolResult:D,serverId:r,readResource:i,noWrapper:!0,showConsole:!1,invoking:k,invoked:A,serverBaseUrl:s})]});if(b&&O&&r&&i)return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(M7,{serverId:r,toolCallId:m,toolName:e,toolInput:E,toolOutput:D,toolMetadata:a,invoking:k,invoked:A,partialToolInput:c,resourceUri:d?.uri||O,readResource:i,className:`my-4`,noWrapper:!0,onSendFollowUp:o,serverBaseUrl:s}),(0,S.jsx)($Ne,{widgetId:m})]});if((x||C)&&O&&r&&i)return(0,S.jsx)(W7,{componentUrl:d?.uri||O,toolName:e,toolArgs:E,toolResult:D,serverId:r,readResource:i,noWrapper:!0,className:`my-4`,showConsole:!1,invoking:k,invoked:A,serverBaseUrl:s});if((b||x||C)&&!O)return(0,S.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px] rounded border`,children:(0,S.jsx)(Vq,{className:`size-5`})});if((b||x)&&(!r||!i))return console.error(`[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:`,{toolName:e,hasServerId:!!r,hasReadResource:!!i}),(0,S.jsx)(`div`,{className:`my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg`,children:(0,S.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Cannot render widget: Missing required props (serverId or readResource)`})});let j=[];if(h?.content&&Array.isArray(h.content))for(let e of h.content)e.type===`resource`&&e.resource?.uri?.startsWith(`ui://`)&&e.resource?.mimeType!==`text/html+skybridge`&&j.push(e.resource);return j.length>0?(0,S.jsx)(S.Fragment,{children:j.map(t=>(0,S.jsx)(QNe,{resource:t},`${e}-mcp-ui-${t.uri}`))}):(console.log(`[ToolResultRenderer] Not rendering (no UI resources found):`,{toolName:e,isAppsSdkTool:x,hasAppsSdkComponent:C,hasResourceData:!!d,contentLength:h?.content?.length}),null)}function tPe({content:e,timestamp:t,attachments:n}){return(!e||e.length===0)&&(!n||n.length===0)?null:(0,S.jsx)(`div`,{className:`flex items-start gap-3 justify-end group/user-message`,"data-testid":`chat-message-user`,children:(0,S.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col items-end`,children:[(0,S.jsxs)(`div`,{className:`bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words`,"data-testid":`chat-message-content`,children:[n&&n.length>0&&(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:n.map((e,t)=>(0,S.jsx)(`div`,{className:`rounded-lg overflow-hidden border border-zinc-300 dark:border-zinc-700`,children:(0,S.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name||`Attachment ${t+1}`,className:`max-w-[200px] max-h-[200px] object-contain`})},t))}),e&&e.length>0&&(0,S.jsx)(`p`,{className:`text-base leading-7 font-sans text-start break-words`,children:e})]}),t&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,S.jsx)(pQ,{text:e}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(t).toLocaleTimeString()})]})]})})}function G7(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 nPe(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(G7):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(G7):[];return t.length>0?t:n}function rPe(e){let t=e.items&&typeof e.items==`object`?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(G7):[],r=Array.isArray(t.oneOf)?t.oneOf.filter(G7):[];return n.length>0?n:r}function iPe({request:e,formData:t,onFieldChange:n,idPrefix:r,testIdPrefix:i,fieldContainerClassName:a=`space-y-2`,textareaRows:o=4,showOuterLabelForBoolean:s=!0,emptyFallback:c}){return(0,S.jsx)(S.Fragment,{children:(0,w.useMemo)(()=>{if(!(`requestedSchema`in e.request))return null;let l=e.request.requestedSchema;if(!l||l.type!==`object`||!l.properties)return c??(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema available`});let u=l.properties,d=l.required||[];return(0,S.jsx)(`div`,{className:`space-y-4`,children:Object.entries(u).map(([e,c])=>{let l=c,u=d.includes(e),f=l.type||`string`,p=l.title||e,m=l.description,h=nPe(l),g=h.length>0,_=Array.isArray(l.enum),v=f===`array`&&Array.isArray(l.items?.enum),y=rPe(l),b=f===`array`&&y.length>0,x=Array.isArray(t[e])?t[e]:[],C=`${r}-${e}`,w=`${i}-${e}`;return(0,S.jsxs)(`div`,{className:a,children:[(f!==`boolean`||s)&&(0,S.jsxs)(AN,{htmlFor:C,children:[p,u&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),m&&(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m}),f===`boolean`?(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:C,"data-testid":w,checked:t[e]||!1,onCheckedChange:t=>n(e,t)}),(0,S.jsxs)(AN,{htmlFor:C,className:`text-sm font-normal cursor-pointer`,children:[p,!s&&u&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]})]}):f===`number`||f===`integer`?(0,S.jsx)(DN,{id:C,"data-testid":w,type:`number`,value:t[e]??``,onChange:t=>{let r=f===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value);n(e,isNaN(r)?``:r)},placeholder:l.default?.toString()||``}):g?(0,S.jsxs)(`select`,{id:C,"data-testid":w,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,S.jsx)(`option`,{value:``,children:`Select...`}),h.map(e=>(0,S.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):_?(0,S.jsxs)(`select`,{id:C,"data-testid":w,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,S.jsx)(`option`,{value:``,children:`Select...`}),l.enum.map((e,t)=>(0,S.jsx)(`option`,{value:e,children:l.enumNames?.[t]||e},e))]}):v?(0,S.jsx)(`div`,{className:`space-y-2`,"data-testid":w,children:l.items.enum.map(t=>{let r=`${C}-${t}`;return(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:r,checked:x.includes(t),onCheckedChange:r=>{n(e,r?[...x,t]:x.filter(e=>e!==t))}}),(0,S.jsx)(AN,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):b?(0,S.jsx)(`div`,{className:`space-y-2`,"data-testid":w,children:y.map(t=>{let r=`${C}-${t.const}`;return(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:r,checked:x.includes(t.const),onCheckedChange:r=>{n(e,r?[...x,t.const]:x.filter(e=>e!==t.const))}}),(0,S.jsx)(AN,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):f===`string`&&(l.format===`textarea`||l.maxLength>100)?(0,S.jsx)(mY,{id:C,"data-testid":w,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:l.default||``,rows:o}):(0,S.jsx)(DN,{id:C,"data-testid":w,type:`text`,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:l.default||``})]},e)})})},[e,t,n,r,i,a,o,s,c])})}function aPe(e){let[t,n]=(0,w.useState)({}),[r,i]=(0,w.useState)(!1),a=e?.request.mode||`form`,o=a===`form`,s=a===`url`;return(0,w.useEffect)(()=>{if(e&&o&&`requestedSchema`in e.request){let t=e.request.requestedSchema,r={};if(t?.type===`object`&&t.properties)for(let[e,n]of Object.entries(t.properties)){let t=n;t.default===void 0?t.type===`array`?r[e]=[]:t.type===`boolean`?r[e]=!1:t.type===`number`||t.type===`integer`?r[e]=0:r[e]=``:r[e]=t.default}n(r)}i(!1)},[e?.id,o]),{formData:t,setFieldValue:(0,w.useCallback)((e,t)=>{n(n=>({...n,[e]:t}))},[]),getMissingRequiredFields:(0,w.useCallback)(()=>!e||!o||!(`requestedSchema`in e.request)?[]:(e.request.requestedSchema?.required??[]).filter(e=>t[e]===void 0||t[e]===``||t[e]===null),[e,t,o]),urlCompleted:r,setUrlCompleted:i,mode:a,isFormMode:o,isUrlMode:s}}function oPe({request:e,onApprove:t,onReject:n}){let{formData:r,setFieldValue:i,getMissingRequiredFields:a,urlCompleted:o,setUrlCompleted:s,mode:c,isFormMode:l,isUrlMode:u}=aPe(e),[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(``),h=()=>{if(!d)if(l){let n=a();if(n.length>0){IM.error(`Missing required fields`,{description:`Please fill in: ${n.join(`, `)}`});return}f(!0),m(`accepted`),t(e.id,{action:`accept`,content:r})}else u&&(f(!0),m(`accepted`),t(e.id,{action:`accept`}))},g=()=>{d||(f(!0),m(`declined`),t(e.id,{action:`decline`}))},_=()=>{d||(f(!0),m(`cancelled`),n(e.id,`User cancelled elicitation request`))},v=u&&`url`in e.request?e.request.url:null;return d?(0,S.jsxs)(`div`,{className:`rounded-lg border border-dashed bg-muted/30 p-3 text-sm text-muted-foreground max-w-2xl`,children:[`Elicitation `,p,` — the tool will continue executing.`]}):(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card shadow-sm p-4 space-y-4 max-w-2xl`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,S.jsx)(`span`,{className:`font-medium text-sm text-card-foreground`,children:`Elicitation Request`}),(0,S.jsx)(kt,{variant:`outline`,className:u?`bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/30`:`bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/30`,children:c}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.serverName})]}),(0,S.jsx)(`p`,{className:`text-sm text-card-foreground`,children:e.request.message}),u&&`url`in e.request&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-muted rounded border`,children:[(0,S.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:v}),(0,S.jsxs)(U,{size:`sm`,variant:`outline`,onClick:()=>{window.open(v??``,`_blank`),s(!0)},children:[(0,S.jsx)(Ff,{className:`h-3 w-3 mr-1`}),`Open`]})]}),(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:`inline-url-done-${e.id}`,checked:o,onCheckedChange:e=>s(!!e)}),(0,S.jsx)(AN,{htmlFor:`inline-url-done-${e.id}`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]}),l&&(0,S.jsx)(iPe,{request:e,formData:r,onFieldChange:i,idPrefix:`inline-field-${e.id}`,testIdPrefix:`inline-elicitation-field`,fieldContainerClassName:`space-y-1.5`,textareaRows:3,showOuterLabelForBoolean:!1,emptyFallback:(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema provided.`})}),(0,S.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,S.jsx)(U,{size:`sm`,onClick:h,disabled:u&&!o,"data-testid":`inline-elicitation-accept`,children:`Accept`}),(0,S.jsx)(U,{size:`sm`,variant:`outline`,onClick:g,"data-testid":`inline-elicitation-decline`,children:`Decline`}),(0,S.jsx)(U,{size:`sm`,variant:`outline`,onClick:_,"data-testid":`inline-elicitation-cancel`,children:`Cancel`})]})]})}var sPe=(0,w.memo)(({messages:e,isLoading:t,serverId:n,readResource:r,tools:i,sendMessage:a,serverBaseUrl:o,pendingElicitationRequests:s,onApproveElicitation:c,onRejectElicitation:l})=>{let u=(0,w.useRef)(null),d=e=>{let t=e=>e.replace(/-/g,`_`),n=t(e);return i?.find(e=>t(e.name)===n)?._meta},f=e=>{let t=TQ(d(e),void 0);return t!==null&&t!==`mcp-ui`},p=(0,w.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
794
|
+
`)}function U7({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:r,resourceUri:i,toolInput:a,resourceAnnotations:o,llmConfig:s,resource:c,onPropsChange:l,requiredProps:u,protocol:d=`mcp-apps`,onUpdateGlobals:f}){let{resolvedTheme:p,setTheme:m}=LP(),{playground:h,updatePlaygroundSettings:g,widgets:_,clearCspViolations:v}=SQ(),y=_.get(n),b=y?.cspViolations??[],x=y?.declaredCsp,C=y?.effectivePolicy,T=b.length>0?GNe(b,x):null,E=b.length>0?JNe(x,C,b,T):``,D=e===`fullscreen`,O=e===`pip`,k=d===`apps-sdk`,{presets:A,activePresetId:j,savePreset:M,deletePreset:N,setActivePreset:P,getActiveProps:F}=DMe(i),[I,L]=(0,w.useState)(!1),ee=!!u?.length&&!j,[te,ne]=(0,w.useState)(()=>ee);(0,w.useEffect)(()=>{ee&&ne(!0)},[ee]);let[re,R]=(0,w.useState)(null),[z,B]=(0,w.useState)(!1),[ie,ae]=(0,w.useState)(!1),[oe,se]=(0,w.useState)(!1),[ce,le]=(0,w.useState)(!1),[ue,de]=(0,w.useState)(!0),[fe,pe]=(0,w.useState)(!0),[me,he]=(0,w.useState)(!0),ge=(0,w.useCallback)(()=>r===`tool`&&a?H7:V7,[r,a]),[_e,ve]=(0,w.useState)(ge());(0,w.useEffect)(()=>{j&&r!==`tool`?ve(j):_e!==V7&&_e!==H7&&ve(ge())},[j,_e,ge,r]),(0,w.useEffect)(()=>{l&&(_e===V7||_e===H7?l(null):j&&l(F()))},[_e,j,a,F,l]);let ye=e=>{if(e===WNe){R(null),L(!0);return}e===V7||e===H7?(P(null),ve(e)):(P(e),ve(e))},be=e=>{M(e),P(e.id),ve(e.id)},xe=(e,t)=>{t.stopPropagation();let n=A.find(t=>t.id===e);n&&(N(e),IM.success(`Preset deleted`,{description:`Preset "${n.name}" has been deleted.`}))},Se=(e,t)=>{t.stopPropagation(),R(e),L(!0)};return(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!D&&!O&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-fullscreen-button`,variant:`outline`,size:`sm`,className:`bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>t(`fullscreen`),children:(0,S.jsx)(Qf,{className:`size-4`})})}),(0,S.jsx)(jd,{children:`Enter fullscreen mode`})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-pip-button`,variant:`outline`,size:`sm`,className:`bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>t(`pip`),children:(0,S.jsx)(sp,{className:`size-4`})})}),(0,S.jsx)(jd,{children:`Picture-in-picture`})]})]}),(0,S.jsxs)(xN,{open:z,onOpenChange:B,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-device-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(()=>{switch(h.deviceType){case`mobile`:return(0,S.jsx)(Sp,{className:`size-3`});case`tablet`:return(0,S.jsx)(Ap,{className:`size-3`});default:return(0,S.jsx)(rp,{className:`size-3`})}})()})})}),(0,S.jsxs)(jd,{children:[`Device: `,h.deviceType]})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[300px]`,"data-testid":`debugger-device-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Device Type`})}),(0,S.jsx)(`div`,{className:`space-y-2`,children:[{value:`desktop`,label:`Desktop`,icon:rp},{value:`mobile`,label:`Mobile`,icon:Sp},{value:`tablet`,label:`Tablet`,icon:Ap}].map(e=>{let t=e.icon;return(0,S.jsxs)(U,{"data-testid":`debugger-device-option-${e.value}`,variant:h.deviceType===e.value?`default`:`outline`,className:`w-full justify-start`,onClick:()=>{g({deviceType:e.value}),k&&f&&f({userAgent:{device:{type:e.value},capabilities:h.capabilities}}),B(!1)},children:[(0,S.jsx)(t,{className:`size-4 mr-2`}),e.label]},e.value)})})]})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-theme-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>{let e=p===`dark`?`light`:`dark`;m(e),f&&f({theme:e})},children:p===`dark`?(0,S.jsx)(ip,{className:`size-3.5`}):(0,S.jsx)(kp,{className:`size-3.5`})})}),(0,S.jsxs)(jd,{children:[`Theme: `,p===`dark`?`Dark`:`Light`]})]}),(0,S.jsxs)(xN,{open:ie,onOpenChange:ae,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-locale-button`,variant:`outline`,size:`sm`,className:`h-8 min-w-[50px] px-2 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(0,S.jsx)(`span`,{className:`text-xs font-mono`,children:h.locale})})})}),(0,S.jsx)(jd,{children:`Locale`})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[400px]`,"data-testid":`debugger-locale-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Select Locale`})}),(0,S.jsxs)(MJ,{children:[(0,S.jsx)(NJ,{placeholder:`Search locales...`,"data-testid":`debugger-locale-search`}),(0,S.jsxs)(PJ,{children:[(0,S.jsx)(FJ,{children:`No locale found.`}),(0,S.jsx)(IJ,{children:oMe.map(e=>(0,S.jsx)(LJ,{value:e.value,"data-testid":`debugger-locale-option-${e.value}`,onSelect:()=>{g({locale:e.value}),k&&f&&f({locale:e.value}),ae(!1)},children:e.label},e.value))})]})]})]})]}),!k&&(0,S.jsxs)(xN,{open:oe,onOpenChange:se,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-timezone-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(0,S.jsx)(Df,{className:`size-3.5`})})})}),(0,S.jsxs)(jd,{children:[`Timezone: `,h.timeZone]})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[400px]`,"data-testid":`debugger-timezone-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Select Timezone`})}),(0,S.jsxs)(MJ,{children:[(0,S.jsx)(NJ,{placeholder:`Search timezones...`,"data-testid":`debugger-timezone-search`}),(0,S.jsxs)(PJ,{children:[(0,S.jsx)(FJ,{children:`No timezone found.`}),(0,S.jsx)(IJ,{children:cMe.map(e=>(0,S.jsx)(LJ,{value:e.value,"data-testid":`debugger-timezone-option-${e.value.replace(/\//g,`-`)}`,onSelect:()=>{g({timeZone:e.value}),se(!1)},children:e.label},e.value))})]})]})]})]}),(0,S.jsxs)(xN,{open:ce,onOpenChange:le,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsxs)(U,{"data-testid":`debugger-csp-button`,variant:`outline`,size:`sm`,className:`relative h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:[h.cspMode===`permissive`?(0,S.jsx)(bp,{className:`size-3.5`}):(0,S.jsx)(yp,{className:`size-3.5`}),b.length>0&&(0,S.jsx)(`span`,{className:`absolute -top-1.5 -right-1.5 flex h-4 min-w-4 items-center justify-center rounded-full px-0.5 text-[9px] font-bold text-white leading-none ${h.cspMode===`permissive`?`bg-yellow-500`:`bg-red-500`}`,children:b.length>99?`99+`:b.length})]})})}),(0,S.jsxs)(jd,{children:[`CSP:`,` `,h.cspMode===`permissive`?`Permissive`:`Declared`,b.length>0&&` · ${b.length} ${h.cspMode===`permissive`?`would be blocked`:`blocked`}`]})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[520px] max-h-[85vh] overflow-y-auto`,"data-testid":`debugger-csp-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`CSP Mode`})}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(U,{"data-testid":`debugger-csp-option-permissive`,variant:h.cspMode===`permissive`?`default`:`outline`,className:`w-full justify-start`,onClick:()=>{g({cspMode:`permissive`}),le(!1)},children:[(0,S.jsx)(bp,{className:`size-4 mr-2`}),(0,S.jsx)(`div`,{className:`flex flex-col items-start`,children:(0,S.jsx)(`span`,{children:`Permissive`})})]}),(0,S.jsxs)(U,{"data-testid":`debugger-csp-option-widget-declared`,variant:h.cspMode===`widget-declared`?`default`:`outline`,className:`w-full justify-start`,onClick:()=>{g({cspMode:`widget-declared`}),le(!1)},children:[(0,S.jsx)(yp,{className:`size-4 mr-2`}),(0,S.jsx)(`div`,{className:`flex flex-col items-start`,children:(0,S.jsx)(`span`,{children:`Widget-Declared`})})]})]}),(0,S.jsxs)(`div`,{className:`mt-3 border border-zinc-200 dark:border-zinc-700 rounded-md overflow-hidden`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-medium bg-zinc-50 dark:bg-zinc-900/50 hover:bg-zinc-100 dark:hover:bg-zinc-800/50 transition-colors`,onClick:()=>de(e=>!e),children:[ue?(0,S.jsx)(yf,{className:`size-3.5 shrink-0`}):(0,S.jsx)(xf,{className:`size-3.5 shrink-0`}),`Current declared CSP`]}),ue&&(0,S.jsx)(`div`,{className:`px-3 pb-3 pt-0 space-y-1.5 text-xs`,children:x?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`connectDomains:`}),` `,x.connectDomains?.length?JSON.stringify(x.connectDomains):`Not declared`]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`resourceDomains:`}),` `,x.resourceDomains?.length?JSON.stringify(x.resourceDomains):`Not declared`]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`frameDomains:`}),` `,x.frameDomains?.length?JSON.stringify(x.frameDomains):`Not declared`]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-mono text-zinc-500 dark:text-zinc-400`,children:`baseUriDomains:`}),` `,x.baseUriDomains?.length?JSON.stringify(x.baseUriDomains):`Not declared`]})]}):(0,S.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:h.cspMode===`permissive`?`Widget-declared (would apply in Widget-Declared mode)`:`No CSP declared`})})]}),(0,S.jsxs)(`div`,{className:`mt-3 border border-zinc-200 dark:border-zinc-700 rounded-md overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 bg-zinc-50 dark:bg-zinc-900/50 hover:bg-zinc-100 dark:hover:bg-zinc-800/50 transition-colors`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`flex-1 flex items-center gap-2 text-left text-sm font-medium min-w-0`,onClick:()=>pe(e=>!e),children:[fe?(0,S.jsx)(yf,{className:`size-3.5 shrink-0`}):(0,S.jsx)(xf,{className:`size-3.5 shrink-0`}),`originalPolicy`]}),C&&(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,onClick:async e=>{e.stopPropagation();try{await lj(C),IM.success(`Policy copied to clipboard`)}catch{IM.error(`Failed to copy`)}},"aria-label":`Copy policy`,children:(0,S.jsx)(jf,{className:`size-3.5`})})}),(0,S.jsx)(jd,{children:`Copy policy`})]})]}),fe&&(0,S.jsx)(`div`,{className:`px-3 pb-3 pt-0`,children:C?(0,S.jsx)(`pre`,{className:`text-[11px] font-mono text-zinc-600 dark:text-zinc-400 whitespace-pre-wrap break-all bg-zinc-50 dark:bg-zinc-900 p-2 rounded border border-zinc-100 dark:border-zinc-800`,children:C}):(0,S.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400 text-xs`,children:`No policy data yet (load widget in Widget-Declared mode)`})})]}),b.length>-1&&(0,S.jsxs)(`div`,{className:`mt-3 border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 bg-amber-50 dark:bg-amber-950/30 hover:bg-amber-100 dark:hover:bg-amber-900/30 transition-colors`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`flex-1 flex items-center gap-2 text-left text-sm font-medium min-w-0 text-amber-800 dark:text-amber-200`,onClick:()=>he(e=>!e),children:[me?(0,S.jsx)(yf,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}):(0,S.jsx)(xf,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),`Prompt for Agents`]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-amber-600 dark:text-amber-400 hover:bg-amber-200/50 dark:hover:bg-amber-800/30`,onClick:async e=>{e.stopPropagation();try{await lj(E),IM.success(`Prompt copied to clipboard`)}catch{IM.error(`Failed to copy`)}},"aria-label":`Copy prompt for agents`,children:(0,S.jsx)(jf,{className:`size-3.5`})})}),(0,S.jsx)(jd,{children:`Copy prompt for agents`})]})]}),me&&(0,S.jsx)(`div`,{className:`px-3 pb-3 pt-0`,children:(0,S.jsx)(`pre`,{className:`text-[11px] font-mono text-zinc-600 dark:text-zinc-400 whitespace-pre-wrap bg-zinc-50 dark:bg-zinc-900 p-2 rounded border border-zinc-100 dark:border-zinc-800 overflow-x-auto max-h-48 overflow-y-auto`,"data-testid":`debugger-csp-prompt-for-agents`,children:E})})]}),b.length>0&&(0,S.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-xs font-semibold uppercase tracking-wide ${h.cspMode===`permissive`?`text-yellow-600 dark:text-yellow-400`:`text-red-600 dark:text-red-400`}`,children:[b.length,` `,h.cspMode===`permissive`?`would-be-blocked`:`blocked`,` `,`request`,b.length===1?``:`s`]}),(0,S.jsx)(`button`,{className:`text-xs text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200 underline`,onClick:()=>v(n),children:`Clear`})]}),(0,S.jsx)(`div`,{className:`max-h-56 overflow-y-auto space-y-1 rounded border border-zinc-200 dark:border-zinc-700 bg-zinc-50 dark:bg-zinc-900 p-2`,children:b.map((e,t)=>(0,S.jsxs)(`div`,{className:`flex flex-col gap-0.5 py-1 border-b border-zinc-100 dark:border-zinc-800 last:border-0`,children:[(0,S.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,S.jsx)(`span`,{className:`shrink-0 rounded bg-red-100 dark:bg-red-900/40 px-1 py-0.5 text-[10px] font-mono font-semibold text-red-700 dark:text-red-300`,children:e.effectiveDirective||e.directive})}),(0,S.jsx)(`span`,{className:`text-[11px] font-mono text-zinc-600 dark:text-zinc-400 break-all leading-snug`,children:e.blockedUri||`(inline)`})]},t))})]})]})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-touch-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${h.capabilities.touch?`border-blue-500 dark:border-blue-400`:``}`,onClick:()=>{let e={...h.capabilities,touch:!h.capabilities.touch};g({capabilities:e}),k&&f&&f({userAgent:{device:{type:h.deviceType},capabilities:e}})},children:(0,S.jsx)(up,{className:`size-3.5 ${h.capabilities.touch?`text-blue-600 dark:text-blue-400`:``}`})})}),(0,S.jsxs)(jd,{children:[`Touch: `,h.capabilities.touch?`Enabled`:`Disabled`]})]}),(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-hover-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900 ${h.capabilities.hover?`border-blue-500 dark:border-blue-400`:``}`,onClick:()=>{let e={...h.capabilities,hover:!h.capabilities.hover};g({capabilities:e}),k&&f&&f({userAgent:{device:{type:h.deviceType},capabilities:e}})},children:(0,S.jsx)(ap,{className:`size-3.5 ${h.capabilities.hover?`text-blue-600 dark:text-blue-400`:``}`})})}),(0,S.jsxs)(jd,{children:[`Hover: `,h.capabilities.hover?`Enabled`:`Disabled`]})]}),(0,S.jsxs)(eY,{children:[(0,S.jsx)(tY,{asChild:!0,children:(0,S.jsx)(U,{"data-testid":`debugger-safe-area-button`,variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,children:(0,S.jsx)(Tp,{className:`size-3.5`})})}),(0,S.jsx)(nY,{className:`w-64 p-3`,"data-testid":`debugger-safe-area-dialog`,children:(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-xs font-medium`,children:`Safe Area Insets`}),(0,S.jsx)(UNe,{value:h.safeAreaInsets,onChange:e=>{g({safeAreaInsets:e}),k&&f&&f({safeArea:{insets:e}})}})]})})]}),r===`tool`?(0,S.jsxs)(xN,{children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(SN,{asChild:!0,children:(0,S.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,"data-testid":`debugger-props-button`,children:(0,S.jsx)(mf,{className:`size-3.5`})})})}),(0,S.jsx)(jd,{children:`View Tool Props`})]}),(0,S.jsxs)(CN,{className:`sm:max-w-[600px]`,"data-testid":`debugger-props-dialog`,children:[(0,S.jsx)(wN,{children:(0,S.jsx)(TN,{children:`Tool Props`})}),(0,S.jsx)(`div`,{className:`overflow-auto max-h-[60vh] rounded-md bg-gray-50 dark:bg-zinc-900 border border-gray-200 dark:border-zinc-700 p-3`,children:(0,S.jsx)(BV,{data:a??{},filename:`tool-props.json`})})]})]}):(0,S.jsxs)(eY,{open:te,onOpenChange:ne,children:[(0,S.jsxs)(kd,{children:[(0,S.jsx)(Ad,{asChild:!0,children:(0,S.jsx)(tY,{asChild:!0,children:(0,S.jsx)(U,{variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${ee?`bg-amber-50 dark:bg-amber-950/40 border-amber-300 dark:border-amber-700 hover:bg-amber-100 dark:hover:bg-amber-900/50 animate-pulse`:`bg-white/90 dark:bg-zinc-900/90 hover:bg-white dark:hover:bg-zinc-900`}`,"data-testid":`debugger-props-button`,children:(0,S.jsx)(mf,{className:`size-3.5 ${ee?`text-amber-500`:``}`})})})}),(0,S.jsxs)(jd,{children:[`Props:`,` `,_e===V7?`No Props`:_e===H7?`Tool Props`:A.find(e=>e.id===_e)?.name||`Custom`]})]}),(0,S.jsxs)(nY,{className:`w-64 p-2`,"data-testid":`debugger-props-popover`,children:[ee&&(0,S.jsxs)(`div`,{className:`mb-2 rounded-md border border-amber-200 dark:border-amber-800/50 bg-amber-50 dark:bg-amber-950/30 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-amber-700 dark:text-amber-300 mb-0.5`,children:`Props required to render this widget:`}),(0,S.jsx)(`p`,{className:`text-xs font-mono text-amber-600 dark:text-amber-400`,children:u.join(`, `)}),(0,S.jsx)(`p`,{className:`text-xs text-amber-500 dark:text-amber-400 mt-1`,children:`Create a preset below to set them.`})]}),(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(U,{variant:_e===V7?`secondary`:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:()=>ye(V7),"data-testid":`debugger-props-no-props`,children:`No Props`}),A.map(e=>(0,S.jsxs)(`div`,{className:`relative group flex items-center`,children:[(0,S.jsx)(U,{variant:_e===e.id?`secondary`:`ghost`,size:`sm`,className:`w-full justify-start pr-14`,onClick:()=>ye(e.id),"data-testid":`debugger-props-preset-${e.id}`,children:e.name}),(0,S.jsxs)(`div`,{className:`absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:t=>Se(e,t),"data-testid":`debugger-props-edit-${e.id}`,children:(0,S.jsx)(vp,{className:`h-3 w-3`})}),(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:t=>xe(e.id,t),"data-testid":`debugger-props-delete-${e.id}`,children:(0,S.jsx)(Mp,{className:`h-3 w-3 text-destructive`})})]})]},e.id)),(0,S.jsx)(U,{variant:`ghost`,size:`sm`,className:`w-full justify-start text-primary`,onClick:()=>ye(WNe),"data-testid":`debugger-props-create-preset`,children:`+ Create Preset...`})]})]})]}),(0,S.jsx)(LMe,{iframeId:n,enabled:!0}),c&&(0,S.jsx)(HNe,{open:I,onOpenChange:L,onSave:be,existingPresets:A,resource:c,resourceAnnotations:o,llmConfig:s||null,editingPreset:re})]})}function YNe({children:e,className:t,noWrapper:n}){return n?e:(0,S.jsx)(`div`,{className:H(`bg-zinc-100 dark:bg-zinc-900 bg-[radial-gradient(circle,_rgba(0,0,0,0.2)_1px,_transparent_1px)] dark:bg-[radial-gradient(circle,_rgba(255,255,255,0.2)_1px,_transparent_1px)] bg-[length:32px_32px]`,t),children:e})}function XNe({componentUrl:e,toolName:t,toolArgs:n,toolResult:r,serverId:i,readResource:a,className:o,noWrapper:s=!1,showConsole:c=!0,customProps:l,serverBaseUrl:u,invoking:d,invoked:f,onUpdateGlobals:p}){let m=(0,w.useRef)(null),h=(0,w.useRef)(null),[g,_]=(0,w.useState)(!1),[v,y]=(0,w.useState)(!0),b=(0,w.useRef)(!1),[x,C]=(0,w.useState)(null),[T,E]=(0,w.useState)(null),[D,O]=(0,w.useState)(400),k=(0,w.useRef)(0),A=(0,w.useRef)(0),j=(0,w.useRef)(!1),[M,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(`inline`),[I,L]=(0,w.useState)(!1),[ee,te]=(0,w.useState)(!1),[ne,re]=(0,w.useState)(!1),[R,z]=(0,w.useState)(null),[B,ie]=(0,w.useState)(null),ae=(0,w.useRef)(null),oe=(0,w.useRef)(null),se=(0,w.useRef)(null),ce=(0,w.useRef)(!1),le=(0,w.useRef)(null),ue=(0,w.useRef)(`tool-${Date.now()}-${Math.random().toString(36).substring(7)}`).current,de=(0,w.useRef)(!1),{servers:fe}=cj(),pe=fe.find(e=>e.id===i),me=(0,w.useRef)(pe);me.current=pe;let he=u??pe?.url,{resolvedTheme:ge}=LP(),{playground:_e,addWidget:ve,addCspViolation:ye}=SQ(),be=(0,w.useRef)(n),xe=(0,w.useRef)(r),Se=(0,w.useRef)(a),Ce=(0,w.useRef)(he),we=(0,w.useRef)(ge),Te=(0,w.useRef)(l);(0,w.useEffect)(()=>{be.current=n,xe.current=r,Se.current=a,Ce.current=he,we.current=ge,Te.current=l}),(0,w.useEffect)(()=>{let n=!1;return(async()=>{let r=xe.current,a=Se.current,o=we.current,s=_e;console.log(`[OpenAIComponentRenderer] Storing widget data with playground:`,{locale:s.locale,deviceType:s.deviceType});try{let c=r?r.structuredContent??{}:null,l=await a(e);if(n)return;let u=null;r?._meta?.[`openai/widgetCSP`]?u=r._meta[`openai/widgetCSP`]:l?.contents?.[0]?._meta?.[`openai/widgetCSP`]&&(u=l.contents[0]._meta[`openai/widgetCSP`]);let d=be.current,f=Te.current,p={...d||{},...f||{}},m={serverId:i,uri:e,toolInput:p,toolOutput:c,toolResponseMetadata:null,resourceData:l,toolId:ue,widgetCSP:u,theme:o,playground:{locale:s.locale,deviceType:s.deviceType,capabilities:s.capabilities,safeAreaInsets:s.safeAreaInsets}},h=await fetch(`/inspector/api/resources/widget/store`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(m)});if(!h.ok){let e=await h.json().catch(()=>({error:`Unknown error`}));throw Error(`Failed to store widget data: ${e.error||h.statusText}`)}if(n)return;z(p),ie(c),re(!1),de.current||(de.current=!0,E(`/inspector/api/resources/widget-content/${ue}?t=${Date.now()}`),ve(ue,{toolName:t,protocol:`chatgpt-app`})),L(!0)}catch(e){if(n)return;console.error(`Error storing widget data:`,e),C(e instanceof Error?e.message:`Failed to prepare widget`)}})(),()=>{n=!0}},[e,i,ue,l,JSON.stringify(n),r]);let Ee=(0,w.useCallback)(e=>{if(se.current={...se.current||{},...e},!m.current?.contentWindow){p&&p(e);return}ce.current||(ce.current=!0,queueMicrotask(()=>{ce.current=!1;let e=se.current;if(se.current=null,!e)return;let t=()=>{if(oe.current!==null)return;let e=0,t=()=>{let n=m.current?.contentWindow,r=ae.current;if(!n||!r){oe.current=null;return}if(n.openai){ae.current=null,oe.current=null,Ee(r);return}if(e+=1,e>=60){oe.current=null;return}oe.current=window.requestAnimationFrame(t)};oe.current=window.requestAnimationFrame(t)};try{let n=m.current?.contentWindow,r=m.current?.contentDocument;if(!n)return;if(e.theme!==void 0&&r){let t=r.documentElement;t.setAttribute(`data-theme`,e.theme),t.style.colorScheme=e.theme,t.classList.remove(`light`,`dark`),t.classList.add(e.theme)}if(n.openai){if(!(e.locale!==void 0||e.safeArea!==void 0||e.userAgent!==void 0||e.maxHeight!==void 0||e.toolOutput!==void 0||e.toolResponseMetadata!==void 0)){let t=e.theme===void 0||n.openai.theme===e.theme,r=e.displayMode===void 0||n.openai.displayMode===e.displayMode;if(t&&r)return}e.displayMode!==void 0&&(n.openai.displayMode=e.displayMode),e.theme!==void 0&&(n.openai.theme=e.theme),e.maxHeight!==void 0&&(n.openai.maxHeight=e.maxHeight),e.locale!==void 0&&(n.openai.locale=e.locale),e.safeArea!==void 0&&(n.openai.safeArea=e.safeArea),e.userAgent!==void 0&&(n.openai.userAgent=e.userAgent),e.toolOutput!==void 0&&(n.openai.toolOutput=e.toolOutput),e.toolResponseMetadata!==void 0&&(n.openai.toolResponseMetadata=e.toolResponseMetadata);try{let e=new n.CustomEvent(`openai:set_globals`,{detail:{globals:{...n.openai}}});n.dispatchEvent(e)}catch{n.postMessage({type:`openai:globalsChanged`,updates:e},`*`)}}else ae.current={...ae.current||{},...e},t();p&&p(e)}catch{let t=m.current?.contentWindow;t&&t.postMessage({type:`openai:globalsChanged`,updates:e},`*`),p&&p(e)}}))},[p]);(0,w.useEffect)(()=>()=>{oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)},[]),(0,w.useEffect)(()=>{if(!r||!g||!m.current?.contentWindow)return;let e=r?.structuredContent||r,t=r?._meta||null,n=JSON.stringify(e);le.current!==n&&(le.current=n,Ee({toolOutput:e,toolResponseMetadata:t}))},[r,g,Ee]);let{handleDisplayModeChange:De,fullscreenShellClassName:Oe,pipShellClassName:ke,isPip:Ae}=vMe({containerRef:h,displayMode:P,setDisplayMode:(0,w.useCallback)(e=>{F(e),Ee({displayMode:e})},[Ee])}),je=(0,w.useRef)(0),[Me,Ne]=(0,w.useState)(0),Pe=(0,w.useCallback)(e=>{m.current=e,e&&(je.current+=1,je.current>1&&(Ne(e=>e+1),b.current&&(y(!0),_(!1))))},[]),Fe=(0,w.useRef)(De);Fe.current=De;let Ie=(0,w.useRef)(null);if((0,w.useEffect)(()=>{if(!T)return;let e=Ie.current!==T;Ie.current=T,e&&(_(!1),b.current||y(!0)),C(null);let t=!1,n=async e=>{let t=m.current;if(!(!t||e.source!==t.contentWindow)){if(e.data?.type===`iframe-console-log`){if(e.data.level===`error`){let t=(Array.isArray(e.data.args)?e.data.args:[])[0],n=typeof t==`string`?t:typeof t?.message==`string`?t.message:`Widget runtime error`,r=typeof t?.error?.stack==`string`?t.error.stack:typeof t?.stack==`string`?t.stack:void 0;typeof window<`u`&&window.parent!==window&&window.parent.postMessage({type:`mcp-inspector:widget:error`,source:`iframe-console:error`,message:n,stack:r,timestamp:Date.now(),url:typeof e.data.url==`string`?e.data.url:void 0,toolId:ue},`*`)}return}if(e.data?.type===`mcp-inspector:getWidgetState`){try{let t=m.current?.contentWindow;t?.openai?.widgetState!==void 0&&m.current?.contentWindow?.postMessage({type:`mcp-inspector:widgetStateResponse`,toolId:e.data.toolId,state:t.openai.widgetState},`*`)}catch{}return}switch(e.data.type){case`openai:csp-violation`:ye(ue,{directive:e.data.directive,effectiveDirective:e.data.effectiveDirective,blockedUri:e.data.blockedUri,sourceFile:e.data.sourceFile,lineNumber:e.data.lineNumber,columnNumber:e.data.columnNumber,timestamp:e.data.timestamp||Date.now()});break;case`openai:setWidgetState`:break;case`openai:callTool`:try{let t=me.current;if(!t)throw Error(`Server connection not available`);let{toolName:n,params:r,requestId:i}=e.data,a=await t.callTool(n,r||{},{timeout:6e5,resetTimeoutOnProgress:!0}),o;o=a&&typeof a==`object`?Array.isArray(a.contents)?{content:a.contents.map(e=>typeof e==`string`?{type:`text`,text:e}:e.type===`text`&&e.text?{type:`text`,text:e.text}:e.type===`image`&&e.data?{type:`image`,image_url:{url:e.data}}:{type:`text`,text:JSON.stringify(e)})}:{content:[{type:`text`,text:typeof a==`string`?a:JSON.stringify(a)}]}:{content:[{type:`text`,text:String(a)}]},m.current?.contentWindow?.postMessage({type:`openai:callTool:response`,requestId:i,result:o},`*`)}catch(t){console.error(`[OpenAIComponentRenderer] Tool call error:`,t),m.current?.contentWindow?.postMessage({type:`openai:callTool:response`,requestId:e.data.requestId,error:t instanceof Error?t.message:String(t)},`*`)}break;case`openai:sendFollowup`:try{let{message:t}=e.data,n=typeof t==`string`?t:t?.prompt||t;if(!n){console.warn(`[OpenAIComponentRenderer] No prompt in followup message`);return}let r=new window.CustomEvent(`mcp-inspector:widget-followup`,{detail:{prompt:n,serverId:i}});window.dispatchEvent(r);try{let e=JSON.parse(localStorage.getItem(`mcp-inspector-pending-followups`)||`[]`);e.push({prompt:n,serverId:i,timestamp:Date.now()}),localStorage.setItem(`mcp-inspector-pending-followups`,JSON.stringify(e.slice(-10)))}catch{}}catch(e){console.error(`[OpenAIComponentRenderer] Failed to send followup:`,e)}break;case`openai:requestDisplayMode`:try{let{mode:t}=e.data;t&&[`inline`,`pip`,`fullscreen`].includes(t)&&await Fe.current(t)}catch(e){console.error(`[OpenAIComponentRenderer] Failed to change display mode:`,e)}break;case`openai:notifyIntrinsicHeight`:try{let{height:t}=e.data;if(typeof t==`number`&&t>0){let e=t;if(P===`fullscreen`||P===`pip`){let n=typeof window<`u`?window.innerHeight:t;e=Math.min(t,n)}(t!==A.current||e!==D)&&(A.current=t,k.current=e,j.current=!0,O(e))}}catch(e){console.error(`[OpenAIComponentRenderer] Failed to handle intrinsic height notification:`,e)}break;default:break}}};window.addEventListener(`message`,n);let r=()=>{if(!t){if(t=!0,_(!0),C(null),m.current)try{let e=!!m.current.contentDocument;e&&I?TMe(m.current):e||L(!1)}catch{L(!1)}ge&&setTimeout(()=>{Ee({theme:ge})},50)}},a=()=>{C(`Failed to load component`)},o=m.current;return o?.addEventListener(`load`,r),o?.addEventListener(`error`,a),o&&(o.contentDocument?.readyState===`complete`||o.contentDocument?.readyState===`interactive`)&&(o.contentDocument?.querySelectorAll(`script`).length??0)>0&&r(),()=>{window.removeEventListener(`message`,n),o?.removeEventListener(`load`,r),o?.removeEventListener(`error`,a)}},[T,I,i,Ee,ne,Me]),(0,w.useEffect)(()=>{if(g){if(!I){Ee({theme:ge});return}try{if(!m.current?.contentDocument)return;let e=m.current.contentDocument.documentElement;e.setAttribute(`data-theme`,ge),e.style.colorScheme=ge,e.classList.remove(`light`,`dark`),e.classList.add(ge)}catch{}Ee({theme:ge})}},[ge,g,I,Ee]),(0,w.useEffect)(()=>{!g||!v||(y(!1),b.current=!0)},[g,v]),(0,w.useEffect)(()=>{if(!T||!I)return;let e=()=>{if(j.current)return;let e=m.current;try{let t=e?.contentWindow?.document?.body;if(!e||!t)return;let n=t.scrollHeight||0,r=typeof window<`u`?window.innerHeight:n,i=Math.min(n,r);i>0&&i!==k.current&&(k.current=i,O(i))}catch{}},t,n=()=>{e(),t=window.requestAnimationFrame(n)};return n(),window.addEventListener(`resize`,e),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,e)}},[T,I]),(0,w.useEffect)(()=>{let e=()=>{let e=h.current;if(!e)return;let t=e.clientHeight;N(t>D)};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[D]),(0,w.useEffect)(()=>{if(T&&ge&&g){let e=setTimeout(()=>{Ee({theme:ge})},0);return()=>clearTimeout(e)}},[ge,T,g,Ee]),x)return(0,S.jsx)(`div`,{className:o,children:(0,S.jsx)(`div`,{className:`bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4`,children:(0,S.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:[`Failed to load component: `,x]})})});if(!T)return(0,S.jsx)(YNe,{className:o,noWrapper:s,children:(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,S.jsx)(Vq,{className:`size-5`})})});let Le=(0,S.jsxs)(`div`,{ref:h,className:H(`w-full h-full flex flex-col min-h-0`,P===`fullscreen`?`items-stretch justify-stretch`:H(`justify-center items-center`,M&&`items-center`),Oe,ke),style:Ae?{maxWidth:O7.DIMENSIONS.PIP_MAX_WIDTH}:void 0,onMouseEnter:()=>Ae&&te(!0),onMouseLeave:()=>Ae&&te(!1),children:[P===`fullscreen`&&(0,S.jsx)(yMe,{title:t,onClose:()=>De(`inline`)}),Ae&&(0,S.jsx)(`button`,{onClick:()=>De(`inline`),className:H(`absolute top-2 right-2 z-50`,`flex items-center justify-center`,`w-8 h-8 rounded-full`,`bg-background/90 hover:bg-background`,`border border-border`,`shadow-lg`,`transition-opacity duration-200`,`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,ee?`opacity-100`:`opacity-0`),"aria-label":`Exit Picture in Picture`,children:(0,S.jsx)(Fp,{className:`w-4 h-4 text-foreground`})}),(0,S.jsx)(`div`,{className:H(`relative w-full min-h-0`,P===`fullscreen`||P===`pip`?`flex flex-1 flex-col`:H(`flex flex-1 justify-center items-center`,M&&`items-center`),P===`inline`&&(d||f)&&`pt-8`),children:(0,S.jsxs)(`div`,{className:H(`relative w-full`,P===`fullscreen`||P===`pip`?`h-full min-h-0 flex-1`:`max-w-[768px]`),children:[P===`inline`&&(d||f)&&(0,S.jsxs)(`div`,{className:`absolute -top-8 left-2 z-10 whitespace-nowrap pointer-events-none`,children:[d&&!r&&(0,S.jsx)(NY,{className:`text-xs`,children:d}),f&&r&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f})]}),(0,S.jsx)(`iframe`,{ref:Pe,src:T,className:H(P===`inline`&&`w-full`,P===`fullscreen`&&`w-full h-full rounded-none`,P===`pip`&&`w-full h-full rounded-lg`),style:{height:P===`fullscreen`||P===`pip`?`100%`:`${D}px`},sandbox:D7,title:`OpenAI Component: ${t}`,allow:`web-share`})]})})]});return(0,S.jsxs)(YNe,{className:o,noWrapper:s,children:[!Ae&&v&&(0,S.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full z-0`,children:(0,S.jsx)(Vq,{className:`size-5`})}),c&&I&&!Ae&&P!==`fullscreen`&&(0,S.jsx)(`div`,{className:`absolute top-2 right-2 z-30 flex items-center gap-2`,children:(0,S.jsx)(U7,{displayMode:P,onDisplayModeChange:De,toolCallId:ue,propsContext:`tool`,resourceUri:e,toolInput:R,resourceAnnotations:void 0,llmConfig:null,resource:null,onPropsChange:void 0,protocol:`apps-sdk`,onUpdateGlobals:Ee})}),Ae&&typeof document<`u`?(0,S.jsxs)(S.Fragment,{children:[v&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-[99] flex items-center justify-center bg-background/40`,children:(0,S.jsx)(Vq,{className:`size-5`})}),(0,Bt.createPortal)(Le,document.body)]}):Le]})}function ZNe(e,t){for(let n of[`componentUrl`,`toolName`,`serverId`,`toolArgs`,`toolResult`,`readResource`,`className`])if(e[n]!==t[n])return!1;return!(e.invoking!==t.invoking||e.invoked!==t.invoked)}var W7=(0,w.memo)(XNe,ZNe),QNe=(0,w.memo)(({resource:e})=>{if(!e.uri?.startsWith(`ui://`))return null;let t=(0,w.useMemo)(()=>{if(e.text)return e.text;if(e.blob)try{return atob(e.blob)}catch{return null}return null},[e.text,e.blob]);return t?(0,S.jsx)(`div`,{className:`my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card`,children:(0,S.jsx)(`iframe`,{srcDoc:t,sandbox:`allow-scripts allow-forms allow-popups`,title:e.uri??`MCP UI Resource`,style:{width:`100%`,height:`100%`,border:`none`,overflow:`auto`}})}):null});function $Ne({widgetId:e}){let{getWidget:t}=SQ(),n=t(e)?.modelContext;if(!n?.content?.length&&!n?.structuredContent)return null;let r=n.content?.map(e=>e.text).join(` `)??JSON.stringify(n.structuredContent).slice(0,80);return(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1`,children:[(0,S.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0`}),(0,S.jsx)(`span`,{className:`font-medium`,children:`State synced to model`}),(0,S.jsx)(`span`,{className:`truncate opacity-60 max-w-[300px]`,children:r})]})}function ePe({toolName:e,toolArgs:t,result:n,serverId:r,readResource:i,toolMeta:a,onSendFollowUp:o,serverBaseUrl:s,partialToolArgs:c,cancelled:l}){let{playground:u}=SQ(),[d,f]=(0,w.useState)(null),p=(0,w.useRef)(null),m=(0,w.useMemo)(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),h=(0,w.useMemo)(()=>{if(!n)return null;if(typeof n==`string`)try{return JSON.parse(n)}catch(e){return console.error(`[ToolResultRenderer] Failed to parse result:`,e),n}return n},[n]),g=(0,w.useMemo)(()=>JSON.stringify(a),[a]),_=(0,w.useMemo)(()=>TQ(a,h),[g,h]),v=(0,w.useMemo)(()=>wQ(a),[g]),y=(0,w.useMemo)(()=>_?_===`both`?u.selectedProtocol?u.selectedProtocol:`mcp-apps`:_:null,[_,u.selectedProtocol]),b=(0,w.useMemo)(()=>y===`mcp-apps`,[y]),x=(0,w.useMemo)(()=>y===`chatgpt-app`,[y]),C=(0,w.useMemo)(()=>!!(h?.content&&Array.isArray(h.content)&&h.content.some(e=>e.type===`resource`&&e.resource?.uri?.startsWith(`ui://`)&&e.resource?.mimeType===`text/html+skybridge`)),[h]),T=(0,w.useMemo)(()=>C&&h.content.find(e=>e.type===`resource`&&e.resource?.uri?.startsWith(`ui://`)&&e.resource?.mimeType===`text/html+skybridge`)?.resource||null,[C,h]),E=(0,w.useMemo)(()=>t,[e,h]),D=(0,w.useMemo)(()=>h,[e,h]),O=(0,w.useMemo)(()=>v&&y?EQ(y,a):b?a?.ui?.resourceUri||null:x&&a?.[`openai/outputTemplate`]||null,[v,y,b,x,g]);(0,w.useEffect)(()=>{if(T){f(T),p.current=T.uri||null;return}O&&p.current===O||(O!==p.current&&f(null),O&&i&&(p.current=O,i(O).then(e=>{e?.contents&&Array.isArray(e.contents)&&e.contents.length>0&&f(e.contents[0])}).catch(e=>{console.error(`[ToolResultRenderer] Failed to fetch resource:`,e),p.current=null})))},[T,O,y,i]);let k=a?.[`openai/toolInvocation/invoking`],A=a?.[`openai/toolInvocation/invoked`];if(v&&d&&r&&i)return(0,S.jsxs)(`div`,{className:`my-4`,children:[y===`mcp-apps`&&(0,S.jsx)(M7,{serverId:r,toolCallId:m,toolName:e,toolInput:E,toolOutput:D,toolMetadata:a,invoking:k,invoked:A,partialToolInput:c,resourceUri:d.uri,readResource:i,noWrapper:!0,onSendFollowUp:o,serverBaseUrl:s,cancelled:l}),y===`chatgpt-app`&&(0,S.jsx)(W7,{componentUrl:d.uri,toolName:e,toolArgs:E,toolResult:D,serverId:r,readResource:i,noWrapper:!0,showConsole:!1,invoking:k,invoked:A,serverBaseUrl:s})]});if(b&&O&&r&&i)return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(M7,{serverId:r,toolCallId:m,toolName:e,toolInput:E,toolOutput:D,toolMetadata:a,invoking:k,invoked:A,partialToolInput:c,resourceUri:d?.uri||O,readResource:i,className:`my-4`,noWrapper:!0,onSendFollowUp:o,serverBaseUrl:s}),(0,S.jsx)($Ne,{widgetId:m})]});if((x||C)&&O&&r&&i)return(0,S.jsx)(W7,{componentUrl:d?.uri||O,toolName:e,toolArgs:E,toolResult:D,serverId:r,readResource:i,noWrapper:!0,className:`my-4`,showConsole:!1,invoking:k,invoked:A,serverBaseUrl:s});if((b||x||C)&&!O)return(0,S.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px] rounded border`,children:(0,S.jsx)(Vq,{className:`size-5`})});if((b||x)&&(!r||!i))return console.error(`[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:`,{toolName:e,hasServerId:!!r,hasReadResource:!!i}),(0,S.jsx)(`div`,{className:`my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg`,children:(0,S.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Cannot render widget: Missing required props (serverId or readResource)`})});let j=[];if(h?.content&&Array.isArray(h.content))for(let e of h.content)e.type===`resource`&&e.resource?.uri?.startsWith(`ui://`)&&e.resource?.mimeType!==`text/html+skybridge`&&j.push(e.resource);return j.length>0?(0,S.jsx)(S.Fragment,{children:j.map(t=>(0,S.jsx)(QNe,{resource:t},`${e}-mcp-ui-${t.uri}`))}):(console.log(`[ToolResultRenderer] Not rendering (no UI resources found):`,{toolName:e,isAppsSdkTool:x,hasAppsSdkComponent:C,hasResourceData:!!d,contentLength:h?.content?.length}),null)}function tPe({content:e,timestamp:t,attachments:n}){return(!e||e.length===0)&&(!n||n.length===0)?null:(0,S.jsx)(`div`,{className:`flex items-start gap-3 justify-end group/user-message`,"data-testid":`chat-message-user`,children:(0,S.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col items-end`,children:[(0,S.jsxs)(`div`,{className:`bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words`,"data-testid":`chat-message-content`,children:[n&&n.length>0&&(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:n.map((e,t)=>(0,S.jsx)(`div`,{className:`rounded-lg overflow-hidden border border-zinc-300 dark:border-zinc-700`,children:(0,S.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name||`Attachment ${t+1}`,className:`max-w-[200px] max-h-[200px] object-contain`})},t))}),e&&e.length>0&&(0,S.jsx)(`p`,{className:`text-base leading-7 font-sans text-start break-words`,children:e})]}),t&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,S.jsx)(pQ,{text:e}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(t).toLocaleTimeString()})]})]})})}function G7(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 nPe(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(G7):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(G7):[];return t.length>0?t:n}function rPe(e){let t=e.items&&typeof e.items==`object`?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(G7):[],r=Array.isArray(t.oneOf)?t.oneOf.filter(G7):[];return n.length>0?n:r}function iPe({request:e,formData:t,onFieldChange:n,idPrefix:r,testIdPrefix:i,fieldContainerClassName:a=`space-y-2`,textareaRows:o=4,showOuterLabelForBoolean:s=!0,emptyFallback:c}){return(0,S.jsx)(S.Fragment,{children:(0,w.useMemo)(()=>{if(!(`requestedSchema`in e.request))return null;let l=e.request.requestedSchema;if(!l||l.type!==`object`||!l.properties)return c??(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema available`});let u=l.properties,d=l.required||[];return(0,S.jsx)(`div`,{className:`space-y-4`,children:Object.entries(u).map(([e,c])=>{let l=c,u=d.includes(e),f=l.type||`string`,p=l.title||e,m=l.description,h=nPe(l),g=h.length>0,_=Array.isArray(l.enum),v=f===`array`&&Array.isArray(l.items?.enum),y=rPe(l),b=f===`array`&&y.length>0,x=Array.isArray(t[e])?t[e]:[],C=`${r}-${e}`,w=`${i}-${e}`;return(0,S.jsxs)(`div`,{className:a,children:[(f!==`boolean`||s)&&(0,S.jsxs)(AN,{htmlFor:C,children:[p,u&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),m&&(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m}),f===`boolean`?(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:C,"data-testid":w,checked:t[e]||!1,onCheckedChange:t=>n(e,t)}),(0,S.jsxs)(AN,{htmlFor:C,className:`text-sm font-normal cursor-pointer`,children:[p,!s&&u&&(0,S.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]})]}):f===`number`||f===`integer`?(0,S.jsx)(DN,{id:C,"data-testid":w,type:`number`,value:t[e]??``,onChange:t=>{let r=f===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value);n(e,isNaN(r)?``:r)},placeholder:l.default?.toString()||``}):g?(0,S.jsxs)(`select`,{id:C,"data-testid":w,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,S.jsx)(`option`,{value:``,children:`Select...`}),h.map(e=>(0,S.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):_?(0,S.jsxs)(`select`,{id:C,"data-testid":w,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,S.jsx)(`option`,{value:``,children:`Select...`}),l.enum.map((e,t)=>(0,S.jsx)(`option`,{value:e,children:l.enumNames?.[t]||e},e))]}):v?(0,S.jsx)(`div`,{className:`space-y-2`,"data-testid":w,children:l.items.enum.map(t=>{let r=`${C}-${t}`;return(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:r,checked:x.includes(t),onCheckedChange:r=>{n(e,r?[...x,t]:x.filter(e=>e!==t))}}),(0,S.jsx)(AN,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):b?(0,S.jsx)(`div`,{className:`space-y-2`,"data-testid":w,children:y.map(t=>{let r=`${C}-${t.const}`;return(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:r,checked:x.includes(t.const),onCheckedChange:r=>{n(e,r?[...x,t.const]:x.filter(e=>e!==t.const))}}),(0,S.jsx)(AN,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):f===`string`&&(l.format===`textarea`||l.maxLength>100)?(0,S.jsx)(mY,{id:C,"data-testid":w,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:l.default||``,rows:o}):(0,S.jsx)(DN,{id:C,"data-testid":w,type:`text`,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:l.default||``})]},e)})})},[e,t,n,r,i,a,o,s,c])})}function aPe(e){let[t,n]=(0,w.useState)({}),[r,i]=(0,w.useState)(!1),a=e?.request.mode||`form`,o=a===`form`,s=a===`url`;return(0,w.useEffect)(()=>{if(e&&o&&`requestedSchema`in e.request){let t=e.request.requestedSchema,r={};if(t?.type===`object`&&t.properties)for(let[e,n]of Object.entries(t.properties)){let t=n;t.default===void 0?t.type===`array`?r[e]=[]:t.type===`boolean`?r[e]=!1:t.type===`number`||t.type===`integer`?r[e]=0:r[e]=``:r[e]=t.default}n(r)}i(!1)},[e?.id,o]),{formData:t,setFieldValue:(0,w.useCallback)((e,t)=>{n(n=>({...n,[e]:t}))},[]),getMissingRequiredFields:(0,w.useCallback)(()=>!e||!o||!(`requestedSchema`in e.request)?[]:(e.request.requestedSchema?.required??[]).filter(e=>t[e]===void 0||t[e]===``||t[e]===null),[e,t,o]),urlCompleted:r,setUrlCompleted:i,mode:a,isFormMode:o,isUrlMode:s}}function oPe({request:e,onApprove:t,onReject:n}){let{formData:r,setFieldValue:i,getMissingRequiredFields:a,urlCompleted:o,setUrlCompleted:s,mode:c,isFormMode:l,isUrlMode:u}=aPe(e),[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(``),h=()=>{if(!d)if(l){let n=a();if(n.length>0){IM.error(`Missing required fields`,{description:`Please fill in: ${n.join(`, `)}`});return}f(!0),m(`accepted`),t(e.id,{action:`accept`,content:r})}else u&&(f(!0),m(`accepted`),t(e.id,{action:`accept`}))},g=()=>{d||(f(!0),m(`declined`),t(e.id,{action:`decline`}))},_=()=>{d||(f(!0),m(`cancelled`),n(e.id,`User cancelled elicitation request`))},v=u&&`url`in e.request?e.request.url:null;return d?(0,S.jsxs)(`div`,{className:`rounded-lg border border-dashed bg-muted/30 p-3 text-sm text-muted-foreground max-w-2xl`,children:[`Elicitation `,p,` — the tool will continue executing.`]}):(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card shadow-sm p-4 space-y-4 max-w-2xl`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,S.jsx)(`span`,{className:`font-medium text-sm text-card-foreground`,children:`Elicitation Request`}),(0,S.jsx)(kt,{variant:`outline`,className:u?`bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/30`:`bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/30`,children:c}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.serverName})]}),(0,S.jsx)(`p`,{className:`text-sm text-card-foreground`,children:e.request.message}),u&&`url`in e.request&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-muted rounded border`,children:[(0,S.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:v}),(0,S.jsxs)(U,{size:`sm`,variant:`outline`,onClick:()=>{window.open(v??``,`_blank`),s(!0)},children:[(0,S.jsx)(Ff,{className:`h-3 w-3 mr-1`}),`Open`]})]}),(0,S.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,S.jsx)(EY,{id:`inline-url-done-${e.id}`,checked:o,onCheckedChange:e=>s(!!e)}),(0,S.jsx)(AN,{htmlFor:`inline-url-done-${e.id}`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]}),l&&(0,S.jsx)(iPe,{request:e,formData:r,onFieldChange:i,idPrefix:`inline-field-${e.id}`,testIdPrefix:`inline-elicitation-field`,fieldContainerClassName:`space-y-1.5`,textareaRows:3,showOuterLabelForBoolean:!1,emptyFallback:(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema provided.`})}),(0,S.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,S.jsx)(U,{size:`sm`,onClick:h,disabled:u&&!o,"data-testid":`inline-elicitation-accept`,children:`Accept`}),(0,S.jsx)(U,{size:`sm`,variant:`outline`,onClick:g,"data-testid":`inline-elicitation-decline`,children:`Decline`}),(0,S.jsx)(U,{size:`sm`,variant:`outline`,onClick:_,"data-testid":`inline-elicitation-cancel`,children:`Cancel`})]})]})}var sPe=(0,w.memo)(({messages:e,isLoading:t,serverId:n,readResource:r,tools:i,sendMessage:a,serverBaseUrl:o,pendingElicitationRequests:s,onApproveElicitation:c,onRejectElicitation:l})=>{let u=(0,w.useRef)(null),d=e=>{let t=e=>e.replace(/-/g,`_`),n=t(e);return i?.find(e=>t(e.name)===n)?._meta},f=e=>{let t=TQ(d(e),void 0);return t!==null&&t!==`mcp-ui`},p=(0,w.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
795
795
|
`),n=e.filter(e=>e.type===`image`&&`data`in e&&`mimeType`in e).map(e=>({type:`image`,data:e.data,mimeType:e.mimeType}));a?.(t,n.length>0?n:void 0)},[a]);(0,w.useEffect)(()=>{e.length>0&&u.current&&u.current.scrollIntoView({behavior:t?`auto`:`smooth`,block:`start`})},[e.length,t]);let m=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 e=typeof t.content==`string`?t.content:Array.isArray(t.content)?t.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(t.content);return!(e&&e.trim().length>0)}return!1})(),h=n=>{if(!t)return!1;let r=e[e.length-1];return n.id===r.id&&r.role===`assistant`};return(0,S.jsxs)(`div`,{className:`space-y-6 max-w-3xl mx-auto px-2`,children:[e.map(e=>{let t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(e.content);return e.role===`user`?(0,S.jsx)(tPe,{content:t,timestamp:e.timestamp,attachments:e.attachments},e.id):e.role===`assistant`?(0,S.jsx)(`div`,{className:`space-y-4`,children:e.parts&&e.parts.length>0?e.parts.map((t,i)=>{let a=t.type===`text`?`${e.id}-text-${i}-${t.text?.slice(0,20)}`:`${e.id}-tool-${t.toolInvocation?.toolName}-${i}`;return t.type===`text`?(0,S.jsx)(mQ,{content:t.text||``,timestamp:i===e.parts.length-1?e.timestamp:void 0,_isStreaming:h(e)},a):t.type===`tool-invocation`&&t.toolInvocation?(0,S.jsxs)(`div`,{children:[(0,S.jsx)(bQ,{toolName:t.toolInvocation.toolName,args:t.toolInvocation.args,result:t.toolInvocation.result,state:t.toolInvocation.state===`error`?`error`:t.toolInvocation.state===`streaming`||t.toolInvocation.state===`pending`?`call`:`result`,partialArgs:t.toolInvocation.partialArgs}),(t.toolInvocation.result||t.toolInvocation.state===`streaming`||f(t.toolInvocation.toolName))&&(0,S.jsx)(`div`,{"data-tool-call-id":`${e.id}-${t.toolInvocation.toolName}-${i}`,children:(0,S.jsx)(ePe,{toolName:t.toolInvocation.toolName,toolArgs:t.toolInvocation.args,result:t.toolInvocation.result||null,serverId:n,readResource:r,serverBaseUrl:o,toolMeta:d(t.toolInvocation.toolName),onSendFollowUp:p,partialToolArgs:t.toolInvocation.partialArgs,cancelled:t.toolInvocation.state===`error`&&t.toolInvocation.result===`Cancelled by user`})})]},a):null}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(mQ,{content:t,timestamp:e.timestamp,_isStreaming:h(e)}),e.toolCalls&&e.toolCalls.length>0&&(0,S.jsx)(`div`,{className:`space-y-2`,children:e.toolCalls.map(t=>{let i=`${e.id}-${t.toolName}-${JSON.stringify(t.args).slice(0,50)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(bQ,{toolName:t.toolName,args:t.args,result:t.result,state:t.result?`result`:`call`}),(t.result||f(t.toolName))&&(0,S.jsx)(`div`,{"data-tool-call-id":i,children:(0,S.jsx)(ePe,{toolName:t.toolName,toolArgs:t.args,result:t.result||null,serverId:n,readResource:r,serverBaseUrl:o,toolMeta:d(t.toolName),onSendFollowUp:p})})]},i)})})]})},e.id):null}),s&&s.length>0&&c&&l&&(0,S.jsx)(`div`,{className:`space-y-3`,children:s.map(e=>(0,S.jsx)(oPe,{request:e,onApprove:c,onReject:l},e.id))}),m&&(0,S.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,S.jsx)(`div`,{className:`flex-1`,children:(0,S.jsx)(`div`,{className:`rounded-lg p-4 max-w-fit`,children:(0,S.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,S.jsx)(`span`,{className:`text-sm`,children:(0,S.jsx)(NY,{duration:2,spread:1,children:`Thinking...`})})})})})}),(0,S.jsx)(`div`,{ref:u})]})});function cPe(e){return JMe(e)}var lPe=e=>{let t=[];for(let n of e){if(n.error||n.result?.isError){let e={id:`prompt-error-${n.promptName}-${n.timestamp}`,role:`assistant`,content:n.error||`Prompt execution failed`,timestamp:n.timestamp};t.push(e);continue}let e=n.result;if(e&&`messages`in e&&Array.isArray(e.messages))for(let r of e.messages){let e=``,i=[];if(typeof r.content==`string`)e=r.content;else if(Array.isArray(r.content)){let t=[];for(let e of r.content)e.type===`text`&&e.text?t.push(e.text):e.type===`image`&&e.data?i.push({type:`image`,data:e.data,mimeType:e.mimeType||`image/png`}):e.type===`resource`&&t.push(`[Resource: ${e.resource?.uri||`embedded`}]`);e=t.join(`
|
|
796
796
|
`)}else r.content&&typeof r.content==`object`&&(r.content.type===`text`&&r.content.text?e=r.content.text:r.content.type===`image`&&r.content.data?i.push({type:`image`,data:r.content.data,mimeType:r.content.mimeType||`image/png`}):e=JSON.stringify(r.content));!e&&i.length===0&&(e=`[no content]`);let a={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:e||``,timestamp:n.timestamp,attachments:i.length>0?i:void 0};t.push(a)}}return t};function uPe({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r,chatApiUrl:i,waitForChatApiUrl:a,widgetModelContexts:o,initialMessages:s,disabledTools:c,streamProtocol:l=`sse`,credentials:u,extraHeaders:d,body:f}){let[p,m]=(0,w.useState)(s??[]),[h,g]=(0,w.useState)(!1),[_,v]=(0,w.useState)([]),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(null),C=(0,w.useRef)(null);return{messages:p,isLoading:h,attachments:_,rateLimitInfo:y,mcpServerAuthRequired:x,sendMessage:(0,w.useCallback)(async(s,h,y)=>{let x=[..._,...y??[]];if(!(s.trim()||h.length>0||x.length>0)||!t||!r)return;let w=[...lPe(h)];if(s.trim()||x.length>0){let e={id:`user-${Date.now()}`,role:`user`,content:s.trim(),timestamp:Date.now(),attachments:x.length>0?x:void 0};w.push(e)}m(e=>[...e,...w]),g(!0),v([]),C.current=new AbortController;try{let r=n;if(n?.type===`oauth`)try{let t=`mcp:auth_${DY(e)}_tokens`,i=localStorage.getItem(t);if(i){let e=JSON.parse(i);r={...n,oauthTokens:e}}else console.warn(`No OAuth tokens found in localStorage for key:`,t)}catch(e){console.warn(`Failed to retrieve OAuth tokens:`,e)}let s=[];if(o&&o.size>0){let e=[];for(let[,t]of o)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
|
|
797
797
|
`)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&s.push({role:`user`,content:`[Current Widget State]\n${e.join(`
|