@mcp-use/inspector 20.0.0-beta.6 → 20.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/cdn/{AnimatePresence-Dcw-FOy8.js → AnimatePresence-D1bZ5_-l.js} +79 -78
  2. package/dist/cdn/{ChatTab-D6J3Gyp7.js → ChatTab-C-Ysv6Zf.js} +1951 -1932
  3. package/dist/cdn/CheckboxIndicator-BjF73mGX.js +252 -0
  4. package/dist/cdn/{ConnectionSettingsForm-CWQueI8J.js → ConnectionSettingsForm-CNuMa6jp.js} +202 -202
  5. package/dist/cdn/{ConnectionSettingsTab-FGyt3QaI.js → ConnectionSettingsTab-qSVQ1aIF.js} +36 -35
  6. package/dist/cdn/{ElicitationTab-CL1KJ0bz.js → ElicitationTab-PEmEDvC5.js} +47 -46
  7. package/dist/cdn/{FormContext-tmgN_Vdr.js → FormContext-NtUiZclE.js} +26 -26
  8. package/dist/cdn/{InspectorContext-UjtEbNod.js → InspectorContext-BBKCdfmK.js} +1 -1
  9. package/dist/cdn/{JSONDisplay-BFxf5oEu.js → JSONDisplay-BJqMz7Ny.js} +22 -22
  10. package/dist/cdn/{ListTabHeader-Cv-GmtGF.js → ListTabHeader-DzmTtN1e.js} +20 -19
  11. package/dist/cdn/{WidgetWrapper-CruwjBOd.js → MCPAppsDebugControls-BpP-Ifap.js} +514 -550
  12. package/dist/cdn/{ManufactOAuthCallback-B98kSYCj.js → ManufactOAuthCallback-ChbbjFIT.js} +2 -2
  13. package/dist/cdn/{MarkdownRenderer-gLqUICEd.js → MarkdownRenderer-CK_6n3T9.js} +23 -23
  14. package/dist/cdn/McpAppsViewPanel-jlsYQ7uS.js +56 -0
  15. package/dist/cdn/{NotificationsTab-CeImSrhx.js → NotificationsTab-B7uebqMV.js} +21 -21
  16. package/dist/cdn/{OAuthCallback-Bg2bP-o9.js → OAuthCallback--NZdLoWx.js} +3 -3
  17. package/dist/cdn/PromptsTab-DSGYL32k.js +902 -0
  18. package/dist/cdn/{ResourcesTab-CQkKni-P.js → ResourcesTab-d3wxN7xC.js} +116 -114
  19. package/dist/cdn/{SamplingTab-D8q-iCMc.js → SamplingTab-DETdWNJk.js} +34 -33
  20. package/dist/cdn/{ServerMetadataTab-CvrKX8fz.js → ServerMetadataTab-BM3VhSLf.js} +9 -9
  21. package/dist/cdn/{StatusIcon-D0-ARyOh.js → StatusIcon-Q3n3YRtE.js} +10 -11
  22. package/dist/cdn/{ToolsTab-6xaVH43x.js → ToolsTab-BMcnfEWg.js} +665 -653
  23. package/dist/cdn/{ViewPreview-Ohh6JwOn.js → ViewPreview-CBhrVdwx.js} +3 -3
  24. package/dist/cdn/{WidgetDebugContext-D4usL_MA.js → WidgetDebugContext-B6yoOVVV.js} +1 -11
  25. package/dist/cdn/WidgetWrapper-BlbQAh_X.js +12 -0
  26. package/dist/cdn/{bell-CGjAO_0s.js → bell-GrTZcnD2.js} +1 -1
  27. package/dist/cdn/{browser-CbQIH4w2.js → browser-DG2Z8392.js} +1 -1
  28. package/dist/cdn/{brush-B_mKhyxG.js → brush-CelVvMGp.js} +1 -1
  29. package/dist/cdn/button-CB4uOoUV.js +2509 -0
  30. package/dist/cdn/card-BA-DQk-G.js +41 -0
  31. package/dist/cdn/{checkbox-By0FklhG.js → checkbox-kwVa4gRX.js} +7 -7
  32. package/dist/cdn/{clock-CmUbSx_B.js → clock-YMF8Gtw5.js} +1 -1
  33. package/dist/cdn/{code-V_0nf5rg.js → code-C8sN2OGR.js} +1 -1
  34. package/dist/cdn/{jsx-runtime-CIxvMpEo.js → createLucideIcon-BONxC1L5.js} +57 -24
  35. package/dist/cdn/{dialog-BsDpuJd3.js → dialog-CJGnC5Ag.js} +171 -171
  36. package/dist/cdn/{dist-DaMB0Su9.js → dist-CTJnCYmk.js} +1 -1
  37. package/dist/cdn/{dist-CXHFvGre.js → dist-SxRsB1iS.js} +3 -3
  38. package/dist/cdn/{external-link-CjmfT6rW.js → external-link-Bo4lQxr1.js} +1 -1
  39. package/dist/cdn/{eye-B7H96av8.js → eye-pSGG7nvf.js} +1 -1
  40. package/dist/cdn/{folder-open-B3lu2rG_.js → folder-open-aM8CPtBO.js} +1 -1
  41. package/dist/cdn/{hash-BVQnWi7q.js → hash-DDs2vE1k.js} +1 -1
  42. package/dist/cdn/{history-Csw4rb44.js → history-BfUFpL1d.js} +1 -1
  43. package/dist/cdn/{index-browser-DkQOzkvX.js → index-browser-Dm3R1Mfe.js} +1 -1
  44. package/dist/cdn/{info-CNiOwqkf.js → info-BMkB68mB.js} +1 -1
  45. package/dist/cdn/{input-C2OBd4PJ.js → input-BCpgLXU1.js} +2993 -5499
  46. package/dist/cdn/inspector.css +1 -1
  47. package/dist/cdn/inspector.js +7106 -7140
  48. package/dist/cdn/{label-B9Jmm9be.js → label-A0UGV8FE.js} +9 -9
  49. package/dist/cdn/{loader-circle-BLy9A_pp.js → loader-circle-BKRHJEB7.js} +1 -1
  50. package/dist/cdn/{maximize-2-CH5Lq90B.js → maximize-2-DdrB_spi.js} +1 -1
  51. package/dist/cdn/{maximize-BALCV_ep.js → maximize-hSOCz133.js} +1 -1
  52. package/dist/cdn/{message-square-BnxdpJxZ.js → message-square-D3tKB3uJ.js} +1 -1
  53. package/dist/cdn/{not-found-DEtSM_Wd.js → not-found-BajFyZpp.js} +9 -11
  54. package/dist/cdn/{play-vuZ5PLnI.js → play-B1leulYf.js} +1 -1
  55. package/dist/cdn/providerMeta-CjGU4rID.js +436 -0
  56. package/dist/cdn/{react-BLtCruam.js → react-Bl-hSkvn.js} +562 -512
  57. package/dist/cdn/{refresh-cw-BXY-Pa0U.js → refresh-cw-CyvXrS91.js} +1 -1
  58. package/dist/cdn/{save-Tgil_AJZ.js → save-CmdEPUAm.js} +1 -1
  59. package/dist/cdn/{select-DDdiIPR2.js → select-CCFHjOGk.js} +808 -807
  60. package/dist/cdn/{servers-Dm72iTpY.js → servers-Dd0Vcp81.js} +5 -1
  61. package/dist/cdn/{shared-DaILIQPP.js → shared-CJVHJhag.js} +36 -36
  62. package/dist/cdn/{sheet-Br_l2kry.js → sheet-oyq1mIyg.js} +620 -619
  63. package/dist/cdn/{sparkles-BntO2rDR.js → sparkles-CxeZpVtX.js} +1 -1
  64. package/dist/cdn/spinner-Be1GlSGX.js +15 -0
  65. package/dist/cdn/{square-check-big-BvwQ17Bl.js → square-check-big-C_4wbfwF.js} +1 -1
  66. package/dist/cdn/{switch-C3IyQuid.js → switch-DHXEA_N5.js} +190 -189
  67. package/dist/cdn/{tabs-subtle-CkdI6Mac.js → tabs-subtle-Dubd6Kj8.js} +269 -268
  68. package/dist/cdn/{telemetry-C7Ytz2BG.js → telemetry-DjQn_Xm9.js} +2 -2
  69. package/dist/cdn/{textarea-DSbwcFVt.js → textarea-CwmI8_uI.js} +6 -6
  70. package/dist/cdn/{trash-2-RwpJY5SL.js → trash-2-BhumJAFE.js} +1 -1
  71. package/dist/cdn/{useAriaLabelledBy-DqAdnppm.js → useAriaLabelledBy-Cra6w3YY.js} +2 -1
  72. package/dist/cdn/{useCompositeItem-BRqEzYh-.js → useCompositeItem-Dhnm-7el.js} +3 -3
  73. package/dist/cdn/{useConfig-BW6uQf2m.js → useConfig-B_adtnP1.js} +2 -2
  74. package/dist/cdn/{useSavedRequests-Ci2I919u.js → useSavedRequests-mSIsDd4c.js} +1 -1
  75. package/dist/cdn/{useViewHostProps-CINeSkth.js → useViewHostProps-CDOm2w6u.js} +124 -109
  76. package/dist/cdn/{wrench-DzGmCfnb.js → wrench-DvK20LUT.js} +1 -1
  77. package/dist/cdn/{x-C3vRQIYu.js → x-EilKPiCX.js} +1 -1
  78. package/dist/cdn/{zap-Mb-pbw2X.js → zap-0Wr9QO7N.js} +1 -1
  79. package/dist/cli.js +61 -2
  80. package/dist/client/components/ChatTab.d.ts.map +1 -1
  81. package/dist/client/components/MCPAppsDebugControls.d.ts.map +1 -1
  82. package/dist/client/components/ToolsTab.d.ts.map +1 -1
  83. package/dist/client/components/chat/ConfigurationDialog.d.ts.map +1 -1
  84. package/dist/client/components/chat/ToolResultRenderer.d.ts.map +1 -1
  85. package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts +29 -0
  86. package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts.map +1 -0
  87. package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +1 -1
  88. package/dist/client/components/tools/ToolResultDisplay.d.ts +2 -1
  89. package/dist/client/components/tools/ToolResultDisplay.d.ts.map +1 -1
  90. package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +1 -1
  91. package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +1 -1
  92. package/dist/client/components/ui/mesh-animation-pause.d.ts +14 -0
  93. package/dist/client/components/ui/mesh-animation-pause.d.ts.map +1 -0
  94. package/dist/client/components/ui/mesh-gradient-colors.d.ts +6 -0
  95. package/dist/client/components/ui/mesh-gradient-colors.d.ts.map +1 -0
  96. package/dist/client/components/ui/mesh-tab-background.d.ts +1 -1
  97. package/dist/client/components/ui/mesh-tab-background.d.ts.map +1 -1
  98. package/dist/client/components/ui/not-found.d.ts.map +1 -1
  99. package/dist/client/context/WidgetDebugContext.d.ts +1 -11
  100. package/dist/client/context/WidgetDebugContext.d.ts.map +1 -1
  101. package/dist/client/hooks/useDeviceViewport.d.ts +1 -5
  102. package/dist/client/hooks/useDeviceViewport.d.ts.map +1 -1
  103. package/dist/client/hooks/useViewHostProps.d.ts +1 -1
  104. package/dist/client/hooks/useViewHostProps.d.ts.map +1 -1
  105. package/dist/client/index.js +2087 -1861
  106. package/dist/client/utils/servers.d.ts +5 -0
  107. package/dist/client/utils/servers.d.ts.map +1 -1
  108. package/dist/server/cdn-shell.d.ts.map +1 -1
  109. package/dist/server/cdn-shell.js +2 -2
  110. package/dist/server/{chunk-GBY4WAVP.js → chunk-BD3ROXCC.js} +1 -1
  111. package/dist/server/{chunk-NUHI6MJ6.js → chunk-BPXKTFQ5.js} +1 -1
  112. package/dist/server/{chunk-IFF5T5J4.js → chunk-XTVIGRTB.js} +61 -2
  113. package/dist/server/cli.js +2 -2
  114. package/dist/server/index.js +3 -3
  115. package/dist/server/middleware.js +3 -3
  116. package/dist/server/version.js +1 -1
  117. package/dist/web/assets/AnimatePresence-FfDQQNFJ.js +9 -0
  118. package/dist/web/assets/ChatTab-DxD-KLW_.js +18 -0
  119. package/dist/web/assets/ConnectionSettingsTab-pO6p0U0f.js +1 -0
  120. package/dist/web/assets/ElicitationTab-o5_z6gqe.js +1 -0
  121. package/dist/web/assets/FormContext-sV-yByKz.js +1 -0
  122. package/dist/web/assets/ListTabHeader-CrGae306.js +1 -0
  123. package/dist/web/assets/MCPAppsDebugControls-CZW1uZdH.js +34 -0
  124. package/dist/web/assets/{ManufactOAuthCallback-BRO6TPkZ.js → ManufactOAuthCallback-BnWhf5bW.js} +1 -1
  125. package/dist/web/assets/{MarkdownRenderer-gaJFjbtr.js → MarkdownRenderer-gUUHRIm1.js} +2 -2
  126. package/dist/web/assets/McpAppsViewPanel-CDJDb4t-.js +1 -0
  127. package/dist/web/assets/{NotificationsTab-LYcfRjyd.js → NotificationsTab-CkJ5E_sR.js} +1 -1
  128. package/dist/web/assets/{OAuthCallback-D8UItgTB.js → OAuthCallback-Dv_mFcua.js} +1 -1
  129. package/dist/web/assets/PromptsTab-CLwWFf6d.js +15 -0
  130. package/dist/web/assets/ResourcesTab-B8cnuq-m.js +2 -0
  131. package/dist/web/assets/SamplingTab-BjYHYRHX.js +1 -0
  132. package/dist/web/assets/ServerMetadataTab-CPlclbb7.js +1 -0
  133. package/dist/web/assets/ToolsTab-BSSwvp4Q.js +8 -0
  134. package/dist/web/assets/{ViewPreview--z6jL0Zg.js → ViewPreview-C_LJdgt9.js} +1 -1
  135. package/dist/web/assets/WidgetWrapper-cv_BM1bY.js +1 -0
  136. package/dist/web/assets/{brush--0LobUi4.js → brush-DX0UZ_pI.js} +1 -1
  137. package/dist/web/assets/button-C8Xa2k4x.js +1 -0
  138. package/dist/web/assets/checkbox-BuuDhnpk.js +1 -0
  139. package/dist/web/assets/code-B14rVdNt.js +1 -0
  140. package/dist/web/assets/createLucideIcon-BEHeJH0M.js +1 -0
  141. package/dist/web/assets/{dist-B8sA8Zml.js → dist-C39gcmyH.js} +4 -4
  142. package/dist/web/assets/index-CyvvaDNR.js +499 -0
  143. package/dist/web/assets/index-bCIH1Sdx.css +1 -0
  144. package/dist/web/assets/input-C0OQCUZy.js +1 -0
  145. package/dist/web/assets/{label-Cdim77Jw.js → label-CI7JWQOo.js} +1 -1
  146. package/dist/web/assets/{maximize-2-BTT9QQU9.js → maximize-2-Br1WQzT2.js} +1 -1
  147. package/dist/web/assets/{maximize-_O55kFcr.js → maximize-CJNgRe6S.js} +1 -1
  148. package/dist/web/assets/{refresh-cw-C9wQl8_d.js → refresh-cw-B5iaAZKn.js} +1 -1
  149. package/dist/web/assets/{save-B-MsgxX9.js → save-TM6fvNrt.js} +1 -1
  150. package/dist/web/assets/select-D6jzbLJn.js +1 -0
  151. package/dist/web/assets/shared-Chk1rURG.js +1 -0
  152. package/dist/web/assets/{sparkles-2OAsc1aP.js → sparkles-BGYTDThM.js} +1 -1
  153. package/dist/web/assets/tabs-subtle-CK4nucyB.js +1 -0
  154. package/dist/web/assets/textarea-CRTXuRmE.js +1 -0
  155. package/dist/web/assets/{useConfig-BAsKhUxf.js → useConfig-CgQbKjVT.js} +1 -1
  156. package/dist/web/assets/useViewHostProps-DFI7Ywo7.js +1 -0
  157. package/dist/web/assets/{zap-Du2Uc5pa.js → zap-BDWHCVHU.js} +1 -1
  158. package/dist/web/index.html +10 -10
  159. package/package.json +2 -2
  160. package/dist/cdn/CheckboxIndicator-Bt4IICtv.js +0 -251
  161. package/dist/cdn/PromptsTab-C4LuwyWN.js +0 -901
  162. package/dist/cdn/card-DgiYnSg-.js +0 -41
  163. package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
  164. package/dist/cdn/providerMeta-BQIfHuNL.js +0 -379
  165. package/dist/cdn/spinner-jQtC7EBj.js +0 -15
  166. package/dist/web/assets/AnimatePresence-C5p0yiY1.js +0 -9
  167. package/dist/web/assets/ChatTab-CsBPVCSc.js +0 -18
  168. package/dist/web/assets/ConnectionSettingsTab-DQTXfnl1.js +0 -1
  169. package/dist/web/assets/ElicitationTab-_FKB7nNG.js +0 -1
  170. package/dist/web/assets/FormContext-DH2caWKO.js +0 -1
  171. package/dist/web/assets/ListTabHeader-R17w_JsB.js +0 -1
  172. package/dist/web/assets/PromptsTab-B2uVMRR2.js +0 -15
  173. package/dist/web/assets/ResourcesTab-DhOZYPjE.js +0 -2
  174. package/dist/web/assets/SamplingTab-C-oY2hoi.js +0 -1
  175. package/dist/web/assets/ServerMetadataTab-BkTxO5KS.js +0 -1
  176. package/dist/web/assets/ToolsTab-DupHgo7A.js +0 -8
  177. package/dist/web/assets/WidgetWrapper-CZaEVEw4.js +0 -34
  178. package/dist/web/assets/checkbox-BQ9mI_6k.js +0 -1
  179. package/dist/web/assets/code-tME-5H6D.js +0 -1
  180. package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
  181. package/dist/web/assets/index-C_fCIJ4C.js +0 -492
  182. package/dist/web/assets/index-fBX3akc8.css +0 -1
  183. package/dist/web/assets/input-CLYhA7PK.js +0 -1
  184. package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
  185. package/dist/web/assets/select-CJ57-Bor.js +0 -1
  186. package/dist/web/assets/shared-CCC9rTz4.js +0 -1
  187. package/dist/web/assets/tabs-subtle-246ABJqx.js +0 -1
  188. package/dist/web/assets/textarea-DLAmNVf_.js +0 -1
  189. package/dist/web/assets/useViewHostProps-CV5zBxUb.js +0 -1
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{a as n,n as r,r as i,sr as a,t as o}from"./input-CLYhA7PK.js";import{t as s}from"./jsx-runtime-Cjj9sGSy.js";import{t as c}from"./label-Cdim77Jw.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-CJ57-Bor.js";import{a as m,i as h,n as ee,o as g,r as _,t as te}from"./shared-CCC9rTz4.js";import{t as v}from"./maximize-2-BTT9QQU9.js";import{t as y}from"./sparkles-2OAsc1aP.js";import{At as b,Bt as x,Jt as S,Kt as C,P as w,b as T,bt as E,hn as ne,in as D,jt as O,ln as k,mn as A,ot as j,vn as M,yt as N}from"./index-C_fCIJ4C.js";import{a as P}from"./dist-B8sA8Zml.js";import{t as F}from"./useConfig-BAsKhUxf.js";import{t as I}from"./textarea-DLAmNVf_.js";var L=e(t(),1),R=s();function z({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i}){return e.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:(0,R.jsx)(x,{vertical:!0,noBorder:!0,message:`No sampling requests`})}):(0,R.jsx)(`div`,{children:e.map((e,a)=>{let o=e.request.params?.messages?.length||0,s=e.request.params?.maxTokens;return(0,R.jsx)(_,{id:`sampling-request-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,R.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,R.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=[];return o>0&&n.push(`${o} message${o>1?`s`:``}`),s&&n.push(`max ${s} tokens`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function B({llmConfig:e}){return{generateResponse:(0,L.useCallback)(async({request:t})=>{if(!e)throw Error(`LLM config is not available`);let n=t.params||{},r=n.maxTokens,i=n.temperature,a=n.messages||[];if(a.length===0)throw Error(`No messages found in sampling request`);let o=[];for(let e of a){if(!e||!e.role)continue;let t=Array.isArray(e.content)?e.content[0]:e.content;t&&t.type===`text`&&t.text&&(e.role===`user`||e.role===`assistant`)&&o.push({role:e.role,content:t.text})}if(o.length===0)throw Error(`No valid messages could be converted. Please ensure messages have 'text' content type.`);return{role:`assistant`,content:{type:`text`,text:await P({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:i??e.temperature,maxTokens:r,baseUrl:e.baseUrl},messages:o})},model:e.model,stopReason:`endTurn`}},[e]),isAvailable:e!==null}}function V({request:t,onApprove:s,onReject:m,onClose:h,previewMode:ee,onTogglePreview:g,isCopied:_,onCopy:te,onDownload:x,onFullscreen:S,llmConfig:w}){let[E,k]=(0,L.useState)(`manual`),[N,P]=(0,L.useState)(`stub-model`),[F,z]=(0,L.useState)(`endTurn`),[V,H]=(0,L.useState)(`assistant`),[U,W]=(0,L.useState)(`text`),[G,K]=(0,L.useState)(`positive`),[q,J]=(0,L.useState)(``),[Y,X]=(0,L.useState)(`image/png`),[Z,re]=(0,L.useState)(!1),[ie,Q]=(0,L.useState)(null),{generateResponse:ae,isAvailable:$}=B({llmConfig:w});(0,L.useEffect)(()=>{t&&(P(E===`llm`&&w?.model?w.model:`stub-model`),z(`endTurn`),H(`assistant`),W(`text`),K(`positive`),J(``),X(`image/png`),Q(null))},[t?.id]),(0,L.useEffect)(()=>{E===`llm`&&w?.model&&P(w.model)},[E,w?.model]);let oe=async()=>{if(!t||!$){console.log(`[SamplingRequestDisplay] Cannot generate:`,{hasRequest:!!t,isAvailable:$});return}console.log(`[SamplingRequestDisplay] Starting LLM generation:`,{requestId:t.id,llmConfig:w}),re(!0),Q(null);try{let e=await ae({request:t.request});console.log(`[SamplingRequestDisplay] LLM generation result:`,{result:e,model:e.model,stopReason:e.stopReason,role:e.role,contentIsArray:Array.isArray(e.content),content:e.content}),P(e.model||w?.model||`stub-model`),z(e.stopReason||`endTurn`),H(e.role||`assistant`);let n=Array.isArray(e.content)?e.content[0]:e.content;console.log(`[SamplingRequestDisplay] Setting content:`,{contentType:n.type,hasText:`text`in n,text:`text`in n?n.text:void 0}),n.type===`text`?(W(`text`),K(n.text||``),console.log(`[SamplingRequestDisplay] Set text content:`,n.text)):n.type===`image`&&(W(`image`),J(n.data||``),X(n.mimeType||`image/png`),console.log(`[SamplingRequestDisplay] Set image content`)),console.log(`[SamplingRequestDisplay] Form state after update:`,{model:N,stopReason:F,role:V,contentType:U,textContent:G})}catch(e){console.error(`[SamplingRequestDisplay] LLM generation error:`,e);let t=e instanceof Error?e.message:`Failed to generate response`;Q(t),j.error(`LLM Generation Failed`,{description:t})}finally{re(!1),console.log(`[SamplingRequestDisplay] Generation complete`)}},se=(0,L.useMemo)(()=>{let e={model:N,stopReason:F,role:V,content:{type:U}};return U===`text`?e.content.text=G:U===`image`&&(e.content.data=q,e.content.mimeType=Y),e},[N,F,V,U,G,q,Y]);return t?(0,R.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:t.serverName}),(0,R.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(t.timestamp).toLocaleString()})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(r,{children:[(0,R.jsx)(n,{render:(0,R.jsx)(a,{variant:`ghost`,size:`sm`,onClick:te,className:`h-8 w-8 p-0`,children:_?(0,R.jsx)(M,{className:`h-4 w-4 text-green-600`}):(0,R.jsx)(ne,{className:`h-4 w-4`})}),nativeButton:!0}),(0,R.jsx)(i,{children:`Copy request`})]}),(0,R.jsxs)(r,{children:[(0,R.jsx)(n,{render:(0,R.jsx)(a,{variant:`ghost`,size:`sm`,onClick:x,className:`h-8 w-8 p-0`,children:(0,R.jsx)(A,{className:`h-4 w-4`})}),nativeButton:!0}),(0,R.jsx)(i,{children:`Download request`})]}),(0,R.jsxs)(r,{children:[(0,R.jsx)(n,{render:(0,R.jsx)(a,{variant:`ghost`,size:`sm`,onClick:S,className:`h-8 w-8 p-0`,children:(0,R.jsx)(v,{className:`h-4 w-4`})}),nativeButton:!0}),(0,R.jsx)(i,{children:`Fullscreen`})]}),(0,R.jsx)(a,{variant:`ghost`,size:`sm`,onClick:h,className:`h-8 w-8 p-0`,children:(0,R.jsx)(C,{className:`h-4 w-4`})})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Request`}),(0,R.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,R.jsx)(T,{data:t.request})})]}),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Response`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(c,{htmlFor:`responseMode-${t.id}`,className:`text-xs text-gray-500 dark:text-gray-400`,children:`Mode:`}),(0,R.jsxs)(p,{value:E,onValueChange:e=>k(e),children:[(0,R.jsx)(u,{id:`responseMode-${t.id}`,className:`w-32 h-8 text-xs`,"data-testid":`sampling-response-mode-select`,children:(0,R.jsx)(l,{})}),(0,R.jsxs)(d,{children:[(0,R.jsx)(f,{value:`manual`,"data-testid":`sampling-response-mode-manual`,children:`Manual`}),(0,R.jsx)(f,{value:`llm`,"data-testid":`sampling-response-mode-llm`,children:`LLM`})]})]})]})]}),E===`llm`&&(0,R.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[$?(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(a,{onClick:oe,disabled:Z,size:`sm`,className:`flex items-center gap-2`,"data-testid":`sampling-generate-llm-button`,children:Z?(0,R.jsxs)(`span`,{"data-testid":`sampling-generating`,className:`flex items-center gap-2`,children:[(0,R.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Generating...`]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(y,{className:`h-4 w-4`}),`Generate with LLM`]})}),(0,R.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`Using `,w?.provider,` (`,w?.model,`)`]})]}):(0,R.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`LLM not configured. Please configure LLM in the Chat tab.`}),ie&&(0,R.jsx)(`div`,{className:`text-xs text-red-600 dark:text-red-400`,"data-testid":`sampling-generation-error`,children:ie})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`model-${t.id}`,children:`Model`}),(0,R.jsx)(o,{id:`model-${t.id}`,value:N,onChange:e=>P(e.target.value),placeholder:`stub-model`,disabled:E===`llm`&&Z,"data-testid":`sampling-model-input`})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`stopReason-${t.id}`,children:`Stop Reason`}),(0,R.jsx)(o,{id:`stopReason-${t.id}`,value:F,onChange:e=>z(e.target.value),placeholder:`endTurn`,disabled:E===`llm`&&Z,"data-testid":`sampling-stop-reason-input`})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`role-${t.id}`,children:`Role`}),(0,R.jsxs)(p,{value:V,onValueChange:e=>H(e),disabled:E===`llm`&&Z,children:[(0,R.jsx)(u,{id:`role-${t.id}`,"data-testid":`sampling-role-select`,children:(0,R.jsx)(l,{})}),(0,R.jsxs)(d,{children:[(0,R.jsx)(f,{value:`assistant`,children:`assistant`}),(0,R.jsx)(f,{value:`user`,children:`user`})]})]})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`contentType-${t.id}`,children:`Content Type`}),(0,R.jsxs)(p,{value:U,onValueChange:e=>W(e),disabled:E===`llm`&&Z,children:[(0,R.jsx)(u,{id:`contentType-${t.id}`,"data-testid":`sampling-content-type-select`,children:(0,R.jsx)(l,{})}),(0,R.jsxs)(d,{children:[(0,R.jsx)(f,{value:`text`,children:`text`}),(0,R.jsx)(f,{value:`image`,children:`image`})]})]})]}),U===`text`&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`text-${t.id}`,children:`Text Content`}),(0,R.jsx)(I,{id:`text-${t.id}`,value:G,onChange:e=>K(e.target.value),placeholder:`Enter response text...`,rows:6,disabled:E===`llm`&&Z,"data-testid":`sampling-text-content`})]}),U===`image`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`imageData-${t.id}`,children:`Base64 Image Data`}),(0,R.jsx)(I,{id:`imageData-${t.id}`,value:q,onChange:e=>J(e.target.value),placeholder:`Base64 encoded image data...`,rows:4,disabled:E===`llm`&&Z})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(c,{htmlFor:`mimeType-${t.id}`,children:`MIME Type`}),(0,R.jsx)(o,{id:`mimeType-${t.id}`,value:Y,onChange:e=>X(e.target.value),placeholder:`image/png`,disabled:E===`llm`&&Z})]})]})]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,R.jsx)(a,{onClick:()=>{if(!t)return;let n=O.CreateMessageResult[`~standard`].validate(se);if(n.issues){j.error(`Invalid response`,{description:`Validation failed: ${n.issues.map(e=>e.message).join(`, `)}`});return}s(t.id,n.value),h(),b(()=>import(`./react-CU_d2d5K.js`).then(t=>e(t.t(),1)).then(e=>{let n=j(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Sampling Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`sampling-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:t.toolName}});window.dispatchEvent(e),j.dismiss(n)}},`View Tool Result`))),{duration:5e3})}),[])},className:`flex-1`,disabled:E===`llm`&&Z,"data-testid":`sampling-approve-button`,children:`Approve`}),(0,R.jsx)(a,{onClick:()=>{t&&(m(t.id,`User rejected sampling request`),h())},variant:`outline`,className:`flex-1`,disabled:E===`llm`&&Z,"data-testid":`sampling-reject-button`,children:`Reject`})]})]}):(0,R.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,R.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a sampling request to view details`})})}function H({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:i,mcpServerUrl:a}){let{selectedSamplingRequestId:o,setSelectedSamplingRequestId:s}=w(),{llmConfig:c}=F({mcpServerUrl:a}),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(``),[p,_]=(0,L.useState)(-1),[v,y]=(0,L.useState)(!0),[b,x]=(0,L.useState)(!1),[C,T]=(0,L.useState)(!0),[ne,D]=(0,L.useState)(!1),O=(0,L.useRef)(null),A=(0,L.useRef)(null),j=(0,L.useRef)(null),M=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(console.log(`[SamplingTab] Auto-selection check:`,{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){let t=e.find(e=>e.id===o);console.log(`[SamplingTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[SamplingTab] Auto-selecting request:`,t.id),s(null),u(t),setTimeout(()=>{let e=document.getElementById(`sampling-request-${t.id}`);console.log(`[SamplingTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[o,e,s]),(0,L.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[SamplingTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[SamplingTab] Selecting request from event:`,n),u(r),setTimeout(()=>{let e=document.getElementById(`sampling-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-sampling`,t),()=>window.removeEventListener(`navigate-to-sampling`,t)},[e]),(0,L.useEffect)(()=>{v&&e.length>0&&O.current&&!M.current&&(O.current.scrollTop=0)},[e.length,v]),(0,L.useEffect)(()=>{let e=O.current;if(!e)return;let t=()=>{e.scrollTop>0&&(M.current=!0,y(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,L.useEffect)(()=>{e.length===0&&(M.current=!1,y(!0))},[e.length]),(0,L.useEffect)(()=>{b&&j.current&&j.current.focus()},[b]);let P=(0,L.useCallback)(()=>{d.trim()||x(!1)},[d]),I=(0,L.useMemo)(()=>{if(!d.trim())return e;let t=d.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,d]);(0,L.useEffect)(()=>{_(-1)},[d]),(0,L.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=I;if(e.key===`ArrowDown`)e.preventDefault(),_(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),_(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&p>=0){e.preventDefault();let t=I[p];t&&B(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p,I]),(0,L.useEffect)(()=>{if(p>=0){let e=`sampling-request-${I[p]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[p,I]);let B=(0,L.useCallback)(e=>{u(e)},[]),H=(0,L.useCallback)(()=>{window.confirm(`Are you sure you want to reject all sampling requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User rejected all requests`)}),u(null))},[e,n]),U=(0,L.useCallback)(async()=>{if(l)try{await N(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),D(!0),setTimeout(()=>D(!1),2e3)}catch(e){console.error(`[SamplingTab] Failed to copy request:`,e)}},[l]),W=(0,L.useCallback)(()=>{if(l)try{let e=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[SamplingTab] Failed to download request:`,e)}},[l]),G=(0,L.useCallback)(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(e){console.error(`[SamplingTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,R.jsxs)(g,{orientation:`horizontal`,className:`h-full`,children:[(0,R.jsx)(m,{defaultSize:40,minSize:30,children:(0,R.jsx)(g,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,R.jsx)(m,{defaultSize:75,minSize:30,className:`h-full overflow-hidden`,children:(0,R.jsx)(ee,{scrollRef:O,children:t=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(te,{isScrolled:t,title:`Sampling`,icon:k,count:I.length,isSearchExpanded:b,searchQuery:d,searchPlaceholder:`Search requests...`,onSearchExpand:()=>x(!0),onSearchChange:f,onSearchBlur:P,bulkAction:{icon:S,label:`Reject all`,onClick:H,disabled:e.length===0},searchInputRef:j}),(0,R.jsx)(z,{requests:I,selectedRequest:l,onRequestSelect:B,focusedIndex:p,formatRelativeTime:E})]})})})})}),(0,R.jsx)(h,{}),(0,R.jsx)(m,{defaultSize:60,minSize:40,children:(0,R.jsx)(`div`,{ref:A,className:`h-full bg-white dark:bg-zinc-900`,children:(0,R.jsx)(V,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:C,onTogglePreview:()=>T(!C),isCopied:ne,onCopy:U,onDownload:W,onFullscreen:G,llmConfig:c})})})]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,R.jsx)(k,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,R.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}export{H as SamplingTab};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{d as n,l as r,u as i}from"./input-CLYhA7PK.js";import{t as a}from"./jsx-runtime-Cjj9sGSy.js";import{t as o}from"./label-Cdim77Jw.js";import{at as s,b as c,gt as l,ht as u,it as d,nt as f,on as p,rt as m,tt as h}from"./index-C_fCIJ4C.js";import{n as g,r as _,t as v}from"./tabs-subtle-246ABJqx.js";import{t as y}from"./inspector-settings-layout-yjKRJDai.js";import{n as b}from"./ListTabHeader-R17w_JsB.js";function x(e){let t={};if(e.protocolVersion&&(t.protocolVersion=e.protocolVersion),e.capabilities&&(t.capabilities=e.capabilities),e.serverInfo){let{icon:n,...r}=e.serverInfo;t.serverInfo=r}return e.instructions&&(t.instructions=e.instructions),t}var S=e(t(),1),C=a();function w({connection:e}){let t=e.capabilities;return t&&Object.keys(t).length>0?(0,C.jsx)(`div`,{className:`overflow-x-auto`,"data-testid":`server-info-capabilities-json`,children:(0,C.jsx)(c,{data:t,filename:`capabilities-${l(e)}.json`})}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`server-info-capabilities`,children:`No capabilities reported.`})}var T=`space-y-1.5 min-w-0`;function E({label:e,children:t,className:n,testId:r}){return(0,C.jsxs)(`div`,{className:n??T,children:[(0,C.jsx)(o,{className:`text-xs text-muted-foreground`,children:e}),(0,C.jsx)(`div`,{className:`min-h-4 text-xs font-mono`,"data-testid":r,children:t})]})}function D({connection:e,inDialog:t=!1}){let n=u(e),r=e.serverInfo?.name||e.serverInfo?.title||e.url||e.name;return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsxs)(h,{className:`border`,children:[(0,C.jsxs)(d,{children:[(0,C.jsx)(s,{className:`text-base font-medium`,children:t?`General`:`Server Information`}),(0,C.jsx)(m,{children:`Server identity from initialize`})]}),(0,C.jsx)(f,{className:`pt-0`,children:(0,C.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-8 gap-y-4`,children:[e.serverInfo?.title&&(0,C.jsx)(E,{label:`Title`,children:(0,C.jsx)(`span`,{className:`inline-block rounded-md bg-muted p-1 px-2`,children:e.serverInfo.title})}),n&&(0,C.jsx)(E,{label:`Alias`,children:(0,C.jsx)(`span`,{className:`inline-block rounded-md bg-muted p-1 px-2`,children:n})}),(0,C.jsx)(E,{label:`Name`,testId:`server-info-name`,children:(0,C.jsx)(`span`,{className:`inline-block rounded-md bg-muted p-1 px-2`,children:r})}),e.serverInfo?.version&&(0,C.jsx)(E,{label:`Version`,children:(0,C.jsx)(`span`,{className:`inline-block rounded-md bg-muted p-1 px-2`,children:e.serverInfo.version})}),e.protocolVersion&&(0,C.jsx)(E,{label:`Protocol`,children:(0,C.jsx)(`span`,{className:`inline-block rounded-md bg-muted p-1 px-2`,children:e.protocolVersion})}),e.serverInfo?.websiteUrl&&(0,C.jsx)(E,{label:`Website`,className:`${T} w-full`,children:(0,C.jsx)(`a`,{href:e.serverInfo.websiteUrl,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-sans text-blue-500 hover:underline`,children:e.serverInfo.websiteUrl})})]})})]}),e.instructions&&(0,C.jsxs)(h,{className:`border`,children:[(0,C.jsxs)(d,{children:[(0,C.jsx)(s,{className:`text-base font-medium`,children:`Instructions`}),(0,C.jsx)(m,{children:`Server guidance for clients and agents`})]}),(0,C.jsx)(f,{className:`pt-0`,children:(0,C.jsx)(`p`,{className:`whitespace-pre-wrap font-sans text-sm text-muted-foreground`,children:e.instructions})})]}),e.serverInfo?.icons&&e.serverInfo.icons.length>0&&(0,C.jsxs)(h,{className:`border`,children:[(0,C.jsxs)(d,{children:[(0,C.jsx)(s,{className:`text-base font-medium`,children:`Icons`}),(0,C.jsx)(m,{children:`Server icon assets from initialize`})]}),(0,C.jsx)(f,{className:`pt-0`,children:(0,C.jsx)(`div`,{className:`flex flex-col gap-2 font-sans`,children:e.serverInfo.icons.map((e,t)=>(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md bg-muted p-2`,"data-testid":`server-info-icon-${t}`,children:[(0,C.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-background`,children:(0,C.jsx)(`img`,{src:e.src,alt:`Server icon ${t+1}`,className:`h-full w-full object-contain`})}),(0,C.jsxs)(`div`,{className:`min-w-0 text-xs`,children:[(0,C.jsx)(`p`,{className:`truncate font-mono`,children:e.src}),(0,C.jsx)(`p`,{className:`text-muted-foreground`,children:e.sizes?.join(`, `)||`no size`})]})]},t))})})]}),(0,C.jsxs)(h,{className:`border`,"data-testid":`server-info-capabilities`,children:[(0,C.jsxs)(d,{children:[(0,C.jsx)(s,{className:`text-base font-medium`,children:`Capabilities`}),(0,C.jsx)(m,{children:`MCP capabilities reported during initialize`})]}),(0,C.jsx)(f,{className:`pt-0`,children:(0,C.jsx)(w,{connection:e})})]})]})}var O=`server-metadata`;function k({connection:e}){let[t,a]=(0,S.useState)(0),[o,s]=(0,S.useState)(!1),u=x(e);return(0,C.jsxs)(`div`,{"data-testid":`server-info-modal`,className:`h-full overflow-y-auto overscroll-none`,onScroll:e=>s(e.currentTarget.scrollTop>0),children:[(0,C.jsx)(`div`,{className:`${r(o)} flex flex-row items-center justify-between gap-2 ${i}`,children:(0,C.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-4`,children:[(0,C.jsxs)(`h2`,{className:`${n} flex items-center gap-1.5`,"data-testid":`server-info-modal-title`,children:[(0,C.jsx)(p,{className:b,"aria-hidden":!0}),`Server Metadata`]}),(0,C.jsxs)(v,{selectedIndex:t,onSelect:a,idPrefix:O,className:`shrink-0`,children:[(0,C.jsx)(g,{label:`Formatted`,index:0}),(0,C.jsx)(g,{label:`Raw`,index:1})]})]})}),(0,C.jsx)(_,{index:0,selectedIndex:t,idPrefix:O,className:y,children:(0,C.jsx)(D,{connection:e})}),(0,C.jsx)(_,{index:1,selectedIndex:t,idPrefix:O,className:`px-4 pt-6 pb-6`,children:(0,C.jsx)(`div`,{"data-testid":`server-info-raw`,children:Object.keys(u).length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No initialize metadata yet. Connect to the server first.`}):(0,C.jsx)(c,{data:u,filename:`initialize-result-${l(e)}-${Date.now()}.json`})})})]})}export{k as ServerMetadataTab};
@@ -1,8 +0,0 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{Lr as n,Nr as r,a as i,cr as a,f as o,n as s,r as c,sr as l,t as u,ur as d}from"./input-CLYhA7PK.js";import{t as f}from"./jsx-runtime-Cjj9sGSy.js";import{t as p}from"./label-Cdim77Jw.js";import{t as m}from"./AnimatePresence-C5p0yiY1.js";import{a as h,i as g,n as _,r as v,t as y}from"./select-CJ57-Bor.js";import{t as b}from"./createLucideIcon-B3b8EU0b.js";import{n as x,r as S,t as C}from"./WidgetWrapper-CZaEVEw4.js";import{n as w,t as T}from"./zap-Du2Uc5pa.js";import{t as E}from"./code-tME-5H6D.js";import{a as D,i as O,n as k,o as ee,r as A,s as j}from"./shared-CCC9rTz4.js";import{t as M}from"./maximize-_O55kFcr.js";import{n as N,t as te}from"./save-B-MsgxX9.js";import{$ as P,$t as F,B as I,Bt as L,Dt as R,F as z,G as B,J as V,Jt as ne,Kt as H,Lt as U,M as W,P as re,Q as G,R as ie,Rt as ae,St as K,U as oe,W as se,X as q,Y as ce,Z as le,_n as ue,b as J,cn as Y,en as de,hn as fe,ot as pe,q as me,qt as he,vn as ge,w as _e,wt as ve,xt as ye,yt as be,z as xe}from"./index-C_fCIJ4C.js";import{t as Se}from"./textarea-DLAmNVf_.js";import{t as Ce}from"./useViewHostProps-CV5zBxUb.js";import{t as we}from"./ListTabHeader-R17w_JsB.js";var Te=b(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),X=e(t(),1),Z=f();function Ee({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:r,focusedIndex:a}){if(e.length===0)return(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:[(0,Z.jsx)(S,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,Z.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`No saved requests yet`}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Execute a tool and click Save to store requests`})]});let o=(e,t)=>{e.stopPropagation(),t()};return(0,Z.jsx)(`div`,{children:e.map((e,u)=>(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(A,{id:`saved-${e.id}`,isSelected:t?.id===e.id,isFocused:a===u,title:e.name,description:e.toolName,metadata:(0,Z.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:new Date(e.savedAt).toLocaleString()})}),onClick:()=>n(e)}),(0,Z.jsx)(`div`,{className:`absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10`,children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(i,{render:(0,Z.jsx)(l,{variant:`secondary`,size:`sm`,onClick:t=>o(t,()=>r(e.id)),className:`h-8 w-8 p-0`,children:(0,Z.jsx)(ne,{className:`h-4 w-4`})}),nativeButton:!0}),(0,Z.jsx)(c,{children:(0,Z.jsx)(`p`,{children:`Delete saved request`})})]})})]},e.id))})}function De({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:i,onCancel:a}){return e?(0,Z.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:a,children:(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100`,children:`Save Request`}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(p,{htmlFor:`request-name`,children:`Request Name (optional)`}),(0,Z.jsx)(u,{id:`request-name`,value:t,onChange:e=>r(e.target.value),placeholder:n,className:`mt-2`,onKeyDown:e=>{e.key===`Enter`&&i()},autoFocus:!0})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(l,{variant:`outline`,onClick:a,children:`Cancel`}),(0,Z.jsxs)(l,{onClick:i,children:[(0,Z.jsx)(te,{className:`h-4 w-4 mr-2`}),`Save`]})]})]})]})}):null}function Oe(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith(`#/`))return e;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 e;return i}function Q(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>Oe(e,t)?.type!==`null`);if(n)return{...Oe(n,t),nullable:!0}}return e}function $(e,t){let n=Q(e||{},t);return n=Oe(n,t),n}function ke(e,t){let n=$(e,t);if(typeof n.type==`string`)return n.type;if(Array.isArray(n.type)){let e=n.type.find(e=>e!==`null`);return typeof e==`string`?e:void 0}}function Ae(e){let t=e?.enum;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:null}function je(e){let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(t)?!0:[`false`,`0`,`no`,`off`].includes(t)?!1:e}function Me(e,t){if(t===`number`||t===`integer`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return t===`boolean`?je(e):e}function Ne(e,t){if(e===void 0)return e;if(t===`object`||t===`array`){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}if(t===`number`||t===`integer`){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return e}return t===`boolean`?typeof e==`boolean`?e:typeof e==`string`?je(e):e:e}function Pe(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(i){t+=a,i=!1,n++;continue}if(a===`\\`){i=!0,t+=a,n++;continue}if(a==="`"){r?(t+=`"`,r=!1):(t+=`"`,r=!0),n++;continue}if(r&&a===`"`){t+=`\\"`,n++;continue}t+=a,n++}return t}function Fe(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{try{let e=Pe(t),n=JSON.parse(e);if(n&&typeof n==`object`&&!Array.isArray(n))return n}catch{return null}}return null}function Ie({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:r,autoFilledFields:i,setFields:a,sendEmptyFields:o,onToggleEmpty:s}){let c=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],d=Object.keys(c).length>0,f=async(e,t)=>{r&&await r(e.clipboardData.getData(`text`),t)&&e.preventDefault()};return d?(0,Z.jsx)(`div`,{className:`space-y-4`,children:Object.entries(c).map(([r,c])=>{let d=$(c,e?.inputSchema||{}),m=Ae(d),b=d.type===`string`&&m!==null,x=d,S=l.includes(r),C=t[r],w=``;C!=null&&(w=typeof C==`string`?C:typeof C==`object`&&C?JSON.stringify(C,null,2):String(C));let T=x.type===`object`||x.type===`array`,E=T?x.type===`array`?`array`:`object`:`string`,D=a?.has(r)??!0,O=s&&(x.type===`string`||T);return T?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(p,{htmlFor:r,className:`text-sm font-medium`,children:[r,S&&(0,Z.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),x?.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:x.description})]}),O&&s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:E===`array`?`Send empty array explicitly`:`Send empty object explicitly`}),(0,Z.jsx)(_e,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,E,e),"aria-label":E===`array`?`Send empty array`:`Send empty object`,title:E===`array`?`Send empty array []`:`Send empty object {}`})]})]}),(0,Z.jsx)(Se,{id:r,"data-testid":`tool-param-${r}`,value:w,onChange:e=>n(r,e.target.value),onPaste:e=>f(e,r),placeholder:`Enter ${r}`,disabled:o?.has(r)??!1,className:`min-h-[100px] ${D?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`})]},r):b&&m?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(p,{htmlFor:r,className:`text-sm font-medium`,children:[r,S&&(0,Z.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),x.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:x.description})]}),(0,Z.jsxs)(y,{value:String(t[r]||``),onValueChange:e=>n(r,e),children:[(0,Z.jsx)(g,{id:r,className:`w-full ${D?``:`opacity-70`}`,"data-testid":`tool-param-${r}`,children:(0,Z.jsx)(h,{placeholder:`Select an option`})}),(0,Z.jsx)(_,{children:m.map((e,t)=>(0,Z.jsx)(v,{value:e,children:x.enumNames?.[t]||e},e))})]})]},r):(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(p,{htmlFor:r,className:`text-sm font-medium`,children:[r,S&&(0,Z.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),x?.description&&(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:x.description})]}),O&&s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`Send empty string`}),(0,Z.jsx)(_e,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,`string`,e),"aria-label":`Send empty string`,title:`Send empty string`})]})]}),(0,Z.jsx)(u,{id:r,"data-testid":`tool-param-${r}`,value:w,onChange:e=>n(r,e.target.value),onPaste:e=>f(e,r),placeholder:`Enter ${r}`,disabled:o?.has(r)??!1,className:`${D?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`})]},r)})}):(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No parameters required`})}function Le({selectedTool:e,toolArgs:t,payloadToSend:r,isExecuting:o,isConnected:u,onArgChange:f,onExecute:p,onSave:m,onCancel:h,onBulkPaste:g,autoFilledFields:_,setFields:v,sendEmptyFields:y,onToggleEmpty:b}){let x=`hidden @[700px]/tool-exec:inline`,S=`hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full`,C=`max-[699px]/tool-exec:size-8 max-[699px]/tool-exec:min-w-8 max-[699px]/tool-exec:shrink-0 max-[699px]/tool-exec:gap-0 max-[699px]/tool-exec:rounded-full max-[699px]/tool-exec:px-0 max-[699px]/tool-exec:py-0`,w=`max-[699px]/tool-exec:!pr-0`,[T,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[ee,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(!1),L=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(L.current&&e?.description){let e=L.current,t=parseFloat(getComputedStyle(e).lineHeight),n=e.scrollHeight;P(Math.round(n/t)>3),M(!1)}},[e?.description]),(0,X.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!o&&u&&(t.preventDefault(),p()),t.key===`Escape`&&o&&h&&(t.preventDefault(),h())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,o,u,p,h]),e?(0,Z.jsxs)(`div`,{className:`flex flex-col h-full @container/tool-exec`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4`,children:(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,"data-testid":`tool-execution-title`,children:e.name}),(0,Z.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,Z.jsxs)(s,{children:[(0,Z.jsx)(i,{render:(0,Z.jsxs)(l,{"data-testid":`tool-execution-metadata-button`,variant:O?`default`:`outline`,onClick:()=>k(!O),disabled:o,size:`sm`,className:n(d,C),title:`View tool metadata`,children:[(0,Z.jsx)(E,{}),(0,Z.jsx)(`span`,{className:x,children:`Metadata`})]}),nativeButton:!0}),(0,Z.jsx)(c,{children:(0,Z.jsx)(`p`,{children:`View tool definition metadata`})})]}),(0,Z.jsxs)(s,{children:[(0,Z.jsx)(i,{render:(0,Z.jsxs)(l,{"data-testid":`tool-execution-copy-payload-button`,variant:`outline`,onClick:async()=>{if(e)try{await be(JSON.stringify(r??t,null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch{}},disabled:o,size:`sm`,className:n(d,C),title:`Copy payload as JSON`,children:[ee?(0,Z.jsx)(ge,{className:`text-green-600`}):(0,Z.jsx)(fe,{}),(0,Z.jsx)(`span`,{className:x,children:ee?`Copied!`:`Payload`})]}),nativeButton:!0}),(0,Z.jsx)(c,{children:(0,Z.jsx)(`p`,{children:`Copy payload as JSON`})})]}),(0,Z.jsxs)(s,{children:[(0,Z.jsx)(i,{render:(0,Z.jsxs)(l,{"data-testid":`tool-execution-save-button`,variant:`outline`,onClick:m,disabled:o,size:`sm`,className:n(d,C),title:`Save request`,children:[(0,Z.jsx)(te,{}),(0,Z.jsx)(`span`,{className:x,children:`Save`})]}),nativeButton:!0}),(0,Z.jsx)(c,{children:(0,Z.jsx)(`p`,{children:`Save request`})})]}),o&&h?(0,Z.jsxs)(s,{open:T?void 0:!1,children:[(0,Z.jsx)(i,{render:(0,Z.jsx)(`div`,{onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1),className:`relative`,children:(0,Z.jsx)(l,{"data-testid":`tool-execution-cancel-button`,onClick:h,variant:T?`destructive`:`default`,size:`sm`,className:n(a,C,w,`transition-all`),children:T?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{}),(0,Z.jsx)(`span`,{className:x,children:`Cancel`}),(0,Z.jsx)(`span`,{className:S,children:`Esc`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(z,{}),(0,Z.jsx)(`span`,{className:x,children:`Executing...`})]})})}),nativeButton:!1}),(0,Z.jsx)(c,{children:(0,Z.jsx)(`p`,{children:`Hover to cancel (or press Esc)`})})]}):(0,Z.jsx)(l,{"data-testid":`tool-execution-execute-button`,onClick:p,disabled:o||!u,size:`sm`,className:n(a,C,w),children:o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(z,{}),(0,Z.jsx)(`span`,{className:x,children:`Executing...`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{}),(0,Z.jsx)(`span`,{className:x,children:`Execute`}),(0,Z.jsx)(`span`,{className:S,children:`⌘↵`})]})})]})]})})}),(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3`,children:[e.description&&(0,Z.jsxs)(`div`,{className:`relative mb-6`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`p`,{ref:L,"data-testid":`tool-execution-description`,className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!j&&N?`line-clamp-3`:``}`,children:e.description}),N&&!j&&(0,Z.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none`})]}),N&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(`button`,{onClick:()=>M(!j),className:`relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors`,children:j?(0,Z.jsxs)(Z.Fragment,{children:[`Show less`,(0,Z.jsx)(Te,{className:`h-3 w-3`})]}):(0,Z.jsxs)(Z.Fragment,{children:[`Show more`,(0,Z.jsx)(ue,{className:`h-3 w-3`})]})})})]}),(0,Z.jsx)(Ie,{selectedTool:e,toolArgs:t,onArgChange:f,onBulkPaste:g,autoFilledFields:_,setFields:v,sendEmptyFields:y,onToggleEmpty:b})]}),(0,Z.jsx)(ie,{open:O,onOpenChange:k,children:(0,Z.jsxs)(I,{scrollable:!0,className:`max-w-3xl max-h-[80vh]`,children:[(0,Z.jsx)(oe,{sticky:!0,children:(0,Z.jsx)(B,{children:`Tool Definition`})}),(0,Z.jsx)(xe,{children:(0,Z.jsx)(se,{onCopy:async()=>{e&&await be(JSON.stringify(e,null,2))},children:(0,Z.jsx)(J,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a tool to get started`}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a tool from the list to view its details and execute it`})]})}function Re({timestamp:e}){let[t,n]=(0,X.useState)(()=>ze(e));return(0,X.useEffect)(()=>{let t=()=>n(ze(e));t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),(0,Z.jsx)(`span`,{children:t})}function ze(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function Be(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>e.type===`text`).map(e=>e.text).filter(Boolean);if(e.length>0)return e.join(`
2
- `)}return`An error occurred`}function Ve(e){try{return JSON.parse(e),!0}catch{return!1}}function He({content:e}){let[t,n]=(0,X.useState)(new Set),r=(0,X.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return!Array.isArray(e)||e.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No content`}):(0,Z.jsx)(`div`,{className:`space-y-4`,children:e.map((e,n)=>{if(e.type===`text`){let i=e.text||``,a=t.has(n),o=Ve(i),s=o?(()=>{try{return JSON.parse(i)}catch{return null}})():null;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Text Content`,a?` (formatted)`:``]}),o&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(n),className:`text-xs text-blue-600 dark:text-blue-400 hover:underline`,"data-testid":`tool-result-format-toggle-${n}`,children:a?`Show as text`:`Try to format`})]}),a&&s!==null?(0,Z.jsx)(J,{data:s,filename:`content-${n}.json`}):(0,Z.jsx)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words`,"data-testid":`tool-execution-results-text-content`,children:i})]},n)}if(e.type===`image`)return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Image Content`}),(0,Z.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,Z.jsx)(`img`,{src:`data:${e.mimeType||`image/png`};base64,${e.data}`,alt:`Result`,className:`max-w-full rounded`,"data-testid":`tool-execution-results-image-content`}),e.annotations&&(0,Z.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,Z.jsx)(J,{data:e.annotations,filename:`image-annotations-${n}.json`,"data-testid":`tool-execution-results-image-annotations`})})]})]},n);if(e.type===`audio`)return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Audio Content`}),(0,Z.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,Z.jsx)(`audio`,{controls:!0,src:`data:${e.mimeType||`audio/wav`};base64,${e.data}`,className:`w-full`,"data-testid":`tool-execution-results-audio-content`}),e.annotations&&(0,Z.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,Z.jsx)(J,{data:e.annotations,filename:`audio-annotations-${n}.json`,"data-testid":`tool-execution-results-audio-annotations`})})]})]},n);if(e.type===`resource_link`)return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Resource Link`}),(0,Z.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[(0,Z.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,e.uri]}),e.name&&(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Name:`}),` `,e.name]}),e.description&&(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Description:`}),` `,e.description]}),e.mimeType&&(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`MIME Type:`}),` `,e.mimeType]}),e.annotations&&(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,Z.jsx)(J,{data:e.annotations,filename:`resource-link-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-link-annotations`})]})]})]},n);if(e.type===`resource`){let t=e.resource||{};return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Embedded Resource`}),(0,Z.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`font-mono text-sm break-all`,"data-testid":`tool-execution-results-resource-uri`,children:[(0,Z.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,t.uri]}),t.mimeType&&(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,"data-testid":`tool-execution-results-mime-type`,children:`MIME Type:`}),` `,t.mimeType]}),t.text&&(0,Z.jsxs)(`div`,{"data-testid":`tool-execution-results-resource-text-content`,children:[(0,Z.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Content:`}),(0,Z.jsx)(`div`,{className:`bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto`,children:t.text})]}),t.blob&&(0,Z.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[`[Binary content: `,t.blob.length||0,` bytes]`]}),t.annotations&&(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,Z.jsx)(J,{data:t.annotations,filename:`resource-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-annotations`})]})]})]},n)}return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Unknown Content Type: `,e.type||`N/A`]}),(0,Z.jsx)(J,{data:e,filename:`content-${n}.json`,"data-testid":`tool-execution-results-unknown-content`})]},n)})})}function Ue({serverId:e,viewId:t,toolName:n,resourceUri:r,toolInput:i,toolOutput:a,toolMetadata:o,readResource:s,customProps:c,displayMode:l,onDisplayModeChange:u,onSendFollowUp:d}){let f=Ce({serverId:e,viewId:t,resourceUri:r,toolName:n,toolInput:i,toolOutput:a,toolMetadata:o,readResource:s,displayMode:l,onDisplayModeChange:u});if(!f)return(0,Z.jsx)(C,{className:`w-full h-full min-h-[240px]`,children:(0,Z.jsx)(z,{className:`size-5`})});let p=l===`inline`?`w-full h-full flex items-center justify-center relative p-4 min-h-0`:`w-full h-full relative p-4`,m=c?JSON.stringify(c):`no-custom-props`;return(0,Z.jsx)(C,{className:`w-full h-full min-h-[240px]`,children:(0,Z.jsx)(ye,{viewId:t,toolName:n,toolInput:i,toolOutput:a,customProps:c,className:p,onMessage:e=>{e.length>0&&d&&d(e)},...f},m)})}function We({results:e,copiedResult:t,serverId:n,readResource:r,onCopy:i,onMaximize:a,isMaximized:o=!1,onRerunTool:s}){let[c,u]=(0,X.useState)(0),[d,f]=(0,X.useState)(!0),[p,m]=(0,X.useState)(null),[h,b]=(0,X.useState)(`inline`),[S,C]=(0,X.useState)(null),w=(0,X.useRef)(!1),E=e[0],D=E?e.filter(e=>e.toolName===E.toolName):[],O=D[c]||D[0],k=e.findIndex(e=>e===O),ee=(O?O.error||Be(O.result):null)??(O==null?``:JSON.stringify(O.result,null,2));(0,X.useEffect)(()=>{D.length>0&&c>=D.length&&u(0)},[D.length,c]),(0,X.useEffect)(()=>{w.current=!1,m(null)},[E?.toolName]);let A=(0,X.useMemo)(()=>O?.args,[O?.timestamp,c]),j=(0,X.useMemo)(()=>O?.result,[O?.timestamp,O?.duration,c]),te=(0,X.useCallback)(e=>r(e),[r]),P=(0,X.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
3
- `),n=e.filter(e=>e.type===`image`).length,r=e.filter(e=>e.type===`resource`).length,i=[n>0&&`${n} image${n>1?`s`:``}`,r>0&&`${r} resource${r>1?`s`:``}`].filter(Boolean).join(`, `);pe.info(`Widget follow-up`,{description:[t,i].filter(Boolean).join(` — `),duration:5e3})},[]),I=(0,X.useMemo)(()=>O&&ve(O.toolMeta)?`mcp-apps`:null,[O]),R=(0,X.useMemo)(()=>O?.toolMeta?K(O.toolMeta):null,[O?.toolMeta]),B=(0,X.useMemo)(()=>I===`mcp-apps`&&!!R,[I,R]),V=(0,X.useMemo)(()=>O?.result?.content||[],[O]),ne=(0,X.useMemo)(()=>R||null,[R]),H=(0,X.useMemo)(()=>!!(V&&V.length>0||O?.result?.structuredContent),[V,O]),U=(0,X.useMemo)(()=>!B&&H,[B,H]),W=(0,X.useMemo)(()=>{let e=[];return B&&R&&e.push({mode:`mcp-apps`,label:`Component (MCP Apps)`}),e.push({mode:`json`,label:`Raw JSON`}),e},[B,R]);return(0,X.useEffect)(()=>{if(W.length===0)return;let e=p&&W.some(e=>e.mode===p),t=W.find(e=>e.mode!==`json`);if(t){let n=w.current;if(w.current=!0,!p||!e||p===`json`&&!n){m(t.mode);return}}else (!p||!e)&&m(`json`)},[W,p]),e.length===0?(0,Z.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`div`,{className:`text-center`,children:(0,Z.jsx)(L,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})}):(0,Z.jsxs)(`div`,{className:`relative flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:[(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,Z.jsxs)(`div`,{className:`space-y-0 flex flex-col flex-1 h-full`,children:[(0,Z.jsxs)(`div`,{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${B||U?`border-b border-gray-200 dark:border-zinc-600 pb-2`:``}`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),O.duration!==void 0&&(0,Z.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,Z.jsx)(T,{className:`h-3 w-3 text-gray-400`}),(0,Z.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[O.duration,`ms`]})]}),B&&(0,Z.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:W.map((e,t)=>(0,Z.jsxs)(X.Fragment,{children:[t>0&&(0,Z.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,Z.jsx)(`button`,{"data-testid":`tool-result-view-${e.mode}`,onClick:()=>m(e.mode),className:`text-xs font-medium ${p===e.mode?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:e.label})]},e.mode))})}),U&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 sm:ml-4`,children:[(0,Z.jsx)(`button`,{onClick:()=>f(!0),className:`text-xs font-medium ${d?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,Z.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,Z.jsx)(`button`,{onClick:()=>f(!1),className:`text-xs font-medium ${d?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[o&&s&&(0,Z.jsxs)(l,{"data-testid":`tool-result-rerun`,variant:`ghost`,size:`sm`,onClick:s,title:`Re-run with same arguments`,children:[(0,Z.jsx)(F,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`Re-run`})]}),B&&a&&(0,Z.jsx)(l,{"data-testid":`tool-result-maximize`,variant:`ghost`,size:`sm`,onClick:a,title:o?`Restore`:`Maximize`,children:o?(0,Z.jsx)(N,{className:`h-4 w-4`}):(0,Z.jsx)(M,{className:`h-4 w-4`})}),D.length>1&&(0,Z.jsxs)(y,{value:c.toString(),onValueChange:e=>u(parseInt(e)),children:[(0,Z.jsx)(g,{className:`w-[140px] h-8 text-xs`,leading:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(Y,{className:`h-3 w-3`}),(0,Z.jsx)(Re,{timestamp:O.timestamp})]})}),(0,Z.jsx)(_,{children:D.map((e,t)=>(0,Z.jsx)(v,{value:t.toString(),children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Y,{className:`h-3 w-3`}),(0,Z.jsx)(`span`,{children:ze(e.timestamp)}),(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,new Date(e.timestamp).toLocaleTimeString(),`)`]})]})},t))})]}),(0,Z.jsx)(l,{"data-testid":`tool-result-copy-${k}`,variant:`ghost`,size:`sm`,onClick:()=>i(k,ee),children:t===k?(0,Z.jsx)(ge,{className:`h-4 w-4`}):(0,Z.jsx)(fe,{className:`h-4 w-4`})})]})]}),(()=>{let e=O.error||Be(O.result);return e?(0,Z.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4`,children:[(0,Z.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,Z.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:e})]}):(()=>{if(!p)return(0,Z.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px]`,children:(0,Z.jsx)(z,{className:`size-5`})});switch(p){case`mcp-apps`:return!B||!R?(0,Z.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Z.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`MCP Apps resource not available`})})}):(0,Z.jsxs)(`div`,{className:`flex flex-1 relative flex-col min-h-0`,children:[(0,Z.jsx)(`div`,{className:`absolute top-2 right-2 z-30 flex items-center gap-2`,children:(0,Z.jsx)(x,{toolCallId:`tool-${O.timestamp}`,displayMode:h,onDisplayModeChange:b,propsContext:`tool`,resourceUri:R,toolInput:O.args,resourceAnnotations:O.toolMeta,llmConfig:null,resource:null,onPropsChange:C})}),(0,Z.jsx)(Ue,{serverId:n,viewId:`tool-${O.timestamp}`,toolName:O.toolName,toolInput:A,toolOutput:j,toolMetadata:O.toolMeta,resourceUri:R,readResource:te,customProps:S||void 0,displayMode:h,onDisplayModeChange:b,onSendFollowUp:P},`mcp-apps-${O.timestamp}`)]});case`json`:if(U&&d){let e=O.result?.structuredContent;return(0,Z.jsxs)(`div`,{className:`px-4 pt-4 space-y-4`,"data-testid":`tool-execution-results-content`,children:[e&&(0,Z.jsxs)(`div`,{className:`space-y-2`,"data-testid":`tool-execution-results-structured-content`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Structured Content`}),(0,Z.jsx)(J,{data:e,filename:`structured-content-${O.toolName}-${Date.now()}.json`})]}),V&&V.length>0&&(0,Z.jsx)(He,{content:V}),!e&&(!V||V.length===0)&&(0,Z.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,"data-testid":`tool-execution-results-no-content`,children:`No content to display`})]})}return(0,Z.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Z.jsx)(J,{data:O.result,filename:`tool-result-${O.toolName}-${Date.now()}.json`})});default:return null}})()})()]})}),ne&&p===`mcp-apps`&&(0,Z.jsx)(`div`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none`,children:(0,Z.jsx)(`span`,{className:`text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block`,children:ne})})]})}function Ge({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:a}){if(e.length===0)return(0,Z.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:[(0,Z.jsx)(he,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,Z.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No tools available`})]});let o=e.some(e=>e.inputSchema?.properties&&Object.keys(e.inputSchema.properties).length>0);return(0,Z.jsx)(`div`,{children:e.map((e,l)=>{let u=e._meta,d=ve(u)?`mcp-apps`:null,f=e.inputSchema?.properties,p=f?Object.keys(f).length:0,m=o&&p>0&&(0,Z.jsxs)(r,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[p,` params`]}),h=d===`mcp-apps`||m?(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[d===`mcp-apps`&&(0,Z.jsxs)(s,{children:[(0,Z.jsx)(i,{render:(0,Z.jsx)(`span`,{className:`inline-flex`,children:(0,Z.jsx)(de,{className:`h-3.5 w-3.5`})}),nativeButton:!1}),(0,Z.jsx)(c,{children:(0,Z.jsx)(`p`,{children:`UI widget`})})]}),m]}):void 0;return(0,Z.jsx)(A,{id:`tool-${e.name}`,"data-testid":`tool-item-${e.name}`,isSelected:t?.name===e.name,isFocused:a===l,title:e.name,description:e.description,metadata:h,onClick:()=>n(e)},e.name)})})}function Ke(e){return V(e,`alert-dialog`)}function qe({...e}){return(0,Z.jsx)(Ke,{"data-slot":`alert-dialog`,...e})}function Je({...e}){return(0,Z.jsx)(ce,{"data-slot":`alert-dialog-portal`,...e})}function Ye({className:e,...t}){return(0,Z.jsx)(P,{"data-slot":`alert-dialog-overlay`,className:n(`fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Xe({className:e,size:t=`default`,...r}){return(0,Z.jsxs)(Je,{children:[(0,Z.jsx)(Ye,{}),(0,Z.jsx)(q,{"data-slot":`alert-dialog-content`,"data-size":t,className:n(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})]})}function Ze({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:n(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function Qe({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:n(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function $e({className:e,...t}){return(0,Z.jsx)(me,{"data-slot":`alert-dialog-title`,className:n(`text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function et({className:e,...t}){return(0,Z.jsx)(le,{"data-slot":`alert-dialog-description`,className:n(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function tt({className:e,...t}){return(0,Z.jsx)(l,{"data-slot":`alert-dialog-action`,className:n(e),...t})}function nt({className:e,variant:t=`outline`,size:r=`default`,...i}){return(0,Z.jsx)(G,{"data-slot":`alert-dialog-cancel`,className:n(e),render:(0,Z.jsx)(l,{variant:t,size:r}),...i})}function rt({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:r,readResource:i,serverId:a}){let[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=(0,X.useCallback)(async()=>{if(!e||c)return;let o=new AbortController;p(o),l(!0);let u=Date.now();try{let c=t,l=e?._meta||e?.metadata,d=l?.ui?.resourceUri;if(d&&typeof d==`string`){try{await i(d)}catch{}s([{toolName:e.name,args:c,result:null,timestamp:u,duration:0,toolMeta:l}])}let f=await r(e.name,c,{timeout:6e5,resetTimeoutOnProgress:!0,signal:o.signal}),p=Date.now()-u,m=f?._meta??l;R(new U({toolName:e.name,serverId:a,success:!0,duration:p})).catch(()=>{}),window.dispatchEvent(new Event(`mcp-tool-executed`)),s(d&&typeof d==`string`?e=>e.map((e,t)=>t===0?{...e,result:f,duration:p,toolMeta:m}:e):t=>[{toolName:e.name,args:n,result:f,timestamp:u,duration:p,toolMeta:m},...t])}catch(t){let r=Date.now()-u;R(new U({toolName:e.name,serverId:a,success:!1,duration:r,error:t instanceof Error?t.message:String(t)})).catch(()=>{}),window.dispatchEvent(new Event(`mcp-tool-executed`));let i=e?._meta||e?.metadata,o={toolName:e.name,args:n,result:null,error:t instanceof Error?t.message:String(t),timestamp:u,duration:r,toolMeta:i};i?.ui?.resourceUri?s([o]):s(e=>[o,...e])}finally{l(!1)}},[e,t,n,c,r,i,a]),h=(0,X.useCallback)(async(e,t)=>{try{await be(t),d(e),setTimeout(()=>d(null),2e3)}catch(e){console.error(`[ToolsTab] Failed to copy result:`,e)}},[]),g=(0,X.useCallback)(e=>{s(t=>t.filter((t,n)=>n!==e))},[]),_=(0,X.useMemo)(()=>e?o.filter(t=>t.toolName===e.name):[],[o,e]);return{results:o,setResults:s,isExecuting:c,copiedResult:u,executeTool:m,handleCopyResult:h,handleDeleteResult:g,handleFullscreen:(0,X.useCallback)(e=>{let t=_[e];if(!t)return;let n=window.open(``,`_blank`,`width=800,height=600`);n&&(n.document.write(`
4
- <html>
5
- <head><title>${t.toolName} Result</title></head>
6
- <body><pre>${JSON.stringify(t.result,null,2)}</pre></body>
7
- </html>
8
- `),n.document.close())},[_]),filteredResults:_,cancelExecution:(0,X.useCallback)(()=>{f?.abort(),p(null),l(!1)},[f])}}function it({ref:e,activeTab:t,filteredTools:n,savedRequests:r,searchQuery:i,setSearchQuery:a,selectedTool:o,results:s,isExecuting:c,handleToolSelect:l,loadSavedRequest:u,refreshTools:d,selectedToolName:f,tools:p,setSelectedToolName:m}){let[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(-1),y=(0,X.useRef)(null),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(`list`),[w,T]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=()=>x(window.innerWidth<1024);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,X.useEffect)(()=>{C(o?`detail`:`list`)},[o]),(0,X.useEffect)(()=>{b&&s.length>0&&!c&&C(`response`)},[s,c,b]),(0,X.useImperativeHandle)(e,()=>({focusSearch:()=>{g(!0),setTimeout(()=>y.current?.focus(),0)},blurSearch:()=>{a(``),g(!1),y.current?.blur()}})),(0,X.useEffect)(()=>{h&&y.current?.focus()},[h]);let E=(0,X.useCallback)(()=>{i.trim()||g(!1)},[i]),D=(0,X.useCallback)(async()=>{if(d){T(!0);try{await d()}finally{T(!1)}}},[d]);return(0,X.useEffect)(()=>{t!==`tools`&&g(!1)},[t]),(0,X.useEffect)(()=>{v(-1)},[i,t]),(0,X.useEffect)(()=>{let e=e=>{let i=e.target;if(i.tagName===`INPUT`||i.tagName===`TEXTAREA`||i.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let a=t===`tools`?n:r;if(e.key===`ArrowDown`)e.preventDefault(),v(e=>e+1>=a.length?0:e+1);else if(e.key===`ArrowUp`)e.preventDefault(),v(e=>e-1<0?a.length-1:e-1);else if(e.key===`Enter`&&_>=0)if(e.preventDefault(),t===`tools`){let e=n[_];e&&l(e)}else{let e=r[_];e&&u(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[_,n,r,t,l,u]),(0,X.useEffect)(()=>{if(_>=0){let e=t===`tools`?`tool-${n[_]?.name}`:`saved-${r[_]?.id}`;document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[_,n,r,t]),(0,X.useEffect)(()=>{if(!f||p.length===0)return;let e=p.find(e=>e.name===f);if(e){m(null);let t=setTimeout(()=>{l(e),document.getElementById(`tool-${e.name}`)?.scrollIntoView({behavior:`smooth`,block:`nearest`})},100);return()=>clearTimeout(t)}},[f,p,l,m]),{isSearchExpanded:h,setIsSearchExpanded:g,focusedIndex:_,searchInputRef:y,isMobile:b,mobileView:S,setMobileView:C,isRefreshing:w,handleSearchBlur:E,handleRefresh:D}}function at({ref:e,tools:t,callTool:n,readResource:r,serverId:i,isConnected:a,refreshTools:s}){let[c,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),{selectedToolName:p,setSelectedToolName:h}=re(),[g,_]=(0,X.useState)({}),[v,y]=(0,X.useState)(new Set),[b,x]=(0,X.useState)(new Set),[C,T]=(0,X.useState)(``),[E,A]=(0,X.useState)(`tools`),{savedRequests:M,saveSavedRequests:N}=W(),[te,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(``),[L,z]=(0,X.useState)(!1),[B,V]=(0,X.useState)({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}),[ne,H]=(0,X.useState)(new Set),U=j(),G=j(),ie=(0,X.useCallback)(()=>{L?(U.current&&U.current.expand(),G.current&&G.current.expand(),z(!1)):(U.current&&U.current.collapse(),G.current&&G.current.collapse(),z(!0))},[L,U,G]),K=(0,X.useMemo)(()=>{if(!C.trim())return t;let e=C.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[t,C]),oe=(0,X.useCallback)(e=>{u(e);let t={},n=new Set;e.inputSchema?.properties&&Object.entries(e.inputSchema.properties).forEach(([e,r])=>{let i=r;i.default!==void 0&&(t[e]=i.default,n.add(e))}),_(t),y(n),x(new Set)},[]),se=(0,X.useCallback)(e=>{let n=t.find(t=>t.name===e.toolName);n&&(u(n),_(e.args),y(new Set(Object.keys(e.args))),x(new Set),f(e))},[t]);(0,X.useEffect)(()=>{if(c){let e=t.find(e=>e.name===c.name);e?e!==c&&(JSON.stringify(e.inputSchema)!==JSON.stringify(c.inputSchema)||e.description!==c.description||JSON.stringify(e?._meta)!==JSON.stringify(c?._meta))&&u(e):(u(null),h(null))}},[t,c,h]);let q=(0,X.useCallback)((e,t)=>{let n=c?.inputSchema||{},r=c?.inputSchema?.properties?.[e],i=r?ke(r,n):`string`,a;a=i===`object`||i===`array`||i===`string`?t:Me(t,i),_(t=>({...t,[e]:a}));let o=String(t).trim()===``;y(t=>{let n=new Set(t);return o?n.delete(e):n.add(e),n}),x(t=>{let n=new Set(t);return n.delete(e),n})},[c]),ce=(0,X.useCallback)((e,t,n)=>{if(n){let n=t===`array`?`[]`:t===`object`?`{}`:``;_(t=>({...t,[e]:n})),y(t=>new Set(t).add(e)),x(t=>new Set(t).add(e))}else x(t=>{let n=new Set(t);return n.delete(e),n}),y(t=>{let n=new Set(t);return n.delete(e),n})},[]),le=(0,X.useCallback)(async(e,t)=>{if(!c)return!1;let n=Fe(e);if(!n)return!1;let r=c.inputSchema?.properties||{},i=Object.keys(r),a=c.inputSchema||{},o=[],s=[];return Object.entries(n).forEach(([e,t])=>{if(i.includes(e)){let n=r[e],i=ke(n,a),c=t;i===`object`||i===`array`?typeof t==`object`&&t?c=JSON.stringify(t,null,2):typeof t==`string`&&(c=t):c=typeof t==`object`&&t?JSON.stringify(t):String(t);let l=g[e];l!=null&&l!==``?o.push({key:e,oldValue:l,newValue:c}):(s.push(e),q(e,String(c)))}}),o.length===0&&s.length===0?!1:o.length===0?(H(new Set(s)),setTimeout(()=>H(new Set),2e3),!0):new Promise(e=>{V({open:!0,parsedObject:n,fieldsToUpdate:o,newFields:s,resolve:e})})},[c,g,q]),ue=(0,X.useCallback)(()=>{if(!B.resolve)return;B.fieldsToUpdate.forEach(({key:e,newValue:t})=>{q(e,String(t))});let e=[...B.fieldsToUpdate.map(e=>e.key),...B.newFields];H(new Set(e)),setTimeout(()=>H(new Set),2e3),B.resolve(!0),V({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null})},[B,q]),J=(0,X.useCallback)(()=>{B.resolve&&(B.resolve(!1),V({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}))},[B]),Y=(0,X.useMemo)(()=>{if(!c?.inputSchema?.properties)return{};let e=c.inputSchema||{},t={};for(let n of v){let r=c.inputSchema.properties[n];if(!r)continue;let i=ke(r,e);t[n]=Ne(b.has(n)?i===`array`?`[]`:i===`object`?`{}`:``:g[n],i)}return t},[c,g,v,b]),{isExecuting:de,copiedResult:fe,executeTool:pe,handleCopyResult:me,handleDeleteResult:ge,handleFullscreen:_e,filteredResults:ve,cancelExecution:ye,results:be}=rt({selectedTool:c,payloadToSend:Y,toolArgs:g,callTool:n,readResource:r,serverId:i}),{isSearchExpanded:xe,setIsSearchExpanded:Se,focusedIndex:Ce,searchInputRef:Te,isMobile:Oe,mobileView:Q,setMobileView:$,isRefreshing:Ae,handleSearchBlur:je,handleRefresh:Pe}=it({ref:e,activeTab:E,filteredTools:K,savedRequests:M,searchQuery:C,setSearchQuery:T,selectedTool:c,results:be,isExecuting:de,handleToolSelect:oe,loadSavedRequest:se,refreshTools:s,selectedToolName:p,tools:t,setSelectedToolName:h}),Ie=(0,X.useCallback)(()=>{c&&(I(``),P(!0))},[c]),Re=(0,X.useCallback)(()=>{if(!c)return;let e={id:`${Date.now()}-${Math.random()}`,name:F.trim()||`${c.name} - ${new Date().toLocaleString()}`,toolName:c.name,args:Y,savedAt:Date.now(),serverId:c._serverId,serverName:c._serverName};N([...M,e]),R(new ae({toolName:c.name,serverId:i})).catch(()=>{}),P(!1),I(``)},[c,F,Y,M,N,i]),ze=(0,X.useCallback)(e=>{N(M.filter(t=>t.id!==e)),d?.id===e&&f(null)},[M,N,d]);return Oe?(0,Z.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[Q!==`list`&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,Z.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>{Q===`response`?$(`detail`):(u(null),$(`list`))},className:`p-0 h-8 w-8`,children:(0,Z.jsx)(w,{className:`h-4 w-4`})}),(0,Z.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,Z.jsx)(`button`,{onClick:()=>{u(null),$(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Tools`}),Q===`detail`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,Z.jsx)(`button`,{onClick:()=>{$(`response`)},className:Q===`detail`?`text-foreground hover:underline`:Q===`response`?`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`:`text-muted-foreground`,children:`Execute`})]}),Q===`response`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,Z.jsx)(`span`,{className:`text-foreground`,children:`Response`})]})]})]}),(0,Z.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,Z.jsxs)(m,{initial:!1,mode:`popLayout`,children:[Q===`list`&&(0,Z.jsx)(o.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:(0,Z.jsx)(k,{children:e=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(we,{isScrolled:e,activeTab:E,isSearchExpanded:xe,searchQuery:C,primaryTabName:`tools`,secondaryTabName:`saved`,primaryTabTitle:`Tools`,secondaryTabTitle:`Saved`,primaryCount:K.length,secondaryCount:M.length,primaryIcon:he,secondaryIcon:S,searchPlaceholder:`Search tools...`,onSearchExpand:()=>Se(!0),onSearchChange:T,onSearchBlur:je,onTabSwitch:()=>A(E===`tools`?`saved`:`tools`),searchInputRef:Te,onRefresh:s?Pe:void 0,isRefreshing:Ae}),E===`tools`?(0,Z.jsx)(Ge,{tools:K,selectedTool:c,onToolSelect:oe,focusedIndex:Ce}):(0,Z.jsx)(Ee,{savedRequests:M,selectedRequest:d,onLoadRequest:se,onDeleteRequest:ze,focusedIndex:Ce})]})})},`list`),Q===`detail`&&(0,Z.jsx)(o.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-10`,children:(0,Z.jsx)(Le,{selectedTool:c,toolArgs:g,payloadToSend:Y,isExecuting:de,isConnected:a,onArgChange:q,onExecute:pe,onSave:Ie,onBulkPaste:le,autoFilledFields:ne,setFields:v,sendEmptyFields:b,onToggleEmpty:ce})},`detail`),Q===`response`&&(0,Z.jsx)(o.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-20`,children:(0,Z.jsx)(We,{results:ve,copiedResult:fe,serverId:i,readResource:r,onCopy:me,onDelete:ge,onFullscreen:_e,onRerunTool:pe})},`response`)]})}),(0,Z.jsx)(De,{isOpen:te,requestName:F,defaultPlaceholder:`${c?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:I,onSave:Re,onCancel:()=>P(!1)}),(0,Z.jsx)(qe,{open:B.open,onOpenChange:e=>{e||J()},children:(0,Z.jsxs)(Xe,{children:[(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)($e,{children:`Auto-fill fields from pasted object?`}),(0,Z.jsxs)(et,{children:[B.fieldsToUpdate.length>0&&(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,Z.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:B.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,Z.jsxs)(`li`,{className:`font-mono`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,Z.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),B.newFields.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,Z.jsx)(`p`,{className:`text-sm font-mono`,children:B.newFields.join(`, `)})]})]})]}),(0,Z.jsxs)(Qe,{children:[(0,Z.jsx)(nt,{onClick:J,children:`Cancel`}),(0,Z.jsx)(tt,{onClick:ue,children:`Auto-fill`})]})]})})]}):(0,Z.jsxs)(ee,{orientation:`horizontal`,className:`h-full`,children:[(0,Z.jsx)(D,{id:`left-panel`,defaultSize:`33%`,minSize:250,collapsedSize:0,collapsible:!0,className:`flex flex-col h-full relative`,panelRef:U,children:(0,Z.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden border-r dark:border-zinc-700`,children:(0,Z.jsx)(k,{children:e=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(we,{isScrolled:e,activeTab:E,isSearchExpanded:xe,searchQuery:C,primaryTabName:`tools`,secondaryTabName:`saved`,primaryTabTitle:`Tools`,secondaryTabTitle:`Saved`,primaryCount:K.length,secondaryCount:M.length,primaryIcon:he,secondaryIcon:S,searchPlaceholder:`Search tools...`,onSearchExpand:()=>Se(!0),onSearchChange:T,onSearchBlur:je,onTabSwitch:()=>A(E===`tools`?`saved`:`tools`),searchInputRef:Te,onRefresh:s?Pe:void 0,isRefreshing:Ae}),E===`tools`?(0,Z.jsx)(Ge,{tools:K,selectedTool:c,onToolSelect:oe,focusedIndex:Ce}):(0,Z.jsx)(Ee,{savedRequests:M,selectedRequest:d,onLoadRequest:se,onDeleteRequest:ze,focusedIndex:Ce})]})})})}),(0,Z.jsx)(O,{withHandle:!0}),(0,Z.jsx)(D,{defaultSize:`67%`,children:(0,Z.jsxs)(ee,{orientation:`vertical`,children:[(0,Z.jsx)(D,{defaultSize:`40%`,collapsible:!0,panelRef:G,children:(0,Z.jsx)(Le,{selectedTool:c,toolArgs:g,payloadToSend:Y,isExecuting:de,isConnected:a,onArgChange:q,onExecute:pe,onSave:Ie,onCancel:ye,onBulkPaste:le,autoFilledFields:ne,setFields:v,sendEmptyFields:b,onToggleEmpty:ce})}),(0,Z.jsx)(O,{withHandle:!0}),(0,Z.jsx)(D,{defaultSize:`60%`,children:(0,Z.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,Z.jsx)(We,{results:ve,copiedResult:fe,serverId:i,readResource:r,onCopy:me,onDelete:ge,onFullscreen:_e,onMaximize:ie,isMaximized:L,onRerunTool:pe})})})]})}),(0,Z.jsx)(De,{isOpen:te,requestName:F,defaultPlaceholder:`${c?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:I,onSave:Re,onCancel:()=>P(!1)}),(0,Z.jsx)(qe,{open:B.open,onOpenChange:e=>{e||J()},children:(0,Z.jsxs)(Xe,{children:[(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)($e,{children:`Auto-fill fields from pasted object?`}),(0,Z.jsxs)(et,{children:[B.fieldsToUpdate.length>0&&(0,Z.jsxs)(`div`,{className:`mb-3`,children:[(0,Z.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,Z.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:B.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,Z.jsxs)(`li`,{className:`font-mono`,children:[(0,Z.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,Z.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,Z.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),B.newFields.length>0&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,Z.jsx)(`p`,{className:`text-sm font-mono`,children:B.newFields.join(`, `)})]})]})]}),(0,Z.jsxs)(Qe,{children:[(0,Z.jsx)(nt,{onClick:J,children:`Cancel`}),(0,Z.jsx)(tt,{onClick:ue,children:`Auto-fill`})]})]})})]})}at.displayName=`ToolsTab`;export{at as ToolsTab};
@@ -1,34 +0,0 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{G as n,K as r,Lr as i,a,n as o,r as s,sr as c,t as l}from"./input-CLYhA7PK.js";import{t as u}from"./jsx-runtime-Cjj9sGSy.js";import{t as d}from"./label-Cdim77Jw.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-CJ57-Bor.js";import{t as _}from"./createLucideIcon-B3b8EU0b.js";import{t as v}from"./maximize-2-BTT9QQU9.js";import{t as y}from"./sparkles-2OAsc1aP.js";import{B as b,D as x,E as S,G as C,Gt as w,H as T,Ht as E,Jt as D,K as O,Kt as k,O as A,Qt as j,R as ee,U as te,V as M,Vt as ne,W as re,Wt as ie,Yt as ae,Zt as oe,_n as se,b as ce,c as N,d as P,f as F,gn as le,hn as ue,in as de,k as fe,l as pe,n as me,nn as he,ot as I,p as ge,tn as _e,w as ve,yt as L,z as ye}from"./index-C_fCIJ4C.js";import{a as R}from"./dist-B8sA8Zml.js";import{t as z}from"./textarea-DLAmNVf_.js";import{a as be,i as xe,n as Se,o as Ce,r as we}from"./useViewHostProps-CV5zBxUb.js";var Te=_(`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`}]]),Ee=_(`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`}]]),De=_(`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`}]]),Oe=_(`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`}]]),ke=_(`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`}]]),Ae=_(`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`}]]),je=_(`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`}]]),Me=_(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Ne=_(`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`}]]),Pe=_(`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`}]]),B=_(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Fe=_(`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`}]]),V=e(t(),1),Ie=[{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 Le(){return Intl.supportedValuesOf(`timeZone`).map(e=>({value:e,label:e.replace(/_/g,` `)}))}var Re=Le(),H=e=>`mcp-inspector-resource-props-${e}`;function ze(e){let[t,n]=(0,V.useState)([]),[r,i]=(0,V.useState)(null);return(0,V.useEffect)(()=>{(()=>{try{let t=H(e),r=localStorage.getItem(t);if(r){let e=JSON.parse(r);n(e.presets||[]),i(e.activePresetId||null)}else n([]),i(null)}catch(e){console.error(`[useResourceProps] Failed to load presets:`,e),n([]),i(null)}})()},[e]),(0,V.useEffect)(()=>{let n=H(e),i={presets:t,activePresetId:r};localStorage.setItem(n,JSON.stringify(i))},[e,t,r]),{presets:t,activePresetId:r,savePreset:(0,V.useCallback)(e=>{n(t=>{let n=t.findIndex(t=>t.id===e.id),r;return n>=0?(r=[...t],r[n]=e):r=[...t,e],r})},[]),deletePreset:(0,V.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e)),i(t=>t===e?null:t)},[]),setActivePreset:(0,V.useCallback)(e=>{i(e)},[]),getActiveProps:(0,V.useCallback)(()=>r&&t.find(e=>e.id===r)?.props||null,[r,t])}}function U(e={}){let{enabled:t=!0,maxLogs:n=1e3,proxyToPageConsole:r=!1}=e,[i,a]=(0,V.useState)([]),[o,s]=(0,V.useState)(!1),c=(0,V.useRef)(0),l=(0,V.useCallback)(e=>{if(!t)return;let i={...e,id:`log-${++c.current}-${Date.now()}`};if(a(e=>[...e,i].slice(-n)),r){let t=`[WIDGET CONSOLE]`,n=e.args.map(e=>{if(typeof e==`object`&&e)try{return JSON.stringify(e,null,2)}catch{return String(e)}return e});switch(e.level){case`error`:console.error(t,...n);break;case`warn`:console.warn(t,...n);break;case`info`:console.info(t,...n);break;case`debug`:console.debug(t,...n);break;case`trace`:console.trace(t,...n);break;default:console.log(t,...n)}}},[t,n,r]),u=(0,V.useCallback)(()=>{a([]),c.current=0},[]);return(0,V.useEffect)(()=>{if(!t)return;let e=e=>{e.data&&e.data.type===`iframe-console-log`&&e.data.level&&Array.isArray(e.data.args)&&l({level:e.data.level,args:e.data.args,timestamp:e.data.timestamp||new Date().toISOString(),url:e.data.url})};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[t,l]),(0,V.useEffect)(()=>{if(t)return Ce.subscribe(l)},[t,l]),{logs:i,addLog:l,clearLogs:u,isOpen:o,setIsOpen:s}}var W=u(),Be=200,Ve=.9;function G(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`string`)return e;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function K(e){if(e.length===0)return[];let t=e[0];if(typeof t!=`string`||!/%[oOdisfc]/.test(t))return e.map(G);let n=e.slice(1),r=0,i=``;for(let e=0;e<t.length;e++){let a=t[e];if(a===`%`&&e+1<t.length){let o=t[e+1],s=n[r++];switch(o){case`o`:case`O`:i+=G(s),e++;break;case`s`:i+=s===void 0?`undefined`:String(s),e++;break;case`d`:case`i`:i+=String(Number.parseInt(String(s??``),10)||0),e++;break;case`f`:i+=String(Number.parseFloat(String(s??``))||0),e++;break;case`c`:e++;break;default:i+=a}continue}i+=a}let a=[i.trim()];for(;r<n.length;)a.push(G(n[r++]));return a.filter(e=>e.length>0)}function He({level:e}){return(0,W.jsx)(`span`,{className:i(`px-1.5 py-0.5 text-[11px] font-mono font-semibold rounded-full text-white shrink-0`,{log:`bg-zinc-500`,info:`bg-blue-500`,warn:`bg-yellow-500`,error:`bg-red-500`,debug:`bg-purple-500`,trace:`bg-gray-500`}[e]),children:e.toUpperCase()})}function Ue({log:e}){let[t,n]=(0,V.useState)(!1),a=(0,V.useMemo)(()=>{try{return new Date(e.timestamp).toLocaleTimeString()}catch{return``}},[e.timestamp]),o=(0,V.useMemo)(()=>K(e.args),[e.args]),s=(0,V.useMemo)(()=>{if(o.length===0)return``;let e=o[0].replace(/\s*\n\s*/g,` `).trim();return(e.length>120?e.slice(0,120)+`…`:e)+(o.length>1?` +${o.length-1}`:``)},[o]),c=async e=>{e.stopPropagation();try{await L(o.join(`
2
- `)),I.success(`Copied to clipboard`)}catch{I.error(`Failed to copy`)}},l=i(`font-mono text-xs border-b border-zinc-200 dark:border-zinc-800`,e.level===`error`&&`bg-red-50/30 dark:bg-red-950/10`,e.level===`warn`&&`bg-yellow-50/30 dark:bg-yellow-950/10`),u=i(`cursor-pointer select-none`,e.level===`error`&&`hover:bg-red-50/50 dark:hover:bg-red-950/20`,e.level===`warn`&&`hover:bg-yellow-50/50 dark:hover:bg-yellow-950/20`,e.level!==`error`&&e.level!==`warn`&&`hover:bg-zinc-100/70 dark:hover:bg-zinc-800/40`);return(0,W.jsxs)(`div`,{className:i(l,`group`),children:[(0,W.jsxs)(`div`,{className:i(`flex items-center gap-2 px-2 py-1.5`,u),onClick:()=>n(e=>!e),children:[(0,W.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500 shrink-0`,children:t?(0,W.jsx)(se,{className:`size-3`}):(0,W.jsx)(r,{className:`size-3`})}),(0,W.jsx)(He,{level:e.level}),(0,W.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400 text-[10px] shrink-0`,children:a}),!t&&(0,W.jsx)(`span`,{className:i(`truncate text-[11px]`,e.level===`error`&&`text-red-700 dark:text-red-400`,e.level===`warn`&&`text-yellow-700 dark:text-yellow-400`,e.level!==`error`&&e.level!==`warn`&&`text-zinc-700 dark:text-zinc-300`),children:s}),t&&e.url&&(0,W.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500 text-[10px] truncate flex-1`,children:(()=>{try{return new URL(e.url).pathname}catch{return e.url}})()}),t&&(0,W.jsx)(`button`,{onClick:c,"aria-label":`Copy log`,className:`ml-auto shrink-0 opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200`,children:(0,W.jsx)(ue,{className:`size-3`})})]}),t&&(0,W.jsx)(`div`,{className:`pl-8 pr-2 pb-2 select-text`,children:o.map((t,n)=>(0,W.jsx)(`pre`,{className:i(`whitespace-pre-wrap wrap-break-word text-[11px]`,e.level===`error`&&`text-red-700 dark:text-red-400`,e.level===`warn`&&`text-yellow-700 dark:text-yellow-400`,e.level!==`error`&&e.level!==`warn`&&`text-zinc-700 dark:text-zinc-300`),children:t},n))})]})}var q=`mcp-inspector-console-proxy-enabled`,We=`mcp-inspector-console-height`,Ge=[`log`,`info`,`warn`,`error`,`debug`,`trace`],Ke={log:`text-zinc-500`,info:`text-blue-500`,warn:`text-yellow-500`,error:`text-red-500`,debug:`text-purple-500`,trace:`text-gray-500`};function qe({iframeId:e,enabled:t=!0}){let[r,l]=(0,V.useState)(()=>{if(typeof window>`u`)return!0;try{return localStorage.getItem(q)===`true`}catch{return!0}}),[u,f]=(0,V.useState)(()=>{if(typeof window>`u`)return 400;try{let e=localStorage.getItem(We);return e?Math.max(Be,parseInt(e,10)):400}catch{return 400}}),p=(0,V.useRef)(!1),m=(0,V.useCallback)(e=>{e.preventDefault(),p.current=!0;let t=e=>{if(!p.current)return;let t=Math.floor(window.innerHeight*Ve);f(Math.min(t,Math.max(Be,window.innerHeight-e.clientY)))},n=()=>{p.current=!1,window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)};window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n)},[]);(0,V.useEffect)(()=>{try{localStorage.setItem(We,String(u))}catch{}},[u]);let[h,g]=(0,V.useState)(`all`),[_,v]=(0,V.useState)(``),{logs:y,clearLogs:b,isOpen:x,setIsOpen:S}=U({enabled:t,proxyToPageConsole:r}),C=(0,V.useRef)(null);(0,V.useEffect)(()=>{try{localStorage.setItem(q,String(r))}catch{}},[r]);let w=(0,V.useMemo)(()=>{let e={log:0,info:0,warn:0,error:0,debug:0,trace:0};for(let t of y)e[t.level]++;return e},[y]),T=w.error,E=w.warn,D=w.log+w.info+w.debug+w.trace,O=y.length,A=(0,V.useMemo)(()=>T>0?`bg-red-500`:E>0?`bg-yellow-500`:`bg-zinc-500`,[T,E,D]),j=(0,V.useMemo)(()=>{let e=h===`all`?y:y.filter(e=>e.level===h),t=_.trim().toLowerCase();return t&&(e=e.filter(e=>{let n=K(e.args).join(` `).toLowerCase(),r=(e.url??``).toLowerCase();return n.includes(t)||r.includes(t)})),e},[y,h,_]);return(0,V.useEffect)(()=>{x&&!_&&C.current&&(C.current.scrollTop=C.current.scrollHeight)},[j,x,_]),(0,W.jsxs)(N,{open:x,onOpenChange:S,children:[(0,W.jsx)(ge,{render:(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsxs)(c,{variant:`outline`,size:`sm`,className:`relative bg-white/90 dark:bg-zinc-900/90 backdrop-blur-sm shadow-sm hover:bg-white dark:hover:bg-zinc-900`,onClick:()=>S(!0),children:[(0,W.jsx)(B,{className:`size-4`}),O>0&&(0,W.jsx)(`span`,{className:i(`ml-2 px-1.5 py-0.5 text-xs rounded-full text-white font-semibold`,A),children:O})]}),nativeButton:!0}),(0,W.jsx)(s,{children:(0,W.jsxs)(`div`,{className:`text-xs space-y-1`,children:[(0,W.jsxs)(`p`,{className:`font-semibold`,children:[O,` console `,O===1?`log`:`logs`]}),T>0&&(0,W.jsxs)(`p`,{className:`text-red-400`,children:[T,` error`,T===1?``:`s`]}),E>0&&(0,W.jsxs)(`p`,{className:`text-yellow-400`,children:[E,` warning`,E===1?``:`s`]}),D>0&&(0,W.jsxs)(`p`,{className:`text-zinc-400`,children:[D,` info`]})]})})]}),nativeButton:!1}),(0,W.jsxs)(pe,{side:`bottom`,className:`flex flex-col p-0 transition-none m-0 gap-0`,style:{height:u},children:[(0,W.jsx)(`div`,{className:`h-1.5 w-full shrink-0 cursor-ns-resize bg-zinc-200 dark:bg-zinc-700 hover:bg-zinc-300 dark:hover:bg-zinc-600 transition-colors`,onMouseDown:m}),(0,W.jsxs)(P,{className:`px-4 py-4 m-0 border-b border-zinc-200 dark:border-zinc-800 shrink-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(F,{className:`flex items-center gap-2`,children:[(0,W.jsx)(B,{className:`size-4`}),`Widget Console Logs`,y.length>0&&(0,W.jsxs)(`span`,{className:`text-sm font-normal text-zinc-500 dark:text-zinc-400`,children:[`(`,y.length,` `,y.length===1?`log`:`logs`,`)`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-4 pr-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ve,{id:`proxy-console-toggle`,checked:r,onCheckedChange:l}),(0,W.jsx)(d,{htmlFor:`proxy-console-toggle`,className:`text-sm font-normal cursor-pointer`,children:`Proxy logs to page console`})]}),y.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:async()=>{try{await L(j.map(e=>{let t=new Date(e.timestamp).toLocaleTimeString();return`[${e.level.toUpperCase()}] ${t}${e.url?` ${e.url}`:``}\n${K(e.args).join(`
3
- `)}`}).join(`
4
-
5
- `)),I.success(`Copied ${j.length} logs to clipboard`)}catch{I.error(`Failed to copy logs to clipboard`)}},className:`-my-2`,children:[(0,W.jsx)(ue,{className:`size-4 mr-1`}),`Copy All`]}),(0,W.jsxs)(c,{variant:`ghost`,size:`sm`,onClick:b,className:`-my-2`,children:[(0,W.jsx)(Fe,{className:`size-4 mr-1`}),`Clear`]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 pt-1`,children:[(0,W.jsxs)(`button`,{onClick:()=>g(`all`),className:i(`px-2 py-0.5 text-xs rounded font-medium transition-colors`,h===`all`?`bg-zinc-200 dark:bg-zinc-700 text-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800`),children:[`All`,O>0&&(0,W.jsx)(`span`,{className:`ml-1 text-[10px] opacity-70`,children:O})]}),Ge.map(e=>{let t=w[e];return(0,W.jsxs)(`button`,{onClick:()=>g(h===e?`all`:e),className:i(`px-2 py-0.5 text-xs rounded font-medium transition-colors`,h===e?`bg-zinc-200 dark:bg-zinc-700 text-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800`),children:[(0,W.jsx)(`span`,{className:i(t>0&&Ke[e]),children:e.charAt(0).toUpperCase()+e.slice(1)}),t>0&&(0,W.jsx)(`span`,{className:i(`ml-1 text-[10px]`,Ke[e]),children:t})]},e)}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1 relative`,children:[(0,W.jsx)(n,{className:`absolute left-2 size-3 text-zinc-400 dark:text-zinc-500 pointer-events-none`}),(0,W.jsx)(`input`,{type:`text`,placeholder:`Filter logs…`,value:_,onChange:e=>v(e.target.value),className:`pl-6 pr-6 py-0.5 text-xs rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 dark:placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500 w-44`}),_&&(0,W.jsx)(`button`,{onClick:()=>v(``),"aria-label":`Clear search`,className:`absolute right-1.5 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,children:(0,W.jsx)(k,{className:`size-3`})})]})]})]}),(0,W.jsx)(`div`,{ref:C,className:`flex-1 overflow-auto bg-zinc-50 dark:bg-zinc-950`,children:j.length===0?(0,W.jsx)(`div`,{className:`flex items-center justify-center h-full text-zinc-500 dark:text-zinc-400`,children:(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsx)(B,{className:`size-8 mx-auto mb-2 opacity-50`}),(0,W.jsx)(`p`,{className:`text-sm`,children:y.length===0?`No console logs yet`:_?`No logs match "${_}"`:`No logs match the current filter`}),(0,W.jsx)(`p`,{className:`text-xs mt-1`,children:y.length===0?`Logs from iframes will appear here`:`${y.length} log${y.length===1?``:`s`} hidden by filter`})]})}):(0,W.jsx)(`div`,{children:j.map(e=>(0,W.jsx)(Ue,{log:e},e.id))})})]})]})}function J(e){let t=e.trim(),n=t.match(/```(?:json)?\s*([\s\S]*?)```/);n&&(t=n[1].trim());let r=t.indexOf(`{`);if(r<0)return null;let i=0;for(let e=r;e<t.length;e++)if(t[e]===`{`)i++;else if(t[e]===`}`&&(i--,i===0))try{return JSON.parse(t.slice(r,e+1))}catch{return null}return null}function Je({llmConfig:e}){return{generateProps:(0,V.useCallback)(async({resource:t,resourceAnnotations:n,propsSchema:r})=>{if(!e)throw Error(`LLM config is not available`);let i=t.mimeType||n?.mimeType||`unknown`,a=t.description||n?.description||`N/A`;if(r?.properties){let n=Object.keys(r.properties).map(e=>{let t=r.properties[e],n=` - ${e} (${t.type||`string`})`,i=t.description?`: ${t.description}`:``,a=``;return t.type===`array`&&t.items?.type===`object`&&t.items?.properties&&(a=` — array of objects with keys: {${Object.keys(t.items.properties).join(`, `)}}`),`${n}${a}${i}`}).join(`
6
- `),i=[{role:`system`,content:`You are helping a developer configure props for a UI widget. The widget has a defined schema with specific props. Generate appropriate values for ONLY the props listed in the schema. Return ONLY a JSON object with these exact keys. For array props, each item must match the specified structure.`},{role:`user`,content:`Widget: ${t.name||t.uri}
7
- Description: ${a}
8
-
9
- Props Schema:
10
- ${n}
11
-
12
- Generate appropriate default/example values for these props. Return ONLY a JSON object with the exact prop names as keys.
13
- Example: {"query": "example search term", "results": [{"fruit": "Apple", "color": "red"}]}`}],o=J(await R({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:i}));if(o)return Object.entries(o).map(([e,t])=>({key:e,value:typeof t==`object`&&t?JSON.stringify(t):String(t)}));throw Error(`Could not parse props from LLM response`)}let o=t.uri?.startsWith(`ui://`)||t.mimeType===`text/html;profile=mcp-app`||!!n?.ui,s=o?`You are helping preview an MCP App widget in the inspector.
14
- Generate sample tool result data (structuredContent) that the widget receives via useToolContext().
15
- Return ONLY a JSON object with realistic sample data the widget needs to render — query strings, item arrays, IDs, labels, etc.
16
- Do NOT generate UI styling props like theme, width, height, or showFilters unless explicitly required.
17
- For search/list widgets, always include the collection array (e.g. "items") with at least 2 sample entries.`:`You are helping a developer configure props for a UI widget/resource.
18
- Analyze the provided information and suggest appropriate props in key-value format.
19
- Return ONLY a JSON object with key-value pairs, where both keys and values are strings.
20
- Example format: {"theme": "dark", "width": "400", "title": "My Widget"}`,c=o?`Widget: ${t.name||t.uri}
21
- Description: ${a}
22
-
23
- Generate sample structuredContent for previewing this widget in the inspector.
24
- Include every data field the widget likely reads from toolOutput (arrays must be non-empty).
25
- Example for a fruit search widget: {"query": "apple", "items": [{"id": "apple", "name": "Apple"}, {"id": "banana", "name": "Banana"}]}
26
- Return ONLY JSON.`:`Resource Information:
27
- - URI: ${t.uri}
28
- - Name: ${t.name||`N/A`}
29
- - Type: ${i}
30
- - Description: ${a}
31
-
32
- 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.`,l=[{role:`system`,content:s},{role:`user`,content:c}],u=await R({config:{provider:e.provider,model:e.model,apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl},messages:l});try{let e=J(u);if(e)return Object.entries(e).map(([e,t])=>({key:e,value:typeof t==`object`&&t?JSON.stringify(t):String(t)}));let t=u.split(`
33
- `),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: ${u.slice(0,100)}...`)}},[e]),isAvailable:e!==null}}function Y(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 Ye(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>e.type!==`null`);if(n)return{...Y(n,t),nullable:!0}}return e}function Xe(e){return Array.isArray(e.enum)?e.enum:null}function X({name:e,schema:t,value:n,onChange:r,required:i=!1,disabled:a=!1,rootSchema:o}){let s=o||t,c=Ye(t,s);c=Y(c,s);let u=Xe(c),_=c.type===`string`&&u!==null,v=c;return v.type===`object`||v.type===`array`?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(d,{htmlFor:e,className:`text-sm font-medium`,children:[e,i&&(0,W.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,W.jsx)(z,{id:e,value:n,onChange:e=>r(e.target.value),placeholder:v?.description||v?.default?JSON.stringify(v.default,null,2):`Enter ${e}`,className:`min-h-[100px]`,disabled:a}),v?.description&&(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:v.description})]}):_&&u?(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(d,{htmlFor:e,className:`text-sm font-medium`,children:[e,i&&(0,W.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,W.jsxs)(g,{value:n||``,onValueChange:r,disabled:a,children:[(0,W.jsx)(p,{id:e,className:`w-full`,children:(0,W.jsx)(f,{placeholder:v.description||`Select an option`})}),(0,W.jsx)(m,{children:u.map((e,t)=>(0,W.jsx)(h,{value:e,children:v.enumNames?.[t]||e},e))})]}),v.description&&(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:v.description})]}):(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(d,{htmlFor:e,className:`text-sm font-medium`,children:[e,i&&(0,W.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,W.jsx)(l,{id:e,value:n,onChange:e=>r(e.target.value),placeholder:v?.description||(v?.default===void 0?`Enter ${e}`:String(v.default)),type:v.type===`number`?`number`:`text`,disabled:a}),v?.description&&(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:v.description})]})}function Ze({open:e,onOpenChange:t,onSave:n,existingPresets:r,resource:i,resourceAnnotations:a,llmConfig:o,editingPreset:s}){let u=(0,V.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]),f=!!u,[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)({}),[_,v]=(0,V.useState)([{id:crypto.randomUUID(),key:``,value:``}]),[x,S]=(0,V.useState)(!1),[w,E]=(0,V.useState)(null),{generateProps:O,isAvailable:k}=Je({llmConfig:o});(0,V.useEffect)(()=>{if(e){if(s)if(m(s.name),f)g(s.props);else{let e=Object.entries(s.props).map(([e,t])=>({id:crypto.randomUUID(),key:e,value:t}));v(e.length>0?e:[{id:crypto.randomUUID(),key:``,value:``}])}else m(``),f?g({}):v([{id:crypto.randomUUID(),key:``,value:``}]);E(null)}},[e,s,f]);let A=()=>{v([..._,{id:crypto.randomUUID(),key:``,value:``}])},ne=e=>{_.length>1&&v(_.filter(t=>t.id!==e))},re=(e,t,n)=>{v(_.map(r=>r.id===e?{...r,[t]:n}:r))};return(0,W.jsx)(ee,{open:e,onOpenChange:t,children:(0,W.jsxs)(b,{scrollable:!0,className:`sm:max-w-[600px] max-h-[80vh]`,"data-testid":`props-config-dialog`,children:[(0,W.jsxs)(te,{children:[(0,W.jsx)(C,{children:s?`Edit Preset`:`Create Props Preset`}),(0,W.jsxs)(M,{children:[`Configure props for `,i.name||i.uri,`. You can manually add key-value pairs or generate them with AI.`]})]}),(0,W.jsxs)(ye,{className:`space-y-4 py-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(d,{htmlFor:`preset-name`,children:`Preset Name`}),(0,W.jsx)(l,{id:`preset-name`,"data-testid":`props-config-preset-name`,value:p,onChange:e=>m(e.target.value),placeholder:`e.g., Dark Theme, Production Config`,disabled:x})]}),(0,W.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(d,{className:`text-sm font-medium`,children:`Generate with AI`}),k&&(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Using `,o?.provider,` (`,o?.model,`)`]})]}),k?(0,W.jsx)(c,{onClick:async()=>{if(!k){I.error(`LLM not configured`,{description:`Please configure LLM in the Chat tab first.`});return}S(!0),E(null);try{let e=await O({resource:i,resourceAnnotations:a,propsSchema:f?u:void 0});if(f){let t={};for(let n of e)u.properties?.[n.key]&&(t[n.key]=n.value);g(t)}else v(e.map(e=>({id:crypto.randomUUID(),key:e.key,value:e.value})));I.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`;E(t),I.error(`LLM Generation Failed`,{description:t})}finally{S(!1)}},disabled:x,size:`sm`,variant:`outline`,className:`w-full`,"data-testid":`props-config-generate-llm-button`,children:x?(0,W.jsxs)(`span`,{"data-testid":`props-config-generating`,className:`flex items-center gap-2`,children:[(0,W.jsx)(de,{className:`h-4 w-4 mr-2 animate-spin`}),`Generating...`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(y,{className:`h-4 w-4 mr-2`}),`Generate Props with LLM`]})}):(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`LLM not configured. Please configure LLM in the Chat tab to use this feature.`}),w&&(0,W.jsx)(`p`,{className:`text-xs text-destructive`,"data-testid":`props-config-error`,children:w})]}),(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(d,{className:`text-sm font-medium`,children:`Props`}),f?(0,W.jsx)(`div`,{className:`space-y-4`,children:Object.entries(u.properties||{}).map(([e,t])=>(0,W.jsx)(X,{name:e,schema:t,value:h[e]||``,onChange:t=>g(n=>({...n,[e]:t})),required:u.required?.includes(e),disabled:x,rootSchema:u},e))}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,W.jsxs)(c,{onClick:A,size:`sm`,variant:`ghost`,disabled:x,"data-testid":`props-config-add-prop`,children:[(0,W.jsx)(j,{className:`h-4 w-4 mr-1`}),`Add Prop`]})}),_.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,W.jsx)(l,{placeholder:`Key`,value:e.key,onChange:t=>re(e.id,`key`,t.target.value),disabled:x,"data-testid":`props-config-key-${t}`}),(0,W.jsx)(l,{placeholder:`Value`,value:e.value,onChange:t=>re(e.id,`value`,t.target.value),disabled:x,"data-testid":`props-config-value-${t}`})]}),(0,W.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>ne(e.id),disabled:_.length===1||x,className:`h-9 w-9 p-0`,"data-testid":`props-config-remove-${t}`,children:(0,W.jsx)(D,{className:`h-4 w-4 text-muted-foreground`})})]},e.id))]})]})]}),(0,W.jsxs)(T,{children:[(0,W.jsx)(c,{variant:`outline`,onClick:()=>t(!1),disabled:x,"data-testid":`props-config-cancel-button`,children:`Cancel`}),(0,W.jsxs)(c,{onClick:()=>{if(!p.trim()){I.error(`Preset name required`,{description:`Please enter a name for this preset.`});return}if(r.find(e=>e.name.toLowerCase()===p.toLowerCase()&&e.id!==s?.id)){I.error(`Duplicate preset name`,{description:`A preset with this name already exists.`});return}let e;if(f)e={...h};else{e={};for(let t of _)t.key.trim()&&(e[t.key.trim()]=t.value)}if(Object.keys(e).length===0){I.error(`No props defined`,{description:`Please add at least one prop with a key.`});return}let i={id:s?.id||crypto.randomUUID(),name:p.trim(),props:e};n(i),t(!1),I.success(s?`Preset updated`:`Preset created`,{description:`Preset "${i.name}" saved successfully.`})},disabled:x,"data-testid":`props-config-save-button`,children:[s?`Update`:`Create`,` Preset`]})]})]})})}function Qe({value:e,onChange:t}){let n=(n,r)=>{let i=parseInt(r,10);isNaN(i)||t({...e,[n]:i})};return(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Top`}),(0,W.jsx)(l,{type:`number`,min:`0`,value:e.top,onChange:e=>n(`top`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-top`})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Right`}),(0,W.jsx)(l,{type:`number`,min:`0`,value:e.right,onChange:e=>n(`right`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-right`})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Bottom`}),(0,W.jsx)(l,{type:`number`,min:`0`,value:e.bottom,onChange:e=>n(`bottom`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-bottom`})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Left`}),(0,W.jsx)(l,{type:`number`,min:`0`,value:e.left,onChange:e=>n(`left`,e.target.value),className:`h-8`,"data-testid":`debugger-safe-area-left`})]})]})}function $e(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 Z=`https://raw.githubusercontent.com/modelcontextprotocol/ext-apps/bcfffb6585ea4fb1e3a9da39fb8911b83399fa71/specification/2026-01-26/apps.mdx`,et=`https://mcp-use.com/docs/typescript/server/csp`;function tt(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: ${Z}`,`- mcp-use CSP docs: ${et}`,``];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 (resource _meta.ui.csp). Use camelCase for MCP Apps (connectDomains, resourceDomains).`),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(`
34
- `)}var Q=`__no_props__`,$=`__tool_props__`,nt=`__create_preset__`,rt=[{value:`desktop`,label:`Desktop`,icon:he},{value:`mobile`,label:`Mobile`,icon:Me},{value:`tablet`,label:`Tablet`,icon:Pe}];function it({options:e,value:t,onValueChange:n,placeholder:r,contentTestId:i,searchTestId:a,optionTestId:o,trigger:s}){let[c,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(``),p=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(!c){f(``);return}let e=requestAnimationFrame(()=>p.current?.focus());return()=>cancelAnimationFrame(e)},[c]);let m=(0,V.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):[...e]},[e,d]),h=m.findIndex(e=>e.value===t);return(0,W.jsxs)(ne,{open:c,onOpenChange:u,children:[s,(0,W.jsxs)(E,{"data-testid":i,checkedIndex:h>=0?h:void 0,className:`w-80 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`border-b border-border p-2`,onKeyDown:e=>e.stopPropagation(),children:(0,W.jsx)(l,{ref:p,value:d,onChange:e=>f(e.target.value),placeholder:r,"data-testid":a,className:`h-8`})}),(0,W.jsx)(`div`,{className:`max-h-64 overflow-y-auto`,children:m.length===0?(0,W.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:`No results found.`}):m.map((e,r)=>(0,W.jsx)(w,{index:r,label:e.label,checked:t===e.value,"data-testid":o(e.value),onSelect:()=>{n(e.value),u(!1)}},e.value))})]})]})}function at({displayMode:e,onDisplayModeChange:t,toolCallId:n,propsContext:i,resourceUri:l,toolInput:u,resourceAnnotations:d,llmConfig:f,resource:p,onPropsChange:m,requiredProps:h}){let{resolvedTheme:g,setTheme:_}=fe(),{playground:y,updatePlaygroundSettings:T,widgets:k,clearCspViolations:j}=me(),M=k.get(n),N=M?.cspViolations??[],P=M?.declaredCsp,F=M?.effectivePolicy,de=N.length>0?$e(N,P):null,pe=N.length>0?tt(P,F,N,de):``,ge=e===`fullscreen`,ve=e===`pip`,{presets:R,activePresetId:z,savePreset:Ce,deletePreset:Ee,setActivePreset:B,getActiveProps:Fe}=ze(l),[Le,H]=(0,V.useState)(!1),U=!!h?.length&&!z,[Be,Ve]=(0,V.useState)(()=>U);(0,V.useEffect)(()=>{U&&Ve(!0)},[U]);let[G,K]=(0,V.useState)(null),[He,Ue]=(0,V.useState)(!1),[q,We]=(0,V.useState)(`mode`),[Ge,Ke]=(0,V.useState)(!0),J=(0,V.useMemo)(()=>be(P),[P]),Je=(0,V.useMemo)(()=>xe(F),[F]),Y=(0,V.useMemo)(()=>we(J,Je),[J,Je]),Ye=(0,V.useMemo)(()=>Se({mode:y.cspMode,declared:P,effectivePolicy:F,violations:N}),[y.cspMode,P,F,N]),Xe=(0,V.useCallback)(()=>i===`tool`&&u?$:Q,[i,u]),[X,Z]=(0,V.useState)(Xe());(0,V.useEffect)(()=>{z&&i!==`tool`?Z(z):X!==Q&&X!==$&&Z(Xe())},[z,X,Xe,i]),(0,V.useEffect)(()=>{if(m){if(X===Q||X===$)m(null);else if(z&&X===z){let e=Fe();e&&m(e)}}},[X,z,u,Fe,m,R]);let et=e=>{if(e===nt){K(null),H(!0);return}if(e===Q||e===$)B(null),Z(e),m?.(null);else{B(e),Z(e);let t=R.find(t=>t.id===e);m?.(t?.props??null)}},at=e=>{Ce(e),B(e.id),Z(e.id),m?.(e.props)},ot=(e,t)=>{t.stopPropagation();let n=R.find(t=>t.id===e);n&&(Ee(e),I.success(`Preset deleted`,{description:`Preset "${n.name}" has been deleted.`}))},st=(e,t)=>{t.stopPropagation(),K(e),H(!0)},ct=()=>{switch(y.deviceType){case`mobile`:return(0,W.jsx)(Me,{className:`size-3`});case`tablet`:return(0,W.jsx)(Pe,{className:`size-3`});default:return(0,W.jsx)(he,{className:`size-3`})}},lt=rt.findIndex(e=>e.value===y.deviceType);return(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!ge&&!ve&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(c,{"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,W.jsx)(v,{className:`size-4`})}),nativeButton:!0}),(0,W.jsx)(s,{children:`Enter fullscreen mode`})]}),(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(c,{"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,W.jsx)(Oe,{className:`size-4`})}),nativeButton:!0}),(0,W.jsx)(s,{children:`Picture-in-picture`})]})]}),(0,W.jsxs)(ne,{children:[(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(ie,{render:(0,W.jsx)(c,{"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:ct()}),nativeButton:!0}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`Device: `,y.deviceType]})]}),(0,W.jsx)(E,{"data-testid":`debugger-device-dialog`,checkedIndex:lt>=0?lt:void 0,className:`w-56`,children:rt.map((e,t)=>(0,W.jsx)(w,{index:t,icon:e.icon,label:e.label,checked:y.deviceType===e.value,"data-testid":`debugger-device-option-${e.value}`,onSelect:()=>T({deviceType:e.value})},e.value))})]}),(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(c,{"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:()=>{_(g===`dark`?`light`:`dark`)},children:g===`dark`?(0,W.jsx)(_e,{className:`size-3.5`}):(0,W.jsx)(ae,{className:`size-3.5`})}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`Theme: `,g===`dark`?`Dark`:`Light`]})]}),(0,W.jsx)(it,{options:Ie,value:y.locale,onValueChange:e=>T({locale:e}),placeholder:`Search locales...`,contentTestId:`debugger-locale-dialog`,searchTestId:`debugger-locale-search`,optionTestId:e=>`debugger-locale-option-${e}`,trigger:(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(ie,{render:(0,W.jsx)(c,{"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,W.jsx)(`span`,{className:`text-xs font-mono`,children:y.locale})}),nativeButton:!0}),nativeButton:!0}),(0,W.jsx)(s,{children:`Locale`})]})}),(0,W.jsx)(it,{options:Re,value:y.timeZone,onValueChange:e=>T({timeZone:e}),placeholder:`Search timezones...`,contentTestId:`debugger-timezone-dialog`,searchTestId:`debugger-timezone-search`,optionTestId:e=>`debugger-timezone-option-${e.replace(/\//g,`-`)}`,trigger:(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(ie,{render:(0,W.jsx)(c,{"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,W.jsx)(le,{className:`size-3.5`})}),nativeButton:!0}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`Timezone: `,y.timeZone]})]})}),(0,W.jsxs)(ee,{open:He,onOpenChange:Ue,children:[(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(O,{render:(0,W.jsxs)(c,{"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:[y.cspMode===`permissive`?(0,W.jsx)(je,{className:`size-3.5`}):(0,W.jsx)(Ae,{className:`size-3.5`}),N.length>0&&(0,W.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 ${y.cspMode===`permissive`?`bg-yellow-500`:`bg-red-500`}`,children:N.length>99?`99+`:N.length})]}),nativeButton:!0}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`CSP:`,` `,y.cspMode===`permissive`?`Permissive`:`Declared`,N.length>0&&` · ${N.length} ${y.cspMode===`permissive`?`would be blocked`:`blocked`}`]})]}),(0,W.jsxs)(b,{scrollable:!0,className:`sm:max-w-[520px] max-h-[85vh]`,"data-testid":`debugger-csp-dialog`,children:[(0,W.jsx)(te,{children:(0,W.jsx)(C,{children:`CSP Mode`})}),(0,W.jsxs)(ye,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{role:`tablist`,"aria-label":`CSP diagnostics`,className:`grid grid-cols-3 rounded-md border border-zinc-200 dark:border-zinc-700 p-1`,children:[[`mode`,`Mode`],[`diff`,`Policy Diff`],[`findings`,`Findings`]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":q===e,onClick:()=>We(e),className:`rounded px-2 py-1.5 text-xs font-medium ${q===e?`bg-zinc-100 dark:bg-zinc-800`:`text-muted-foreground`}`,children:t},e))}),q===`mode`&&(0,W.jsxs)(`div`,{role:`tabpanel`,className:`space-y-2`,children:[(0,W.jsxs)(c,{"data-testid":`debugger-csp-option-permissive`,variant:y.cspMode===`permissive`?`default`:`outline`,className:`w-full justify-start`,onClick:()=>T({cspMode:`permissive`}),children:[(0,W.jsx)(je,{className:`size-4 mr-2`}),`Permissive`]}),(0,W.jsxs)(c,{"data-testid":`debugger-csp-option-widget-declared`,variant:y.cspMode===`widget-declared`?`default`:`outline`,className:`w-full justify-start`,onClick:()=>T({cspMode:`widget-declared`}),children:[(0,W.jsx)(Ae,{className:`size-4 mr-2`}),`Widget-Declared`]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Permissive records would-be blocks; Widget-Declared enforces the resource metadata policy.`})]}),q===`diff`&&(0,W.jsxs)(`div`,{role:`tabpanel`,className:`space-y-2`,children:[Y.length?(0,W.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded border border-zinc-200 dark:border-zinc-700`,children:Y.map(e=>(0,W.jsxs)(`div`,{className:`border-b border-zinc-100 dark:border-zinc-800 p-2 text-xs last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`code`,{children:e.directive}),(0,W.jsx)(`span`,{className:`text-[10px] uppercase text-muted-foreground`,children:e.status})]}),(0,W.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-muted-foreground break-all`,children:[`requested: `,e.requested.join(` `)||`—`,(0,W.jsx)(`br`,{}),`effective: `,e.effective.join(` `)||`—`]})]},e.directive))}):(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No requested or effective policy data yet.`}),F&&(0,W.jsxs)(c,{variant:`outline`,size:`sm`,onClick:async()=>{try{await L(F),I.success(`Policy copied to clipboard`)}catch{I.error(`Failed to copy`)}},children:[(0,W.jsx)(ue,{className:`size-3.5 mr-2`}),`Copy effective policy`]})]}),q===`findings`&&(0,W.jsxs)(`div`,{role:`tabpanel`,className:`space-y-2`,children:[(0,W.jsx)(`div`,{className:`space-y-1.5`,children:Ye.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded border border-zinc-200 dark:border-zinc-700 p-2`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium`,children:e.title}),(0,W.jsx)(`div`,{className:`text-[11px] text-muted-foreground break-all`,children:e.detail})]},`${e.title}-${t}`))}),N.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`span`,{className:`text-xs font-medium`,children:[N.length,` observed request`,N.length===1?``:`s`]}),(0,W.jsx)(`button`,{className:`text-xs text-muted-foreground underline`,onClick:()=>j(n),children:`Clear`})]}),(0,W.jsxs)(`div`,{className:`border border-amber-200 dark:border-amber-800 rounded-md overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between bg-amber-50 dark:bg-amber-950/30 px-3 py-2`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-xs font-medium text-amber-800 dark:text-amber-200`,onClick:()=>Ke(e=>!e),children:[Ge?(0,W.jsx)(se,{className:`size-3.5`}):(0,W.jsx)(r,{className:`size-3.5`}),`Prompt for Agents`]}),(0,W.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>void L(pe),"aria-label":`Copy prompt for agents`,children:(0,W.jsx)(ue,{className:`size-3.5`})})]}),Ge&&(0,W.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap p-2 text-[11px]`,"data-testid":`debugger-csp-prompt-for-agents`,children:pe})]})]})]})]})]})]}),(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(c,{"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 ${y.capabilities.touch?`border-blue-500 dark:border-blue-400`:``}`,onClick:()=>{T({capabilities:{...y.capabilities,touch:!y.capabilities.touch}})},children:(0,W.jsx)(ke,{className:`size-3.5 ${y.capabilities.touch?`text-blue-600 dark:text-blue-400`:``}`})}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`Touch: `,y.capabilities.touch?`Enabled`:`Disabled`]})]}),(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(c,{"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 ${y.capabilities.hover?`border-blue-500 dark:border-blue-400`:``}`,onClick:()=>{T({capabilities:{...y.capabilities,hover:!y.capabilities.hover}})},children:(0,W.jsx)(De,{className:`size-3.5 ${y.capabilities.hover?`text-blue-600 dark:text-blue-400`:``}`})}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`Hover: `,y.capabilities.hover?`Enabled`:`Disabled`]})]}),(0,W.jsxs)(S,{children:[(0,W.jsx)(A,{render:(0,W.jsx)(c,{"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,W.jsx)(Ne,{className:`size-3.5`})}),nativeButton:!0}),(0,W.jsx)(x,{className:`w-64 p-3`,"data-testid":`debugger-safe-area-dialog`,children:(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-xs font-medium`,children:`Safe Area Insets`}),(0,W.jsx)(Qe,{value:y.safeAreaInsets,onChange:e=>{T({safeAreaInsets:e})}})]})})]}),i===`tool`?(0,W.jsxs)(ee,{children:[(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(O,{render:(0,W.jsx)(c,{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,W.jsx)(Te,{className:`size-3.5`})}),nativeButton:!0}),nativeButton:!0}),(0,W.jsx)(s,{children:`View Tool Props`})]}),(0,W.jsxs)(b,{scrollable:!0,className:`sm:max-w-[600px] max-h-[85vh]`,"data-testid":`debugger-props-dialog`,children:[(0,W.jsx)(te,{children:(0,W.jsx)(C,{children:`Tool Props`})}),(0,W.jsx)(ye,{children:(0,W.jsx)(re,{children:(0,W.jsx)(ce,{data:u??{},filename:`tool-props.json`})})})]})]}):(0,W.jsxs)(S,{open:Be,onOpenChange:Ve,children:[(0,W.jsxs)(o,{children:[(0,W.jsx)(a,{render:(0,W.jsx)(A,{render:(0,W.jsx)(c,{variant:`outline`,size:`sm`,className:`h-8 w-8 p-0 backdrop-blur-sm shadow-sm ${U?`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,W.jsx)(Te,{className:`size-3.5 ${U?`text-amber-500`:``}`})}),nativeButton:!0}),nativeButton:!0}),(0,W.jsxs)(s,{children:[`Props:`,` `,X===Q?`No Props`:X===$?`Tool Props`:R.find(e=>e.id===X)?.name||`Custom`]})]}),(0,W.jsxs)(x,{className:`w-64 p-2`,"data-testid":`debugger-props-popover`,children:[U&&(0,W.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,W.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,W.jsx)(`p`,{className:`text-xs font-mono text-amber-600 dark:text-amber-400`,children:h.join(`, `)}),(0,W.jsx)(`p`,{className:`text-xs text-amber-500 dark:text-amber-400 mt-1`,children:`Create a preset below to set them.`})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(c,{variant:X===Q?`secondary`:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:()=>et(Q),"data-testid":`debugger-props-no-props`,children:`No Props`}),R.map(e=>(0,W.jsxs)(`div`,{className:`relative group flex items-center`,children:[(0,W.jsx)(c,{variant:X===e.id?`secondary`:`ghost`,size:`sm`,className:`w-full justify-start pr-14`,onClick:()=>et(e.id),"data-testid":`debugger-props-preset-${e.id}`,children:e.name}),(0,W.jsxs)(`div`,{className:`absolute right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,W.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:t=>st(e,t),"data-testid":`debugger-props-edit-${e.id}`,children:(0,W.jsx)(oe,{className:`h-3 w-3`})}),(0,W.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:t=>ot(e.id,t),"data-testid":`debugger-props-delete-${e.id}`,children:(0,W.jsx)(D,{className:`h-3 w-3 text-destructive`})})]})]},e.id)),(0,W.jsx)(c,{variant:`ghost`,size:`sm`,className:`w-full justify-start text-primary`,onClick:()=>et(nt),"data-testid":`debugger-props-create-preset`,children:`+ Create Preset...`})]})]})]}),(0,W.jsx)(qe,{iframeId:n,enabled:!0}),p&&(0,W.jsx)(Ze,{open:Le,onOpenChange:H,onSave:at,existingPresets:R,resource:p,resourceAnnotations:d,llmConfig:f||null,editingPreset:G})]})}function ot({children:e,className:t,noWrapper:n}){return n?e:(0,W.jsx)(`div`,{className:i(`flex flex-1 items-center justify-center bg-zinc-50 dark:bg-zinc-800`,`[background-image:radial-gradient(circle,rgba(0,0,0,0.12)_1px,transparent_1px)]`,`dark:[background-image:radial-gradient(circle,rgba(255,255,255,0.1)_1px,transparent_1px)]`,`bg-[length:32px_32px]`,t),children:e})}export{at as n,Ee as r,ot as t};
@@ -1 +0,0 @@
1
- import{Lr as e}from"./input-CLYhA7PK.js";import{t}from"./jsx-runtime-Cjj9sGSy.js";import{g as n,h as r,vn as i}from"./index-C_fCIJ4C.js";var a=t();function o({className:t,...o}){return(0,a.jsx)(n,{"data-slot":`checkbox`,className:e(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,t),...o,children:(0,a.jsx)(r,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,a.jsx)(i,{})})})}export{o as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-B3b8EU0b.js";var t=e(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]);export{t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";var n=e(t()),r=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),i=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),a=e=>{let t=i(e);return t.charAt(0).toUpperCase()+t.slice(1)},o=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),s=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},c={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`},l=(0,n.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:a=``,children:l,iconNode:u,...d},f)=>(0,n.createElement)(`svg`,{ref:f,...c,width:t,height:t,stroke:e,strokeWidth:i?Number(r)*24/Number(t):r,className:o(`lucide`,a),...!l&&!s(d)&&{"aria-hidden":`true`},...d},[...u.map(([e,t])=>(0,n.createElement)(e,t)),...Array.isArray(l)?l:[l]])),u=(e,t)=>{let i=(0,n.forwardRef)(({className:i,...s},c)=>(0,n.createElement)(l,{ref:c,iconNode:t,className:o(`lucide-${r(a(e))}`,`lucide-${e}`,i),...s}));return i.displayName=a(e),i};export{u as t};