@jonathanleelx/meddle 0.4.5-beta.2 → 0.4.5-beta.3

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 (23) hide show
  1. package/mcp-server.js +3 -1
  2. package/package.json +1 -1
  3. package/web/dist/assets/{checkbox-BjgW3JOF.js → checkbox-PKkvo6cn.js} +1 -1
  4. package/web/dist/assets/{code-fixer-Dt1-I4oU.js → code-fixer-CXlb1cN3.js} +1 -1
  5. package/web/dist/assets/detail-panel-Ctl9eso1.js +4 -0
  6. package/web/dist/assets/{global-panel-shell-DQfzAiE3.js → global-panel-shell-PTg7xaym.js} +1 -1
  7. package/web/dist/assets/{health-panel-CXJXs_vk.js → health-panel-pdzWYSTh.js} +1 -1
  8. package/web/dist/assets/{index-CJEpfTlv.js → index-BB8Kl9wK.js} +2 -2
  9. package/web/dist/assets/{mobile-proxy-panel-DgcpJ6i3.js → mobile-proxy-panel-C3uLDCci.js} +1 -1
  10. package/web/dist/assets/{mock-config-BdB8i3Ya.js → mock-config-BUPDw5l6.js} +1 -1
  11. package/web/dist/assets/{mock-editor-panel-DVc02vmv.js → mock-editor-panel-Cd-IcUfX.js} +1 -1
  12. package/web/dist/assets/{monaco-editor-CQN8dHo_.js → monaco-editor-CUsyh0Fx.js} +1 -1
  13. package/web/dist/assets/{plugin-code-editor-CTZOUqd4.js → plugin-code-editor-B1s07F0K.js} +1 -1
  14. package/web/dist/assets/{plugin-config-d85hDX1A.js → plugin-config-CZvH0XnM.js} +1 -1
  15. package/web/dist/assets/{plugin-generator-DXg9oA6K.js → plugin-generator-BzYQZ63A.js} +1 -1
  16. package/web/dist/assets/{plugin-test-dialog-jnPKqlyB.js → plugin-test-dialog-D0PKIfXW.js} +1 -1
  17. package/web/dist/assets/{route-preview-CxQRynvv.js → route-preview-Bpay16um.js} +1 -1
  18. package/web/dist/assets/{rule-ai-assistant-panel-DRRVsOYI.js → rule-ai-assistant-panel-B3zTS8S3.js} +1 -1
  19. package/web/dist/assets/{rule-config-Bom87V01.js → rule-config-DpHCgvVh.js} +1 -1
  20. package/web/dist/assets/{select-Br6TEqmY.js → select-DozhHbSJ.js} +1 -1
  21. package/web/dist/assets/{settings-panel-4chG4hHj.js → settings-panel-BiXW0HbO.js} +1 -1
  22. package/web/dist/index.html +1 -1
  23. package/web/dist/assets/detail-panel-D9Zdv48f.js +0 -4
@@ -1 +1 @@
1
- import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./circle-alert-Q8cZk9Rv.js";import{t as o}from"./circle-x-C9USji_R.js";import{t as s}from"./plus-tVxSydJ8.js";import{t as ee}from"./refresh-cw-CG3HaiQT.js";import{t as te}from"./rotate-ccw-CAYM6Vv0.js";import{t as c}from"./smartphone-DKeDuJTU.js";import{a as ne,i as l,n as re,o as ie,r as ae,t as oe}from"./select-Br6TEqmY.js";import"./es2015-CfXu88Y7.js";import{t as se}from"./switch-C-Xk56TK.js";import{a as u,c as ce,l as le,n as ue,o as d,r as f,s as de,t as fe}from"./ai-config-store-DQXVJVn_.js";import{$ as p,A as m,B as pe,G as me,H as he,J as ge,O as h,U as g,V as _,X as _e,Z as ve,_ as ye,at as be,b as v,c as xe,d as Se,f as Ce,g as we,h as Te,it as Ee,k as y,l as b,lt as x,m as S,mt as De,o as Oe,p as C,pt as w,s as ke,u as T,v as Ae,y as je,z as E}from"./index-CJEpfTlv.js";import{n as Me,r as Ne,t as Pe}from"./alert-Bve02Ufr.js";var Fe=n(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=n(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Le=n(`stethoscope`,[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]),D=t(i(),1),O=e(),Re=[{value:`75`,label:`75%`,scale:.75},{value:`90`,label:`90%`,scale:.9},{value:`100`,label:`100%`,scale:1},{value:`110`,label:`110%`,scale:1.1},{value:`125`,label:`125%`,scale:1.25},{value:`150`,label:`150%`,scale:1.5}],ze=[{value:`auto`,label:`自动`,color:`linear-gradient(135deg, oklch(0.623 0.214 259.815), oklch(0.606 0.25 292.717))`},{value:`neutral`,label:`中性`,color:`oklch(0.556 0 0)`},{value:`blue`,label:`蓝色`,color:`oklch(0.623 0.214 259.815)`},{value:`violet`,label:`紫色`,color:`oklch(0.606 0.25 292.717)`},{value:`green`,label:`绿色`,color:`oklch(0.627 0.194 149.214)`},{value:`orange`,label:`橙色`,color:`oklch(0.646 0.222 41.116)`},{value:`rose`,label:`玫红`,color:`oklch(0.645 0.246 16.439)`}],k=`app-panel-content mt-0`,A=`app-field-group`,j=`app-section`,M=e=>{if(!e)return`100`;let t={small:`90`,medium:`100`,large:`110`};return e in t?t[e]:Re.some(t=>t.value===e)?e:`100`};function Be({open:e=!1,onOpenChange:t,embedded:n=!1}){let{theme:i,accentColor:Be,setTheme:Ve,setAccentColor:He,setZoom:N}=Oe(),[P,Ue]=(0,D.useState)(`preferences`),[F,I]=(0,D.useState)(()=>f()),[L,We]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[Ge,H]=(0,D.useState)(``),[U,W]=(0,D.useState)(null),[G,Ke]=(0,D.useState)(``),[qe,Je]=(0,D.useState)([]),[K,q]=(0,D.useState)({}),[J,Ye]=(0,D.useState)(``),[Y,Xe]=(0,D.useState)(``),[X,Z]=(0,D.useState)(null),[Ze,Qe]=(0,D.useState)(!1),[Q,$e]=(0,D.useState)(()=>M(ke().fontSize)),[et,tt]=(0,D.useState)(!1);(0,D.useEffect)(()=>{xe().then(e=>{let t=M(e.fontSize);$e(t),N(parseInt(t,10)/100),tt(!0)}).catch(()=>{tt(!0)})},[N]),(0,D.useEffect)(()=>{if(!et)return;let e=M(Q);N(parseInt(e,10)/100),b({fontSize:e}).catch(console.error)},[N,et,Q]),(0,D.useEffect)(()=>{(e||n)&&(xe().then(e=>{I(e.aiConfig),Ke(e.mocksFilePath||``),q(e.clientAliases||{})}).catch(()=>{I(f())}),V(null),H(``),fetch(`/api/rule-files`).then(e=>e.json()).then(e=>{Array.isArray(e)&&Je(e)}).catch(()=>{}))},[e,n]);let nt=e=>{let t=u(e);I({...F,provider:e,baseUrl:t.baseUrl,model:t.model})},rt=async()=>{z(!0);try{await b({aiConfig:F}),ce(F),V(`success`),H(`AI 配置保存成功`),T.success(`AI 配置保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},it=()=>{de(),I(f()),V(null),H(``)},at=async()=>{if(!d(F)){V(`error`),H(`请填写完整的配置信息`);return}z(!0),V(null),H(`测试中...`);try{let e=F.baseUrl,t={"Content-Type":`application/json`},n;F.provider===`anthropic`?(t[`x-api-key`]=F.apiKey,t[`anthropic-version`]=`2023-06-01`,n={model:F.model,max_tokens:100,system:`You are a helpful assistant.`,messages:[{role:`user`,content:`Say "test successful"`}],temperature:.3}):(t.Authorization=`Bearer ${F.apiKey}`,n={model:F.model,messages:[{role:`system`,content:`You are a helpful assistant.`},{role:`user`,content:`Say "test successful"`}],temperature:.3,max_tokens:100});let r=await fetch(e,{method:`POST`,headers:t,body:JSON.stringify(n)});if(!r.ok){let e=await r.text();throw Error(`API错误 (${r.status}): ${e}`)}let i=await r.json();if(F.provider===`anthropic`){if(!i.content?.[0]?.text)throw Error(`API响应格式不正确`)}else if(!i.choices?.[0]?.message?.content)throw Error(`API响应格式不正确`);V(`success`),H(`连接测试成功! API配置正常`)}catch(e){V(`error`),H(e instanceof Error?e.message:`测试失败`)}finally{z(!1)}},ot=(0,D.useCallback)(async()=>{try{let e=await fetch(`/api/refresh-config`,{method:`POST`});if(e.ok){let t=await e.json();V(`success`),H(t.message||`配置已刷新`),setTimeout(()=>{V(null),H(``)},2e3)}else{let t=await e.json();V(`error`),H(t.error||`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}}catch(e){console.error(`刷新配置失败:`,e),V(`error`),H(`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}},[]),st=(0,D.useCallback)(async()=>{Qe(!0),Z(null);try{let e=await fetch(`/api/config-doctor`);e.ok?Z(await e.json()):(V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3))}catch(e){console.error(`诊断失败:`,e),V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3)}finally{Qe(!1)}},[]),ct=()=>{let e=J.trim(),t=Y.trim();!e||!t||(q(n=>({...n,[e]:t})),Ye(``),Xe(``))},lt=async()=>{z(!0);try{await b({clientAliases:K}),V(`success`),H(`客户端名称已保存,新请求立即生效`),T.success(`客户端名称保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},ut=async()=>{z(!0);try{await b({mocksFilePath:G}),V(`success`),H(`Mock 文件路径已更新,刷新页面后生效`),T.success(`Mock 文件路径保存成功`),setTimeout(()=>{V(null),H(``)},3e3)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}};Se({active:(e||n)&&P!==`preferences`,enabled:!R,priority:Ce.panel,onSave:()=>{if(P===`config`)return ut();if(P===`clients`)return lt();if(P===`ai`)return rt()}});let $=(0,O.jsxs)(O.Fragment,{children:[!n&&(0,O.jsxs)(Ae,{className:`px-6 pt-6 pb-4`,children:[(0,O.jsxs)(je,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ve,{className:`h-5 w-5`}),`系统设置`]}),(0,O.jsx)(ye,{children:`管理系统偏好、配置和 AI 功能`})]}),(0,O.jsxs)(pe,{value:P,onValueChange:e=>Ue(e),orientation:`vertical`,className:`min-h-0 flex-1 gap-0`,children:[(0,O.jsxs)(he,{"aria-label":`设置分类`,className:`h-full w-14 shrink-0 self-stretch justify-start gap-1 rounded-none border-r bg-muted/25 p-2 group-data-[orientation=vertical]/tabs:!h-full sm:w-44 sm:p-3`,children:[(0,O.jsxs)(g,{value:`preferences`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(ve,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`偏好设置`})]}),(0,O.jsxs)(g,{value:`config`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(x,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`配置文件`})]}),(0,O.jsxs)(g,{value:`clients`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(c,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`客户端`})]}),(0,O.jsxs)(g,{value:`ai`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(_e,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`AI 配置`})]})]}),(0,O.jsxs)(_,{value:`preferences`,className:k,children:[(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`主题`}),(0,O.jsxs)(oe,{value:i,onValueChange:e=>Ve(e),children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择主题`})}),(0,O.jsx)(re,{children:(0,O.jsxs)(ae,{children:[(0,O.jsx)(l,{value:`system`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(be,{className:`size-4`}),`跟随系统`]})}),(0,O.jsx)(l,{value:`light`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ge,{className:`size-4`}),`浅色模式`]})}),(0,O.jsx)(l,{value:`dark`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(Ee,{className:`size-4`}),`深色模式`]})})]})})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`强调色`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`统一按钮、状态、选中项和焦点样式。自动模式会根据明暗主题选择合适的颜色。`})]}),(0,O.jsx)(h,{type:`single`,value:Be,onValueChange:e=>{e&&He(e)},variant:`outline`,spacing:1,className:`flex-wrap justify-start`,"aria-label":`强调色`,children:ze.map(e=>(0,O.jsxs)(y,{value:e.value,"aria-label":e.label,children:[e.value===`auto`?(0,O.jsx)(_e,{"data-icon":`inline-start`}):(0,O.jsx)(`span`,{className:`size-3 rounded-full border border-foreground/10`,style:{background:e.color}}),e.label]},e.value))})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`缩放比例`}),(0,O.jsxs)(oe,{value:Q,onValueChange:$e,children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择缩放比例`})}),(0,O.jsx)(re,{children:(0,O.jsx)(ae,{children:Re.map(e=>(0,O.jsx)(l,{value:e.value,children:e.label},e.value))})})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`关于`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Meddle - HTTP 调试代理工具`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`版本: 1.0.0`})]})]}),(0,O.jsxs)(_,{value:`config`,className:k,children:[(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`路由规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:`~/.meddle/route-rules/`})]}),qe.length>0?(0,O.jsx)(`div`,{className:`space-y-2`,children:qe.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2.5 text-sm`,children:[(0,O.jsx)(E,{variant:e.enabled?`default`:`secondary`,className:`text-[10px]`,children:e.enabled?`已启用`:`未启用`}),(0,O.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[e.name,`.txt`]}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.ruleCount,` 条规则`]})]},e.name))}):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`暂无规则文件`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`规则文件存放于 ~/.meddle/route-rules/ 目录,纯文本格式。在"路由规则"页面管理。`})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`Mock 规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:G||`默认: ~/.meddle/mocks.json`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`mocksPath`,className:`text-xs text-muted-foreground`,children:`自定义 Mock 规则文件路径(留空使用默认)`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`mocksPath`,value:G,onChange:e=>Ke(e.target.value),placeholder:`如: /path/to/my-mocks.json`,className:`flex-1 h-8 text-sm font-mono`}),(0,O.jsxs)(C,{variant:`outline`,size:`sm`,onClick:ut,disabled:R,className:`h-8`,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-3 w-3`}),`应用`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`必须是 JSON 格式的 Mock 规则文件`})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`操作`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:ot,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1`}),`重新加载配置`]}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:st,disabled:Ze,children:[(0,O.jsx)(Le,{className:`h-4 w-4 mr-1`}),Ze?`诊断中...`:`诊断配置`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`点击重新加载可应用修改后的配置文件,点击诊断配置可检查配置有效性`})]}),X&&(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-sm font-medium`,children:[(0,O.jsx)(Le,{className:`h-4 w-4`}),`诊断结果`]}),(0,O.jsxs)(`div`,{className:`mb-3 p-3 rounded-md border ${X.status===`ok`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:X.status===`warning`?`bg-yellow-50 dark:bg-yellow-950/20 border-yellow-200 dark:border-yellow-900`:`bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900`}`,children:[X.status===`ok`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(w,{className:`h-5 w-5 text-green-600 dark:text-green-400`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-green-700 dark:text-green-300`,children:`所有检查通过!配置正常。`})]}),X.status===`warning`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(a,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-yellow-700 dark:text-yellow-300`,children:[`发现 `,X.warnings.length,` 个警告`]})]}),X.status===`error`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-5 w-5 text-red-600 dark:text-red-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:[`发现 `,X.errors.length,` 个错误`]})]})]}),(0,O.jsx)(`div`,{className:A,children:X.checks.map((e,t)=>(0,O.jsx)(`div`,{className:`p-2 rounded border bg-card`,children:(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(w,{className:`h-4 w-4 text-green-600 dark:text-green-400 mt-0.5 shrink-0`}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono truncate`,children:e.path}),e.details&&(0,O.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.details.totalFiles!==void 0&&`${e.details.enabledFiles}/${e.details.totalFiles} 个文件已启用`,e.details.totalRules!==void 0&&` · ${e.details.totalRules} 条规则`,e.details.rules!==void 0&&`${e.details.rules} 条规则`,e.details.total!==void 0&&`${e.details.total} 条规则 (${e.details.enabled} 已启用)`,e.details.size!==void 0&&` · ${e.details.size} bytes`]})]})]})},t))}),X.warnings&&X.warnings.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-yellow-700 dark:text-yellow-300`,children:`警告:`}),X.warnings.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,O.jsx)(a,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]}),X.errors&&X.errors.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-red-700 dark:text-red-300`,children:`错误:`}),X.errors.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-red-600 dark:text-red-400`,children:[(0,O.jsx)(o,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]})]})]})]}),(0,O.jsxs)(_,{value:`clients`,className:k,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4`}),`远程客户端名称`]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将日志中的客户端 IP 映射为设备名称。保存后新请求立即生效,无需重启代理。`})]}),(0,O.jsx)(`div`,{className:A,children:Object.entries(K).length===0?(0,O.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground`,children:`尚未配置设备名称`}):Object.entries(K).map(([e,t])=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:e,readOnly:!0,className:`h-8 flex-1 font-mono text-xs bg-muted/40`,"aria-label":`客户端 IP ${e}`}),(0,O.jsx)(m,{value:t,onChange:t=>{let n=t.target.value;q(t=>({...t,[e]:n}))},className:`h-8 flex-1 text-sm`,"aria-label":`${e} 的设备名称`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>{q(t=>{let n={...t};return delete n[e],n})},title:`删除设备名称`,children:(0,O.jsx)(me,{className:`h-4 w-4`})})]},e))}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`添加设备`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:J,onChange:e=>Ye(e.target.value),placeholder:`客户端 IP,例如 10.13.232.187`,className:`h-8 flex-1 font-mono text-xs`}),(0,O.jsx)(m,{value:Y,onChange:e=>Xe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ct()},placeholder:`设备名称,例如 iPhone`,className:`h-8 flex-1 text-sm`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-8`,onClick:ct,disabled:!J.trim()||!Y.trim(),children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加`]})]})]}),(0,O.jsxs)(C,{onClick:lt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存客户端名称`]})]}),(0,O.jsxs)(_,{value:`ai`,className:k,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`启用 AI 功能`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`启用智能代码修复功能`})]}),(0,O.jsx)(se,{checked:F.enabled,onCheckedChange:e=>I({...F,enabled:e}),"aria-label":`启用 AI 功能`})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`AI 模型配置`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:()=>{W({name:``,provider:`openai`,apiKey:``,baseUrl:`https://api.openai.com/v1/chat/completions`,model:`gpt-4o-mini`})},children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加模型`]})]}),(0,O.jsx)(`div`,{className:A,children:F.models&&F.models.length>0?F.models.map(e=>(0,O.jsx)(`div`,{className:`p-3 rounded-md border ${F.activeModelId===e.id?`border-primary bg-primary/5`:`border-border`}`,children:(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),F.activeModelId===e.id&&(0,O.jsx)(E,{variant:`default`,className:`text-xs`,children:`当前使用`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[e.provider===`openai`?`OpenAI`:`Anthropic`,` - `,e.model]})]}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[F.activeModelId!==e.id&&(0,O.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(le(F,e.id)),className:`h-7 text-xs`,children:[(0,O.jsx)(De,{className:`h-3 w-3 mr-1`}),`使用`]}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(ue(F,e.id)),className:`h-7 w-7 p-0 text-destructive`,children:(0,O.jsx)(me,{className:`h-3 w-3`})})]})]})},e.id)):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground italic py-4 text-center`,children:`暂无模型配置,点击"添加模型"创建`})}),U&&(0,O.jsxs)(`div`,{className:`space-y-5 rounded-md border border-primary bg-primary/5 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`新增模型`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>W(null),className:`h-6 w-6 p-0`,children:(0,O.jsx)(o,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelName`,className:`text-xs`,children:`模型名称`}),(0,O.jsx)(m,{id:`newModelName`,value:U.name||``,onChange:e=>W({...U,name:e.target.value}),placeholder:`如:GPT-4o Mini`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`服务商`}),(0,O.jsxs)(h,{type:`single`,value:U.provider,onValueChange:e=>{if(e===`openai`){let e=u(`openai`);W({...U,provider:`openai`,baseUrl:e.baseUrl,model:e.model})}else if(e===`anthropic`){let e=u(`anthropic`);W({...U,provider:`anthropic`,baseUrl:e.baseUrl,model:e.model})}},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelApiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsx)(m,{id:`newModelApiKey`,type:L?`text`:`password`,value:U.apiKey||``,onChange:e=>W({...U,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelModel`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`newModelModel`,value:U.model||``,onChange:e=>W({...U,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelBaseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`newModelBaseUrl`,value:U.baseUrl||``,onChange:e=>W({...U,baseUrl:e.target.value}),placeholder:`API 端点`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:()=>W(null),className:`h-7 text-xs`,children:`取消`}),(0,O.jsxs)(r,{size:`sm`,onClick:()=>{U.name&&U.apiKey&&U.model&&U.baseUrl&&(I(fe(F,U)),W(null))},disabled:!U.name||!U.apiKey||!U.model||!U.baseUrl,className:`h-7 text-xs`,children:[(0,O.jsx)(s,{className:`h-3 w-3 mr-1`}),`添加`]})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`传统配置(向后兼容)`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`如果未配置多模型,将使用此配置`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`AI 服务商`}),(0,O.jsxs)(h,{type:`single`,value:F.provider,onValueChange:e=>{(e===`openai`||e===`anthropic`)&&nt(e)},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`apiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`apiKey`,type:L?`text`:`password`,value:F.apiKey,onChange:e=>I({...F,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`flex-1 h-8 text-sm`}),(0,O.jsx)(r,{variant:`outline`,size:`icon`,onClick:()=>We(!L),className:`h-8 w-8`,children:L?(0,O.jsx)(Fe,{className:`h-4 w-4`}):(0,O.jsx)(Ie,{className:`h-4 w-4`})})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`model`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`model`,value:F.model,onChange:e=>I({...F,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`baseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`baseUrl`,value:F.baseUrl,onChange:e=>I({...F,baseUrl:e.target.value}),placeholder:F.provider===`openai`?`https://api.openai.com/v1/chat/completions`:`https://api.anthropic.com/v1/messages`,className:`h-8 text-sm`})]}),Ge&&(0,O.jsxs)(Pe,{variant:B===`error`?`destructive`:`default`,children:[B===`success`?(0,O.jsx)(w,{}):B===`error`?(0,O.jsx)(o,{}):(0,O.jsx)(a,{}),(0,O.jsx)(Ne,{children:B===`success`?`操作成功`:B===`error`?`操作失败`:`处理中`}),(0,O.jsx)(Me,{children:Ge})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`flex justify-between`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:it,children:[(0,O.jsx)(te,{className:`h-4 w-4 mr-1`}),`重置`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:at,disabled:!d(F)||R,children:`测试连接`}),(0,O.jsxs)(C,{size:`sm`,onClick:rt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存`]})]})]})]})]})]});return n?(0,O.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:$}):(0,O.jsx)(Te,{open:e,onOpenChange:t,children:(0,O.jsx)(we,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:600,storageKey:`settings-panel`,children:$})})}export{Be as SettingsPanel};
1
+ import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./circle-alert-Q8cZk9Rv.js";import{t as o}from"./circle-x-C9USji_R.js";import{t as s}from"./plus-tVxSydJ8.js";import{t as ee}from"./refresh-cw-CG3HaiQT.js";import{t as te}from"./rotate-ccw-CAYM6Vv0.js";import{t as c}from"./smartphone-DKeDuJTU.js";import{a as ne,i as l,n as re,o as ie,r as ae,t as oe}from"./select-DozhHbSJ.js";import"./es2015-CfXu88Y7.js";import{t as se}from"./switch-C-Xk56TK.js";import{a as u,c as ce,l as le,n as ue,o as d,r as f,s as de,t as fe}from"./ai-config-store-DQXVJVn_.js";import{$ as p,A as m,B as pe,G as me,H as he,J as ge,O as h,U as g,V as _,X as _e,Z as ve,_ as ye,at as be,b as v,c as xe,d as Se,f as Ce,g as we,h as Te,it as Ee,k as y,l as b,lt as x,m as S,mt as De,o as Oe,p as C,pt as w,s as ke,u as T,v as Ae,y as je,z as E}from"./index-BB8Kl9wK.js";import{n as Me,r as Ne,t as Pe}from"./alert-Bve02Ufr.js";var Fe=n(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=n(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Le=n(`stethoscope`,[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]),D=t(i(),1),O=e(),Re=[{value:`75`,label:`75%`,scale:.75},{value:`90`,label:`90%`,scale:.9},{value:`100`,label:`100%`,scale:1},{value:`110`,label:`110%`,scale:1.1},{value:`125`,label:`125%`,scale:1.25},{value:`150`,label:`150%`,scale:1.5}],ze=[{value:`auto`,label:`自动`,color:`linear-gradient(135deg, oklch(0.623 0.214 259.815), oklch(0.606 0.25 292.717))`},{value:`neutral`,label:`中性`,color:`oklch(0.556 0 0)`},{value:`blue`,label:`蓝色`,color:`oklch(0.623 0.214 259.815)`},{value:`violet`,label:`紫色`,color:`oklch(0.606 0.25 292.717)`},{value:`green`,label:`绿色`,color:`oklch(0.627 0.194 149.214)`},{value:`orange`,label:`橙色`,color:`oklch(0.646 0.222 41.116)`},{value:`rose`,label:`玫红`,color:`oklch(0.645 0.246 16.439)`}],k=`app-panel-content mt-0`,A=`app-field-group`,j=`app-section`,M=e=>{if(!e)return`100`;let t={small:`90`,medium:`100`,large:`110`};return e in t?t[e]:Re.some(t=>t.value===e)?e:`100`};function Be({open:e=!1,onOpenChange:t,embedded:n=!1}){let{theme:i,accentColor:Be,setTheme:Ve,setAccentColor:He,setZoom:N}=Oe(),[P,Ue]=(0,D.useState)(`preferences`),[F,I]=(0,D.useState)(()=>f()),[L,We]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[Ge,H]=(0,D.useState)(``),[U,W]=(0,D.useState)(null),[G,Ke]=(0,D.useState)(``),[qe,Je]=(0,D.useState)([]),[K,q]=(0,D.useState)({}),[J,Ye]=(0,D.useState)(``),[Y,Xe]=(0,D.useState)(``),[X,Z]=(0,D.useState)(null),[Ze,Qe]=(0,D.useState)(!1),[Q,$e]=(0,D.useState)(()=>M(ke().fontSize)),[et,tt]=(0,D.useState)(!1);(0,D.useEffect)(()=>{xe().then(e=>{let t=M(e.fontSize);$e(t),N(parseInt(t,10)/100),tt(!0)}).catch(()=>{tt(!0)})},[N]),(0,D.useEffect)(()=>{if(!et)return;let e=M(Q);N(parseInt(e,10)/100),b({fontSize:e}).catch(console.error)},[N,et,Q]),(0,D.useEffect)(()=>{(e||n)&&(xe().then(e=>{I(e.aiConfig),Ke(e.mocksFilePath||``),q(e.clientAliases||{})}).catch(()=>{I(f())}),V(null),H(``),fetch(`/api/rule-files`).then(e=>e.json()).then(e=>{Array.isArray(e)&&Je(e)}).catch(()=>{}))},[e,n]);let nt=e=>{let t=u(e);I({...F,provider:e,baseUrl:t.baseUrl,model:t.model})},rt=async()=>{z(!0);try{await b({aiConfig:F}),ce(F),V(`success`),H(`AI 配置保存成功`),T.success(`AI 配置保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},it=()=>{de(),I(f()),V(null),H(``)},at=async()=>{if(!d(F)){V(`error`),H(`请填写完整的配置信息`);return}z(!0),V(null),H(`测试中...`);try{let e=F.baseUrl,t={"Content-Type":`application/json`},n;F.provider===`anthropic`?(t[`x-api-key`]=F.apiKey,t[`anthropic-version`]=`2023-06-01`,n={model:F.model,max_tokens:100,system:`You are a helpful assistant.`,messages:[{role:`user`,content:`Say "test successful"`}],temperature:.3}):(t.Authorization=`Bearer ${F.apiKey}`,n={model:F.model,messages:[{role:`system`,content:`You are a helpful assistant.`},{role:`user`,content:`Say "test successful"`}],temperature:.3,max_tokens:100});let r=await fetch(e,{method:`POST`,headers:t,body:JSON.stringify(n)});if(!r.ok){let e=await r.text();throw Error(`API错误 (${r.status}): ${e}`)}let i=await r.json();if(F.provider===`anthropic`){if(!i.content?.[0]?.text)throw Error(`API响应格式不正确`)}else if(!i.choices?.[0]?.message?.content)throw Error(`API响应格式不正确`);V(`success`),H(`连接测试成功! API配置正常`)}catch(e){V(`error`),H(e instanceof Error?e.message:`测试失败`)}finally{z(!1)}},ot=(0,D.useCallback)(async()=>{try{let e=await fetch(`/api/refresh-config`,{method:`POST`});if(e.ok){let t=await e.json();V(`success`),H(t.message||`配置已刷新`),setTimeout(()=>{V(null),H(``)},2e3)}else{let t=await e.json();V(`error`),H(t.error||`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}}catch(e){console.error(`刷新配置失败:`,e),V(`error`),H(`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}},[]),st=(0,D.useCallback)(async()=>{Qe(!0),Z(null);try{let e=await fetch(`/api/config-doctor`);e.ok?Z(await e.json()):(V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3))}catch(e){console.error(`诊断失败:`,e),V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3)}finally{Qe(!1)}},[]),ct=()=>{let e=J.trim(),t=Y.trim();!e||!t||(q(n=>({...n,[e]:t})),Ye(``),Xe(``))},lt=async()=>{z(!0);try{await b({clientAliases:K}),V(`success`),H(`客户端名称已保存,新请求立即生效`),T.success(`客户端名称保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},ut=async()=>{z(!0);try{await b({mocksFilePath:G}),V(`success`),H(`Mock 文件路径已更新,刷新页面后生效`),T.success(`Mock 文件路径保存成功`),setTimeout(()=>{V(null),H(``)},3e3)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}};Se({active:(e||n)&&P!==`preferences`,enabled:!R,priority:Ce.panel,onSave:()=>{if(P===`config`)return ut();if(P===`clients`)return lt();if(P===`ai`)return rt()}});let $=(0,O.jsxs)(O.Fragment,{children:[!n&&(0,O.jsxs)(Ae,{className:`px-6 pt-6 pb-4`,children:[(0,O.jsxs)(je,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ve,{className:`h-5 w-5`}),`系统设置`]}),(0,O.jsx)(ye,{children:`管理系统偏好、配置和 AI 功能`})]}),(0,O.jsxs)(pe,{value:P,onValueChange:e=>Ue(e),orientation:`vertical`,className:`min-h-0 flex-1 gap-0`,children:[(0,O.jsxs)(he,{"aria-label":`设置分类`,className:`h-full w-14 shrink-0 self-stretch justify-start gap-1 rounded-none border-r bg-muted/25 p-2 group-data-[orientation=vertical]/tabs:!h-full sm:w-44 sm:p-3`,children:[(0,O.jsxs)(g,{value:`preferences`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(ve,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`偏好设置`})]}),(0,O.jsxs)(g,{value:`config`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(x,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`配置文件`})]}),(0,O.jsxs)(g,{value:`clients`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(c,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`客户端`})]}),(0,O.jsxs)(g,{value:`ai`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(_e,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`AI 配置`})]})]}),(0,O.jsxs)(_,{value:`preferences`,className:k,children:[(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`主题`}),(0,O.jsxs)(oe,{value:i,onValueChange:e=>Ve(e),children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择主题`})}),(0,O.jsx)(re,{children:(0,O.jsxs)(ae,{children:[(0,O.jsx)(l,{value:`system`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(be,{className:`size-4`}),`跟随系统`]})}),(0,O.jsx)(l,{value:`light`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ge,{className:`size-4`}),`浅色模式`]})}),(0,O.jsx)(l,{value:`dark`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(Ee,{className:`size-4`}),`深色模式`]})})]})})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`强调色`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`统一按钮、状态、选中项和焦点样式。自动模式会根据明暗主题选择合适的颜色。`})]}),(0,O.jsx)(h,{type:`single`,value:Be,onValueChange:e=>{e&&He(e)},variant:`outline`,spacing:1,className:`flex-wrap justify-start`,"aria-label":`强调色`,children:ze.map(e=>(0,O.jsxs)(y,{value:e.value,"aria-label":e.label,children:[e.value===`auto`?(0,O.jsx)(_e,{"data-icon":`inline-start`}):(0,O.jsx)(`span`,{className:`size-3 rounded-full border border-foreground/10`,style:{background:e.color}}),e.label]},e.value))})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`缩放比例`}),(0,O.jsxs)(oe,{value:Q,onValueChange:$e,children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择缩放比例`})}),(0,O.jsx)(re,{children:(0,O.jsx)(ae,{children:Re.map(e=>(0,O.jsx)(l,{value:e.value,children:e.label},e.value))})})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`关于`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Meddle - HTTP 调试代理工具`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`版本: 1.0.0`})]})]}),(0,O.jsxs)(_,{value:`config`,className:k,children:[(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`路由规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:`~/.meddle/route-rules/`})]}),qe.length>0?(0,O.jsx)(`div`,{className:`space-y-2`,children:qe.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2.5 text-sm`,children:[(0,O.jsx)(E,{variant:e.enabled?`default`:`secondary`,className:`text-[10px]`,children:e.enabled?`已启用`:`未启用`}),(0,O.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[e.name,`.txt`]}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.ruleCount,` 条规则`]})]},e.name))}):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`暂无规则文件`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`规则文件存放于 ~/.meddle/route-rules/ 目录,纯文本格式。在"路由规则"页面管理。`})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`Mock 规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:G||`默认: ~/.meddle/mocks.json`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`mocksPath`,className:`text-xs text-muted-foreground`,children:`自定义 Mock 规则文件路径(留空使用默认)`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`mocksPath`,value:G,onChange:e=>Ke(e.target.value),placeholder:`如: /path/to/my-mocks.json`,className:`flex-1 h-8 text-sm font-mono`}),(0,O.jsxs)(C,{variant:`outline`,size:`sm`,onClick:ut,disabled:R,className:`h-8`,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-3 w-3`}),`应用`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`必须是 JSON 格式的 Mock 规则文件`})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`操作`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:ot,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1`}),`重新加载配置`]}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:st,disabled:Ze,children:[(0,O.jsx)(Le,{className:`h-4 w-4 mr-1`}),Ze?`诊断中...`:`诊断配置`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`点击重新加载可应用修改后的配置文件,点击诊断配置可检查配置有效性`})]}),X&&(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-sm font-medium`,children:[(0,O.jsx)(Le,{className:`h-4 w-4`}),`诊断结果`]}),(0,O.jsxs)(`div`,{className:`mb-3 p-3 rounded-md border ${X.status===`ok`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:X.status===`warning`?`bg-yellow-50 dark:bg-yellow-950/20 border-yellow-200 dark:border-yellow-900`:`bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900`}`,children:[X.status===`ok`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(w,{className:`h-5 w-5 text-green-600 dark:text-green-400`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-green-700 dark:text-green-300`,children:`所有检查通过!配置正常。`})]}),X.status===`warning`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(a,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-yellow-700 dark:text-yellow-300`,children:[`发现 `,X.warnings.length,` 个警告`]})]}),X.status===`error`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-5 w-5 text-red-600 dark:text-red-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:[`发现 `,X.errors.length,` 个错误`]})]})]}),(0,O.jsx)(`div`,{className:A,children:X.checks.map((e,t)=>(0,O.jsx)(`div`,{className:`p-2 rounded border bg-card`,children:(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(w,{className:`h-4 w-4 text-green-600 dark:text-green-400 mt-0.5 shrink-0`}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono truncate`,children:e.path}),e.details&&(0,O.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.details.totalFiles!==void 0&&`${e.details.enabledFiles}/${e.details.totalFiles} 个文件已启用`,e.details.totalRules!==void 0&&` · ${e.details.totalRules} 条规则`,e.details.rules!==void 0&&`${e.details.rules} 条规则`,e.details.total!==void 0&&`${e.details.total} 条规则 (${e.details.enabled} 已启用)`,e.details.size!==void 0&&` · ${e.details.size} bytes`]})]})]})},t))}),X.warnings&&X.warnings.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-yellow-700 dark:text-yellow-300`,children:`警告:`}),X.warnings.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,O.jsx)(a,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]}),X.errors&&X.errors.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-red-700 dark:text-red-300`,children:`错误:`}),X.errors.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-red-600 dark:text-red-400`,children:[(0,O.jsx)(o,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]})]})]})]}),(0,O.jsxs)(_,{value:`clients`,className:k,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4`}),`远程客户端名称`]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将日志中的客户端 IP 映射为设备名称。保存后新请求立即生效,无需重启代理。`})]}),(0,O.jsx)(`div`,{className:A,children:Object.entries(K).length===0?(0,O.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground`,children:`尚未配置设备名称`}):Object.entries(K).map(([e,t])=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:e,readOnly:!0,className:`h-8 flex-1 font-mono text-xs bg-muted/40`,"aria-label":`客户端 IP ${e}`}),(0,O.jsx)(m,{value:t,onChange:t=>{let n=t.target.value;q(t=>({...t,[e]:n}))},className:`h-8 flex-1 text-sm`,"aria-label":`${e} 的设备名称`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>{q(t=>{let n={...t};return delete n[e],n})},title:`删除设备名称`,children:(0,O.jsx)(me,{className:`h-4 w-4`})})]},e))}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`添加设备`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:J,onChange:e=>Ye(e.target.value),placeholder:`客户端 IP,例如 10.13.232.187`,className:`h-8 flex-1 font-mono text-xs`}),(0,O.jsx)(m,{value:Y,onChange:e=>Xe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ct()},placeholder:`设备名称,例如 iPhone`,className:`h-8 flex-1 text-sm`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-8`,onClick:ct,disabled:!J.trim()||!Y.trim(),children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加`]})]})]}),(0,O.jsxs)(C,{onClick:lt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存客户端名称`]})]}),(0,O.jsxs)(_,{value:`ai`,className:k,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`启用 AI 功能`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`启用智能代码修复功能`})]}),(0,O.jsx)(se,{checked:F.enabled,onCheckedChange:e=>I({...F,enabled:e}),"aria-label":`启用 AI 功能`})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`AI 模型配置`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:()=>{W({name:``,provider:`openai`,apiKey:``,baseUrl:`https://api.openai.com/v1/chat/completions`,model:`gpt-4o-mini`})},children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加模型`]})]}),(0,O.jsx)(`div`,{className:A,children:F.models&&F.models.length>0?F.models.map(e=>(0,O.jsx)(`div`,{className:`p-3 rounded-md border ${F.activeModelId===e.id?`border-primary bg-primary/5`:`border-border`}`,children:(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),F.activeModelId===e.id&&(0,O.jsx)(E,{variant:`default`,className:`text-xs`,children:`当前使用`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[e.provider===`openai`?`OpenAI`:`Anthropic`,` - `,e.model]})]}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[F.activeModelId!==e.id&&(0,O.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(le(F,e.id)),className:`h-7 text-xs`,children:[(0,O.jsx)(De,{className:`h-3 w-3 mr-1`}),`使用`]}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(ue(F,e.id)),className:`h-7 w-7 p-0 text-destructive`,children:(0,O.jsx)(me,{className:`h-3 w-3`})})]})]})},e.id)):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground italic py-4 text-center`,children:`暂无模型配置,点击"添加模型"创建`})}),U&&(0,O.jsxs)(`div`,{className:`space-y-5 rounded-md border border-primary bg-primary/5 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`新增模型`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>W(null),className:`h-6 w-6 p-0`,children:(0,O.jsx)(o,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelName`,className:`text-xs`,children:`模型名称`}),(0,O.jsx)(m,{id:`newModelName`,value:U.name||``,onChange:e=>W({...U,name:e.target.value}),placeholder:`如:GPT-4o Mini`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`服务商`}),(0,O.jsxs)(h,{type:`single`,value:U.provider,onValueChange:e=>{if(e===`openai`){let e=u(`openai`);W({...U,provider:`openai`,baseUrl:e.baseUrl,model:e.model})}else if(e===`anthropic`){let e=u(`anthropic`);W({...U,provider:`anthropic`,baseUrl:e.baseUrl,model:e.model})}},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelApiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsx)(m,{id:`newModelApiKey`,type:L?`text`:`password`,value:U.apiKey||``,onChange:e=>W({...U,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelModel`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`newModelModel`,value:U.model||``,onChange:e=>W({...U,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelBaseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`newModelBaseUrl`,value:U.baseUrl||``,onChange:e=>W({...U,baseUrl:e.target.value}),placeholder:`API 端点`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:()=>W(null),className:`h-7 text-xs`,children:`取消`}),(0,O.jsxs)(r,{size:`sm`,onClick:()=>{U.name&&U.apiKey&&U.model&&U.baseUrl&&(I(fe(F,U)),W(null))},disabled:!U.name||!U.apiKey||!U.model||!U.baseUrl,className:`h-7 text-xs`,children:[(0,O.jsx)(s,{className:`h-3 w-3 mr-1`}),`添加`]})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`传统配置(向后兼容)`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`如果未配置多模型,将使用此配置`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`AI 服务商`}),(0,O.jsxs)(h,{type:`single`,value:F.provider,onValueChange:e=>{(e===`openai`||e===`anthropic`)&&nt(e)},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`apiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`apiKey`,type:L?`text`:`password`,value:F.apiKey,onChange:e=>I({...F,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`flex-1 h-8 text-sm`}),(0,O.jsx)(r,{variant:`outline`,size:`icon`,onClick:()=>We(!L),className:`h-8 w-8`,children:L?(0,O.jsx)(Fe,{className:`h-4 w-4`}):(0,O.jsx)(Ie,{className:`h-4 w-4`})})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`model`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`model`,value:F.model,onChange:e=>I({...F,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`baseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`baseUrl`,value:F.baseUrl,onChange:e=>I({...F,baseUrl:e.target.value}),placeholder:F.provider===`openai`?`https://api.openai.com/v1/chat/completions`:`https://api.anthropic.com/v1/messages`,className:`h-8 text-sm`})]}),Ge&&(0,O.jsxs)(Pe,{variant:B===`error`?`destructive`:`default`,children:[B===`success`?(0,O.jsx)(w,{}):B===`error`?(0,O.jsx)(o,{}):(0,O.jsx)(a,{}),(0,O.jsx)(Ne,{children:B===`success`?`操作成功`:B===`error`?`操作失败`:`处理中`}),(0,O.jsx)(Me,{children:Ge})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`flex justify-between`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:it,children:[(0,O.jsx)(te,{className:`h-4 w-4 mr-1`}),`重置`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:at,disabled:!d(F)||R,children:`测试连接`}),(0,O.jsxs)(C,{size:`sm`,onClick:rt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存`]})]})]})]})]})]});return n?(0,O.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:$}):(0,O.jsx)(Te,{open:e,onOpenChange:t,children:(0,O.jsx)(we,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:600,storageKey:`settings-panel`,children:$})})}export{Be as SettingsPanel};
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>web</title>
8
- <script type="module" crossorigin src="/assets/index-CJEpfTlv.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-BB8Kl9wK.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/button-BTToMaBW.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/dist-DZJ9SMlJ.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/dist-C6eaYCUo.js">
@@ -1,4 +0,0 @@
1
- import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{t as o}from"./chevron-down-CPngAx4M.js";import{t as s}from"./chevron-right-V1DGIDbL.js";import{t as c}from"./circle-x-C9USji_R.js";import{n as l,t as u}from"./server-Cpj4KNwN.js";import{t as d}from"./copy-BYjq1hdN.js";import{t as f}from"./shield-check-OqUmVLQt.js";import{t as p}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{B as m,H as h,S as g,U as _,V as v,_t as y,at as b,et as x,g as S,gt as C,h as ee,m as w,ot as T,v as E,x as D,y as O,z as k}from"./index-CJEpfTlv.js";import{n as A,t as j}from"./body-diff-view-D7dCWajG.js";import{n as te,t as ne}from"./syntax-highlight-BHsSDUha.js";import{t as re}from"./clipboard-DmLDmwss.js";var ie=n(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),ae=n(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),M=n(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),N=t(i(),1);function P(e){return Object.entries(e||{}).map(([e,t])=>`${e}: ${t}`).join(`
2
- `)}var F=e();function I({text:e,label:t}){return(0,F.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-5 px-1.5 text-[10px] text-muted-foreground hover:text-foreground`,"aria-label":`复制${t}`,onClick:()=>void re(e),children:[(0,F.jsx)(d,{className:`h-3 w-3 mr-0.5`}),`复制`]})}function L({body:e}){let[t,n]=(0,N.useState)(`source`),r=(0,N.useMemo)(()=>ne(e||``)===`json`,[e]),i=(0,N.useMemo)(()=>{if(!r)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},[e,r]),a=(0,N.useMemo)(()=>te(t===`formatted`?i:e,r?`json`:void 0),[e,i,t,r]);return e?(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[r?(0,F.jsx)(m,{value:t,onValueChange:e=>n(e),className:`w-fit`,children:(0,F.jsxs)(h,{className:`h-6`,children:[(0,F.jsx)(_,{value:`source`,className:`h-5 px-2 text-[10px]`,children:`源数据`}),(0,F.jsx)(_,{value:`formatted`,className:`h-5 px-2 text-[10px]`,children:`格式化`})]})}):(0,F.jsx)(`span`,{}),(0,F.jsx)(I,{text:e,label:`Body`})]}),(0,F.jsx)(`div`,{className:`font-mono text-xs bg-muted/30 rounded p-2`,children:(0,F.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:a})})]}):(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无内容`})}function R({headers:e}){let t=Object.entries(e||{});return t.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无头部信息`}):(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)(I,{text:P(e),label:`Headers`})}),(0,F.jsx)(`div`,{className:`font-mono text-xs space-y-0.5`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex gap-2 py-0.5 hover:bg-muted/50 px-1 rounded`,children:[(0,F.jsxs)(`span`,{className:`text-purple-600 shrink-0 font-semibold`,children:[e,`:`]}),(0,F.jsx)(`span`,{className:`text-foreground/80 break-all`,children:t})]},e))})]})}function z(e){return e>=200&&e<300?`bg-green-100 text-green-800`:e>=300&&e<400?`bg-blue-100 text-blue-800`:e>=400&&e<500?`bg-amber-100 text-amber-800`:e>=500?`bg-red-100 text-red-800`:``}function B(e){switch(e){case`ok`:return`bg-green-100 text-green-800 border-green-200`;case`error`:return`bg-red-100 text-red-800 border-red-200`;case`skipped`:return`bg-amber-100 text-amber-800 border-amber-200`;case`short-circuited`:return`bg-blue-100 text-blue-800 border-blue-200`;default:return``}}function V(e){switch(e){case`ok`:return`通过`;case`error`:return`异常`;case`skipped`:return`跳过`;case`short-circuited`:return`已短路返回`;default:return e}}function H(e){switch(e){case`builtin`:return`内置`;case`custom`:return`自定义`;case`system`:return`系统`;default:return e}}function U(e){return e.replace(/^builtin\./,``).replace(/^custom\./,``)}function W(e,t){return`${t}-${e.hook}-${e.name}`}function G(e){return e===`onBeforeResponse`||e===`onAfterResponse`?`response`:`request`}function K(e,t){return Array.from(new Set([...Object.keys(e),...Object.keys(t)])).sort().map(n=>({key:n,before:e[n]??``,after:t[n]??``})).filter(e=>e.before!==e.after)}function q({headers:e}){let t=Object.entries(e);return t.length===0?(0,F.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`}):(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(([e,t])=>(0,F.jsxs)(`div`,{className:`break-all`,children:[(0,F.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`:`]}),` `,t]},e))})}function J({lines:e,className:t}){return e.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsx)(`div`,{className:`rounded-lg border bg-muted/20 p-2 text-xs font-mono space-y-1 ${t||``}`,children:e.map((e,t)=>(0,F.jsxs)(`div`,{className:`whitespace-pre-wrap break-all px-2 py-1 rounded ${e.type===`added`?`bg-green-500/10 text-green-700 dark:text-green-300`:`bg-red-500/10 text-red-700 dark:text-red-300`}`,children:[(0,F.jsx)(`span`,{className:`mr-1`,children:e.type===`added`?`+ `:`- `}),e.text]},`${e.type}-${t}-${e.text}`))})}function Y(e,t,n){let r=[];return t!==void 0&&t!==``&&r.push({type:`removed`,text:`${e} ${t}`}),n!==void 0&&n!==``&&r.push({type:`added`,text:`${e} ${n}`}),r}function oe(e,t){let n=[];return e!==void 0&&e!==``&&n.push({type:`removed`,text:e}),t!==void 0&&t!==``&&n.push({type:`added`,text:t}),n}function se(e){let t=e.replace(/\r\n/g,`
3
- `).split(`
4
- `);return t[t.length-1]===``&&t.pop(),t.length>0?t:[``]}function X(e){if(!e)return!1;if(/^\(binary(?:,\s*\d+\s+bytes)?\)$/i.test(e.trim()))return!0;let t=0;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r===9||r===10||r===13||(r<32||r===65533)&&(t+=1)}return t>0&&t/Math.max(e.length,1)>.15}function Z({before:e,after:t}){let[n,i]=(0,N.useState)(!1),a=(0,N.useMemo)(()=>K(e,t),[e,t]),c=(0,N.useMemo)(()=>a.flatMap(e=>Y(e.key,e.before,e.after)),[a]);return c.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(J,{lines:c}),(0,F.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>i(e=>!e),children:[n?(0,F.jsx)(o,{className:`h-3.5 w-3.5 mr-1`}):(0,F.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整头部`:`展开完整头部`]}),n&&(0,F.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`变更前`}),(0,F.jsx)(q,{headers:e})]}),(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`变更后`}),(0,F.jsx)(q,{headers:t})]})]})]})}function Q({before:e,after:t}){let[n,i]=(0,N.useState)(!1),a=(0,N.useMemo)(()=>A(e||``,t||``).filter(e=>e.added||e.removed),[e,t]),c=(0,N.useMemo)(()=>X(e||``)||X(t||``),[e,t]),l=(0,N.useMemo)(()=>c?oe(e||``,t||``):a.flatMap(e=>se(e.value).map(t=>({type:e.added?`added`:`removed`,text:t}))),[e,t,a,c]);return l.length===0?(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(J,{lines:l,className:`max-h-40 overflow-auto`}),!c&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(r,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>i(e=>!e),children:[n?(0,F.jsx)(o,{className:`h-3.5 w-3.5 mr-1`}):(0,F.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整 Diff`:`展开完整 Diff`]}),n&&(0,F.jsx)(j,{original:e,modified:t,mode:`inline`,maxHeight:`220px`})]})]})}function ce({stage:e}){let t=e.changes;return t?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(t.targetBefore||t.targetAfter)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Request URL Diff`}),(0,F.jsx)(J,{lines:Y(`Request URL`,t.targetBefore,t.targetAfter||t.target)})]}),(t.requestHeadersBefore||t.requestHeadersAfter)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Request Header Diff`}),(0,F.jsx)(Z,{before:t.requestHeadersBefore||{},after:t.requestHeadersAfter||{}})]}),(t.responseStatusCodeBefore!==void 0||t.responseStatusCodeAfter!==void 0)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Status Diff`}),(0,F.jsx)(J,{lines:Y(`Response Status`,t.responseStatusCodeBefore,t.responseStatusCodeAfter??t.responseStatusCode)})]}),(t.responseHeadersBefore||t.responseHeadersAfter)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Header Diff`}),(0,F.jsx)(Z,{before:t.responseHeadersBefore||{},after:t.responseHeadersAfter||{}})]}),(t.responseBodyBefore!==void 0||t.responseBodyAfter!==void 0)&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Body Diff`}),(0,F.jsx)(Q,{before:t.responseBodyBefore||``,after:t.responseBodyAfter||t.responseBody||``})]})]}):null}function le({stage:e,index:t,isLast:n,accentClass:i}){let[a,c]=(0,N.useState)(e.status!==`skipped`);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border bg-background/90 p-3 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-6 px-1 text-xs`,onClick:()=>c(e=>!e),title:a?`收起`:`展开`,children:a?(0,F.jsx)(o,{className:`h-3.5 w-3.5`}):(0,F.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,F.jsxs)(`span`,{className:`font-medium text-sm`,children:[t+1,`. `,U(e.name)]}),(0,F.jsx)(k,{variant:`outline`,className:`text-xs font-normal`,children:e.hook}),(0,F.jsx)(k,{variant:`outline`,className:`text-xs font-normal`,children:H(e.type)})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.status===`short-circuited`?`这一阶段直接生成了响应,请求不会继续往后转发。`:e.status===`error`?`这一阶段执行失败,影响了后续处理流程。`:`这一阶段执行完成,请求继续进入下一步。`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,F.jsx)(k,{className:`text-xs border ${B(e.status)}`,children:V(e.status)}),(0,F.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.duration,`ms`]})]})]}),a&&(0,F.jsxs)(F.Fragment,{children:[e.target&&(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`当前 Target`}),(0,F.jsx)(`div`,{className:`font-mono text-xs break-all`,children:e.target})]}),(0,F.jsx)(ce,{stage:e}),e.error&&(0,F.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[`Error: `,e.error]})]})]}),!n&&(0,F.jsx)(`div`,{className:`flex justify-center py-1`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full ${i} animate-pulse`}),(0,F.jsx)(C,{className:`h-4 w-4 ${i} animate-bounce`})]})})]})}function $({title:e,description:t,stages:n,icon:r,roleLabel:i,roleIcon:a,accentClass:o}){return(0,F.jsxs)(`div`,{className:`rounded-xl border bg-card p-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`flex items-center gap-2 mb-2`,children:(0,F.jsxs)(k,{variant:`outline`,className:`text-[11px] font-normal`,children:[(0,F.jsx)(`span`,{className:`mr-1`,children:a}),i]})}),(0,F.jsxs)(`h4`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:o,children:r}),e]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t})]}),(0,F.jsxs)(k,{variant:`outline`,className:`text-xs`,children:[n.length,` 个阶段`]})]}),n.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无阶段信息`}):(0,F.jsx)(`div`,{className:`space-y-3`,children:n.map(({stage:e,index:t},r)=>(0,F.jsx)(le,{stage:e,index:t,isLast:r===n.length-1,accentClass:o},W(e,t)))})]})}function ue(e){let t=[...e.stages].reverse().find(e=>e.status===`short-circuited`);if(t)return{label:`提前返回响应`,description:`在 ${U(t.name)} 阶段直接生成响应`,icon:(0,F.jsx)(ie,{className:`h-4 w-4 text-blue-500`})};let n=[...e.stages].reverse().find(e=>e.status===`error`);return n?{label:`处理过程中出现异常`,description:`${U(n.name)} 执行失败`,icon:(0,F.jsx)(c,{className:`h-4 w-4 text-red-500`})}:{label:`进入正常代理流程`,description:`请求经过检查后继续转发到目标服务`,icon:(0,F.jsx)(a,{className:`h-4 w-4 text-emerald-500`})}}function de({inspection:e}){let t=ue(e),n=e.stages.map((e,t)=>({stage:e,index:t})),r=n.filter(({stage:e})=>G(e.hook)===`request`),i=n.filter(({stage:e})=>G(e.hook)===`response`);return(0,F.jsxs)(`div`,{className:`space-y-4 pt-3`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border bg-gradient-to-br from-muted/20 via-background to-muted/10 p-4 space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,F.jsx)(k,{variant:`outline`,className:`font-mono`,children:e.method}),(0,F.jsx)(`span`,{className:`font-mono text-muted-foreground truncate flex-1`,children:e.url}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,F.jsx)(l,{className:`h-3.5 w-3.5`}),(0,F.jsxs)(`span`,{className:`text-xs`,children:[e.totalDuration,`ms`]})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,F.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,F.jsx)(M,{className:`h-3.5 w-3.5`}),`请求入口`]}),(0,F.jsx)(`div`,{className:`text-sm font-medium`,children:`请求进入代理`}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`从浏览器或客户端发起,进入 Meddle 的处理流水线`})]}),(0,F.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,F.jsx)(f,{className:`h-3.5 w-3.5`}),`处理阶段`]}),(0,F.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.stages.length,` 个阶段`]}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`按实际执行顺序记录插件和系统模块对请求的处理`})]}),(0,F.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[t.icon,`最终结果`]}),(0,F.jsx)(`div`,{className:`text-sm font-medium`,children:t.label}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:t.description})]})]})]}),e.stages.length===0?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无处理阶段信息(插件模式可能未开启)`}):(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(ae,{className:`h-3.5 w-3.5`}),(0,F.jsx)(`span`,{children:`默认仅展示改动内容;跳过阶段默认折叠,可单独展开查看更多。`})]}),(0,F.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,F.jsx)($,{title:`请求阶段`,description:`客户端请求进入代理后,按顺序执行请求侧处理阶段`,stages:r,icon:(0,F.jsx)(M,{className:`h-4 w-4 text-blue-500`}),roleLabel:`客户端`,roleIcon:(0,F.jsx)(b,{className:`h-3 w-3 text-blue-500`}),accentClass:`text-blue-500`}),(0,F.jsx)($,{title:`响应阶段`,description:`服务器响应返回代理后,按顺序执行响应侧处理阶段`,stages:i,icon:(0,F.jsx)(y,{className:`h-4 w-4 text-emerald-500`}),roleLabel:`服务器`,roleIcon:(0,F.jsx)(u,{className:`h-3 w-3 text-emerald-500`}),accentClass:`text-emerald-500`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:`请求进入`}),(0,F.jsx)(a,{className:`h-4 w-4 animate-pulse text-blue-500`}),(0,F.jsx)(`span`,{children:`请求阶段`}),(0,F.jsx)(a,{className:`h-4 w-4 animate-pulse text-violet-500`}),(0,F.jsx)(`span`,{children:`响应阶段`}),(0,F.jsx)(a,{className:`h-4 w-4 animate-pulse text-emerald-500`}),(0,F.jsx)(`span`,{children:`最终返回`})]})]})]})}function fe({open:e=!1,onClose:t,embedded:n=!1,detail:i,loading:a,error:o,selectedRecord:s,onCreateMock:c,onReplay:l}){let[u,d]=(0,N.useState)(!1),f=()=>{i&&s&&c&&c({source:s.source,responseBody:i.responseBody,statusCode:i.statusCode,responseHeaders:i.responseHeaders})},[b,C]=(0,N.useState)(null),A=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(E,{className:`px-4 pt-4 pb-2`,children:(0,F.jsxs)(O,{className:`flex items-center gap-2 text-base`,children:[`请求详情`,i&&(0,F.jsxs)(k,{className:`${z(i.statusCode)} border-0`,children:[i.statusCode,` `,i.statusMessage]}),s?.clientType&&(0,F.jsxs)(k,{variant:`outline`,className:`max-w-48 text-[10px] font-mono`,title:[s.clientName,s.clientIp].filter(Boolean).join(` · `),children:[s.clientName||(s.clientType===`local`?`本机`:s.clientType===`plugin`?`插件测试`:`远程设备`),s.clientIp?` · ${s.clientIp}`:``]}),s?.applicationName&&(0,F.jsxs)(k,{variant:`outline`,className:`max-w-56 gap-1.5 text-[10px]`,title:[s.applicationIdentitySource===`local-process`?`识别方式: 本机进程`:s.applicationIdentitySource===`user-agent`?`识别方式: User-Agent 推断`:s.applicationIdentitySource===`client-reported`?`识别方式: 客户端上报`:void 0,s.applicationIdentityConfidence?`可信度: ${s.applicationIdentityConfidence===`high`?`高`:s.applicationIdentityConfidence===`medium`?`中`:`低`}`:void 0,s.applicationProcess,s.applicationPid?`PID ${s.applicationPid}`:void 0,s.applicationBundleId,s.applicationPath].filter(Boolean).join(` · `),children:[(0,F.jsx)(D,{record:s,compact:!0}),(0,F.jsx)(`span`,{className:`truncate`,children:s.applicationName}),s.applicationIdentitySource===`user-agent`&&(0,F.jsx)(`span`,{className:`shrink-0 text-[9px] text-muted-foreground`,children:`推断`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,children:[i&&l&&s?.id!=null&&(0,F.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:async()=>{if(s?.id!=null&&l){d(!0),C(null);try{await l(s.id)}catch(e){C(e.message||`重放失败`)}finally{d(!1)}}},disabled:u,title:`使用相同的请求参数重新发送请求`,children:[(0,F.jsx)(x,{className:`h-3.5 w-3.5 mr-1 ${u?`animate-spin`:``}`}),u?`重放中...`:`重放`]}),i&&c&&!s?.mock&&(0,F.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:f,children:[(0,F.jsx)(p,{className:`h-3.5 w-3.5 mr-1`}),`创建 Mock`]})]})]})}),(0,F.jsx)(w,{}),b&&(0,F.jsx)(`div`,{className:`mx-4 mt-2 px-3 py-2 rounded-md bg-red-50 border border-red-200 text-red-700 text-xs`,children:b}),o&&!a&&!i&&(0,F.jsx)(`div`,{className:`mx-4 mt-2 px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-amber-800 text-xs`,children:o}),a?(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,F.jsx)(T,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):i?(0,F.jsxs)(m,{defaultValue:`request`,className:`flex-1 flex flex-col min-h-0`,children:[(0,F.jsxs)(h,{className:`mx-4 mt-2 w-fit`,children:[(0,F.jsx)(_,{value:`request`,children:`请求`}),(0,F.jsx)(_,{value:`response`,children:`响应`}),(0,F.jsxs)(_,{value:`inspect`,children:[(0,F.jsx)(y,{className:`h-3.5 w-3.5 mr-1`}),`Inspect`]})]}),(0,F.jsx)(v,{value:`request`,className:`flex-1 min-h-0 mt-0`,children:(0,F.jsx)(g,{className:`h-full px-4 pb-4`,children:(0,F.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Request Headers`}),(0,F.jsx)(R,{headers:i.requestHeaders})]}),(0,F.jsx)(w,{}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Request Body`}),(0,F.jsx)(L,{body:i.requestBody})]})]})})}),(0,F.jsx)(v,{value:`response`,className:`flex-1 min-h-0 mt-0`,children:(0,F.jsx)(g,{className:`h-full px-4 pb-4`,children:(0,F.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Response Headers`}),(0,F.jsx)(R,{headers:i.responseHeaders})]}),(0,F.jsx)(w,{}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Response Body`}),(0,F.jsx)(L,{body:i.responseBody})]})]})})}),(0,F.jsx)(v,{value:`inspect`,className:`flex-1 min-h-0 mt-0`,children:(0,F.jsx)(g,{className:`h-full px-4 pb-4`,children:i.inspection?(0,F.jsx)(de,{inspection:i.inspection}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full py-12 text-muted-foreground`,children:[(0,F.jsx)(y,{className:`h-12 w-12 mb-4 opacity-50`}),(0,F.jsx)(`p`,{className:`text-sm`,children:`无 Inspect 信息`}),(0,F.jsx)(`p`,{className:`text-xs mt-1`,children:`需要开启插件模式(on/shadow)才能查看请求生命周期`})]})})})]}):(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm px-6 text-center`,children:s?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`div`,{children:`详情数据暂不可用`}),(0,F.jsxs)(`div`,{className:`text-xs font-mono break-all`,children:[s.method,` `,s.source]})]}):(0,F.jsx)(`div`,{children:`无法加载详情`})})]});return n?(0,F.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:A}):(0,F.jsx)(ee,{open:e,onOpenChange:e=>!e&&t?.(),children:(0,F.jsx)(S,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:640,storageKey:`detail-panel`,children:A})})}export{fe as DetailPanel};