@jonathanleelx/meddle 0.5.0-beta.22 → 0.5.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONFIG_STRUCTURE.md +1 -0
- package/README.md +16 -0
- package/bin/commands/route/active.js +14 -1
- package/bin/commands/route/add.js +27 -30
- package/bin/commands/route/delete.js +31 -30
- package/bin/commands/route/index.js +4 -0
- package/bin/commands/route/list.js +2 -2
- package/bin/commands/route/show.js +10 -1
- package/bin/commands/route/update.js +32 -30
- package/bin/lib/api-client.js +14 -2
- package/bin/lib/file-access.js +39 -1
- package/bin/lib/rule-file-edit.js +263 -0
- package/bin/lib/ruleset-readonly.js +61 -0
- package/dist/core/mock-handler.d.ts +0 -6
- package/dist/core/mock-handler.d.ts.map +1 -1
- package/dist/core/mock-handler.js +101 -11
- package/dist/core/mock-handler.js.map +1 -1
- package/dist/core/rule-file-edit.d.ts +81 -0
- package/dist/core/rule-file-edit.d.ts.map +1 -0
- package/dist/core/rule-file-edit.js +243 -0
- package/dist/core/rule-file-edit.js.map +1 -0
- package/dist/core/static-server.d.ts.map +1 -1
- package/dist/core/static-server.js +15 -13
- package/dist/core/static-server.js.map +1 -1
- package/dist/server/agent/tools.d.ts.map +1 -1
- package/dist/server/agent/tools.js +18 -17
- package/dist/server/agent/tools.js.map +1 -1
- package/dist/server/app-info.d.ts +14 -0
- package/dist/server/app-info.d.ts.map +1 -1
- package/dist/server/app-info.js +33 -1
- package/dist/server/app-info.js.map +1 -1
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js +51 -9
- package/dist/server/config.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/rule-files.d.ts +23 -0
- package/dist/server/rule-files.d.ts.map +1 -1
- package/dist/server/rule-files.js +169 -81
- package/dist/server/rule-files.js.map +1 -1
- package/dist/server/ruleset-lock.d.ts +62 -0
- package/dist/server/ruleset-lock.d.ts.map +1 -0
- package/dist/server/ruleset-lock.js +234 -0
- package/dist/server/ruleset-lock.js.map +1 -0
- package/mcp-server.js +87 -88
- package/package.json +1 -1
- package/web/dist/assets/{checkbox-v2kzp7K8.js → checkbox-CQyFsZzS.js} +1 -1
- package/web/dist/assets/detail-panel-D56nCma2.js +4 -0
- package/web/dist/assets/dist-BQN0rzUS.js +1 -0
- package/web/dist/assets/dist-DLQKRjuW.js +5 -0
- package/web/dist/assets/es2015-DPJTBYa9.js +41 -0
- package/web/dist/assets/{global-panel-shell-D32I98dR.js → global-panel-shell-SKPshqTf.js} +2 -2
- package/web/dist/assets/health-panel-CvI-VsvG.js +1 -0
- package/web/dist/assets/index-C6dPxxT3.css +2 -0
- package/web/dist/assets/index-Dcm171u1.js +21 -0
- package/web/dist/assets/mobile-proxy-panel-cpkvsdBT.js +8 -0
- package/web/dist/assets/mock-config-CtZ866iI.js +1 -0
- package/web/dist/assets/mock-editor-panel-CweYBdeM.js +20 -0
- package/web/dist/assets/{mocks-file-missing-note-DmrrCBYY.js → mocks-file-missing-note-C-QJ8Bpm.js} +1 -1
- package/web/dist/assets/{monaco-editor-6oLiu4W6.js → monaco-editor-Cge8h-Ca.js} +2 -2
- package/web/dist/assets/pane-bar-Dvi-MHuB.js +1 -0
- package/web/dist/assets/{pane-split-DYB05onX.js → pane-split-ChCHxR7K.js} +1 -1
- package/web/dist/assets/panel-heading-Crmy9fo0.js +1 -0
- package/web/dist/assets/plugin-code-editor-VaL2lVyD.js +2 -0
- package/web/dist/assets/plugin-config-DSiOk77l.js +2 -0
- package/web/dist/assets/{plugin-generator-Ba4hP5rg.js → plugin-generator-iAksMY2Q.js} +2 -2
- package/web/dist/assets/plugin-test-dialog-Cx6ifDnm.js +7 -0
- package/web/dist/assets/route-preview-T0s6si4V.js +1 -0
- package/web/dist/assets/{rule-ai-assistant-panel-CQTsZMJu.js → rule-ai-assistant-panel-DzfobTWM.js} +2 -2
- package/web/dist/assets/rule-config-ESpfkJg6.js +15 -0
- package/web/dist/assets/{rule-overview-panel-CmWdMs4I.js → rule-overview-panel-BswSByar.js} +1 -1
- package/web/dist/assets/settings-panel-Cj-1Z8Ow.js +1 -0
- package/web/dist/assets/{switch-DpLnRvOJ.js → switch-94vgsMHm.js} +1 -1
- package/web/dist/assets/toast-9yeTf7d9.js +1 -0
- package/web/dist/assets/use-mocks-file-status-BUIUJ4oQ.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/assets/detail-panel-DK7pM43g.js +0 -4
- package/web/dist/assets/dist-BNcjMpca.js +0 -1
- package/web/dist/assets/dist-DD7AvbXP.js +0 -1
- package/web/dist/assets/dist-UcOFuoN0.js +0 -5
- package/web/dist/assets/es2015-CRmLuA2o.js +0 -41
- package/web/dist/assets/health-panel-Dw7qdFVS.js +0 -1
- package/web/dist/assets/index-CYUNdxqh.css +0 -2
- package/web/dist/assets/index-CkoYwomI.js +0 -18
- package/web/dist/assets/mobile-proxy-panel-DtiDkpAa.js +0 -8
- package/web/dist/assets/mock-config-C3jSpNNu.js +0 -1
- package/web/dist/assets/mock-editor-panel-ByCYWJjO.js +0 -20
- package/web/dist/assets/panel-heading-BS8loc49.js +0 -1
- package/web/dist/assets/plugin-code-editor-DGzCBEpg.js +0 -2
- package/web/dist/assets/plugin-config-NVw234EF.js +0 -2
- package/web/dist/assets/plugin-test-dialog-B4ojc2_9.js +0 -7
- package/web/dist/assets/route-preview-BspvfNdW.js +0 -1
- package/web/dist/assets/rule-config-DDOeMRXa.js +0 -15
- package/web/dist/assets/settings-panel-aB0ojA9D.js +0 -1
- /package/web/dist/assets/{ai-config-store-B_VpGvwx.js → ai-config-store-C8D_PUGV.js} +0 -0
- /package/web/dist/assets/{alert-BmsRCcSL.js → alert-B514Frte.js} +0 -0
- /package/web/dist/assets/{babel-D1quDdNt.js → babel-bwZm0qi3.js} +0 -0
- /package/web/dist/assets/{body-diff-view-ByCHr9bv.js → body-diff-view-SfLCLzs9.js} +0 -0
- /package/web/dist/assets/{clipboard-DUgC_tNv.js → clipboard-Bt1qY01V.js} +0 -0
- /package/web/dist/assets/{dist-Bq2klZ3g.js → dist-Bsv9ad5F.js} +0 -0
- /package/web/dist/assets/{dist-BCvvYbmI.js → dist-fzPL-8F9.js} +0 -0
- /package/web/dist/assets/{dist-YM3jbhT-.js → dist-wv9ebJK_.js} +0 -0
- /package/web/dist/assets/{editor-pane-actions-DN-pxFsl.js → editor-pane-actions-_ckwcCII.js} +0 -0
- /package/web/dist/assets/{estree--Vq99DGn.js → estree-MatbZDwq.js} +0 -0
- /package/web/dist/assets/{html-D2PZBPnP.js → html-CCrsbFYX.js} +0 -0
- /package/web/dist/assets/{postcss-DfIslWug.js → postcss-BxN7Gr8n.js} +0 -0
- /package/web/dist/assets/{standalone-D-fjaAIs.js → standalone-DsnFnsqM.js} +0 -0
- /package/web/dist/assets/{syntax-highlight-EJCxGikd.js → syntax-highlight-BFgN_C0Y.js} +0 -0
- /package/web/dist/assets/{table-C3mgEjkP.js → table-DaXD6jJv.js} +0 -0
- /package/web/dist/assets/{textarea-BjWF0pk4.js → textarea-9wB8Hsz-.js} +0 -0
- /package/web/dist/assets/{wand-sparkles-DDGjzjnX.js → wand-sparkles-Bmt4dDOf.js} +0 -0
- /package/web/dist/assets/{wifi-QkTcTrED.js → wifi-Cjj_Br1u.js} +0 -0
- /package/web/dist/assets/{zap-CEVoVkAg.js → zap-BuOtogAv.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,d as t,p as n,t as r}from"./button-BFNlGZ5p.js";import"./dist-CFZ4xMSF.js";import{t as i}from"./refresh-cw-BfLoHqg5.js";import{t as a}from"./table-2-DvGHhMm4.js";import{G as o,H as s,J as c,K as l,U as u,W as d,at as f,bt as p,ft as m,h,it as g,kt as ee,nt as _,q as v,rt as y,tt as te,wt as b}from"./index-CkoYwomI.js";import{a as x,i as S,n as C,o as w,r as T,t as E}from"./table-C3mgEjkP.js";var D=n(t(),1),O=e(),k=`border-l-2 border-l-transparent`,A=`text-muted-foreground opacity-75`;function j(e){return e.length>0?e.map(e=>`!${e}`).join(` `):`—`}function M({rules:e,activeFileName:t,onLocateRule:n,onSelectFile:M}){let[N,ne]=(0,D.useState)(null),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(`merged`),[B,V]=(0,D.useState)(``),H=(0,D.useDeferredValue)(B),U=(0,D.useCallback)(async()=>{F(!0),L(null);try{let e=await fetch(`/api/rule-files/overview`);if(!e.ok)throw Error(`加载失败(${e.status})`);ne(await e.json())}catch(e){L(e instanceof Error?e.message:`加载失败`)}finally{F(!1)}},[]);(0,D.useEffect)(()=>{U()},[U]);let W=(0,D.useMemo)(()=>N?.perFileRules.find(e=>e.name===t)??null,[N,t]),G=(0,D.useMemo)(()=>{if(!W||W.error)return!1;let t=W.rules.map(e=>({rule:e.rawRule,target:e.rawTarget,enabled:e.enabled,exclusions:e.exclusions}));return h(e)!==h(t)},[W,e]),K=(0,D.useMemo)(()=>{let e=new Map;for(let t of N?.conflicts??[])e.set(t.pattern,t);return e},[N]),q=(0,D.useCallback)(e=>{let t=H.trim().toLowerCase();return t?e.some(e=>e&&e.toLowerCase().includes(t)):!0},[H]),J=(0,D.useMemo)(()=>(N?.mergedRules??[]).map(e=>({winner:e,shadowed:K.get(e.pattern)?.shadowed??[]})).filter(({winner:e,shadowed:t})=>q([e.rawRule,e.rawTarget,e.file])||t.some(e=>q([e.rawRule,e.rawTarget,e.file]))),[N,K,q]),Y=N?.mergedRules.length??0,X=N?.conflicts.reduce((e,t)=>e+t.shadowed.length,0)??0,Z=(0,D.useMemo)(()=>(N?.perFileRules??[]).map(e=>({...e,matched:e.rules.filter(t=>q([t.rawRule,t.rawTarget,e.name]))})).filter(e=>e.error!=null||q([e.name])||e.matched.length>0),[N,q]),re=N?.perFileRules.reduce((e,t)=>e+t.rules.length,0)??0,ie=Z.reduce((e,t)=>e+t.matched.length,0),Q=(0,D.useCallback)((e,t,r)=>{n(e,t,r)},[n]),ae=(0,D.useCallback)((e,t)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M(t))},[M]),oe=()=>{if(P)return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-2`,children:[(0,O.jsx)(f,{className:`h-8 w-full`}),(0,O.jsx)(f,{className:`h-8 w-full`}),(0,O.jsx)(f,{className:`h-8 w-3/4`})]});if(I)return(0,O.jsxs)(u,{className:`min-h-0 flex-1`,children:[(0,O.jsxs)(l,{children:[(0,O.jsx)(v,{variant:`icon`,children:(0,O.jsx)(m,{})}),(0,O.jsx)(c,{children:`加载失败`}),(0,O.jsx)(o,{children:I})]}),(0,O.jsx)(d,{children:(0,O.jsxs)(r,{variant:`outline`,onClick:()=>void U(),children:[(0,O.jsx)(i,{"data-icon":`inline-start`}),`重试`]})})]});let e=(N?.files.length??0)>0,t=N?.perFileRules.some(e=>e.rules.length>0||e.error!=null)??!1,n=H.trim().length>0;return e?t?R===`merged`&&!n&&(N?.mergedRules.length??0)===0?(0,O.jsx)(u,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(l,{children:[(0,O.jsx)(v,{variant:`icon`,children:(0,O.jsx)(b,{})}),(0,O.jsx)(c,{children:`没有生效中的规则`}),(0,O.jsx)(o,{children:`规则全部被禁用,或没有启用任何规则文件;切换到「按文件」查看全部规则`})]})}):n&&R===`merged`&&J.length===0||n&&R===`files`&&Z.every(e=>e.matched.length===0&&e.error==null)?$():R===`merged`?se():ce():(0,O.jsx)(u,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(l,{children:[(0,O.jsx)(v,{variant:`icon`,children:(0,O.jsx)(ee,{})}),(0,O.jsx)(c,{children:`所有规则文件都是空的`}),(0,O.jsx)(o,{children:`还没有任何路由规则,先去路由规则页添加一条吧`})]})}):(0,O.jsx)(u,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(l,{children:[(0,O.jsx)(v,{variant:`icon`,children:(0,O.jsx)(a,{})}),(0,O.jsx)(c,{children:`还没有规则文件`}),(0,O.jsx)(o,{children:`在路由规则页点击「+」创建第一个规则文件`})]})})},$=()=>(0,O.jsxs)(u,{className:`min-h-0 flex-1`,children:[(0,O.jsxs)(l,{children:[(0,O.jsx)(v,{variant:`icon`,children:(0,O.jsx)(p,{})}),(0,O.jsx)(c,{children:`无匹配结果`}),(0,O.jsxs)(o,{children:[`没有找到符合「`,H.trim(),`」的规则`]})]}),(0,O.jsx)(d,{children:(0,O.jsx)(r,{variant:`outline`,onClick:()=>V(``),children:`清空筛选`})})]}),se=()=>(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border`,children:[(0,O.jsx)(`div`,{className:`meddle-thin-scroll shrink-0 overflow-x-auto bg-card`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`6rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(x,{children:(0,O.jsxs)(w,{children:[(0,O.jsx)(S,{children:`来源`}),(0,O.jsx)(S,{children:`规则`}),(0,O.jsx)(S,{className:`hidden md:table-cell`,children:`排除`}),(0,O.jsx)(S,{children:`目标`})]})})]})}),(0,O.jsx)(s,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`6rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(C,{children:J.map(({winner:e,shadowed:t})=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsxs)(w,{className:`${k} cursor-pointer`,onClick:()=>Q(e.file,e.rawRule,e.rawTarget),title:`点击定位到该规则`,children:[(0,O.jsx)(T,{className:`truncate text-xs text-muted-foreground`,children:e.file}),(0,O.jsxs)(T,{className:`break-all font-mono text-xs`,children:[e.rawRule,t.length>0&&(0,O.jsx)(y,{variant:`default`,className:`ml-2 px-1 py-0 text-[10px]`,title:`同名规则最终生效的定义`,children:`生效`})]}),(0,O.jsx)(T,{className:`hidden break-all font-mono text-xs text-muted-foreground md:table-cell`,children:j(e.exclusions)}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:e.rawTarget})]}),t.map((t,n)=>(0,O.jsxs)(w,{className:`${k} cursor-pointer ${A}`,onClick:()=>Q(t.file,t.rawRule,t.rawTarget),title:`点击定位到该规则`,children:[(0,O.jsx)(T,{className:`truncate text-xs`,children:t.file}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:(0,O.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[t.rawRule,(0,O.jsx)(y,{variant:`destructive`,className:`px-1 py-0 text-[10px]`,title:`已被 ${e.file} 中的同名规则覆盖,实际不生效`,children:`已被覆盖`})]})}),(0,O.jsx)(T,{className:`hidden break-all font-mono text-xs md:table-cell`,children:`—`}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:t.rawTarget})]},`merged-shadowed-${n}`))]},`merged-group-${e.pattern}`))})]})})]}),ce=()=>(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border`,children:[(0,O.jsx)(`div`,{className:`meddle-thin-scroll shrink-0 overflow-x-auto bg-card`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`3.5rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(x,{children:(0,O.jsxs)(w,{children:[(0,O.jsx)(S,{children:`状态`}),(0,O.jsx)(S,{children:`规则`}),(0,O.jsx)(S,{className:`hidden md:table-cell`,children:`排除`}),(0,O.jsx)(S,{children:`目标`})]})})]})}),(0,O.jsx)(s,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`3.5rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(C,{children:Z.map(e=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsx)(w,{className:`hover:bg-accent/60`,children:(0,O.jsx)(T,{colSpan:4,className:`cursor-pointer bg-muted/50 p-2 align-middle`,role:`button`,tabIndex:0,onClick:()=>M(e.name),onKeyDown:t=>ae(t,e.name),title:`点击切换到该规则文件`,children:(0,O.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 font-medium`,children:[e.name,(0,O.jsx)(y,{variant:e.enabled?`default`:`secondary`,className:`px-1 py-0 text-[10px]`,children:e.enabled?`启用`:`禁用`}),(0,O.jsx)(y,{variant:`secondary`,className:`px-1 py-0 text-[10px]`,children:e.rules.length})]})})}),e.error&&(0,O.jsx)(w,{className:`text-destructive`,children:(0,O.jsx)(T,{colSpan:4,className:`p-2 text-xs`,children:(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{className:`h-3.5 w-3.5 shrink-0`}),`读取失败:`,e.error]})})}),e.matched.map((t,n)=>(0,O.jsxs)(w,{className:`cursor-pointer ${t.enabled?``:`opacity-60`}`,onClick:()=>Q(e.name,t.rawRule,t.rawTarget),title:`点击定位到该规则`,children:[(0,O.jsx)(T,{children:(0,O.jsx)(y,{variant:t.enabled?`default`:`secondary`,className:`px-1 py-0 text-[10px]`,children:t.enabled?`启用`:`禁用`})}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:t.rawRule}),(0,O.jsx)(T,{className:`hidden break-all font-mono text-xs text-muted-foreground md:table-cell`,children:j(t.exclusions)}),(0,O.jsx)(T,{className:`break-all font-mono text-xs ${t.enabled?``:`line-through`}`,children:t.rawTarget})]},`file-rule-${n}`))]},`file-group-${e.name}`))})]})})]}),le=R===`merged`?Y+X:re,ue=R===`merged`?J.reduce((e,t)=>e+1+t.shadowed.length,0):ie;return(0,O.jsxs)(`div`,{className:`app-panel-content flex h-full flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(te,{type:`single`,value:R,onValueChange:e=>{e&&z(e)},variant:`outline`,size:`sm`,className:`bg-background`,"aria-label":`总览视图`,children:[(0,O.jsx)(_,{value:`merged`,children:`生效规则`}),(0,O.jsx)(_,{value:`files`,children:`按文件`})]}),(0,O.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,O.jsx)(p,{className:`pointer-events-none absolute top-1/2 left-2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,O.jsx)(g,{value:B,onChange:e=>V(e.target.value),placeholder:`搜索规则 / 目标 / 文件名`,className:`h-8 pl-8`,"aria-label":`搜索规则`})]}),(0,O.jsx)(r,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>void U(),disabled:P,"aria-label":`刷新总览`,title:`刷新`,children:(0,O.jsx)(i,{})})]}),G&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:[(0,O.jsx)(m,{className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsxs)(`span`,{children:[`「`,t,`」有未保存修改,此处展示的是代理当前使用的`,(0,O.jsx)(`b`,{children:`已保存内容`})]})]}),!P&&!I&&(N?.files.length??0)>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[ue,` / `,le,` 条`,R===`merged`&&H.trim()===``&&X>0?`,其中 ${X} 条被同名规则覆盖`:``]}),R===`merged`&&(0,O.jsx)(`span`,{children:`按代理实际生效顺序排列(后定义覆盖先定义)`}),R===`files`&&(0,O.jsx)(`span`,{children:`点击文件名切换到该文件`})]}),oe()]})}export{M as RuleOverviewPanel};
|
|
1
|
+
import{c as e,d as t,p as n,t as r}from"./button-BFNlGZ5p.js";import"./dist-CFZ4xMSF.js";import{t as i}from"./refresh-cw-BfLoHqg5.js";import{t as ee}from"./table-2-DvGHhMm4.js";import{$ as a,B as o,H as s,I as c,L as l,Q as u,R as d,St as f,V as p,X as m,Y as te,Z as h,_t as g,l as _,ot as v,pt as y,z as b}from"./index-Dcm171u1.js";import{a as x,i as S,n as C,o as w,r as T,t as E}from"./table-DaXD6jJv.js";var D=n(t(),1),O=e(),k=`border-l-2 border-l-transparent`,A=`text-muted-foreground opacity-75`;function j(e){return e.length>0?e.map(e=>`!${e}`).join(` `):`—`}function M({rules:e,activeFileName:t,onLocateRule:n,onSelectFile:M}){let[N,ne]=(0,D.useState)(null),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(`merged`),[B,V]=(0,D.useState)(``),H=(0,D.useDeferredValue)(B),U=(0,D.useCallback)(async()=>{F(!0),L(null);try{let e=await fetch(`/api/rule-files/overview`);if(!e.ok)throw Error(`加载失败(${e.status})`);ne(await e.json())}catch(e){L(e instanceof Error?e.message:`加载失败`)}finally{F(!1)}},[]);(0,D.useEffect)(()=>{U()},[U]);let W=(0,D.useMemo)(()=>N?.perFileRules.find(e=>e.name===t)??null,[N,t]),G=(0,D.useMemo)(()=>{if(!W||W.error)return!1;let t=W.rules.map(e=>({rule:e.rawRule,target:e.rawTarget,enabled:e.enabled,exclusions:e.exclusions}));return _(e)!==_(t)},[W,e]),K=(0,D.useMemo)(()=>{let e=new Map;for(let t of N?.conflicts??[])e.set(t.pattern,t);return e},[N]),q=(0,D.useCallback)(e=>{let t=H.trim().toLowerCase();return t?e.some(e=>e&&e.toLowerCase().includes(t)):!0},[H]),J=(0,D.useMemo)(()=>(N?.mergedRules??[]).map(e=>({winner:e,shadowed:K.get(e.pattern)?.shadowed??[]})).filter(({winner:e,shadowed:t})=>q([e.rawRule,e.rawTarget,e.file])||t.some(e=>q([e.rawRule,e.rawTarget,e.file]))),[N,K,q]),Y=N?.mergedRules.length??0,X=N?.conflicts.reduce((e,t)=>e+t.shadowed.length,0)??0,Z=(0,D.useMemo)(()=>(N?.perFileRules??[]).map(e=>({...e,matched:e.rules.filter(t=>q([t.rawRule,t.rawTarget,e.name]))})).filter(e=>e.error!=null||q([e.name])||e.matched.length>0),[N,q]),re=N?.perFileRules.reduce((e,t)=>e+t.rules.length,0)??0,ie=Z.reduce((e,t)=>e+t.matched.length,0),Q=(0,D.useCallback)((e,t,r)=>{n(e,t,r)},[n]),ae=(0,D.useCallback)((e,t)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M(t))},[M]),oe=()=>{if(P)return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-2`,children:[(0,O.jsx)(a,{className:`h-8 w-full`}),(0,O.jsx)(a,{className:`h-8 w-full`}),(0,O.jsx)(a,{className:`h-8 w-3/4`})]});if(I)return(0,O.jsxs)(l,{className:`min-h-0 flex-1`,children:[(0,O.jsxs)(o,{children:[(0,O.jsx)(p,{variant:`icon`,children:(0,O.jsx)(v,{})}),(0,O.jsx)(s,{children:`加载失败`}),(0,O.jsx)(b,{children:I})]}),(0,O.jsx)(d,{children:(0,O.jsxs)(r,{variant:`outline`,onClick:()=>void U(),children:[(0,O.jsx)(i,{"data-icon":`inline-start`}),`重试`]})})]});let e=(N?.files.length??0)>0,t=N?.perFileRules.some(e=>e.rules.length>0||e.error!=null)??!1,n=H.trim().length>0;return e?t?R===`merged`&&!n&&(N?.mergedRules.length??0)===0?(0,O.jsx)(l,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(o,{children:[(0,O.jsx)(p,{variant:`icon`,children:(0,O.jsx)(g,{})}),(0,O.jsx)(s,{children:`没有生效中的规则`}),(0,O.jsx)(b,{children:`规则全部被禁用,或没有启用任何规则文件;切换到「按文件」查看全部规则`})]})}):n&&R===`merged`&&J.length===0||n&&R===`files`&&Z.every(e=>e.matched.length===0&&e.error==null)?$():R===`merged`?se():ce():(0,O.jsx)(l,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(o,{children:[(0,O.jsx)(p,{variant:`icon`,children:(0,O.jsx)(f,{})}),(0,O.jsx)(s,{children:`所有规则文件都是空的`}),(0,O.jsx)(b,{children:`还没有任何路由规则,先去路由规则页添加一条吧`})]})}):(0,O.jsx)(l,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(o,{children:[(0,O.jsx)(p,{variant:`icon`,children:(0,O.jsx)(ee,{})}),(0,O.jsx)(s,{children:`还没有规则文件`}),(0,O.jsx)(b,{children:`在路由规则页点击「+」创建第一个规则文件`})]})})},$=()=>(0,O.jsxs)(l,{className:`min-h-0 flex-1`,children:[(0,O.jsxs)(o,{children:[(0,O.jsx)(p,{variant:`icon`,children:(0,O.jsx)(y,{})}),(0,O.jsx)(s,{children:`无匹配结果`}),(0,O.jsxs)(b,{children:[`没有找到符合「`,H.trim(),`」的规则`]})]}),(0,O.jsx)(d,{children:(0,O.jsx)(r,{variant:`outline`,onClick:()=>V(``),children:`清空筛选`})})]}),se=()=>(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border`,children:[(0,O.jsx)(`div`,{className:`meddle-thin-scroll shrink-0 overflow-x-auto bg-card`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`6rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(x,{children:(0,O.jsxs)(w,{children:[(0,O.jsx)(S,{children:`来源`}),(0,O.jsx)(S,{children:`规则`}),(0,O.jsx)(S,{className:`hidden md:table-cell`,children:`排除`}),(0,O.jsx)(S,{children:`目标`})]})})]})}),(0,O.jsx)(c,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`6rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(C,{children:J.map(({winner:e,shadowed:t})=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsxs)(w,{className:`${k} cursor-pointer`,onClick:()=>Q(e.file,e.rawRule,e.rawTarget),title:`点击定位到该规则`,children:[(0,O.jsx)(T,{className:`truncate text-xs text-muted-foreground`,children:e.file}),(0,O.jsxs)(T,{className:`break-all font-mono text-xs`,children:[e.rawRule,t.length>0&&(0,O.jsx)(h,{variant:`default`,className:`ml-2 px-1 py-0 text-[10px]`,title:`同名规则最终生效的定义`,children:`生效`})]}),(0,O.jsx)(T,{className:`hidden break-all font-mono text-xs text-muted-foreground md:table-cell`,children:j(e.exclusions)}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:e.rawTarget})]}),t.map((t,n)=>(0,O.jsxs)(w,{className:`${k} cursor-pointer ${A}`,onClick:()=>Q(t.file,t.rawRule,t.rawTarget),title:`点击定位到该规则`,children:[(0,O.jsx)(T,{className:`truncate text-xs`,children:t.file}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:(0,O.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[t.rawRule,(0,O.jsx)(h,{variant:`destructive`,className:`px-1 py-0 text-[10px]`,title:`已被 ${e.file} 中的同名规则覆盖,实际不生效`,children:`已被覆盖`})]})}),(0,O.jsx)(T,{className:`hidden break-all font-mono text-xs md:table-cell`,children:`—`}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:t.rawTarget})]},`merged-shadowed-${n}`))]},`merged-group-${e.pattern}`))})]})})]}),ce=()=>(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border`,children:[(0,O.jsx)(`div`,{className:`meddle-thin-scroll shrink-0 overflow-x-auto bg-card`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`3.5rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(x,{children:(0,O.jsxs)(w,{children:[(0,O.jsx)(S,{children:`状态`}),(0,O.jsx)(S,{children:`规则`}),(0,O.jsx)(S,{className:`hidden md:table-cell`,children:`排除`}),(0,O.jsx)(S,{children:`目标`})]})})]})}),(0,O.jsx)(c,{className:`min-h-0 flex-1`,children:(0,O.jsxs)(E,{className:`table-fixed`,children:[(0,O.jsxs)(`colgroup`,{children:[(0,O.jsx)(`col`,{style:{width:`3.5rem`}}),(0,O.jsx)(`col`,{}),(0,O.jsx)(`col`,{style:{width:`8rem`}}),(0,O.jsx)(`col`,{})]}),(0,O.jsx)(C,{children:Z.map(e=>(0,O.jsxs)(D.Fragment,{children:[(0,O.jsx)(w,{className:`hover:bg-accent/60`,children:(0,O.jsx)(T,{colSpan:4,className:`cursor-pointer bg-muted/50 p-2 align-middle`,role:`button`,tabIndex:0,onClick:()=>M(e.name),onKeyDown:t=>ae(t,e.name),title:`点击切换到该规则文件`,children:(0,O.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 font-medium`,children:[e.name,(0,O.jsx)(h,{variant:e.enabled?`default`:`secondary`,className:`px-1 py-0 text-[10px]`,children:e.enabled?`启用`:`禁用`}),(0,O.jsx)(h,{variant:`secondary`,className:`px-1 py-0 text-[10px]`,children:e.rules.length})]})})}),e.error&&(0,O.jsx)(w,{className:`text-destructive`,children:(0,O.jsx)(T,{colSpan:4,className:`p-2 text-xs`,children:(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),`读取失败:`,e.error]})})}),e.matched.map((t,n)=>(0,O.jsxs)(w,{className:`cursor-pointer ${t.enabled?``:`opacity-60`}`,onClick:()=>Q(e.name,t.rawRule,t.rawTarget),title:`点击定位到该规则`,children:[(0,O.jsx)(T,{children:(0,O.jsx)(h,{variant:t.enabled?`default`:`secondary`,className:`px-1 py-0 text-[10px]`,children:t.enabled?`启用`:`禁用`})}),(0,O.jsx)(T,{className:`break-all font-mono text-xs`,children:t.rawRule}),(0,O.jsx)(T,{className:`hidden break-all font-mono text-xs text-muted-foreground md:table-cell`,children:j(t.exclusions)}),(0,O.jsx)(T,{className:`break-all font-mono text-xs ${t.enabled?``:`line-through`}`,children:t.rawTarget})]},`file-rule-${n}`))]},`file-group-${e.name}`))})]})})]}),le=R===`merged`?Y+X:re,ue=R===`merged`?J.reduce((e,t)=>e+1+t.shadowed.length,0):ie;return(0,O.jsxs)(`div`,{className:`app-panel-content flex h-full flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(te,{type:`single`,value:R,onValueChange:e=>{e&&z(e)},variant:`outline`,size:`sm`,className:`bg-background`,"aria-label":`总览视图`,children:[(0,O.jsx)(m,{value:`merged`,children:`生效规则`}),(0,O.jsx)(m,{value:`files`,children:`按文件`})]}),(0,O.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,O.jsx)(y,{className:`pointer-events-none absolute top-1/2 left-2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,O.jsx)(u,{value:B,onChange:e=>V(e.target.value),placeholder:`搜索规则 / 目标 / 文件名`,className:`h-8 pl-8`,"aria-label":`搜索规则`})]}),(0,O.jsx)(r,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>void U(),disabled:P,"aria-label":`刷新总览`,title:`刷新`,children:(0,O.jsx)(i,{})})]}),G&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:[(0,O.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),(0,O.jsxs)(`span`,{children:[`「`,t,`」有未保存修改,此处展示的是代理当前使用的`,(0,O.jsx)(`b`,{children:`已保存内容`})]})]}),!P&&!I&&(N?.files.length??0)>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[ue,` / `,le,` 条`,R===`merged`&&H.trim()===``&&X>0?`,其中 ${X} 条被同名规则覆盖`:``]}),R===`merged`&&(0,O.jsx)(`span`,{children:`按代理实际生效顺序排列(后定义覆盖先定义)`}),R===`files`&&(0,O.jsx)(`span`,{children:`点击文件名切换到该文件`})]}),oe()]})}export{M as RuleOverviewPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,d as t,p as n,t as r,u as i}from"./button-BFNlGZ5p.js";import"./dist-CFZ4xMSF.js";import{t as ee}from"./check-BkfHQ6re.js";import{t as a}from"./circle-alert-zMagrFuI.js";import{t as o}from"./circle-x-BEkinhez.js";import{t as s}from"./plus-ixZQRprm.js";import{t as te}from"./refresh-cw-BfLoHqg5.js";import{t as ne}from"./rotate-ccw-CRguJya4.js";import{t as re}from"./smartphone-D4Q7cQfm.js";import{c as ie}from"./dist-BQN0rzUS.js";import"./es2015-DPJTBYa9.js";import{t as ae}from"./switch-94vgsMHm.js";import{a as c,c as oe,l as se,n as ce,o as l,r as u,s as le,t as ue}from"./ai-config-store-C8D_PUGV.js";import{n as d}from"./toast-9yeTf7d9.js";import{a as de,i as fe,n as pe,o as me,r as he}from"./use-mocks-file-status-BUIUJ4oQ.js";import{A as f,C as ge,Et as p,G as _e,J as ve,K as m,M as h,Q as g,S as ye,T as _,U as be,W as xe,X as v,Y as y,Z as Se,_ as Ce,b as we,bt as Te,d as Ee,dt as De,f as Oe,ft as ke,g as Ae,h as je,j as Me,k as Ne,kt as b,lt as Pe,m as x,mt as Fe,p as Ie,q as Le,w as Re,x as ze,y as S,yt as Be}from"./index-Dcm171u1.js";import{n as Ve,r as He,t as Ue}from"./alert-B514Frte.js";import{n as We}from"./pane-bar-Dvi-MHuB.js";import{i as Ge,o as Ke,r as qe,t as Je}from"./mocks-file-missing-note-C-QJ8Bpm.js";var Ye=i(`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`}]]),Xe=i(`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`}]]),Ze=i(`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`}]]),C=n(t(),1),w={version:null,routeRulesDir:null,routeRulesDirDisplay:null};function T(e){return typeof e==`string`&&e.trim()||null}function Qe(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...w};let t=e;return{version:T(t.version),routeRulesDir:T(t.routeRulesDir),routeRulesDirDisplay:T(t.routeRulesDirDisplay)}}async function $e(){try{let e=await fetch(`/api/version`);return e.ok?Qe(await e.json()):{...w}}catch{return{...w}}}var E=e(),et=[{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}],tt=[{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)`}],D=`app-panel-content mt-0`,O=`app-field-group`,k=`app-section`,nt=`$MEDDLE_HOME/route-rules/`,A=e=>{if(!e)return`100`;let t={small:`90`,medium:`100`,large:`110`};return e in t?t[e]:et.some(t=>t.value===e)?e:`100`};function j({open:e=!1,onOpenChange:t,embedded:n=!1}){let{theme:i,accentColor:w,setTheme:T,setAccentColor:Qe,setZoom:j}=Ee(),[M,rt]=(0,C.useState)(`preferences`),[N,P]=(0,C.useState)(()=>u()),[F,it]=(0,C.useState)(!1),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[at,B]=(0,C.useState)(``),[V,H]=(0,C.useState)(null),[U,W]=(0,C.useState)(``),{status:G,refresh:K}=me(),[ot,st]=(0,C.useState)([]),[q,J]=(0,C.useState)({}),[Y,ct]=(0,C.useState)(``),[X,lt]=(0,C.useState)(``),[Z,ut]=(0,C.useState)(null),[dt,ft]=(0,C.useState)(!1),[pt,mt]=(0,C.useState)(null),[ht,gt]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return $e().then(t=>{if(e)return;mt(t.version);let n=t.routeRulesDirDisplay||t.routeRulesDir;n&>({display:n,path:t.routeRulesDir})}),()=>{e=!0}},[]);let _t=ht?.display??nt,[Q,vt]=(0,C.useState)(()=>A(Oe().fontSize)),[yt,bt]=(0,C.useState)(!1);(0,C.useEffect)(()=>{Ie().then(e=>{let t=A(e.fontSize);vt(t),j(parseInt(t,10)/100),bt(!0)}).catch(()=>{bt(!0)})},[j]),(0,C.useEffect)(()=>{if(!yt)return;let e=A(Q);j(parseInt(e,10)/100),x({fontSize:e}).catch(console.error)},[j,yt,Q]),(0,C.useEffect)(()=>{(e||n)&&(Ie().then(e=>{P(e.aiConfig),W(e.mocksFilePath||``),J(e.clientAliases||{})}).catch(()=>{P(u())}),z(null),B(``),fetch(`/api/rule-files`).then(e=>e.json()).then(e=>{Array.isArray(e)&&st(e)}).catch(()=>{}))},[e,n]);let xt=e=>{let t=c(e);P({...N,provider:e,baseUrl:t.baseUrl,model:t.model})},$=async()=>{L(!0);try{await x({aiConfig:N}),oe(N),z(`success`),B(`AI 配置保存成功`),d.success(`AI 配置保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;z(`error`),B(t),d.error(t)}finally{L(!1)}},St=()=>{le(),P(u()),z(null),B(``)},Ct=async()=>{if(!l(N)){z(`error`),B(`请填写完整的配置信息`);return}L(!0),z(null),B(`测试中…`);try{let e=N.baseUrl,t={"Content-Type":`application/json`},n;N.provider===`anthropic`?(t[`x-api-key`]=N.apiKey,t[`anthropic-version`]=`2023-06-01`,n={model:N.model,max_tokens:100,system:`You are a helpful assistant.`,messages:[{role:`user`,content:`Say "test successful"`}],temperature:.3}):(t.Authorization=`Bearer ${N.apiKey}`,n={model:N.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(N.provider===`anthropic`){if(!i.content?.[0]?.text)throw Error(`API响应格式不正确`)}else if(!i.choices?.[0]?.message?.content)throw Error(`API响应格式不正确`);z(`success`),B(`连接测试成功! API配置正常`)}catch(e){z(`error`),B(e instanceof Error?e.message:`测试失败`)}finally{L(!1)}},wt=(0,C.useCallback)(async()=>{try{let e=await fetch(`/api/refresh-config`,{method:`POST`});if(e.ok){let t=await e.json();K(),z(`success`),B(t.message||`配置已刷新`),setTimeout(()=>{z(null),B(``)},2e3)}else{let t=await e.json();z(`error`),B(t.error||`刷新配置失败`),setTimeout(()=>{z(null),B(``)},2e3)}}catch(e){console.error(`刷新配置失败:`,e),z(`error`),B(`刷新配置失败`),setTimeout(()=>{z(null),B(``)},2e3)}},[K]),Tt=(0,C.useCallback)(async()=>{ft(!0),ut(null);try{let e=await fetch(`/api/config-doctor`);e.ok?ut(await e.json()):(z(`error`),B(`诊断失败`),setTimeout(()=>{z(null),B(``)},2e3))}catch(e){console.error(`诊断失败:`,e),z(`error`),B(`诊断失败`),setTimeout(()=>{z(null),B(``)},2e3)}finally{ft(!1)}},[]),Et=()=>{let e=Y.trim(),t=X.trim();!e||!t||(J(n=>({...n,[e]:t})),ct(``),lt(``))},Dt=async()=>{L(!0);try{await x({clientAliases:q}),z(`success`),B(`客户端名称已保存,新请求立即生效`),d.success(`客户端名称保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;z(`error`),B(t),d.error(t)}finally{L(!1)}},Ot=async()=>{L(!0);try{await x({mocksFilePath:U}),K(),z(`success`),B(`Mock 文件路径已更新,已切换到新文件`),d.success(`Mock 文件路径保存成功`),setTimeout(()=>{z(null),B(``)},3e3)}catch(e){let t=e instanceof Error?e.message:`保存失败`;z(`error`),B(t),d.error(t)}finally{L(!1)}};je({active:(e||n)&&M!==`preferences`,enabled:!I,priority:Ae.panel,onSave:()=>{if(M===`config`)return Ot();if(M===`clients`)return Dt();if(M===`ai`)return $()}});let kt=(0,E.jsxs)(E.Fragment,{children:[!n&&(0,E.jsxs)(ge,{className:`px-6 pt-6 pb-4`,children:[(0,E.jsxs)(Re,{className:`flex items-center gap-2`,children:[(0,E.jsx)(ke,{className:`h-5 w-5`}),`系统设置`]}),(0,E.jsx)(ye,{children:`管理系统偏好、配置和 AI 功能`})]}),(0,E.jsxs)(Ne,{value:M,onValueChange:e=>rt(e),orientation:`vertical`,className:`min-h-0 flex-1 gap-0`,children:[(0,E.jsxs)(Me,{"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,E.jsxs)(h,{value:`preferences`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,E.jsx)(ke,{}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`偏好设置`})]}),(0,E.jsxs)(h,{value:`config`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,E.jsx)(p,{}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`配置文件`})]}),(0,E.jsxs)(h,{value:`clients`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,E.jsx)(re,{}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`客户端`})]}),(0,E.jsxs)(h,{value:`ai`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,E.jsx)(De,{}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`AI 配置`})]})]}),(0,E.jsxs)(f,{value:`preferences`,className:D,children:[(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{className:`text-sm`,children:`主题`}),(0,E.jsxs)(be,{value:i,onValueChange:e=>T(e),children:[(0,E.jsx)(Le,{children:(0,E.jsx)(ve,{placeholder:`选择主题`})}),(0,E.jsx)(xe,{children:(0,E.jsxs)(_e,{children:[(0,E.jsx)(m,{value:`system`,children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(Te,{className:`size-4`}),`跟随系统`]})}),(0,E.jsx)(m,{value:`light`,children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(Pe,{className:`size-4`}),`浅色模式`]})}),(0,E.jsx)(m,{value:`dark`,children:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(Be,{className:`size-4`}),`深色模式`]})})]})})]})]}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,E.jsx)(_,{className:`text-sm`,children:`强调色`}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`统一按钮、状态、选中项和焦点样式。自动模式会根据明暗主题选择合适的颜色。`})]}),(0,E.jsx)(y,{type:`single`,value:w,onValueChange:e=>{e&&Qe(e)},variant:`outline`,spacing:1,className:`flex-wrap justify-start`,"aria-label":`强调色`,children:tt.map(e=>(0,E.jsxs)(v,{value:e.value,"aria-label":e.label,children:[e.value===`auto`?(0,E.jsx)(De,{"data-icon":`inline-start`}):(0,E.jsx)(`span`,{className:`size-3 rounded-full border border-foreground/10`,style:{background:e.color}}),e.label]},e.value))})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{className:`text-sm`,children:`缩放比例`}),(0,E.jsxs)(be,{value:Q,onValueChange:vt,children:[(0,E.jsx)(Le,{children:(0,E.jsx)(ve,{placeholder:`选择缩放比例`})}),(0,E.jsx)(xe,{children:(0,E.jsx)(_e,{children:et.map(e=>(0,E.jsx)(m,{value:e.value,children:e.label},e.value))})})]})]}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(`h3`,{className:`text-sm font-medium`,children:`关于`}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Meddle - HTTP 调试代理工具`}),(0,E.jsxs)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`settings-app-version`,children:[`版本: `,pt??`—`]})]})]}),(0,E.jsxs)(f,{value:`config`,className:D,children:[(0,E.jsxs)(`div`,{className:k,children:[(0,E.jsx)(_,{className:`text-sm font-medium`,children:`路由规则文件`}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,E.jsx)(p,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,E.jsx)(`span`,{"data-testid":`settings-route-rules-dir`,className:`text-xs font-mono flex-1 wrap-anywhere`,title:ht?.path??void 0,children:(0,E.jsx)(Je,{path:_t})})]}),ot.length>0?(0,E.jsx)(`div`,{className:`space-y-2`,children:ot.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2.5 text-sm`,children:[(0,E.jsx)(Se,{variant:e.enabled?`default`:`secondary`,className:`text-[10px]`,children:e.enabled?`已启用`:`未启用`}),(0,E.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[e.name,`.txt`]}),(0,E.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.ruleCount,` 条规则`]})]},e.name))}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`暂无规则文件`}),(0,E.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`规则文件存放于 `,_t,` 目录,纯文本格式。在"路由规则"页面管理。`]})]})]}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:k,children:[(0,E.jsx)(_,{className:`text-sm font-medium`,children:`Mock 规则文件`}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(`span`,{"data-testid":`settings-mocks-file-current-label`,className:`text-xs text-muted-foreground`,children:`当前使用`}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,E.jsx)(p,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,E.jsx)(`span`,{"data-testid":`settings-mocks-file-resolved`,className:`text-xs font-mono flex-1 wrap-anywhere`,title:G?.path,children:G?.path?(0,E.jsx)(Je,{path:G.path}):U||`默认: ~/.meddle/mocks.json`})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`mocksPath`,className:`text-xs text-muted-foreground`,children:`自定义 Mock 规则文件路径(留空使用默认)`}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(g,{id:`mocksPath`,value:U,onChange:e=>W(e.target.value),placeholder:`如: /path/to/my-mocks.json`,className:`flex-1 h-8 text-sm font-mono`}),(0,E.jsx)(We,{onClick:Ot,saving:I,label:`应用`,savingLabel:`应用中…`,"data-testid":`settings-mocks-file-apply`,className:`h-8`})]}),G?.legacyMocksPath?(0,E.jsx)(Ge,{oldPath:G.legacyMocksPath.oldPath,newPath:G.legacyMocksPath.newPath,visible:fe(U),onUseOldPath:()=>W(G.legacyMocksPath.oldPath)}):null,(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`必须是 JSON 格式的 Mock 规则文件。支持 ~ 表示用户主目录;相对路径相对于 Meddle 配置目录。`}),he(G)?(0,E.jsx)(qe,{testId:`settings-mocks-file-invalid`,location:pe(G.parseError)}):de(G)&&!G.legacyMocksPath?(0,E.jsx)(Ke,{testId:`settings-mocks-file-missing`}):null]})]})]}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(`h3`,{className:`text-sm font-medium`,children:`操作`}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsxs)(r,{variant:`outline`,size:`sm`,onClick:wt,children:[(0,E.jsx)(te,{className:`h-4 w-4 mr-1`}),`重新加载配置`]}),(0,E.jsxs)(r,{variant:`outline`,size:`sm`,onClick:Tt,disabled:dt,children:[(0,E.jsx)(Ze,{className:`h-4 w-4 mr-1`}),dt?`诊断中…`:`诊断配置`]})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`点击重新加载可应用修改后的配置文件,点击诊断配置可检查配置有效性`})]}),Z&&(0,E.jsxs)(`div`,{className:k,children:[(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-sm font-medium`,children:[(0,E.jsx)(Ze,{className:`h-4 w-4`}),`诊断结果`]}),(0,E.jsxs)(`div`,{className:`mb-3 p-3 rounded-md border ${Z.status===`ok`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:Z.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:[Z.status===`ok`&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(b,{className:`h-5 w-5 text-green-600 dark:text-green-400`}),(0,E.jsx)(`span`,{className:`text-sm font-medium text-green-700 dark:text-green-300`,children:`所有检查通过!配置正常。`})]}),Z.status===`warning`&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(a,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`}),(0,E.jsxs)(`span`,{className:`text-sm font-medium text-yellow-700 dark:text-yellow-300`,children:[`发现 `,Z.warnings.length,` 个警告`]})]}),Z.status===`error`&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(o,{className:`h-5 w-5 text-red-600 dark:text-red-400`}),(0,E.jsxs)(`span`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:[`发现 `,Z.errors.length,` 个错误`]})]})]}),(0,E.jsx)(`div`,{className:O,children:Z.checks.map((e,t)=>(0,E.jsx)(`div`,{className:`p-2 rounded border bg-card`,children:(0,E.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,E.jsx)(b,{className:`h-4 w-4 text-green-600 dark:text-green-400 mt-0.5 shrink-0`}),(0,E.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,E.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono truncate`,children:e.path}),e.details&&(0,E.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))}),Z.warnings&&Z.warnings.length>0&&(0,E.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium text-yellow-700 dark:text-yellow-300`,children:`警告:`}),Z.warnings.map((e,t)=>(0,E.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,E.jsx)(a,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,E.jsx)(`span`,{children:e})]},t))]}),Z.errors&&Z.errors.length>0&&(0,E.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium text-red-700 dark:text-red-300`,children:`错误:`}),Z.errors.map((e,t)=>(0,E.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-red-600 dark:text-red-400`,children:[(0,E.jsx)(o,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,E.jsx)(`span`,{children:e})]},t))]})]})]})]}),(0,E.jsxs)(f,{value:`clients`,className:D,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,E.jsx)(re,{className:`h-4 w-4`}),`远程客户端名称`]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将日志中的客户端 IP 映射为设备名称。保存后新请求立即生效,无需重启代理。`})]}),(0,E.jsx)(`div`,{className:O,children:Object.entries(q).length===0?(0,E.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground`,children:`尚未配置设备名称`}):Object.entries(q).map(([e,t])=>(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(g,{value:e,readOnly:!0,className:`h-8 flex-1 font-mono text-xs bg-muted/40`,"aria-label":`客户端 IP ${e}`}),(0,E.jsx)(g,{value:t,onChange:t=>{let n=t.target.value;J(t=>({...t,[e]:n}))},className:`h-8 flex-1 text-sm`,"aria-label":`${e} 的设备名称`}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>{J(t=>{let n={...t};return delete n[e],n})},title:`删除设备名称`,"aria-label":`删除设备名称`,children:(0,E.jsx)(ie,{className:`h-4 w-4`})})]},e))}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{className:`text-sm`,children:`添加设备`}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(g,{value:Y,onChange:e=>ct(e.target.value),placeholder:`客户端 IP,例如 10.13.232.187`,className:`h-8 flex-1 font-mono text-xs`}),(0,E.jsx)(g,{value:X,onChange:e=>lt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Et()},placeholder:`设备名称,例如 iPhone`,className:`h-8 flex-1 text-sm`}),(0,E.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-8`,onClick:Et,disabled:!Y.trim()||!X.trim(),children:[(0,E.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加`]})]})]}),(0,E.jsxs)(Ce,{onClick:Dt,disabled:I,children:[(0,E.jsx)(Fe,{"data-icon":`inline-start`,className:`h-4 w-4`}),I?`保存中…`:`保存客户端名称`]})]}),(0,E.jsxs)(f,{value:`ai`,className:D,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(_,{className:`text-sm`,children:`启用 AI 功能`}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`启用智能代码修复功能`})]}),(0,E.jsx)(ae,{checked:N.enabled,onCheckedChange:e=>P({...N,enabled:e}),"aria-label":`启用 AI 功能`})]}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:k,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(_,{className:`text-sm`,children:`AI 模型配置`}),(0,E.jsxs)(r,{variant:`outline`,size:`sm`,onClick:()=>{H({name:``,provider:`openai`,apiKey:``,baseUrl:`https://api.openai.com/v1/chat/completions`,model:`gpt-4o-mini`})},children:[(0,E.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加模型`]})]}),(0,E.jsx)(`div`,{className:O,children:N.models&&N.models.length>0?N.models.map(e=>(0,E.jsx)(`div`,{className:`p-3 rounded-md border ${N.activeModelId===e.id?`border-primary bg-primary/5`:`border-border`}`,children:(0,E.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,E.jsxs)(`div`,{className:`flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),N.activeModelId===e.id&&(0,E.jsx)(Se,{variant:`default`,className:`text-xs`,children:`当前使用`})]}),(0,E.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[e.provider===`openai`?`OpenAI`:`Anthropic`,` - `,e.model]})]}),(0,E.jsxs)(`div`,{className:`flex gap-1`,children:[N.activeModelId!==e.id&&(0,E.jsxs)(r,{variant:`ghost`,size:`xs`,onClick:()=>P(se(N,e.id)),children:[(0,E.jsx)(ee,{className:`h-3 w-3 mr-1`}),`使用`]}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-sm`,onClick:()=>P(ce(N,e.id)),className:`text-destructive`,"aria-label":`删除模型`,children:(0,E.jsx)(ie,{className:`h-3 w-3`})})]})]})},e.id)):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground italic py-4 text-center`,children:`暂无模型配置,点击"添加模型"创建`})}),V&&(0,E.jsxs)(`div`,{className:`space-y-5 rounded-md border border-primary bg-primary/5 p-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(_,{className:`text-sm font-medium`,children:`新增模型`}),(0,E.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:()=>H(null),"aria-label":`关闭新增模型表单`,children:(0,E.jsx)(o,{className:`h-4 w-4`})})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`newModelName`,className:`text-xs`,children:`模型名称`}),(0,E.jsx)(g,{id:`newModelName`,value:V.name||``,onChange:e=>H({...V,name:e.target.value}),placeholder:`如:GPT-4o Mini`,className:`h-8 text-sm`})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{className:`text-xs`,children:`服务商`}),(0,E.jsxs)(y,{type:`single`,value:V.provider,onValueChange:e=>{if(e===`openai`){let e=c(`openai`);H({...V,provider:`openai`,baseUrl:e.baseUrl,model:e.model})}else if(e===`anthropic`){let e=c(`anthropic`);H({...V,provider:`anthropic`,baseUrl:e.baseUrl,model:e.model})}},variant:`outline`,size:`sm`,spacing:0,children:[(0,E.jsx)(v,{value:`openai`,children:`OpenAI`}),(0,E.jsx)(v,{value:`anthropic`,children:`Anthropic`})]})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`newModelApiKey`,className:`text-xs`,children:`API Key`}),(0,E.jsx)(g,{id:`newModelApiKey`,type:F?`text`:`password`,value:V.apiKey||``,onChange:e=>H({...V,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`h-8 text-sm`})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`newModelModel`,className:`text-xs`,children:`模型`}),(0,E.jsx)(g,{id:`newModelModel`,value:V.model||``,onChange:e=>H({...V,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`newModelBaseUrl`,className:`text-xs`,children:`API 端点`}),(0,E.jsx)(g,{id:`newModelBaseUrl`,value:V.baseUrl||``,onChange:e=>H({...V,baseUrl:e.target.value}),placeholder:`API 端点`,className:`h-8 text-sm`})]}),(0,E.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,E.jsx)(r,{variant:`outline`,size:`xs`,onClick:()=>H(null),children:`取消`}),(0,E.jsxs)(r,{size:`xs`,onClick:()=>{V.name&&V.apiKey&&V.model&&V.baseUrl&&(P(ue(N,V)),H(null))},disabled:!V.name||!V.apiKey||!V.model||!V.baseUrl,children:[(0,E.jsx)(s,{className:`h-3 w-3 mr-1`}),`添加`]})]})]})]}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(_,{className:`text-sm`,children:`传统配置(向后兼容)`}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`如果未配置多模型,将使用此配置`})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{className:`text-xs`,children:`AI 服务商`}),(0,E.jsxs)(y,{type:`single`,value:N.provider,onValueChange:e=>{(e===`openai`||e===`anthropic`)&&xt(e)},variant:`outline`,size:`sm`,spacing:0,children:[(0,E.jsx)(v,{value:`openai`,children:`OpenAI`}),(0,E.jsx)(v,{value:`anthropic`,children:`Anthropic`})]})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`apiKey`,className:`text-xs`,children:`API Key`}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(g,{id:`apiKey`,type:F?`text`:`password`,value:N.apiKey,onChange:e=>P({...N,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`flex-1 h-8 text-sm`}),(0,E.jsx)(r,{variant:`outline`,size:`icon-sm`,onClick:()=>it(!F),"aria-label":F?`隐藏 API Key`:`显示 API Key`,children:F?(0,E.jsx)(Ye,{className:`h-4 w-4`}):(0,E.jsx)(Xe,{className:`h-4 w-4`})})]})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`model`,className:`text-xs`,children:`模型`}),(0,E.jsx)(g,{id:`model`,value:N.model,onChange:e=>P({...N,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,E.jsxs)(`div`,{className:O,children:[(0,E.jsx)(_,{htmlFor:`baseUrl`,className:`text-xs`,children:`API 端点`}),(0,E.jsx)(g,{id:`baseUrl`,value:N.baseUrl,onChange:e=>P({...N,baseUrl:e.target.value}),placeholder:N.provider===`openai`?`https://api.openai.com/v1/chat/completions`:`https://api.anthropic.com/v1/messages`,className:`h-8 text-sm`})]}),at&&(0,E.jsxs)(Ue,{variant:R===`error`?`destructive`:`default`,children:[R===`success`?(0,E.jsx)(b,{}):R===`error`?(0,E.jsx)(o,{}):(0,E.jsx)(a,{}),(0,E.jsx)(He,{children:R===`success`?`操作成功`:R===`error`?`操作失败`:`处理中`}),(0,E.jsx)(Ve,{children:at})]}),(0,E.jsx)(S,{}),(0,E.jsxs)(`div`,{className:`flex justify-between`,children:[(0,E.jsxs)(r,{variant:`outline`,size:`sm`,onClick:St,children:[(0,E.jsx)(ne,{className:`h-4 w-4 mr-1`}),`重置`]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(r,{variant:`outline`,size:`sm`,onClick:Ct,disabled:!l(N)||I,children:`测试连接`}),(0,E.jsxs)(Ce,{size:`sm`,onClick:$,disabled:I,children:[(0,E.jsx)(Fe,{"data-icon":`inline-start`,className:`h-4 w-4`}),I?`保存中…`:`保存`]})]})]})]})]})]});return n?(0,E.jsx)(`div`,{"data-testid":`settings-fullwidth`,className:`app-workspace-content flex h-full min-h-0 w-full flex-col overflow-hidden p-0`,children:(0,E.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border bg-card`,children:kt})}):(0,E.jsx)(we,{open:e,onOpenChange:t,children:(0,E.jsx)(ze,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:600,storageKey:`settings-panel`,children:kt})})}export{j as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,d as t,l as n,o as r,p as i}from"./button-BFNlGZ5p.js";import{a,o,r as s,t as c}from"./dist-CFZ4xMSF.js";import{n as l,t as u}from"./dist-
|
|
1
|
+
import{c as e,d as t,l as n,o as r,p as i}from"./button-BFNlGZ5p.js";import{a,o,r as s,t as c}from"./dist-CFZ4xMSF.js";import{n as l,t as u}from"./dist-fzPL-8F9.js";var d=i(t(),1),f=e(),p=`Switch`,[m,h]=a(p),[g,_]=m(p),v=d.forwardRef((e,t)=>{let{__scopeSwitch:n,name:i,checked:a,defaultChecked:l,required:u,disabled:m,value:h=`on`,onCheckedChange:_,form:v,...y}=e,[b,x]=d.useState(null),w=r(t,e=>x(e)),T=d.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=c({prop:a,defaultProp:l??!1,onChange:_,caller:p});return(0,f.jsxs)(g,{scope:n,checked:D,disabled:m,children:[(0,f.jsx)(o.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":u,"data-state":C(D),"data-disabled":m?``:void 0,disabled:m,value:h,...y,ref:w,onClick:s(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,f.jsx)(S,{control:b,bubbles:!T.current,name:i,value:h,checked:D,required:u,disabled:m,form:v,style:{transform:`translateX(-100%)`}})]})});v.displayName=p;var y=`SwitchThumb`,b=d.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=_(y,n);return(0,f.jsx)(o.span,{"data-state":C(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});b.displayName=y;var x=`SwitchBubbleInput`,S=d.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:i=!0,...a},o)=>{let s=d.useRef(null),c=r(s,o),p=l(n),m=u(t);return d.useEffect(()=>{let e=s.current;if(!e)return;let t=window.HTMLInputElement.prototype,r=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==n&&r){let t=new Event(`click`,{bubbles:i});r.call(e,n),e.dispatchEvent(t)}},[p,n,i]),(0,f.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});S.displayName=x;function C(e){return e?`checked`:`unchecked`}var w=v,T=b;function E({className:e,...t}){return(0,f.jsx)(w,{"data-slot":`switch`,className:n(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-5 w-9 shrink-0 items-center rounded-full border-2 border-transparent shadow-xs transition-colors outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,f.jsx)(T,{"data-slot":`switch-thumb`,className:n(`bg-background pointer-events-none block size-4 rounded-full ring-0 shadow-lg transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})})}export{E as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e,p as t}from"./button-BFNlGZ5p.js";import{c as n}from"./dist-CFZ4xMSF.js";var r=t(e(),1),i=t(n(),1);function a(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var o=e=>{switch(e){case`success`:return l;case`info`:return d;case`warning`:return u;case`error`:return f;default:return null}},s=Array(12).fill(0),c=({visible:e,className:t})=>r.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},r.createElement(`div`,{className:`sonner-spinner`},s.map((e,t)=>r.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),l=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),u=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),d=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),f=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},r.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),p=r.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},r.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),r.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),ee=()=>{let[e,t]=r.useState(document.hidden);return r.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},m=1,h=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:m++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let i=Promise.resolve(e instanceof Function?e():e),a=n!==void 0,o,s=i.then(async e=>{if(o=[`resolve`,e],r.isValidElement(e))a=!1,this.create({id:n,type:`default`,message:e});else if(_(e)&&!e.ok){a=!1;let i=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,o=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}else if(e instanceof Error){a=!1;let i=typeof t.error==`function`?await t.error(e):t.error,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}else if(t.success!==void 0){a=!1;let i=typeof t.success==`function`?await t.success(e):t.success,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`success`,description:o,...s})}}).catch(async e=>{if(o=[`reject`,e],t.error!==void 0){a=!1;let i=typeof t.error==`function`?await t.error(e):t.error,o=typeof t.description==`function`?await t.description(e):t.description,s=typeof i==`object`&&!r.isValidElement(i)?i:{message:i};this.create({id:n,type:`error`,description:o,...s})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((e,t)=>s.then(()=>o[0]===`reject`?t(o[1]):e(o[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(e,t)=>{let n=t?.id||m++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},g=(e,t)=>{let n=t?.id||m++;return h.addToast({title:e,...t,id:n}),n},_=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,v=g,y=Object.assign(v,{success:h.success,info:h.info,warning:h.warning,error:h.error,custom:h.custom,message:h.message,promise:h.promise,dismiss:h.dismiss,loading:h.loading},{getHistory:()=>h.toasts,getToasts:()=>h.getActiveToasts()});a(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function b(e){return e.label!==void 0}var te=3,x=`24px`,S=`16px`,C=4e3,w=356,T=14,E=45,D=200;function O(...e){return e.filter(Boolean).join(` `)}function k(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var ne=e=>{let{invert:t,toast:n,unstyled:i,interacting:a,setHeights:s,visibleToasts:l,heights:u,index:d,toasts:f,expanded:m,removeToast:h,defaultRichColors:g,closeButton:_,style:v,cancelButtonStyle:y,actionButtonStyle:te,className:x=``,descriptionClassName:S=``,duration:w,position:T,gap:ne,expandByDefault:A,classNames:j,icons:M,closeButtonAriaLabel:N=`Close toast`}=e,[P,F]=r.useState(null),[I,re]=r.useState(null),[L,R]=r.useState(!1),[z,B]=r.useState(!1),[V,H]=r.useState(!1),[ie,ae]=r.useState(!1),[oe,se]=r.useState(!1),[ce,U]=r.useState(0),[le,ue]=r.useState(0),W=r.useRef(n.duration||w||C),de=r.useRef(null),G=r.useRef(null),fe=d===0,pe=d+1<=l,K=n.type,q=n.dismissible!==!1,me=n.className||``,he=n.descriptionClassName||``,J=r.useMemo(()=>u.findIndex(e=>e.toastId===n.id)||0,[u,n.id]),ge=r.useMemo(()=>n.closeButton??_,[n.closeButton,_]),_e=r.useMemo(()=>n.duration||w||C,[n.duration,w]),Y=r.useRef(0),X=r.useRef(0),ve=r.useRef(0),Z=r.useRef(null),[ye,be]=T.split(`-`),xe=r.useMemo(()=>u.reduce((e,t,n)=>n>=J?e:e+t.height,0),[u,J]),Se=ee(),Ce=n.invert||t,Q=K===`loading`;X.current=r.useMemo(()=>J*ne+xe,[J,xe]),r.useEffect(()=>{W.current=_e},[_e]),r.useEffect(()=>{R(!0)},[]),r.useEffect(()=>{let e=G.current;if(e){let t=e.getBoundingClientRect().height;return ue(t),s(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>s(e=>e.filter(e=>e.toastId!==n.id))}},[s,n.id]),r.useLayoutEffect(()=>{if(!L)return;let e=G.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ue(r),s(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[L,n.title,n.description,s,n.id,n.jsx,n.action,n.cancel]);let $=r.useCallback(()=>{B(!0),U(X.current),s(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{h(n)},D)},[n,h,s,X]);r.useEffect(()=>{if(n.promise&&K===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return m||a||Se?(()=>{if(ve.current<Y.current){let e=new Date().getTime()-Y.current;W.current-=e}ve.current=new Date().getTime()})():W.current!==1/0&&(Y.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),$()},W.current)),()=>clearTimeout(e)},[m,a,n,K,Se,$]),r.useEffect(()=>{n.delete&&($(),n.onDismiss==null||n.onDismiss.call(n,n))},[$,n.delete]);function we(){return M?.loading?r.createElement(`div`,{className:O(j?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":K===`loading`},M.loading):r.createElement(c,{className:O(j?.loader,n?.classNames?.loader),visible:K===`loading`})}let Te=n.icon||M?.[K]||o(K);return r.createElement(`li`,{tabIndex:0,ref:G,className:O(x,me,j?.toast,n?.classNames?.toast,j?.default,j?.[K],n?.classNames?.[K]),"data-sonner-toast":``,"data-rich-colors":n.richColors??g,"data-styled":!(n.jsx||n.unstyled||i),"data-mounted":L,"data-promise":!!n.promise,"data-swiped":oe,"data-removed":z,"data-visible":pe,"data-y-position":ye,"data-x-position":be,"data-index":d,"data-front":fe,"data-swiping":V,"data-dismissible":q,"data-type":K,"data-invert":Ce,"data-swipe-out":ie,"data-swipe-direction":I,"data-expanded":!!(m||A&&L),"data-testid":n.testId,style:{"--index":d,"--toasts-before":d,"--z-index":f.length-d,"--offset":`${z?ce:X.current}px`,"--initial-height":A?`auto`:`${le}px`,...v,...n.style},onDragEnd:()=>{H(!1),F(null),Z.current=null},onPointerDown:e=>{e.button!==2&&(Q||!q||(de.current=new Date,U(X.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(H(!0),Z.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(ie||!q)return;Z.current=null;let e=Number(G.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(G.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-de.current?.getTime(),i=P===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=E||a>.11){U(X.current),n.onDismiss==null||n.onDismiss.call(n,n),re(P===`x`?e>0?`right`:`left`:t>0?`down`:`up`),$(),ae(!0);return}else{var o,s;(o=G.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=G.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}se(!1),H(!1),F(null)},onPointerMove:t=>{var n,r;if(!Z.current||!q||window.getSelection()?.toString().length>0)return;let i=t.clientY-Z.current.y,a=t.clientX-Z.current.x,o=e.swipeDirections??k(T);!P&&(Math.abs(a)>1||Math.abs(i)>1)&&F(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(P===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(P===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&se(!0),(n=G.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=G.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ge&&!n.jsx&&K!==`loading`?r.createElement(`button`,{"aria-label":N,"data-disabled":Q,"data-close-button":!0,onClick:Q||!q?()=>{}:()=>{$(),n.onDismiss==null||n.onDismiss.call(n,n)},className:O(j?.closeButton,n?.classNames?.closeButton)},M?.close??p):null,(K||n.icon||n.promise)&&n.icon!==null&&(M?.[K]!==null||n.icon)?r.createElement(`div`,{"data-icon":``,className:O(j?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||we():null,n.type===`loading`?null:Te):null,r.createElement(`div`,{"data-content":``,className:O(j?.content,n?.classNames?.content)},r.createElement(`div`,{"data-title":``,className:O(j?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?r.createElement(`div`,{"data-description":``,className:O(S,he,j?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),r.isValidElement(n.cancel)?n.cancel:n.cancel&&b(n.cancel)?r.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||y,onClick:e=>{b(n.cancel)&&q&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),$())},className:O(j?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,r.isValidElement(n.action)?n.action:n.action&&b(n.action)?r.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||te,onClick:e=>{b(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&$())},className:O(j?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function A(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function j(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?S:x;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var M=r.forwardRef(function(e,t){let{id:n,invert:a,position:o=`bottom-right`,hotkey:s=[`altKey`,`KeyT`],expand:c,closeButton:l,className:u,offset:d,mobileOffset:f,theme:p=`light`,richColors:ee,duration:m,style:g,visibleToasts:_=te,toastOptions:v,dir:y=A(),gap:b=T,icons:x,containerAriaLabel:S=`Notifications`}=e,[C,E]=r.useState([]),D=r.useMemo(()=>n?C.filter(e=>e.toasterId===n):C.filter(e=>!e.toasterId),[C,n]),O=r.useMemo(()=>Array.from(new Set([o].concat(D.filter(e=>e.position).map(e=>e.position)))),[D,o]),[k,M]=r.useState([]),[N,P]=r.useState(!1),[F,I]=r.useState(!1),[re,L]=r.useState(p===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:p),R=r.useRef(null),z=s.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),B=r.useRef(null),V=r.useRef(!1),H=r.useCallback(e=>{E(t=>(t.find(t=>t.id===e.id)?.delete||h.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return r.useEffect(()=>h.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{E(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{i.flushSync(()=>{E(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[C]),r.useEffect(()=>{if(p!==`system`){L(p);return}if(p===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?L(`dark`):L(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{L(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{L(e?`dark`:`light`)}catch(e){console.error(e)}})}},[p]),r.useEffect(()=>{C.length<=1&&P(!1)},[C]),r.useEffect(()=>{let e=e=>{if(s.every(t=>e[t]||e.code===t)){var t;P(!0),(t=R.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===R.current||R.current?.contains(document.activeElement))&&P(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s]),r.useEffect(()=>{if(R.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,V.current=!1)}},[R.current]),r.createElement(`section`,{ref:t,"aria-label":`${S} ${z}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},O.map((t,n)=>{let[i,o]=t.split(`-`);return D.length?r.createElement(`ol`,{key:t,dir:y===`auto`?A():y,tabIndex:-1,ref:R,className:u,"data-sonner-toaster":!0,"data-sonner-theme":re,"data-y-position":i,"data-x-position":o,style:{"--front-toast-height":`${k[0]?.height||0}px`,"--width":`${w}px`,"--gap":`${b}px`,...g,...j(d,f)},onBlur:e=>{V.current&&!e.currentTarget.contains(e.relatedTarget)&&(V.current=!1,B.current&&=(B.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||V.current||(V.current=!0,B.current=e.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{F||P(!1)},onDragEnd:()=>P(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I(!0)},onPointerUp:()=>I(!1)},D.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>r.createElement(ne,{key:n.id,icons:x,index:i,toast:n,defaultRichColors:ee,duration:v?.duration??m,className:v?.className,descriptionClassName:v?.descriptionClassName,invert:a,visibleToasts:_,closeButton:v?.closeButton??l,interacting:F,position:t,style:v?.style,unstyled:v?.unstyled,classNames:v?.classNames,cancelButtonStyle:v?.cancelButtonStyle,actionButtonStyle:v?.actionButtonStyle,closeButtonAriaLabel:v?.closeButtonAriaLabel,removeToast:H,toasts:D.filter(e=>e.position==n.position),heights:k.filter(e=>e.position==n.position),setHeights:M,expandByDefault:c,gap:b,expanded:N,swipeDirections:e.swipeDirections}))):null}))}),N=3e3;function P(e){return{...e,duration:N}}var F={success(e,t){return y.success(e,P(t))},info(e,t){return y.info(e,P(t))},warning(e,t){return y.warning(e,P(t))},error(e,t){return y.error(e,P(t))},dismiss:y.dismiss};export{F as n,M as r,N as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e,p as t}from"./button-BFNlGZ5p.js";var n=t(e(),1);function r(e){return!!e&&e.valid===!1&&!!e.parseError}function i(e){return e.line==null?e.message:`第 ${e.line} 行第 ${e.column} 列:${e.message}`}function a(e){return!!e&&e.custom&&!e.exists}var o=`mocksUpdated`,s=`mocksFileStatusChanged`;function c(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let{path:t,exists:n,custom:r,valid:i,parseError:a,legacyMocksPath:o}=e;if(typeof t!=`string`||typeof n!=`boolean`)return null;let s=null;if(i===!1&&a&&typeof a==`object`){let e=a;s={line:typeof e.line==`number`?e.line:null,column:typeof e.column==`number`?e.column:null,message:typeof e.message==`string`?e.message:``}}let c=null;if(o&&typeof o==`object`){let e=o;typeof e.oldPath==`string`&&typeof e.newPath==`string`&&(c={configured:typeof e.configured==`string`?e.configured:``,oldPath:e.oldPath,newPath:e.newPath})}return{path:t,exists:n,custom:r===!0,valid:!s,parseError:s,legacyMocksPath:c}}function l(e){let[t,r]=(0,n.useState)(null),i=(0,n.useCallback)(async()=>{try{let e=await fetch(`/api/mocks-file`,{cache:`no-store`});if(!e.ok)return;r(c(await e.json()))}catch{}},[]);return(0,n.useEffect)(()=>{i()},[i,e]),(0,n.useEffect)(()=>{let e=()=>{i()};return window.addEventListener(o,e),window.addEventListener(s,e),()=>{window.removeEventListener(o,e),window.removeEventListener(s,e)}},[i]),{status:t,refresh:i}}function u(e){let t=e.trim();return!(!t||t.startsWith(`/`)||t.startsWith(`\\`)||/^[A-Za-z]:[\\/]/.test(t)||t===`~`||t.startsWith(`~/`)||t.startsWith(`~\\`))}export{a,u as i,i as n,l as o,r,s as t};
|
package/web/dist/index.html
CHANGED
|
@@ -5,23 +5,24 @@
|
|
|
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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-Dcm171u1.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/button-BFNlGZ5p.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/dist-CFZ4xMSF.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/dist-C-E2R2jk.js">
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-fzPL-8F9.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-BQN0rzUS.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-Bsv9ad5F.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/dist-LiAcI8CK.js">
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/es2015-CRmLuA2o.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/es2015-DPJTBYa9.js">
|
|
18
17
|
<link rel="modulepreload" crossorigin href="/assets/dist-CRmX_NvH.js">
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-DLQKRjuW.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-wv9ebJK_.js">
|
|
21
20
|
<link rel="modulepreload" crossorigin href="/assets/check-BkfHQ6re.js">
|
|
22
21
|
<link rel="modulepreload" crossorigin href="/assets/chevron-down-DHwUtL4O.js">
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
24
|
-
<link rel="
|
|
22
|
+
<link rel="modulepreload" crossorigin href="/assets/toast-9yeTf7d9.js">
|
|
23
|
+
<link rel="modulepreload" crossorigin href="/assets/use-mocks-file-status-BUIUJ4oQ.js">
|
|
24
|
+
<link rel="modulepreload" crossorigin href="/assets/ai-config-store-C8D_PUGV.js">
|
|
25
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C6dPxxT3.css">
|
|
25
26
|
</head>
|
|
26
27
|
<body>
|
|
27
28
|
<div id="root"></div>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{c as e,d as t,p as n,t as r,u as i}from"./button-BFNlGZ5p.js";import"./dist-CFZ4xMSF.js";import{t as a}from"./arrow-right-BNum_060.js";import{t as o}from"./check-BkfHQ6re.js";import{t as s}from"./chevron-down-DHwUtL4O.js";import{t as c}from"./circle-x-BEkinhez.js";import{n as l,t as u}from"./server-eYXq3PbE.js";import{t as d}from"./copy-BRnscYy1.js";import{t as f}from"./shield-check-hQXjdfZ7.js";import{t as p}from"./wand-sparkles-DDGjzjnX.js";import"./es2015-CRmLuA2o.js";import{A as m,B as h,D as g,Dt as _,E as ee,F as v,H as y,I as b,L as x,Ot as te,Pt as S,R as C,Rt as w,St as T,T as E,V as ne,b as D,k as re,rt as O,zt as k}from"./index-CkoYwomI.js";import{n as A,t as j}from"./body-diff-view-ByCHr9bv.js";import{n as M,t as ie}from"./syntax-highlight-EJCxGikd.js";import{t as ae}from"./clipboard-DUgC_tNv.js";var N=i(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),oe=i(`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`}]]),P=i(`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`}]]),F=i(`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`}]]),I=n(t(),1);function L(e){return Object.entries(e||{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
2
|
-
`)}var R=e(),z=2e3;function B({text:e,label:t}){let[n,i]=(0,I.useState)(!1),a=(0,I.useRef)(null);async function s(){try{await ae(e),i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),z),D.success(`已复制${t}`)}catch{D.error(`复制${t}失败,请手动选择复制`)}}return(0,R.jsxs)(r,{variant:`ghost`,size:`xs`,className:`text-[11px] text-muted-foreground hover:text-foreground`,"aria-label":n?`复制${t}成功`:`复制${t}`,onClick:()=>void s(),children:[n?(0,R.jsx)(o,{className:`h-3 w-3 mr-1 text-green-600`}):(0,R.jsx)(d,{className:`h-3 w-3 mr-1`}),n?`已复制`:`复制`]})}function V({body:e}){let[t,n]=(0,I.useState)(`source`),r=(0,I.useMemo)(()=>ie(e||``)===`json`,[e]),i=(0,I.useMemo)(()=>{if(!r)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},[e,r]),a=(0,I.useMemo)(()=>M(t===`formatted`?i:e,r?`json`:void 0),[e,i,t,r]);return e?(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[r?(0,R.jsx)(v,{value:t,onValueChange:e=>n(e),className:`w-fit`,children:(0,R.jsxs)(x,{className:`h-6 px-1`,children:[(0,R.jsx)(C,{value:`source`,className:`h-6 px-2 text-[11px]`,children:`源数据`}),(0,R.jsx)(C,{value:`formatted`,className:`h-6 px-2 text-[11px]`,children:`格式化`})]})}):(0,R.jsx)(`span`,{}),(0,R.jsx)(B,{text:e,label:`Body`})]}),(0,R.jsx)(`div`,{className:`font-mono text-xs bg-muted/30 rounded p-2 overflow-x-auto`,children:(0,R.jsx)(`pre`,{className:`whitespace-pre`,children:a})})]}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无内容`})}function H({headers:e}){let t=Object.entries(e||{});return t.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无头部信息`}):(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,R.jsx)(`div`,{className:`flex justify-end`,children:(0,R.jsx)(B,{text:L(e),label:`Headers`})}),(0,R.jsx)(`div`,{className:`font-mono text-xs space-y-0.5`,children:t.map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex gap-2 py-0.5 hover:bg-muted/50 px-1 rounded`,children:[(0,R.jsxs)(`span`,{className:`text-purple-600 shrink-0 font-semibold`,children:[e,`:`]}),(0,R.jsx)(`span`,{className:`text-foreground/80 break-all`,children:t})]},e))})]})}function U(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 W(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 G(e){switch(e){case`ok`:return`通过`;case`error`:return`异常`;case`skipped`:return`跳过`;case`short-circuited`:return`已短路返回`;default:return e}}function K(e){switch(e){case`builtin`:return`内置`;case`custom`:return`自定义`;case`system`:return`系统`;default:return e}}function q(e){return e.replace(/^builtin\./,``).replace(/^custom\./,``)}function se(e,t){return`${t}-${e.hook}-${e.name}`}function J(e){return e===`onBeforeResponse`||e===`onAfterResponse`?`response`:`request`}function ce(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 Y({lines:e,className:t}){return e.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,R.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,R.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,R.jsx)(`span`,{className:`mr-1`,children:e.type===`added`?`+ `:`- `}),e.text]},`${e.type}-${t}-${e.text}`))})}function X(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 le(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 ue(e){let t=e.replace(/\r\n/g,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`);return t[t.length-1]===``&&t.pop(),t.length>0?t:[``]}function Z(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 Q({before:e,after:t}){let[n,i]=(0,I.useState)(!1),a=(0,I.useMemo)(()=>ce(e,t),[e,t]),o=(0,I.useMemo)(()=>a.flatMap(e=>X(e.key,e.before,e.after)),[a]);return o.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(Y,{lines:o}),(0,R.jsxs)(r,{variant:`ghost`,size:`xs`,onClick:()=>i(e=>!e),children:[n?(0,R.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}):(0,R.jsx)(N,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整头部`:`展开完整头部`]}),n&&(0,R.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`变更前`}),(0,R.jsx)(H,{headers:e})]}),(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`变更后`}),(0,R.jsx)(H,{headers:t})]})]})]})}function de({before:e,after:t}){let[n,i]=(0,I.useState)(!1),a=(0,I.useMemo)(()=>A(e||``,t||``).filter(e=>e.added||e.removed),[e,t]),o=(0,I.useMemo)(()=>Z(e||``)||Z(t||``),[e,t]),c=(0,I.useMemo)(()=>o?le(e||``,t||``):a.flatMap(e=>ue(e.value).map(t=>({type:e.added?`added`:`removed`,text:t}))),[e,t,a,o]);return c.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(B,{text:e,label:`变更前 Body`}),(0,R.jsx)(B,{text:t,label:`变更后 Body`})]}),(0,R.jsx)(Y,{lines:c,className:`meddle-thin-scroll max-h-40 overflow-auto`}),!o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(r,{variant:`ghost`,size:`xs`,onClick:()=>i(e=>!e),children:[n?(0,R.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}):(0,R.jsx)(N,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整 Diff`:`展开完整 Diff`]}),n&&(0,R.jsx)(j,{original:e,modified:t,mode:`inline`,maxHeight:`220px`})]})]})}function fe({stage:e}){let t=e.changes;return t?(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(t.targetBefore||t.targetAfter)&&(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Request URL Diff`}),(0,R.jsx)(Y,{lines:X(`Request URL`,t.targetBefore,t.targetAfter||t.target)})]}),(t.requestHeadersBefore||t.requestHeadersAfter)&&(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Request Header Diff`}),(0,R.jsx)(Q,{before:t.requestHeadersBefore||{},after:t.requestHeadersAfter||{}})]}),(t.responseStatusCodeBefore!==void 0||t.responseStatusCodeAfter!==void 0)&&(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Status Diff`}),(0,R.jsx)(Y,{lines:X(`Response Status`,t.responseStatusCodeBefore,t.responseStatusCodeAfter??t.responseStatusCode)})]}),(t.responseHeadersBefore||t.responseHeadersAfter)&&(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Header Diff`}),(0,R.jsx)(Q,{before:t.responseHeadersBefore||{},after:t.responseHeadersAfter||{}})]}),(t.responseBodyBefore!==void 0||t.responseBodyAfter!==void 0)&&(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-2`,children:`Response Body Diff`}),(0,R.jsx)(de,{before:t.responseBodyBefore||``,after:t.responseBodyAfter||t.responseBody||``})]})]}):null}function pe({stage:e,index:t,isLast:n,accentClass:i}){let[a,o]=(0,I.useState)(e.status!==`skipped`);return(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-xl border bg-background/90 p-3 space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,R.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:()=>o(e=>!e),title:a?`收起`:`展开`,"aria-label":a?`收起`:`展开`,children:a?(0,R.jsx)(s,{className:`h-3.5 w-3.5`}):(0,R.jsx)(N,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`span`,{className:`font-medium text-sm`,children:[t+1,`. `,q(e.name)]}),(0,R.jsx)(O,{variant:`outline`,className:`text-xs font-normal`,children:e.hook}),(0,R.jsx)(O,{variant:`outline`,className:`text-xs font-normal`,children:K(e.type)})]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.status===`short-circuited`?`这一阶段直接生成了响应,请求不会继续往后转发。`:e.status===`error`?`这一阶段执行失败,影响了后续处理流程。`:`这一阶段执行完成,请求继续进入下一步。`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,R.jsx)(O,{className:`text-xs border ${W(e.status)}`,children:G(e.status)}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.duration,`ms`]})]})]}),a&&(0,R.jsxs)(R.Fragment,{children:[e.target&&(0,R.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground mb-1`,children:`当前 Target`}),(0,R.jsx)(`div`,{className:`font-mono text-xs break-all`,children:e.target})]}),(0,R.jsx)(fe,{stage:e}),e.error&&(0,R.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,R.jsx)(`div`,{className:`flex justify-center py-1`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,R.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full ${i} animate-pulse`}),(0,R.jsx)(w,{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,R.jsxs)(`div`,{className:`rounded-xl border bg-card p-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2 mb-2`,children:(0,R.jsxs)(O,{variant:`outline`,className:`text-[11px] font-normal`,children:[(0,R.jsx)(`span`,{className:`mr-1`,children:a}),i]})}),(0,R.jsxs)(`h4`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:o,children:r}),e]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t})]}),(0,R.jsxs)(O,{variant:`outline`,className:`text-xs`,children:[n.length,` 个阶段`]})]}),n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无阶段信息`}):(0,R.jsx)(`div`,{className:`space-y-3`,children:n.map(({stage:e,index:t},r)=>(0,R.jsx)(pe,{stage:e,index:t,isLast:r===n.length-1,accentClass:o},se(e,t)))})]})}function me(e){let t=[...e.stages].reverse().find(e=>e.status===`short-circuited`);if(t)return{label:`提前返回响应`,description:`在 ${q(t.name)} 阶段直接生成响应`,icon:(0,R.jsx)(oe,{className:`h-4 w-4 text-blue-500`})};let n=[...e.stages].reverse().find(e=>e.status===`error`);return n?{label:`处理过程中出现异常`,description:`${q(n.name)} 执行失败`,icon:(0,R.jsx)(c,{className:`h-4 w-4 text-red-500`})}:{label:`进入正常代理流程`,description:`请求经过检查后继续转发到目标服务`,icon:(0,R.jsx)(a,{className:`h-4 w-4 text-emerald-500`})}}function he({inspection:e}){let t=me(e),n=e.stages.map((e,t)=>({stage:e,index:t})),r=n.filter(({stage:e})=>J(e.hook)===`request`),i=n.filter(({stage:e})=>J(e.hook)===`response`);return(0,R.jsxs)(`div`,{className:`space-y-4 pt-3`,children:[(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,R.jsx)(O,{variant:`outline`,className:`font-mono`,children:e.method}),(0,R.jsx)(`span`,{className:`font-mono text-muted-foreground truncate flex-1`,children:e.url}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,R.jsx)(l,{className:`h-3.5 w-3.5`}),(0,R.jsxs)(`span`,{className:`text-xs`,children:[e.totalDuration,`ms`]})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,R.jsx)(F,{className:`h-3.5 w-3.5`}),`请求入口`]}),(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:`请求进入代理`}),(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`从浏览器或客户端发起,进入 Meddle 的处理流水线`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,R.jsx)(f,{className:`h-3.5 w-3.5`}),`处理阶段`]}),(0,R.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.stages.length,` 个阶段`]}),(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`按实际执行顺序记录插件和系统模块对请求的处理`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[t.icon,`最终结果`]}),(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:t.label}),(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:t.description})]})]})]}),e.stages.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无处理阶段信息(插件模式可能未开启)`}):(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(P,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{children:`默认仅展示改动内容;跳过阶段默认折叠,可单独展开查看更多。`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,R.jsx)($,{title:`请求阶段`,description:`客户端请求进入代理后,按顺序执行请求侧处理阶段`,stages:r,icon:(0,R.jsx)(F,{className:`h-4 w-4 text-blue-500`}),roleLabel:`客户端`,roleIcon:(0,R.jsx)(_,{className:`h-3 w-3 text-blue-500`}),accentClass:`text-blue-500`}),(0,R.jsx)($,{title:`响应阶段`,description:`服务器响应返回代理后,按顺序执行响应侧处理阶段`,stages:i,icon:(0,R.jsx)(k,{className:`h-4 w-4 text-emerald-500`}),roleLabel:`服务器`,roleIcon:(0,R.jsx)(u,{className:`h-3 w-3 text-emerald-500`}),accentClass:`text-emerald-500`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`请求进入`}),(0,R.jsx)(a,{className:`h-4 w-4 animate-pulse text-blue-500`}),(0,R.jsx)(`span`,{children:`请求阶段`}),(0,R.jsx)(a,{className:`h-4 w-4 animate-pulse text-violet-500`}),(0,R.jsx)(`span`,{children:`响应阶段`}),(0,R.jsx)(a,{className:`h-4 w-4 animate-pulse text-emerald-500`}),(0,R.jsx)(`span`,{children:`最终返回`})]})]})]})}function ge(e){return e==null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function _e({record:e,detail:t}){let n=h(e),r=Object.entries(t.requestHeaders||{}).slice(0,6),i=n.kind===`rule`?`source: ${e.source}\ntarget: ${e.target}`:n.kind===`mock`?`mock: true · ${e.source}`:`pass · ${e.source}`;return(0,R.jsxs)(`div`,{className:`space-y-3 pt-3`,"data-testid":`detail-overview-hit`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[72px_1fr] gap-x-3 gap-y-1.5 text-xs`,children:[(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:`方法`}),(0,R.jsx)(`div`,{className:`font-mono font-medium`,children:e.method}),(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:`URL`}),(0,R.jsx)(`div`,{className:`break-all font-mono`,children:e.source}),(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:`状态`}),(0,R.jsxs)(`div`,{className:`font-mono`,children:[t.statusCode,` `,t.statusMessage]}),(0,R.jsx)(`div`,{className:`text-muted-foreground`,children:`延迟`}),(0,R.jsx)(`div`,{className:`font-mono tabular-nums`,children:ge(e.duration)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`命中规则 / Mock`}),(0,R.jsx)(`div`,{className:`mb-1 text-sm font-semibold`,children:n.title}),(0,R.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:n.description}),(0,R.jsx)(`pre`,{className:`meddle-thin-scroll w-full overflow-x-auto rounded border bg-muted/30 px-2 py-1.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all`,"data-testid":`detail-hit-box`,"data-hit-kind":n.kind,children:i})]}),r.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`请求 Headers(节选)`}),(0,R.jsx)(`div`,{className:`grid grid-cols-[minmax(72px,90px)_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>(0,R.jsxs)(I.Fragment,{children:[(0,R.jsx)(`div`,{className:`truncate text-muted-foreground`,title:e,children:e}),(0,R.jsx)(`div`,{className:`truncate font-mono`,title:t,children:t})]},e))})]})]})}function ve({open:e=!1,onClose:t,embedded:n=!1,detail:i,loading:a,error:o,selectedRecord:s,onCreateMock:c,onReplay:l,onJumpToRule:u}){let[d,f]=(0,I.useState)(!1),h=()=>{i&&s&&c&&c({source:s.source,responseBody:i.responseBody,statusCode:i.statusCode,responseHeaders:i.responseHeaders})},[_,w]=(0,I.useState)(null),D=(0,R.jsxs)(R.Fragment,{children:[`请求详情`,i&&(0,R.jsxs)(O,{className:`${U(i.statusCode)} border-0`,children:[i.statusCode,` `,i.statusMessage]}),s?.clientType&&(0,R.jsxs)(O,{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,R.jsxs)(O,{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,R.jsx)(ne,{record:s,compact:!0}),(0,R.jsx)(`span`,{className:`truncate`,children:s.applicationName}),s.applicationIdentitySource===`user-agent`&&(0,R.jsx)(`span`,{className:`shrink-0 text-[9px] text-muted-foreground`,children:`推断`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 ml-auto`,children:[i&&l&&s?.id!=null&&(0,R.jsxs)(r,{variant:`outline`,size:`xs`,onClick:async()=>{if(s?.id!=null&&l){f(!0),w(null);try{await l(s.id)}catch(e){w(e.message||`重放失败`)}finally{f(!1)}}},disabled:d,title:`使用相同的请求参数重新发送请求`,children:[(0,R.jsx)(T,{className:`h-3.5 w-3.5 mr-1 ${d?`animate-spin`:``}`}),d?`重放中...`:`重放`]}),s&&u&&s.source!==s.target&&!s.mock&&(0,R.jsxs)(r,{variant:`outline`,size:`xs`,onClick:()=>u(s),title:`跳转到路由规则配置`,"data-testid":`detail-jump-to-rule`,children:[(0,R.jsx)(S,{className:`h-3.5 w-3.5 mr-1`}),`查看规则`]}),i&&c&&!s?.mock&&(0,R.jsxs)(r,{variant:`outline`,size:`xs`,onClick:h,"data-testid":`detail-create-mock`,children:[(0,R.jsx)(p,{className:`h-3.5 w-3.5 mr-1`}),`创建 Mock`]})]})]}),A=(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsx)(`div`,{className:`px-3 pt-2.5 pb-1.5`,"data-testid":`detail-panel-header`,children:(0,R.jsx)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:D})}):(0,R.jsx)(re,{className:`px-4 pt-4 pb-2`,children:(0,R.jsx)(m,{className:`flex items-center gap-2 text-base`,children:D})}),(0,R.jsx)(E,{}),_&&(0,R.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:_}),o&&!a&&!i&&(0,R.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,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,R.jsx)(te,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):i&&s?(0,R.jsxs)(v,{defaultValue:`overview`,className:`flex-1 flex flex-col min-h-0`,children:[(0,R.jsxs)(x,{className:`mx-4 mt-2 w-fit`,children:[(0,R.jsx)(C,{value:`overview`,"data-testid":`detail-tab-overview`,children:`概览`}),(0,R.jsx)(C,{value:`request`,children:`请求`}),(0,R.jsx)(C,{value:`response`,children:`响应`}),(0,R.jsxs)(C,{value:`inspect`,children:[(0,R.jsx)(k,{className:`h-3.5 w-3.5 mr-1`}),`Inspect`]})]}),(0,R.jsx)(b,{value:`overview`,className:`flex-1 min-h-0 mt-0`,children:(0,R.jsx)(y,{className:`h-full px-4 pb-4`,children:(0,R.jsx)(_e,{record:s,detail:i})})}),(0,R.jsx)(b,{value:`request`,className:`flex-1 min-h-0 mt-0`,children:(0,R.jsx)(y,{className:`h-full px-4 pb-4`,children:(0,R.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Request Headers`}),(0,R.jsx)(H,{headers:i.requestHeaders})]}),(0,R.jsx)(E,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Request Body`}),(0,R.jsx)(V,{body:i.requestBody})]})]})})}),(0,R.jsx)(b,{value:`response`,className:`flex-1 min-h-0 mt-0`,children:(0,R.jsx)(y,{className:`h-full px-4 pb-4`,children:(0,R.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Response Headers`}),(0,R.jsx)(H,{headers:i.responseHeaders})]}),(0,R.jsx)(E,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5 uppercase tracking-wider`,children:`Response Body`}),(0,R.jsx)(V,{body:i.responseBody})]})]})})}),(0,R.jsx)(b,{value:`inspect`,className:`flex-1 min-h-0 mt-0`,children:(0,R.jsx)(y,{className:`h-full px-4 pb-4`,children:i.inspection?(0,R.jsx)(he,{inspection:i.inspection}):(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full py-12 text-muted-foreground`,children:[(0,R.jsx)(k,{className:`h-12 w-12 mb-4 opacity-50`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`无 Inspect 信息`}),(0,R.jsx)(`p`,{className:`text-xs mt-1`,children:`需要开启插件模式(on/shadow)才能查看请求生命周期`})]})})})]}):s?(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm px-6 text-center`,children:(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{children:`详情数据暂不可用`}),(0,R.jsxs)(`div`,{className:`text-xs font-mono break-all`,children:[s.method,` `,s.source]})]})}):(0,R.jsx)(`div`,{"data-testid":`detail-empty-state`,className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`选择左侧一条流量以查看详情 / 命中信息`})]});return n?(0,R.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:A}):(0,R.jsx)(ee,{open:e,onOpenChange:e=>!e&&t?.(),children:(0,R.jsx)(g,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:640,storageKey:`detail-panel`,children:A})})}export{ve as DetailPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,d as t,o as n,p as r}from"./button-BFNlGZ5p.js";import{c as i,n as a,o,r as s,s as c}from"./dist-CFZ4xMSF.js";import{t as l}from"./dist-C-E2R2jk.js";var u=r(t(),1);function d(e,t=globalThis?.document){let n=l(e);u.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var f=e(),p=`DismissableLayer`,m=`dismissableLayer.update`,h=`dismissableLayer.pointerDownOutside`,g=`dismissableLayer.focusOutside`,_,v=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),y=u.forwardRef((e,t)=>{let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:l,onDismiss:p,...h}=e,g=u.useContext(v),[y,b]=u.useState(null),x=y?.ownerDocument??globalThis?.document,[,T]=u.useState({}),E=n(t,e=>b(e)),D=Array.from(g.layers),[O]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),k=D.indexOf(O),A=y?D.indexOf(y):-1,j=g.layersWithOutsidePointerEventsDisabled.size>0,M=A>=k,N=S(e=>{let t=e.target,n=[...g.branches].some(e=>e.contains(t));!M||n||(a?.(e),l?.(e),e.defaultPrevented||p?.())},x),P=C(e=>{let t=e.target;[...g.branches].some(e=>e.contains(t))||(c?.(e),l?.(e),e.defaultPrevented||p?.())},x);return d(e=>{A===g.layers.size-1&&(i?.(e),!e.defaultPrevented&&p&&(e.preventDefault(),p()))},x),u.useEffect(()=>{if(y)return r&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(_=x.body.style.pointerEvents,x.body.style.pointerEvents=`none`),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),w(),()=>{r&&g.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=_)}},[y,x,r,g]),u.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),w())},[y,g]),u.useEffect(()=>{let e=()=>T({});return document.addEventListener(m,e),()=>document.removeEventListener(m,e)},[]),(0,f.jsx)(o.div,{...h,ref:E,style:{pointerEvents:j?M?`auto`:`none`:void 0,...e.style},onFocusCapture:s(e.onFocusCapture,P.onFocusCapture),onBlurCapture:s(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:s(e.onPointerDownCapture,N.onPointerDownCapture)})});y.displayName=p;var b=`DismissableLayerBranch`,x=u.forwardRef((e,t)=>{let r=u.useContext(v),i=u.useRef(null),a=n(t,i);return u.useEffect(()=>{let e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),(0,f.jsx)(o.div,{...e,ref:a})});x.displayName=b;function S(e,t=globalThis?.document){let n=l(e),r=u.useRef(!1),i=u.useRef(()=>{});return u.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){T(h,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function C(e,t=globalThis?.document){let n=l(e),r=u.useRef(!1);return u.useEffect(()=>{let e=e=>{e.target&&!r.current&&T(g,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function w(){let e=new CustomEvent(m);document.dispatchEvent(e)}function T(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?c(i,a):i.dispatchEvent(a)}var E=r(i(),1),D=`Portal`,O=u.forwardRef((e,t)=>{let{container:n,...r}=e,[i,s]=u.useState(!1);a(()=>s(!0),[]);let c=n||i&&globalThis?.document?.body;return c?E.createPortal((0,f.jsx)(o.div,{...r,ref:t}),c):null});O.displayName=D;export{y as n,O as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,d as t,o as n,p as r}from"./button-BFNlGZ5p.js";import{a as i,c as a,n as o,o as s}from"./dist-CFZ4xMSF.js";import{t as c}from"./dist-C-E2R2jk.js";import{t as l}from"./dist-BCvvYbmI.js";var u=r(t(),1),d=e(),f=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),p=`VisuallyHidden`,m=u.forwardRef((e,t)=>(0,d.jsx)(s.span,{...e,ref:t,style:{...f,...e.style}}));m.displayName=p;var h=m,g=[`top`,`right`,`bottom`,`left`],_=Math.min,v=Math.max,y=Math.round,b=Math.floor,x=e=>({x:e,y:e}),S={left:`right`,right:`left`,bottom:`top`,top:`bottom`},C={start:`end`,end:`start`};function w(e,t,n){return v(e,_(t,n))}function T(e,t){return typeof e==`function`?e(t):e}function E(e){return e.split(`-`)[0]}function D(e){return e.split(`-`)[1]}function O(e){return e===`x`?`y`:`x`}function k(e){return e===`y`?`height`:`width`}var A=new Set([`top`,`bottom`]);function j(e){return A.has(E(e))?`y`:`x`}function M(e){return O(j(e))}function N(e,t,n){n===void 0&&(n=!1);let r=D(e),i=M(e),a=k(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=H(o)),[o,H(o)]}function P(e){let t=H(e);return[F(e),t,F(t)]}function F(e){return e.replace(/start|end/g,e=>C[e])}var I=[`left`,`right`],L=[`right`,`left`],R=[`top`,`bottom`],z=[`bottom`,`top`];function B(e,t,n){switch(e){case`top`:case`bottom`:return n?t?L:I:t?I:L;case`left`:case`right`:return t?R:z;default:return[]}}function V(e,t,n,r){let i=D(e),a=B(E(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(F)))),a}function H(e){return e.replace(/left|right|bottom|top/g,e=>S[e])}function ee(e){return{top:0,right:0,bottom:0,left:0,...e}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function ne(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function re(e,t,n){let{reference:r,floating:i}=e,a=j(t),o=M(t),s=k(o),c=E(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(D(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ie(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=T(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ne(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ne(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ae=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=re(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:{...o,detectOverflow:o.detectOverflow??ie},elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=re(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},oe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=T(e,t)||{};if(l==null)return{};let d=te(u),f={x:n,y:r},p=M(i),m=k(p),h=await o.getDimensions(l),g=p===`y`,v=g?`top`:`left`,y=g?`bottom`:`right`,b=g?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],S=f[p]-a.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),E=C?C[b]:0;(!E||!await(o.isElement==null?void 0:o.isElement(C)))&&(E=s.floating[b]||a.floating[m]);let O=x/2-S/2,A=E/2-h[m]/2-1,j=_(d[v],A),N=_(d[y],A),P=j,F=E-h[m]-N,I=E/2-h[m]/2+O,L=w(P,I,F),R=!c.arrow&&D(i)!=null&&I!==L&&a.reference[m]/2-(I<P?j:N)-h[m]/2<0,z=R?I<P?I-P:I-F:0;return{[p]:f[p]+z,data:{[p]:L,centerOffset:I-L-z,...R&&{alignmentOffset:z}},reset:R}}}),se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=T(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=E(r),_=j(o),v=E(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[H(o)]:P(o)),x=p!==`none`;!d&&x&&b.push(...V(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],D=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=N(r,a,y);w.push(C[e[0]],C[e[1]])}if(D=[...D,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==j(t))||D.every(e=>j(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=j(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function le(e){return g.some(t=>e[t]>=0)}var ue=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=T(e,t);switch(i){case`referenceHidden`:{let e=ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:le(e)}}}case`escaped`:{let e=ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:le(e)}}}default:return{}}}}},de=new Set([`left`,`top`]);async function fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=E(n),s=D(n),c=j(n)===`y`,l=de.has(o)?-1:1,u=a&&c?-1:1,d=T(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fe(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},me=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=T(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=j(E(i)),p=O(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=w(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=w(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},he=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=T(e,t),u={x:n,y:r},d=j(i),f=O(d),p=u[f],m=u[d],h=T(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=de.has(E(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ge=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=T(e,t),u=await o.detectOverflow(t,l),d=E(i),f=D(i),p=j(i)===`y`,{width:m,height:h}=a.floating,g,y;d===`top`||d===`bottom`?(g=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,g=f===`end`?`top`:`bottom`);let b=h-u.top-u.bottom,x=m-u.left-u.right,S=_(h-u[g],b),C=_(m-u[y],x),w=!t.middlewareData.shift,O=S,k=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(O=b),w&&!f){let e=v(u.left,0),t=v(u.right,0),n=v(u.top,0),r=v(u.bottom,0);p?k=m-2*(e!==0||t!==0?e+t:v(u.left,u.right)):O=h-2*(n!==0||r!==0?n+r:v(u.top,u.bottom))}await c({...t,availableWidth:k,availableHeight:O});let A=await o.getDimensions(s.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function _e(){return typeof window<`u`}function U(e){return ve(e)?(e.nodeName||``).toLowerCase():`#document`}function W(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function G(e){return((ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ve(e){return _e()?e instanceof Node||e instanceof W(e).Node:!1}function K(e){return _e()?e instanceof Element||e instanceof W(e).Element:!1}function q(e){return _e()?e instanceof HTMLElement||e instanceof W(e).HTMLElement:!1}function ye(e){return!_e()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof W(e).ShadowRoot}var be=new Set([`inline`,`contents`]);function J(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!be.has(i)}var xe=new Set([`table`,`td`,`th`]);function Se(e){return xe.has(U(e))}var Ce=[`:popover-open`,`:modal`];function we(e){return Ce.some(t=>{try{return e.matches(t)}catch{return!1}})}var Te=[`transform`,`translate`,`scale`,`rotate`,`perspective`],Ee=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],De=[`paint`,`layout`,`strict`,`content`];function Oe(e){let t=Ae(),n=K(e)?X(e):e;return Te.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||Ee.some(e=>(n.willChange||``).includes(e))||De.some(e=>(n.contain||``).includes(e))}function ke(e){let t=Z(e);for(;q(t)&&!Y(t);){if(Oe(t))return t;if(we(t))return null;t=Z(t)}return null}function Ae(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var je=new Set([`html`,`body`,`#document`]);function Y(e){return je.has(U(e))}function X(e){return W(e).getComputedStyle(e)}function Me(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Z(e){if(U(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||G(e);return ye(t)?t.host:t}function Ne(e){let t=Z(e);return Y(t)?e.ownerDocument?e.ownerDocument.body:e.body:q(t)&&J(t)?t:Ne(t)}function Pe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ne(e),i=r===e.ownerDocument?.body,a=W(r);if(i){let e=Fe(a);return t.concat(a,a.visualViewport||[],J(r)?r:[],e&&n?Pe(e):[])}return t.concat(r,Pe(r,[],n))}function Fe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ie(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=q(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=y(n)!==a||y(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Le(e){return K(e)?e:e.contextElement}function Q(e){let t=Le(e);if(!q(t))return x(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ie(t),o=(a?y(n.width):n.width)/r,s=(a?y(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Re=x(0);function ze(e){let t=W(e);return!Ae()||!t.visualViewport?Re:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Be(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==W(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Le(e),o=x(1);t&&(r?K(r)&&(o=Q(r)):o=Q(e));let s=Be(a,n,r)?ze(a):x(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=W(a),t=r&&K(r)?W(r):r,n=e,i=Fe(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=W(i),i=Fe(n)}}return ne({width:u,height:d,x:c,y:l})}function Ve(e,t){let n=Me(e).scrollLeft;return t?t.left+n:$(G(e)).left+n}function He(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ve(e,n),y:n.top+t.scrollTop}}function Ue(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=G(r),s=t?we(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=x(1),u=x(0),d=q(r);if((d||!d&&!a)&&((U(r)!==`body`||J(o))&&(c=Me(r)),q(r))){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?He(o,c):x(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function We(e){return Array.from(e.getClientRects())}function Ge(e){let t=G(e),n=Me(e),r=e.ownerDocument.body,i=v(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=v(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Ve(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=v(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Ke=25;function qe(e,t){let n=W(e),r=G(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ae();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Ve(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ke&&(a-=o)}else l<=Ke&&(a+=l);return{width:a,height:o,x:s,y:c}}var Je=new Set([`absolute`,`fixed`]);function Ye(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=q(e)?Q(e):x(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Xe(e,t,n){let r;if(t===`viewport`)r=qe(e,n);else if(t===`document`)r=Ge(G(e));else if(K(t))r=Ye(t,n);else{let n=ze(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ne(r)}function Ze(e,t){let n=Z(e);return n===t||!K(n)||Y(n)?!1:X(n).position===`fixed`||Ze(n,t)}function Qe(e,t){let n=t.get(e);if(n)return n;let r=Pe(e,[],!1).filter(e=>K(e)&&U(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?Z(e):e;for(;K(o)&&!Y(o);){let t=X(o),n=Oe(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Je.has(i.position)||J(o)&&!n&&Ze(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function $e(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?we(t)?[]:Qe(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=Xe(t,n,i);return e.top=v(r.top,e.top),e.right=_(r.right,e.right),e.bottom=_(r.bottom,e.bottom),e.left=v(r.left,e.left),e},Xe(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function et(e){let{width:t,height:n}=Ie(e);return{width:t,height:n}}function tt(e,t,n){let r=q(t),i=G(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=x(0);function l(){c.x=Ve(i)}if(r||!r&&!a)if((U(t)!==`body`||J(i))&&(s=Me(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?He(i,s):x(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function nt(e){return X(e).position===`static`}function rt(e,t){if(!q(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return G(e)===n&&(n=n.ownerDocument.body),n}function it(e,t){let n=W(e);if(we(e))return n;if(!q(e)){let t=Z(e);for(;t&&!Y(t);){if(K(t)&&!nt(t))return t;t=Z(t)}return n}let r=rt(e,t);for(;r&&Se(r)&&nt(r);)r=rt(r,t);return r&&Y(r)&&nt(r)&&!Oe(r)?n:r||ke(e)||n}var at=async function(e){let t=this.getOffsetParent||it,n=this.getDimensions,r=await n(e.floating);return{reference:tt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ot(e){return X(e).direction===`rtl`}var st={convertOffsetParentRelativeRectToViewportRelativeRect:Ue,getDocumentElement:G,getClippingRect:$e,getOffsetParent:it,getElementRects:at,getClientRects:We,getDimensions:et,getScale:Q,isElement:K,isRTL:ot};function ct(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lt(e,t){let n=null,r,i=G(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=b(d),h=b(i.clientWidth-(u+f)),g=b(i.clientHeight-(d+p)),y=b(u),x={rootMargin:-m+`px `+-h+`px `+-g+`px `+-y+`px`,threshold:v(0,_(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!ct(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function ut(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Le(e),u=i||a?[...l?Pe(l):[],...Pe(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?lt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!ct(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var dt=pe,ft=me,pt=se,mt=ge,ht=ue,gt=oe,_t=he,vt=(e,t,n)=>{let r=new Map,i={platform:st,...n},a={...i.platform,_c:r};return ae(e,t,{...i,platform:a})},yt=r(a(),1),bt=typeof document<`u`?u.useLayoutEffect:function(){};function xt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!xt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!xt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function St(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ct(e,t){let n=St(e);return Math.round(t*n)/n}function wt(e){let t=u.useRef(e);return bt(()=>{t.current=e}),t}function Tt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[d,f]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=u.useState(r);xt(p,r)||m(r);let[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=u.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=u.useRef(null),w=u.useRef(null),T=u.useRef(d),E=c!=null,D=wt(c),O=wt(i),k=wt(l),A=u.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),vt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!xt(T.current,t)&&(T.current=t,yt.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);bt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=u.useRef(!1);bt(()=>(j.current=!0,()=>{j.current=!1}),[]),bt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=u.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=u.useMemo(()=>({reference:x,floating:S}),[x,S]),P=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Ct(N.floating,d.x),r=Ct(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...St(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var Et=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:gt({element:r.current,padding:i}).fn(n):r?gt({element:r,padding:i}).fn(n):{}}}},Dt=(e,t)=>({...dt(e),options:[e,t]}),Ot=(e,t)=>({...ft(e),options:[e,t]}),kt=(e,t)=>({..._t(e),options:[e,t]}),At=(e,t)=>({...pt(e),options:[e,t]}),jt=(e,t)=>({...mt(e),options:[e,t]}),Mt=(e,t)=>({...ht(e),options:[e,t]}),Nt=(e,t)=>({...Et(e),options:[e,t]}),Pt=`Arrow`,Ft=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,d.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,d.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ft.displayName=Pt;var It=Ft,Lt=`Popper`,[Rt,zt]=i(Lt),[Bt,Vt]=Rt(Lt),Ht=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null);return(0,d.jsx)(Bt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ht.displayName=Lt;var Ut=`PopperAnchor`,Wt=u.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:i,...a}=e,o=Vt(Ut,r),c=u.useRef(null),l=n(t,c),f=u.useRef(null);return u.useEffect(()=>{let e=f.current;f.current=i?.current||c.current,e!==f.current&&o.onAnchorChange(f.current)}),i?null:(0,d.jsx)(s.div,{...a,ref:l})});Wt.displayName=Ut;var Gt=`PopperContent`,[Kt,qt]=Rt(Gt),Jt=u.forwardRef((e,t)=>{let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:f=`center`,alignOffset:p=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Vt(Gt,r),[w,T]=u.useState(null),E=n(t,e=>T(e)),[D,O]=u.useState(null),k=l(D),A=k?.width??0,j=k?.height??0,M=i+(f===`center`?``:`-`+f),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],F=P.length>0,I={padding:N,boundary:P.filter(Qt),altBoundary:F},{refs:L,floatingStyles:R,placement:z,isPositioned:B,middlewareData:V}=Tt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>ut(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[Dt({mainAxis:a+j,alignmentAxis:p}),h&&Ot({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?kt():void 0,...I}),h&&At({...I}),jt({...I,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Nt({element:D,padding:m}),$t({arrowWidth:A,arrowHeight:j}),y&&Mt({strategy:`referenceHidden`,...I})]}),[H,ee]=en(z),te=c(x);o(()=>{B&&te?.()},[B,te]);let ne=V.arrow?.x,re=V.arrow?.y,ie=V.arrow?.centerOffset!==0,[ae,oe]=u.useState();return o(()=>{w&&oe(window.getComputedStyle(w).zIndex)},[w]),(0,d.jsx)(`div`,{ref:L.setFloating,"data-radix-popper-content-wrapper":``,style:{...R,transform:B?R.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(` `),...V.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,d.jsx)(Kt,{scope:r,placedSide:H,onArrowChange:O,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,d.jsx)(s.div,{"data-side":H,"data-align":ee,...S,ref:E,style:{...S.style,animation:B?void 0:`none`}})})})});Jt.displayName=Gt;var Yt=`PopperArrow`,Xt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Zt=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=qt(Yt,n),a=Xt[i.placedSide];return(0,d.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,d.jsx)(It,{...r,ref:t,style:{...r.style,display:`block`}})})});Zt.displayName=Yt;function Qt(e){return e!==null}var $t=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=en(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function en(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var tn=Ht,nn=Wt,rn=Jt,an=Zt;export{zt as a,tn as i,an as n,h as o,rn as r,f as s,nn as t};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{c as e,d as t,o as n,p as r,r as i,u as a}from"./button-BFNlGZ5p.js";import{a as o,i as s,o as c,r as l,t as u}from"./dist-CFZ4xMSF.js";import{t as d}from"./dist-CRmX_NvH.js";import{n as f}from"./dist-C-E2R2jk.js";import{n as p,t as m}from"./dist-BNcjMpca.js";import{i as h,n as g,r as _,t as v}from"./es2015-CRmLuA2o.js";var y=a(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),b=r(t(),1),x=e(),S=`Dialog`,[C,ee]=o(S),[w,T]=C(S),E=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=b.useRef(null),c=b.useRef(null),[l,d]=u({prop:r,defaultProp:i??!1,onChange:a,caller:S});return(0,x.jsx)(w,{scope:t,triggerRef:s,contentRef:c,contentId:f(),titleId:f(),descriptionId:f(),open:l,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};E.displayName=S;var D=`DialogTrigger`,O=b.forwardRef((e,t)=>{let{__scopeDialog:r,...i}=e,a=T(D,r),o=n(t,a.triggerRef);return(0,x.jsx)(c.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.contentId,"data-state":J(a.open),...i,ref:o,onClick:l(e.onClick,a.onOpenToggle)})});O.displayName=D;var k=`DialogPortal`,[A,j]=C(k,{forceMount:void 0}),M=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=T(k,t);return(0,x.jsx)(A,{scope:t,forceMount:n,children:b.Children.map(r,e=>(0,x.jsx)(d,{present:n||a.open,children:(0,x.jsx)(m,{asChild:!0,container:i,children:e})}))})};M.displayName=k;var N=`DialogOverlay`,P=b.forwardRef((e,t)=>{let n=j(N,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=T(N,e.__scopeDialog);return a.modal?(0,x.jsx)(d,{present:r||a.open,children:(0,x.jsx)(I,{...i,ref:t})}):null});P.displayName=N;var F=i(`DialogOverlay.RemoveScroll`),I=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(N,n);return(0,x.jsx)(g,{as:F,allowPinchZoom:!0,shards:[i.contentRef],children:(0,x.jsx)(c.div,{"data-state":J(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),L=`DialogContent`,R=b.forwardRef((e,t)=>{let n=j(L,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=T(L,e.__scopeDialog);return(0,x.jsx)(d,{present:r||a.open,children:a.modal?(0,x.jsx)(z,{...i,ref:t}):(0,x.jsx)(B,{...i,ref:t})})});R.displayName=L;var z=b.forwardRef((e,t)=>{let r=T(L,e.__scopeDialog),i=b.useRef(null),a=n(t,r.contentRef,i);return b.useEffect(()=>{let e=i.current;if(e)return v(e)},[]),(0,x.jsx)(V,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:l(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:l(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:l(e.onFocusOutside,e=>e.preventDefault())})}),B=b.forwardRef((e,t)=>{let n=T(L,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return(0,x.jsx)(V,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),V=b.forwardRef((e,t)=>{let{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,...s}=e,c=T(L,r),l=b.useRef(null),u=n(t,l);return _(),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(h,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:o,children:(0,x.jsx)(p,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":J(c.open),...s,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Z,{titleId:c.titleId}),(0,x.jsx)($,{contentRef:l,descriptionId:c.descriptionId})]})]})}),H=`DialogTitle`,U=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(H,n);return(0,x.jsx)(c.h2,{id:i.titleId,...r,ref:t})});U.displayName=H;var W=`DialogDescription`,G=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(W,n);return(0,x.jsx)(c.p,{id:i.descriptionId,...r,ref:t})});G.displayName=W;var K=`DialogClose`,q=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(K,n);return(0,x.jsx)(c.button,{type:`button`,...r,ref:t,onClick:l(e.onClick,()=>i.onOpenChange(!1))})});q.displayName=K;function J(e){return e?`open`:`closed`}var Y=`DialogTitleWarning`,[te,X]=s(Y,{contentName:L,titleName:H,docsSlug:`dialog`}),Z=({titleId:e})=>{let t=X(Y),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
2
|
-
|
|
3
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
|
-
|
|
5
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Q=`DialogDescriptionWarning`,$=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${X(Q).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},ne=E,re=M,ie=P,ae=R,oe=U,se=G,ce=q;export{re as a,y as c,ie as i,ae as n,ne as o,se as r,oe as s,ce as t};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import{c as e,d as t,o as n,p as r}from"./button-BFNlGZ5p.js";import{o as i}from"./dist-CFZ4xMSF.js";import{t as a}from"./dist-C-E2R2jk.js";var o=r(t(),1),s=e(),c=`focusScope.autoFocusOnMount`,l=`focusScope.autoFocusOnUnmount`,u={bubbles:!1,cancelable:!0},d=`FocusScope`,f=o.forwardRef((e,t)=>{let{loop:r=!1,trapped:d=!1,onMountAutoFocus:f,onUnmountAutoFocus:g,..._}=e,[v,x]=o.useState(null),S=a(f),w=a(g),T=o.useRef(null),E=n(t,e=>x(e)),D=o.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;o.useEffect(()=>{if(d){let e=function(e){if(D.paused||!v)return;let t=e.target;v.contains(t)?T.current=t:y(T.current,{select:!0})},t=function(e){if(D.paused||!v)return;let t=e.relatedTarget;t!==null&&(v.contains(t)||y(T.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&y(v)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return v&&r.observe(v,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[d,v,D.paused]),o.useEffect(()=>{if(v){b.add(D);let e=document.activeElement;if(!v.contains(e)){let t=new CustomEvent(c,u);v.addEventListener(c,S),v.dispatchEvent(t),t.defaultPrevented||(p(C(h(v)),{select:!0}),document.activeElement===e&&y(v))}return()=>{v.removeEventListener(c,S),setTimeout(()=>{let t=new CustomEvent(l,u);v.addEventListener(l,w),v.dispatchEvent(t),t.defaultPrevented||y(e??document.body,{select:!0}),v.removeEventListener(l,w),b.remove(D)},0)}}},[v,S,w,D]);let O=o.useCallback(e=>{if(!r&&!d||D.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){let t=e.currentTarget,[i,a]=m(t);i&&a?!e.shiftKey&&n===a?(e.preventDefault(),r&&y(i,{select:!0})):e.shiftKey&&n===i&&(e.preventDefault(),r&&y(a,{select:!0})):n===t&&e.preventDefault()}},[r,d,D.paused]);return(0,s.jsx)(i.div,{tabIndex:-1,..._,ref:E,onKeyDown:O})});f.displayName=d;function p(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(y(r,{select:t}),document.activeElement!==n)return}function m(e){let t=h(e);return[g(t,e),g(t.reverse(),e)]}function h(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function g(e,t){for(let n of e)if(!_(n,{upTo:t}))return n}function _(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function v(e){return e instanceof HTMLInputElement&&`select`in e}function y(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&v(e)&&t&&e.select()}}var b=x();function x(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=S(e,t),e.unshift(t)},remove(t){e=S(e,t),e[0]?.resume()}}}function S(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function C(e){return e.filter(e=>e.tagName!==`A`)}var w=0;function T(){o.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??E()),document.body.insertAdjacentElement(`beforeend`,e[1]??E()),w++,()=>{w===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),w--}},[])}function E(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var D=function(){return D=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},D.apply(this,arguments)};function O(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ee(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var k=`right-scroll-bar-position`,A=`width-before-scroll-bar`,te=`with-scroll-bars-hidden`,ne=`--removed-body-scroll-bar-size`;function j(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function re(e,t){var n=(0,o.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var ie=typeof window<`u`?o.useLayoutEffect:o.useEffect,M=new WeakMap;function ae(e,t){var n=re(t||null,function(t){return e.forEach(function(e){return j(e,t)})});return ie(function(){var t=M.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||j(e,null)}),i.forEach(function(e){r.has(e)||j(e,a)})}M.set(n,e)},[e]),n}function oe(e){return e}function se(e,t){t===void 0&&(t=oe);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ce(e){e===void 0&&(e={});var t=se(null);return t.options=D({async:!0,ssr:!1},e),t}var N=function(e){var t=e.sideCar,n=O(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return o.createElement(r,D({},n))};N.isSideCarExport=!0;function le(e,t){return e.useMedium(t),N}var P=ce(),F=function(){},I=o.forwardRef(function(e,t){var n=o.useRef(null),r=o.useState({onScrollCapture:F,onWheelCapture:F,onTouchMoveCapture:F}),i=r[0],a=r[1],s=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=O(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=ae([n,t]),w=D(D({},x),i);return o.createElement(o.Fragment,null,d&&o.createElement(S,{sideCar:P,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),s?o.cloneElement(o.Children.only(c),D(D({},w),{ref:C})):o.createElement(y,D({},w,{className:l,ref:C}),c))});I.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},I.classNames={fullWidth:A,zeroRight:k};var L,ue=function(){if(L)return L;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function de(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=ue();return t&&e.setAttribute(`nonce`,t),e}function fe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function pe(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var me=function(){var e=0,t=null;return{add:function(n){e==0&&(t=de())&&(fe(t,n),pe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},he=function(){var e=me();return function(t,n){o.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},R=function(){var e=he();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},ge={left:0,top:0,right:0,gap:0},z=function(e){return parseInt(e||``,10)||0},_e=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[z(n),z(r),z(i)]},ve=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return ge;var t=_e(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ye=R(),B=`data-scroll-locked`,be=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
|
-
.${te} {
|
|
3
|
-
overflow: hidden ${r};
|
|
4
|
-
padding-right: ${s}px ${r};
|
|
5
|
-
}
|
|
6
|
-
body[${B}] {
|
|
7
|
-
overflow: hidden ${r};
|
|
8
|
-
overscroll-behavior: contain;
|
|
9
|
-
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
10
|
-
padding-left: ${i}px;
|
|
11
|
-
padding-top: ${a}px;
|
|
12
|
-
padding-right: ${o}px;
|
|
13
|
-
margin-left:0;
|
|
14
|
-
margin-top:0;
|
|
15
|
-
margin-right: ${s}px ${r};
|
|
16
|
-
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.${k} {
|
|
20
|
-
right: ${s}px ${r};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.${A} {
|
|
24
|
-
margin-right: ${s}px ${r};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.${k} .${k} {
|
|
28
|
-
right: 0 ${r};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.${A} .${A} {
|
|
32
|
-
margin-right: 0 ${r};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
body[${B}] {
|
|
36
|
-
${ne}: ${s}px;
|
|
37
|
-
}
|
|
38
|
-
`},V=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},xe=function(){o.useEffect(function(){return document.body.setAttribute(B,(V()+1).toString()),function(){var e=V()-1;e<=0?document.body.removeAttribute(B):document.body.setAttribute(B,e.toString())}},[])},Se=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;xe();var a=o.useMemo(function(){return ve(i)},[i]);return o.createElement(ye,{styles:be(a,!t,i,n?``:`!important`)})},H=!1;if(typeof window<`u`)try{var U=Object.defineProperty({},`passive`,{get:function(){return H=!0,!0}});window.addEventListener(`test`,U,U),window.removeEventListener(`test`,U,U)}catch{H=!1}var W=H?{passive:!1}:!1,Ce=function(e){return e.tagName===`TEXTAREA`},G=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Ce(e)&&n[t]===`visible`)},we=function(e){return G(e,`overflowY`)},Te=function(e){return G(e,`overflowX`)},K=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),q(e,r)){var i=Oe(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ee=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},De=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},q=function(e,t){return e===`v`?we(t):Te(t)},Oe=function(e,t){return e===`v`?Ee(t):De(t)},ke=function(e,t){return e===`h`&&t===`rtl`?-1:1},Ae=function(e,t,n,r,i){var a=ke(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Oe(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&q(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},J=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},je=function(e){return[e.deltaX,e.deltaY]},Me=function(e){return e&&`current`in e?e.current:e},Ne=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pe=function(e){return`
|
|
39
|
-
.block-interactivity-${e} {pointer-events: none;}
|
|
40
|
-
.allow-interactivity-${e} {pointer-events: all;}
|
|
41
|
-
`},Fe=0,Y=[];function Ie(e){var t=o.useRef([]),n=o.useRef([0,0]),r=o.useRef(),i=o.useState(Fe++)[0],a=o.useState(R)[0],s=o.useRef(e);o.useEffect(function(){s.current=e},[e]),o.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ee([e.lockRef.current],(e.shards||[]).map(Me),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var c=o.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!s.current.allowPinchZoom;var i=J(e),a=n.current,o=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(o)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=K(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=K(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(o||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ae(h,t,e,h===`h`?o:c,!0)},[]),l=o.useCallback(function(e){var n=e;if(!(!Y.length||Y[Y.length-1]!==a)){var r=`deltaY`in n?je(n):J(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Ne(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var o=(s.current.shards||[]).map(Me).filter(Boolean).filter(function(e){return e.contains(n.target)});(o.length>0?c(n,o[0]):!s.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=o.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Le(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=o.useCallback(function(e){n.current=J(e),r.current=void 0},[]),f=o.useCallback(function(t){u(t.type,je(t),t.target,c(t,e.lockRef.current))},[]),p=o.useCallback(function(t){u(t.type,J(t),t.target,c(t,e.lockRef.current))},[]);o.useEffect(function(){return Y.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,l,W),document.addEventListener(`touchmove`,l,W),document.addEventListener(`touchstart`,d,W),function(){Y=Y.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,l,W),document.removeEventListener(`touchmove`,l,W),document.removeEventListener(`touchstart`,d,W)}},[]);var m=e.removeScrollBar,h=e.inert;return o.createElement(o.Fragment,null,h?o.createElement(a,{styles:Pe(i)}):null,m?o.createElement(Se,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Le(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Re=le(P,Ie),ze=o.forwardRef(function(e,t){return o.createElement(I,D({},e,{ref:t,sideCar:Re}))});ze.classNames=I.classNames;var Be=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},X=new WeakMap,Z=new WeakMap,Q={},$=0,Ve=function(e){return e&&(e.host||Ve(e.parentNode))},He=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ve(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Ue=function(e,t,n,r){var i=He(t,Array.isArray(e)?e:[e]);Q[n]||(Q[n]=new WeakMap);var a=Q[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(X.get(e)||0)+1,l=(a.get(e)||0)+1;X.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Z.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),$++,function(){o.forEach(function(e){var t=X.get(e)-1,i=a.get(e)-1;X.set(e,t),a.set(e,i),t||(Z.has(e)||e.removeAttribute(r),Z.delete(e)),i||e.removeAttribute(n)}),$--,$||(X=new WeakMap,X=new WeakMap,Z=new WeakMap,Q={})}},We=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Be(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Ue(r,i,n,`aria-hidden`)):function(){return null}};export{f as i,ze as n,T as r,We as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,d as t,l as n,p as r,t as i,u as a}from"./button-BFNlGZ5p.js";import"./dist-CFZ4xMSF.js";import{t as o}from"./circle-x-BEkinhez.js";import{n as s,t as c}from"./server-eYXq3PbE.js";import{t as l}from"./refresh-cw-BfLoHqg5.js";import{t as ee}from"./shield-check-hQXjdfZ7.js";import{t as u}from"./wifi-QkTcTrED.js";import{t as d}from"./switch-DpLnRvOJ.js";import{At as te,G as f,It as p,J as m,K as h,U as g,at as _,ct as v,dt as y,ft as b,ht as ne,lt as x,ot as S,q as C,rt as w,st as re,ut as T}from"./index-CkoYwomI.js";import{n as E,r as D,t as O}from"./alert-BmsRCcSL.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./table-C3mgEjkP.js";var F=a(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),I=a(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),L=a(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),R=a(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),z=r(t(),1),B=e(),V={ok:`正常`,degraded:`降级`,critical:`严重`},ie={cpu:`CPU`,rss:`RSS 内存`,connections:`连接数`,mitmServers:`MITM 服务`,eventLoopDelay:`事件循环延迟`,fds:`文件描述符`};function H(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.generatedAt==`number`&&typeof t.status==`string`&&typeof t.pid==`number`&&typeof t.uptimeSec==`number`&&!!t.memory&&!!t.cpu&&!!t.connections&&!!t.mitmServers&&Array.isArray(t.checks)}async function U(){let e=await fetch(`/api/health`,{cache:`no-store`});if(!e.ok)throw Error(`健康接口返回 ${e.status}`);let t=await e.json();if(!H(t))throw Error(`健康接口返回格式不正确`);return t}function W(e){if(!Number.isFinite(e))return`-`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=t[0];for(let e=1;e<t.length&&n>=1024;e+=1)n/=1024,r=t[e];return`${n>=10?n.toFixed(0):n.toFixed(1)} ${r}`}function G(e){if(!Number.isFinite(e)||e<0)return`-`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60);return t>0?`${t}天 ${n}小时`:n>0?`${n}小时 ${r}分钟`:r>0?`${r}分钟 ${i}秒`:`${i}秒`}function K(e){return e?new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(new Date(e)):`-`}function q(e,t){return t===`bytes`?W(e):t===`%`?`${e.toFixed(1)}%`:t===`ms`?`${e.toFixed(1)} ms`:String(e)}function J(e,t){return t===`bytes`?W(e):t===`%`?`${e}%`:t===`ms`?`${e} ms`:String(e)}function ae(e){if(!e||typeof e!=`object`)return null;let t=e;return Array.isArray(t.keys)?{windowMs:Number(t.windowMs)||0,maxPerWindow:Number(t.maxPerWindow)||0,keys:t.keys,suppressedTotal:Number(t.suppressedTotal)||0}:null}function Y({status:e}){return(0,B.jsxs)(w,{variant:e===`critical`?`destructive`:e===`degraded`?`secondary`:`default`,children:[e===`ok`?(0,B.jsx)(p,{}):e===`degraded`?(0,B.jsx)(b,{}):(0,B.jsx)(o,{}),V[e]]})}function oe({icon:e,label:t,value:n,detail:r}){return(0,B.jsxs)(S,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsx)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:(0,B.jsxs)(y,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(e,{}),t]})}),(0,B.jsxs)(v,{className:`flex flex-col gap-1 p-[var(--ui-page-padding)]`,children:[(0,B.jsx)(`div`,{className:`text-2xl font-semibold tracking-tight`,children:n}),(0,B.jsx)(`div`,{className:`min-h-4 truncate text-xs text-muted-foreground`,title:r,children:r})]})]})}function X({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-lg border bg-background p-[var(--ui-section-gap)]`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`truncate text-sm font-medium`,title:t,children:t})]})}function se(){return(0,B.jsxs)(`div`,{className:`app-workspace-content`,"aria-label":`正在读取健康状态`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(_,{className:`h-7 w-40`}),(0,B.jsx)(_,{className:`h-4 w-64`})]}),(0,B.jsx)(_,{className:`h-8 w-28`})]}),(0,B.jsx)(`div`,{className:`grid gap-[var(--ui-section-gap)] md:grid-cols-2 xl:grid-cols-6`,children:Array.from({length:6}).map((e,t)=>(0,B.jsx)(_,{className:`h-32 w-full`},t))}),(0,B.jsx)(_,{className:`h-80 w-full`})]})}function Z(){let[e,t]=(0,z.useState)(null),[r,a]=(0,z.useState)(!0),[o,p]=(0,z.useState)(!1),[_,V]=(0,z.useState)(``),[H,Z]=(0,z.useState)(!0),Q=(0,z.useCallback)(async(e=!1)=>{e?p(!0):a(!0),V(``);try{t(await U())}catch(e){V(e instanceof Error?e.message:`无法读取健康状态`)}finally{a(!1),p(!1)}},[]);(0,z.useEffect)(()=>{Q()},[Q]),(0,z.useEffect)(()=>{if(!H)return;let e=window.setInterval(()=>{Q(!0)},5e3);return()=>window.clearInterval(e)},[H,Q]);let $=(0,z.useMemo)(()=>ae(e?.logs),[e]);if(r&&!e)return(0,B.jsx)(se,{});if(!e)return(0,B.jsxs)(`div`,{className:`app-workspace-content`,children:[(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`加载失败`}),(0,B.jsx)(E,{children:_||`无法读取健康状态`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(),children:[(0,B.jsx)(l,{"data-icon":`inline-start`}),`重新检测`]})]});let ce=[{icon:F,label:`CPU`,value:`${e.cpu.percent.toFixed(1)}%`,detail:`${e.cpu.cores} 核 · load ${e.cpu.loadAverage.map(e=>e.toFixed(2)).join(` / `)}`},{icon:L,label:`RSS 内存`,value:W(e.memory.rss),detail:`Heap ${W(e.memory.heapUsed)} / ${W(e.memory.heapTotal)}`},{icon:R,label:`TCP 连接`,value:String(e.connections.total),detail:`代理 ${e.connections.proxySockets} · TLS ${e.connections.mitmTlsSockets} · WS ${e.connections.webSockets}`},{icon:c,label:`MITM 服务`,value:String(e.mitmServers.count),detail:`${e.mitmServers.activeSockets} 个活跃 socket`},{icon:ne,label:`文件描述符`,value:e.process.fdCount==null?`-`:String(e.process.fdCount),detail:`handles ${e.process.activeHandles??`-`} · requests ${e.process.activeRequests??`-`}`},{icon:I,label:`事件循环`,value:`${e.eventLoop.maxMs.toFixed(1)} ms`,detail:`mean ${e.eventLoop.meanMs.toFixed(1)} ms`}];return(0,B.jsxs)(`div`,{className:`meddle-thin-scroll app-workspace-content overflow-y-auto`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`运行健康`}),(0,B.jsx)(Y,{status:e.status})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[`PID `,e.pid]}),(0,B.jsxs)(`span`,{children:[`运行 `,G(e.uptimeSec)]}),(0,B.jsx)(`span`,{children:e.platform}),(0,B.jsxs)(`span`,{children:[`更新 `,K(e.generatedAt)]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border bg-background px-3 text-sm`,children:[(0,B.jsx)(d,{checked:H,onCheckedChange:Z,"aria-label":`自动刷新健康信息`}),(0,B.jsx)(`span`,{children:`自动刷新`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(!0),disabled:o,children:[(0,B.jsx)(l,{"data-icon":`inline-start`,className:n(o&&`animate-spin`)}),`刷新`]})]})]}),_&&(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`刷新失败`}),(0,B.jsx)(E,{children:_})]}),(0,B.jsx)(`div`,{className:`grid gap-[var(--ui-section-gap)] md:grid-cols-2 xl:grid-cols-6`,children:ce.map(e=>(0,B.jsx)(oe,{...e},e.label))}),(0,B.jsxs)(`div`,{className:`grid gap-[var(--ui-section-gap)] xl:grid-cols-[minmax(0,1.3fr)_minmax(360px,0.7fr)]`,children:[(0,B.jsxs)(S,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(te,{}),`健康检查`]}),(0,B.jsx)(x,{children:`阈值来自当前进程的 MEDDLE_WATCHDOG 配置。`})]}),(0,B.jsx)(v,{className:`p-0`,children:(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`项目`}),(0,B.jsx)(A,{children:`状态`}),(0,B.jsx)(A,{children:`当前值`}),(0,B.jsx)(A,{children:`阈值`})]})}),(0,B.jsx)(j,{children:e.checks.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`font-medium`,children:ie[e.name]||e.name}),(0,B.jsx)(N,{children:(0,B.jsx)(Y,{status:e.status})}),(0,B.jsx)(N,{children:q(e.value,e.unit)}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:J(e.limit,e.unit)})]},e.name))})]})})]}),(0,B.jsxs)(S,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ee,{}),`守护策略`]}),(0,B.jsx)(x,{children:`连续命中严重阈值后按策略处理。`}),(0,B.jsx)(re,{children:(0,B.jsx)(w,{variant:e.watchdog.config.enabled?`default`:`secondary`,children:e.watchdog.config.enabled?`已启用`:`已关闭`})})]}),(0,B.jsxs)(v,{className:`grid gap-[var(--ui-section-gap)] p-[var(--ui-page-padding)] sm:grid-cols-2`,children:[(0,B.jsx)(X,{label:`动作`,value:e.watchdog.config.action===`exit`?`退出重启`:`仅告警`}),(0,B.jsx)(X,{label:`检测间隔`,value:G(e.watchdog.config.intervalMs/1e3)}),(0,B.jsx)(X,{label:`最小运行时间`,value:G(e.watchdog.config.minUptimeMs/1e3)}),(0,B.jsx)(X,{label:`失败阈值`,value:`${e.watchdog.consecutiveFailures}/${e.watchdog.config.failureThreshold}`}),(0,B.jsx)(X,{label:`CPU 阈值`,value:`${e.watchdog.config.cpuPercent}%`}),(0,B.jsx)(X,{label:`RSS 阈值`,value:W(e.watchdog.config.rssBytes)}),(0,B.jsx)(X,{label:`连接阈值`,value:String(e.watchdog.config.connectionCount)}),(0,B.jsx)(X,{label:`FD 阈值`,value:String(e.watchdog.config.fdCount)}),e.watchdog.lastReason&&(0,B.jsx)(`div`,{className:`sm:col-span-2`,children:(0,B.jsxs)(O,{children:[(0,B.jsx)(b,{}),(0,B.jsx)(D,{children:`最近命中`}),(0,B.jsx)(E,{children:e.watchdog.lastReason})]})})]})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-[var(--ui-section-gap)] xl:grid-cols-2`,children:[(0,B.jsxs)(S,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{}),`MITM 服务池`]}),(0,B.jsxs)(x,{children:[e.mitmServers.count,` 个动态 HTTPS 服务。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:e.mitmServers.items.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Host`}),(0,B.jsx)(A,{children:`端口`}),(0,B.jsx)(A,{children:`Socket`}),(0,B.jsx)(A,{children:`空闲`})]})}),(0,B.jsx)(j,{children:e.mitmServers.items.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.host,children:e.host}),(0,B.jsx)(N,{children:e.port??`-`}),(0,B.jsxs)(N,{children:[e.activeSockets,` / `,e.webSockets,` WS`]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:e.idleForMs==null?`-`:G(e.idleForMs/1e3)})]},`${e.host}:${e.port??`dynamic`}`))})]}):(0,B.jsx)(g,{className:`border-0 py-10`,children:(0,B.jsxs)(h,{children:[(0,B.jsx)(C,{variant:`icon`,children:(0,B.jsx)(c,{})}),(0,B.jsx)(m,{children:`暂无动态 HTTPS 服务`}),(0,B.jsx)(f,{children:`当前没有活跃的 MITM 目标。`})]})})})]}),(0,B.jsxs)(S,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(s,{}),`日志限流`]}),(0,B.jsxs)(x,{children:[`已抑制 `,$?.suppressedTotal??0,` 条重复日志。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:$&&$.keys.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Key`}),(0,B.jsx)(A,{children:`级别`}),(0,B.jsx)(A,{children:`输出 / 抑制`}),(0,B.jsx)(A,{children:`最近`})]})}),(0,B.jsx)(j,{children:$.keys.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.key,children:e.key}),(0,B.jsx)(N,{children:(0,B.jsx)(w,{variant:e.level===`error`?`destructive`:e.level===`warn`?`secondary`:`outline`,children:e.level})}),(0,B.jsxs)(N,{children:[e.emitted,` / `,e.suppressed]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:K(e.lastSeenAt)})]},e.key))})]}):(0,B.jsx)(g,{className:`border-0 py-10`,children:(0,B.jsxs)(h,{children:[(0,B.jsx)(C,{variant:`icon`,children:(0,B.jsx)(s,{})}),(0,B.jsx)(m,{children:`暂无限流记录`}),(0,B.jsx)(f,{children:`当前没有被抑制的重复日志。`})]})})})]})]})]})}export{Z as HealthPanel};
|