@jonathanleelx/meddle 0.5.0-beta.9 → 0.5.0
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 +9 -2
- package/README.md +18 -0
- package/bin/commands/mock/add.js +37 -21
- package/bin/commands/mock/delete.js +16 -24
- package/bin/commands/mock/index.js +8 -4
- package/bin/commands/mock/list.js +35 -18
- package/bin/commands/mock/toggle.js +17 -27
- package/bin/commands/mock/update.js +39 -30
- package/bin/commands/route/active.js +20 -3
- package/bin/commands/route/add.js +113 -94
- package/bin/commands/route/create.js +8 -1
- package/bin/commands/route/delete.js +85 -51
- package/bin/commands/route/index.js +20 -2
- package/bin/commands/route/list.js +2 -2
- package/bin/commands/route/show.js +10 -1
- package/bin/commands/route/update.js +135 -92
- package/bin/commands/update.js +4 -0
- package/bin/index.js +7 -3
- package/bin/lib/api-client.js +14 -2
- package/bin/lib/file-access.js +217 -35
- package/bin/lib/output.js +24 -3
- package/bin/lib/proxy-detect.js +99 -20
- package/bin/lib/proxy-or-file.js +90 -0
- package/bin/lib/route-write-args.js +150 -0
- package/bin/lib/rule-file-edit.js +263 -0
- package/bin/lib/ruleset-readonly.js +61 -0
- package/bin/lib/update-check.js +67 -6
- package/dist/cert.d.ts.map +1 -1
- package/dist/cert.js +43 -0
- package/dist/cert.js.map +1 -1
- package/dist/core/browser.d.ts +8 -1
- package/dist/core/browser.d.ts.map +1 -1
- package/dist/core/browser.js +239 -36
- package/dist/core/browser.js.map +1 -1
- package/dist/core/config-diagnostics.d.ts.map +1 -1
- package/dist/core/config-diagnostics.js +6 -1
- package/dist/core/config-diagnostics.js.map +1 -1
- package/dist/core/custom-plugin-loader.d.ts.map +1 -1
- package/dist/core/custom-plugin-loader.js +2 -0
- package/dist/core/custom-plugin-loader.js.map +1 -1
- package/dist/core/mock-handler.d.ts +59 -0
- package/dist/core/mock-handler.d.ts.map +1 -1
- package/dist/core/mock-handler.js +627 -29
- package/dist/core/mock-handler.js.map +1 -1
- package/dist/core/mock-utils.d.ts +58 -0
- package/dist/core/mock-utils.d.ts.map +1 -0
- package/dist/core/mock-utils.js +167 -0
- package/dist/core/mock-utils.js.map +1 -0
- package/dist/core/plugin-bootstrap-runner.d.ts +1 -0
- package/dist/core/plugin-bootstrap-runner.d.ts.map +1 -1
- package/dist/core/plugin-bootstrap-runner.js +37 -1
- package/dist/core/plugin-bootstrap-runner.js.map +1 -1
- package/dist/core/plugin-source.d.ts +24 -0
- package/dist/core/plugin-source.d.ts.map +1 -0
- package/dist/core/plugin-source.js +47 -0
- package/dist/core/plugin-source.js.map +1 -0
- 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/core/types.d.ts +13 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/plugins/builtin/mock-plugin.d.ts.map +1 -1
- package/dist/plugins/builtin/mock-plugin.js +6 -5
- package/dist/plugins/builtin/mock-plugin.js.map +1 -1
- package/dist/server/agent/tools.d.ts.map +1 -1
- package/dist/server/agent/tools.js +24 -18
- package/dist/server/agent/tools.js.map +1 -1
- package/dist/server/app-info.d.ts +33 -0
- package/dist/server/app-info.d.ts.map +1 -0
- package/dist/server/app-info.js +116 -0
- package/dist/server/app-info.js.map +1 -0
- package/dist/server/config.d.ts +1 -0
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js +101 -9
- package/dist/server/config.js.map +1 -1
- package/dist/server/health.d.ts.map +1 -1
- package/dist/server/health.js +8 -0
- package/dist/server/health.js.map +1 -1
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/mocks.d.ts +26 -0
- package/dist/server/mocks.d.ts.map +1 -1
- package/dist/server/mocks.js +110 -13
- package/dist/server/mocks.js.map +1 -1
- package/dist/server/plugins.d.ts.map +1 -1
- package/dist/server/plugins.js +56 -11
- package/dist/server/plugins.js.map +1 -1
- package/dist/server/rule-files.d.ts +36 -0
- package/dist/server/rule-files.d.ts.map +1 -1
- package/dist/server/rule-files.js +395 -107
- 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/index.js +36 -7
- package/mcp-server.js +90 -88
- package/package.json +1 -1
- package/plugins/builtin/mock-plugin.ts +9 -5
- package/web/dist/assets/alert-B514Frte.js +1 -0
- package/web/dist/assets/arrow-right-BNum_060.js +1 -0
- package/web/dist/assets/{body-diff-view-B-4XWmL6.js → body-diff-view-SfLCLzs9.js} +2 -2
- package/web/dist/assets/button-BFNlGZ5p.js +1 -0
- package/web/dist/assets/check-BkfHQ6re.js +1 -0
- package/web/dist/assets/checkbox-CQyFsZzS.js +1 -0
- package/web/dist/assets/chevron-down-DHwUtL4O.js +1 -0
- package/web/dist/assets/{circle-alert-Q8cZk9Rv.js → circle-alert-zMagrFuI.js} +1 -1
- package/web/dist/assets/{circle-x-C9USji_R.js → circle-x-BEkinhez.js} +1 -1
- package/web/dist/assets/code-DD-AYxxu.js +1 -0
- package/web/dist/assets/{copy-BYjq1hdN.js → copy-BRnscYy1.js} +1 -1
- package/web/dist/assets/detail-panel-BtgWWeu3.js +4 -0
- package/web/dist/assets/dist-BQN0rzUS.js +1 -0
- package/web/dist/assets/{dist-CEd_wnRC.js → dist-C-E2R2jk.js} +1 -1
- package/web/dist/assets/{dist-C6eaYCUo.js → dist-CFZ4xMSF.js} +1 -1
- package/web/dist/assets/{dist-DWmDaXVN.js → dist-CRmX_NvH.js} +1 -1
- package/web/dist/assets/{dist-C8RHq5At.js → dist-DLQKRjuW.js} +1 -1
- package/web/dist/assets/{dist-Blyulj4_.js → dist-LiAcI8CK.js} +1 -1
- package/web/dist/assets/{dist-Ce4ujolc.js → dist-fzPL-8F9.js} +1 -1
- package/web/dist/assets/{dist-DoE7uybN.js → dist-wv9ebJK_.js} +1 -1
- package/web/dist/assets/editor-pane-actions-_ckwcCII.js +1 -0
- package/web/dist/assets/{es2015-DG46NGN7.js → es2015-DPJTBYa9.js} +1 -1
- package/web/dist/assets/{global-panel-shell-5cJneeis.js → global-panel-shell-NaUhzX7J.js} +3 -3
- package/web/dist/assets/health-panel-DhXLqcOU.js +1 -0
- package/web/dist/assets/index-B-6nUrqW.js +21 -0
- package/web/dist/assets/index-EWNlAdFB.css +2 -0
- package/web/dist/assets/mobile-proxy-panel-BY8Oi-qC.js +8 -0
- package/web/dist/assets/mock-config-TPmfJwAt.js +1 -0
- package/web/dist/assets/mock-editor-panel-WQwcHSTD.js +20 -0
- package/web/dist/assets/mocks-file-missing-note-BR5oWFLh.js +1 -0
- package/web/dist/assets/monaco-editor-BGLPrb0C.js +11 -0
- package/web/dist/assets/pane-bar-gFRISZLD.js +1 -0
- package/web/dist/assets/pane-split-B6aLmY7G.js +1 -0
- package/web/dist/assets/panel-heading-DT_nXayM.js +1 -0
- package/web/dist/assets/{pencil-line-Cqe41E4h.js → pencil-line-CEZ7D-de.js} +1 -1
- package/web/dist/assets/plugin-code-editor--Gf4ZwGb.js +2 -0
- package/web/dist/assets/plugin-config-DsX9xCW_.js +2 -0
- package/web/dist/assets/plugin-generator-Bj4f6dxo.js +2 -0
- package/web/dist/assets/plugin-test-dialog-DICuykBK.js +7 -0
- package/web/dist/assets/plus-ixZQRprm.js +1 -0
- package/web/dist/assets/{refresh-cw-CG3HaiQT.js → refresh-cw-BfLoHqg5.js} +1 -1
- package/web/dist/assets/rotate-ccw-CRguJya4.js +1 -0
- package/web/dist/assets/route-preview-C-LzS1lT.js +1 -0
- package/web/dist/assets/{rule-ai-assistant-panel-DMh0F9dr.js → rule-ai-assistant-panel-BEfPNBbx.js} +2 -2
- package/web/dist/assets/rule-config-Dw9pcuah.js +15 -0
- package/web/dist/assets/rule-overview-panel-C4QQ7U3S.js +1 -0
- package/web/dist/assets/{server-Cpj4KNwN.js → server-eYXq3PbE.js} +1 -1
- package/web/dist/assets/settings-panel-D8DEH8aH.js +1 -0
- package/web/dist/assets/{shield-check-OqUmVLQt.js → shield-check-hQXjdfZ7.js} +1 -1
- package/web/dist/assets/smartphone-D4Q7cQfm.js +1 -0
- package/web/dist/assets/switch-94vgsMHm.js +1 -0
- package/web/dist/assets/{syntax-highlight-Dk0-ewLI.js → syntax-highlight-BFgN_C0Y.js} +1 -1
- package/web/dist/assets/{table-2-BR5e3z8m.js → table-2-DvGHhMm4.js} +1 -1
- package/web/dist/assets/table-DaXD6jJv.js +1 -0
- package/web/dist/assets/textarea-9wB8Hsz-.js +1 -0
- package/web/dist/assets/toast-9yeTf7d9.js +1 -0
- package/web/dist/assets/use-mocks-file-status-BUIUJ4oQ.js +1 -0
- package/web/dist/assets/{wand-sparkles-CJ7fSnom.js → wand-sparkles-Bmt4dDOf.js} +1 -1
- package/web/dist/assets/{wifi-CCLKyySQ.js → wifi-Cjj_Br1u.js} +1 -1
- package/web/dist/assets/{zap-DR-xiUMe.js → zap-BuOtogAv.js} +1 -1
- package/web/dist/index.html +16 -10
- package/web/dist/assets/alert-DCvlZAiv.js +0 -1
- package/web/dist/assets/arrow-right-B4Mrlj2-.js +0 -1
- package/web/dist/assets/button-BTToMaBW.js +0 -1
- package/web/dist/assets/checkbox-D1Z9DtjF.js +0 -1
- package/web/dist/assets/chevron-down-CPngAx4M.js +0 -1
- package/web/dist/assets/chevron-right-V1DGIDbL.js +0 -1
- package/web/dist/assets/code-5_eJ_XpJ.js +0 -1
- package/web/dist/assets/code-fixer-D48sCDtp.js +0 -20
- package/web/dist/assets/detail-panel-BSFz9CUw.js +0 -4
- package/web/dist/assets/file-system-access-_og-Tg9o.js +0 -1
- package/web/dist/assets/health-panel-BS3L2e5d.js +0 -1
- package/web/dist/assets/index-CvTR1IVi.js +0 -18
- package/web/dist/assets/index-bfV7sxx5.css +0 -2
- package/web/dist/assets/mobile-proxy-panel-tU0NyJ3P.js +0 -8
- package/web/dist/assets/mock-config-CULJP6Vt.js +0 -1
- package/web/dist/assets/mock-editor-panel-9wlDaySA.js +0 -1
- package/web/dist/assets/monaco-editor-BttaUoOz.js +0 -11
- package/web/dist/assets/plugin-code-editor-BAIBp4lg.js +0 -2
- package/web/dist/assets/plugin-config-ButUV2SZ.js +0 -1
- package/web/dist/assets/plugin-generator-uceUPSCv.js +0 -2
- package/web/dist/assets/plugin-test-dialog-BrJ4HfRX.js +0 -7
- package/web/dist/assets/plus-tVxSydJ8.js +0 -1
- package/web/dist/assets/rotate-ccw-CAYM6Vv0.js +0 -1
- package/web/dist/assets/route-preview-C4cGrS1-.js +0 -1
- package/web/dist/assets/rule-config-BTTGNwMs.js +0 -15
- package/web/dist/assets/rule-overview-panel-SFR2OloL.js +0 -1
- package/web/dist/assets/select-aBXQ0zNa.js +0 -1
- package/web/dist/assets/settings-panel-BMReDG8b.js +0 -1
- package/web/dist/assets/smartphone-DKeDuJTU.js +0 -1
- package/web/dist/assets/switch-Bes_YiJu.js +0 -1
- package/web/dist/assets/table-nW7uQVcl.js +0 -1
- package/web/dist/assets/textarea-BSI0rnW6.js +0 -1
- /package/web/dist/assets/{babel-DCr4VA1c.js → babel-bwZm0qi3.js} +0 -0
- /package/web/dist/assets/{clipboard-VhPXNN5m.js → clipboard-Bt1qY01V.js} +0 -0
- /package/web/dist/assets/{estree-qO_m2Qaw.js → estree-MatbZDwq.js} +0 -0
- /package/web/dist/assets/{html-VDGahtyk.js → html-CCrsbFYX.js} +0 -0
- /package/web/dist/assets/{postcss-BUm8EKMw.js → postcss-BxN7Gr8n.js} +0 -0
- /package/web/dist/assets/{standalone-Bj8SSd8Q.js → standalone-DsnFnsqM.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as e}from"./button-BFNlGZ5p.js";var t=e(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{u as e}from"./button-BFNlGZ5p.js";var t=e(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]);export{t};
|
|
@@ -0,0 +1,4 @@
|
|
|
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 ee}from"./wand-sparkles-Bmt4dDOf.js";import"./es2015-DPJTBYa9.js";import{n as p}from"./toast-9yeTf7d9.js";import{A as m,F as h,I as g,L as _,M as v,Mt as y,N as b,Nt as x,Ot as S,Q as C,S as w,St as te,T as ne,b as T,gt as E,j as D,w as re,x as ie,xt as O}from"./index-B-6nUrqW.js";import{n as k,t as A}from"./body-diff-view-SfLCLzs9.js";import{n as j,t as M}from"./syntax-highlight-BFgN_C0Y.js";import{t as N}from"./clipboard-Bt1qY01V.js";var P=i(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ae=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`}]]),oe=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 se(e){return Object.entries(e||{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
2
|
+
`)}var L=e(),R=2e3;function z({text:e,label:t}){let[n,i]=(0,I.useState)(!1),a=(0,I.useRef)(null);async function s(){try{await N(e),i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),R),p.success(`已复制${t}`)}catch{p.error(`复制${t}失败,请手动选择复制`)}}return(0,L.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,L.jsx)(o,{className:`h-3 w-3 mr-1 text-green-600`}):(0,L.jsx)(d,{className:`h-3 w-3 mr-1`}),n?`已复制`:`复制`]})}function B({body:e}){let[t,n]=(0,I.useState)(`source`),r=(0,I.useMemo)(()=>M(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)(()=>j(t===`formatted`?i:e,r?`json`:void 0),[e,i,t,r]);return e?(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[r?(0,L.jsx)(m,{value:t,onValueChange:e=>n(e),className:`w-fit`,children:(0,L.jsxs)(v,{className:`h-6 px-1`,children:[(0,L.jsx)(b,{value:`source`,className:`h-6 px-2 text-[11px]`,children:`源数据`}),(0,L.jsx)(b,{value:`formatted`,className:`h-6 px-2 text-[11px]`,children:`格式化`})]})}):(0,L.jsx)(`span`,{}),(0,L.jsx)(z,{text:e,label:`Body`})]}),(0,L.jsx)(`div`,{className:`font-mono text-xs bg-muted/30 rounded p-2 overflow-x-auto`,children:(0,L.jsx)(`pre`,{className:`whitespace-pre`,children:a})})]}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无内容`})}function V({headers:e}){let t=Object.entries(e||{});return t.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`无头部信息`}):(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsx)(z,{text:se(e),label:`Headers`})}),(0,L.jsx)(`div`,{className:`font-mono text-xs space-y-0.5`,children:t.map(([e,t])=>(0,L.jsxs)(`div`,{className:`flex gap-2 py-0.5 hover:bg-muted/50 px-1 rounded`,children:[(0,L.jsxs)(`span`,{className:`text-purple-600 shrink-0 font-semibold`,children:[e,`:`]}),(0,L.jsx)(`span`,{className:`text-foreground/80 break-all`,children:t})]},e))})]})}function H(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 U(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 W(e){switch(e){case`ok`:return`通过`;case`error`:return`异常`;case`skipped`:return`跳过`;case`short-circuited`:return`已短路返回`;default:return e}}function G(e){switch(e){case`builtin`:return`内置`;case`custom`:return`自定义`;case`system`:return`系统`;default:return e}}function K(e){return e.replace(/^builtin\./,``).replace(/^custom\./,``)}function ce(e,t){return`${t}-${e.hook}-${e.name}`}function q(e){return e===`onBeforeResponse`||e===`onAfterResponse`?`response`:`request`}function le(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 J({lines:e,className:t}){return e.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,L.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,L.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,L.jsx)(`span`,{className:`mr-1`,children:e.type===`added`?`+ `:`- `}),e.text]},`${e.type}-${t}-${e.text}`))})}function Y(e,t,n){let r=[];return t!==void 0&&t!==``&&r.push({type:`removed`,text:`${e} ${t}`}),n!==void 0&&n!==``&&r.push({type:`added`,text:`${e} ${n}`}),r}function ue(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 de(e){let t=e.replace(/\r\n/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`);return t[t.length-1]===``&&t.pop(),t.length>0?t:[``]}function X(e){if(!e)return!1;if(/^\(binary(?:,\s*\d+\s+bytes)?\)$/i.test(e.trim()))return!0;let t=0;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r===9||r===10||r===13||(r<32||r===65533)&&(t+=1)}return t>0&&t/Math.max(e.length,1)>.15}function Z({before:e,after:t}){let[n,i]=(0,I.useState)(!1),a=(0,I.useMemo)(()=>le(e,t),[e,t]),o=(0,I.useMemo)(()=>a.flatMap(e=>Y(e.key,e.before,e.after)),[a]);return o.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(J,{lines:o}),(0,L.jsxs)(r,{variant:`ghost`,size:`xs`,onClick:()=>i(e=>!e),children:[n?(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}):(0,L.jsx)(P,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整头部`:`展开完整头部`]}),n&&(0,L.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:`变更前`}),(0,L.jsx)(V,{headers:e})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 text-xs font-mono`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:`变更后`}),(0,L.jsx)(V,{headers:t})]})]})]})}function fe({before:e,after:t}){let[n,i]=(0,I.useState)(!1),a=(0,I.useMemo)(()=>k(e||``,t||``).filter(e=>e.added||e.removed),[e,t]),o=(0,I.useMemo)(()=>X(e||``)||X(t||``),[e,t]),c=(0,I.useMemo)(()=>o?ue(e||``,t||``):a.flatMap(e=>de(e.value).map(t=>({type:e.added?`added`:`removed`,text:t}))),[e,t,a,o]);return c.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`无变更`}):(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(z,{text:e,label:`变更前 Body`}),(0,L.jsx)(z,{text:t,label:`变更后 Body`})]}),(0,L.jsx)(J,{lines:c,className:`meddle-thin-scroll max-h-40 overflow-auto`}),!o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(r,{variant:`ghost`,size:`xs`,onClick:()=>i(e=>!e),children:[n?(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-1`}):(0,L.jsx)(P,{className:`h-3.5 w-3.5 mr-1`}),n?`收起完整 Diff`:`展开完整 Diff`]}),n&&(0,L.jsx)(A,{original:e,modified:t,mode:`inline`,maxHeight:`220px`})]})]})}function Q({stage:e}){let t=e.changes;return t?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(t.targetBefore||t.targetAfter)&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Request URL diff`}),(0,L.jsx)(J,{lines:Y(`Request URL`,t.targetBefore,t.targetAfter||t.target)})]}),(t.requestHeadersBefore||t.requestHeadersAfter)&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Request header diff`}),(0,L.jsx)(Z,{before:t.requestHeadersBefore||{},after:t.requestHeadersAfter||{}})]}),(t.responseStatusCodeBefore!==void 0||t.responseStatusCodeAfter!==void 0)&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Response status diff`}),(0,L.jsx)(J,{lines:Y(`Response Status`,t.responseStatusCodeBefore,t.responseStatusCodeAfter??t.responseStatusCode)})]}),(t.responseHeadersBefore||t.responseHeadersAfter)&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Response header diff`}),(0,L.jsx)(Z,{before:t.responseHeadersBefore||{},after:t.responseHeadersAfter||{}})]}),(t.responseBodyBefore!==void 0||t.responseBodyAfter!==void 0)&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Response body diff`}),(0,L.jsx)(fe,{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,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border bg-background/90 p-3 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsx)(r,{variant:`ghost`,size:`icon-xs`,onClick:()=>o(e=>!e),title:a?`收起`:`展开`,"aria-label":a?`收起`:`展开`,children:a?(0,L.jsx)(s,{className:`h-3.5 w-3.5`}):(0,L.jsx)(P,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`span`,{className:`font-medium text-sm`,children:[t+1,`. `,K(e.name)]}),(0,L.jsx)(C,{variant:`outline`,className:`text-xs font-normal`,children:e.hook}),(0,L.jsx)(C,{variant:`outline`,className:`text-xs font-normal`,children:G(e.type)})]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.status===`short-circuited`?`这一阶段直接生成了响应,请求不会继续往后转发。`:e.status===`error`?`这一阶段执行失败,影响了后续处理流程。`:`这一阶段执行完成,请求继续进入下一步。`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,L.jsx)(C,{className:`text-xs border ${U(e.status)}`,children:W(e.status)}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.duration,`ms`]})]})]}),a&&(0,L.jsxs)(L.Fragment,{children:[e.target&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:`当前 target`}),(0,L.jsx)(`div`,{className:`font-mono text-xs break-all`,children:e.target})]}),(0,L.jsx)(Q,{stage:e}),e.error&&(0,L.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,L.jsx)(`div`,{className:`flex justify-center py-1`,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,L.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full ${i} animate-pulse`}),(0,L.jsx)(y,{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,L.jsxs)(`div`,{className:`rounded-xl border bg-card p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`flex items-center gap-2 mb-2`,children:(0,L.jsxs)(C,{variant:`outline`,className:`text-[11px] font-normal`,children:[(0,L.jsx)(`span`,{className:`mr-1`,children:a}),i]})}),(0,L.jsxs)(`h4`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:o,children:r}),e]}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t})]}),(0,L.jsxs)(C,{variant:`outline`,className:`text-xs`,children:[n.length,` 个阶段`]})]}),n.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无阶段信息`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:n.map(({stage:e,index:t},r)=>(0,L.jsx)(pe,{stage:e,index:t,isLast:r===n.length-1,accentClass:o},ce(e,t)))})]})}function me(e){let t=[...e.stages].reverse().find(e=>e.status===`short-circuited`);if(t)return{label:`提前返回响应`,description:`在 ${K(t.name)} 阶段直接生成响应`,icon:(0,L.jsx)(ae,{className:`h-4 w-4 text-blue-500`})};let n=[...e.stages].reverse().find(e=>e.status===`error`);return n?{label:`处理过程中出现异常`,description:`${K(n.name)} 执行失败`,icon:(0,L.jsx)(c,{className:`h-4 w-4 text-red-500`})}:{label:`进入正常代理流程`,description:`请求经过检查后继续转发到目标服务`,icon:(0,L.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})=>q(e.hook)===`request`),i=n.filter(({stage:e})=>q(e.hook)===`response`);return(0,L.jsxs)(`div`,{className:`space-y-4 pt-3`,children:[(0,L.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,L.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,L.jsx)(C,{variant:`outline`,className:`font-mono`,children:e.method}),(0,L.jsx)(`span`,{className:`font-mono text-muted-foreground truncate flex-1`,children:e.url}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,L.jsx)(l,{className:`h-3.5 w-3.5`}),(0,L.jsxs)(`span`,{className:`text-xs`,children:[e.totalDuration,`ms`]})]})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,L.jsx)(F,{className:`h-3.5 w-3.5`}),`请求入口`]}),(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:`请求进入代理`}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`从浏览器或客户端发起,进入 Meddle 的处理流水线`})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,L.jsx)(f,{className:`h-3.5 w-3.5`}),`处理阶段`]}),(0,L.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.stages.length,` 个阶段`]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`按实际执行顺序记录插件和系统模块对请求的处理`})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border bg-background/80 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[t.icon,`最终结果`]}),(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:t.label}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:t.description})]})]})]}),e.stages.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`无处理阶段信息(插件模式可能未开启)`}):(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(oe,{className:`h-3.5 w-3.5`}),(0,L.jsx)(`span`,{children:`默认仅展示改动内容;跳过阶段默认折叠,可单独展开查看更多。`})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,L.jsx)($,{title:`请求阶段`,description:`客户端请求进入代理后,按顺序执行请求侧处理阶段`,stages:r,icon:(0,L.jsx)(F,{className:`h-4 w-4 text-blue-500`}),roleLabel:`客户端`,roleIcon:(0,L.jsx)(O,{className:`h-3 w-3 text-blue-500`}),accentClass:`text-blue-500`}),(0,L.jsx)($,{title:`响应阶段`,description:`服务器响应返回代理后,按顺序执行响应侧处理阶段`,stages:i,icon:(0,L.jsx)(x,{className:`h-4 w-4 text-emerald-500`}),roleLabel:`服务器`,roleIcon:(0,L.jsx)(u,{className:`h-3 w-3 text-emerald-500`}),accentClass:`text-emerald-500`})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:`请求进入`}),(0,L.jsx)(a,{className:`h-4 w-4 animate-pulse text-blue-500`}),(0,L.jsx)(`span`,{children:`请求阶段`}),(0,L.jsx)(a,{className:`h-4 w-4 animate-pulse text-violet-500`}),(0,L.jsx)(`span`,{children:`响应阶段`}),(0,L.jsx)(a,{className:`h-4 w-4 animate-pulse text-emerald-500`}),(0,L.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,L.jsxs)(`div`,{className:`space-y-3 pt-3`,"data-testid":`detail-overview-hit`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-[72px_1fr] gap-x-3 gap-y-1.5 text-xs`,children:[(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:`方法`}),(0,L.jsx)(`div`,{className:`font-mono font-medium`,children:e.method}),(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:`URL`}),(0,L.jsx)(`div`,{className:`break-all font-mono`,children:e.source}),(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:`状态`}),(0,L.jsxs)(`div`,{className:`font-mono`,children:[t.statusCode,` `,t.statusMessage]}),(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:`延迟`}),(0,L.jsx)(`div`,{className:`font-mono tabular-nums`,children:ge(e.duration)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`mb-1.5 text-xs font-semibold text-muted-foreground`,children:`命中规则 / Mock`}),(0,L.jsx)(`div`,{className:`mb-1 text-sm font-semibold`,children:n.title}),(0,L.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:n.description}),(0,L.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,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`mb-1.5 text-xs font-semibold text-muted-foreground`,children:`请求 headers(节选)`}),(0,L.jsx)(`div`,{className:`grid grid-cols-[minmax(72px,90px)_1fr] gap-x-3 gap-y-1 text-xs`,children:r.map(([e,t])=>(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(`div`,{className:`truncate text-muted-foreground`,title:e,children:e}),(0,L.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,showTitle:d=!0}){let[f,p]=(0,I.useState)(!1),h=()=>{i&&s&&c&&c({source:s.source,responseBody:i.responseBody,statusCode:i.statusCode,responseHeaders:i.responseHeaders})},[y,O]=(0,I.useState)(null),k=(0,L.jsxs)(L.Fragment,{children:[i&&l&&s?.id!=null&&(0,L.jsxs)(r,{variant:`outline`,size:`xs`,onClick:async()=>{if(s?.id!=null&&l){p(!0),O(null);try{await l(s.id)}catch(e){O(e.message||`重放失败`)}finally{p(!1)}}},disabled:f,title:`使用相同的请求参数重新发送请求`,children:[(0,L.jsx)(E,{className:`h-3.5 w-3.5 mr-1 ${f?`animate-spin`:``}`}),f?`重放中…`:`重放`]}),s&&u&&s.source!==s.target&&!s.mock&&(0,L.jsxs)(r,{variant:`outline`,size:`xs`,onClick:()=>u(s),title:`跳转到路由规则配置`,"data-testid":`detail-jump-to-rule`,children:[(0,L.jsx)(S,{className:`h-3.5 w-3.5 mr-1`}),`查看规则`]}),i&&c&&!s?.mock&&(0,L.jsxs)(r,{variant:`outline`,size:`xs`,onClick:h,"data-testid":`detail-create-mock`,children:[(0,L.jsx)(ee,{className:`h-3.5 w-3.5 mr-1`}),`创建 Mock`]})]}),A=(0,L.jsx)(`div`,{"data-testid":`detail-panel-actions`,className:`ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5`,children:k}),j=(0,L.jsxs)(L.Fragment,{children:[d&&(0,L.jsx)(`span`,{"data-testid":`detail-panel-title`,className:`shrink-0 whitespace-nowrap`,children:`请求详情`}),i&&(0,L.jsxs)(C,{className:`${H(i.statusCode)} max-w-full min-w-0 shrink truncate border-0`,children:[i.statusCode,` `,i.statusMessage]}),s?.clientType&&(0,L.jsxs)(C,{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,L.jsxs)(C,{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,L.jsx)(g,{record:s,compact:!0}),(0,L.jsx)(`span`,{className:`truncate`,children:s.applicationName}),s.applicationIdentitySource===`user-agent`&&(0,L.jsx)(`span`,{className:`shrink-0 text-[9px] text-muted-foreground`,children:`推断`})]}),d?A:null]}),M=d?null:(0,L.jsx)(`div`,{"data-testid":`detail-panel-actions`,className:`flex max-w-full shrink-0 flex-wrap items-center gap-1.5 border-t px-3 py-2`,children:k}),N=`flex min-w-0 flex-wrap items-center gap-2 text-sm font-semibold text-foreground`,P=(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsx)(`div`,{className:`min-w-0 px-3 pt-2.5 pb-1.5`,"data-testid":`detail-panel-header`,children:d?(0,L.jsx)(`h2`,{className:N,children:j}):(0,L.jsx)(`div`,{className:N,children:j})}):(0,L.jsx)(re,{className:`min-w-0 px-4 pt-4 pb-2`,children:(0,L.jsx)(ne,{className:`flex min-w-0 flex-wrap items-center gap-2 text-base`,children:j})}),(0,L.jsx)(T,{}),y&&(0,L.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:y}),o&&!a&&!i&&(0,L.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,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(te,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):i&&s?(0,L.jsxs)(m,{defaultValue:`overview`,className:`flex-1 flex flex-col min-h-0`,children:[(0,L.jsxs)(v,{className:`mx-4 mt-2 w-fit`,children:[(0,L.jsx)(b,{value:`overview`,"data-testid":`detail-tab-overview`,children:`概览`}),(0,L.jsx)(b,{value:`request`,children:`请求`}),(0,L.jsx)(b,{value:`response`,children:`响应`}),(0,L.jsxs)(b,{value:`inspect`,children:[(0,L.jsx)(x,{className:`h-3.5 w-3.5 mr-1`}),`Inspect`]})]}),(0,L.jsx)(D,{value:`overview`,className:`flex-1 min-h-0 mt-0`,children:(0,L.jsx)(_,{className:`h-full px-4 pb-4`,children:(0,L.jsx)(_e,{record:s,detail:i})})}),(0,L.jsx)(D,{value:`request`,className:`flex-1 min-h-0 mt-0`,children:(0,L.jsx)(_,{className:`h-full px-4 pb-4`,children:(0,L.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5`,children:`Request headers`}),(0,L.jsx)(V,{headers:i.requestHeaders})]}),(0,L.jsx)(T,{}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5`,children:`Request body`}),(0,L.jsx)(B,{body:i.requestBody})]})]})})}),(0,L.jsx)(D,{value:`response`,className:`flex-1 min-h-0 mt-0`,children:(0,L.jsx)(_,{className:`h-full px-4 pb-4`,children:(0,L.jsxs)(`div`,{className:`space-y-3 pt-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5`,children:`Response headers`}),(0,L.jsx)(V,{headers:i.responseHeaders})]}),(0,L.jsx)(T,{}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground mb-1.5`,children:`Response body`}),(0,L.jsx)(B,{body:i.responseBody})]})]})})}),(0,L.jsx)(D,{value:`inspect`,className:`flex-1 min-h-0 mt-0`,children:(0,L.jsx)(_,{className:`h-full px-4 pb-4`,children:i.inspection?(0,L.jsx)(he,{inspection:i.inspection}):(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full py-12 text-muted-foreground`,children:[(0,L.jsx)(x,{className:`h-12 w-12 mb-4 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`无 Inspect 信息`}),(0,L.jsx)(`p`,{className:`text-xs mt-1`,children:`需要开启插件模式(on/shadow)才能查看请求生命周期`})]})})})]}):s?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm px-6 text-center`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{children:`详情数据暂不可用`}),(0,L.jsxs)(`div`,{className:`text-xs font-mono break-all`,children:[s.method,` `,s.source]})]})}):(0,L.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:`选择左侧一条流量以查看详情 / 命中信息`}),M]});return n?(0,L.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:P}):(0,L.jsx)(ie,{open:e,onOpenChange:e=>!e&&t?.(),children:(0,L.jsx)(w,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:640,storageKey:`detail-panel`,children:P})})}export{ve as DetailPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,d as t,o as n,p as r,u as i}from"./button-BFNlGZ5p.js";import{a,c as o,n as s,o as c}from"./dist-CFZ4xMSF.js";import{t as l}from"./dist-C-E2R2jk.js";import{t as u}from"./dist-fzPL-8F9.js";var d=i(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),f=r(t(),1),p=e(),m=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`}),h=`VisuallyHidden`,g=f.forwardRef((e,t)=>(0,p.jsx)(c.span,{...e,ref:t,style:{...m,...e.style}}));g.displayName=h;var _=g,v=[`top`,`right`,`bottom`,`left`],y=Math.min,b=Math.max,x=Math.round,S=Math.floor,C=e=>({x:e,y:e}),w={left:`right`,right:`left`,bottom:`top`,top:`bottom`},T={start:`end`,end:`start`};function E(e,t,n){return b(e,y(t,n))}function D(e,t){return typeof e==`function`?e(t):e}function O(e){return e.split(`-`)[0]}function k(e){return e.split(`-`)[1]}function A(e){return e===`x`?`y`:`x`}function j(e){return e===`y`?`height`:`width`}var M=new Set([`top`,`bottom`]);function N(e){return M.has(O(e))?`y`:`x`}function P(e){return A(N(e))}function ee(e,t,n){n===void 0&&(n=!1);let r=k(e),i=P(e),a=j(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=V(o)),[o,V(o)]}function F(e){let t=V(e);return[I(e),t,I(t)]}function I(e){return e.replace(/start|end/g,e=>T[e])}var L=[`left`,`right`],R=[`right`,`left`],z=[`top`,`bottom`],B=[`bottom`,`top`];function te(e,t,n){switch(e){case`top`:case`bottom`:return n?t?R:L:t?L:R;case`left`:case`right`:return t?z:B;default:return[]}}function ne(e,t,n,r){let i=k(e),a=te(O(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(I)))),a}function V(e){return e.replace(/left|right|bottom|top/g,e=>w[e])}function re(e){return{top:0,right:0,bottom:0,left:0,...e}}function ie(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:re(e)}function H(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 ae(e,t,n){let{reference:r,floating:i}=e,a=N(t),o=P(t),s=j(o),c=O(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(k(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 oe(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}=D(t,e),p=ie(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=H(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=H(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 se=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}=ae(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??oe},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}=ae(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},ce=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}=D(e,t)||{};if(l==null)return{};let d=ie(u),f={x:n,y:r},p=P(i),m=j(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=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)),w=C?C[b]:0;(!w||!await(o.isElement==null?void 0:o.isElement(C)))&&(w=s.floating[b]||a.floating[m]);let T=x/2-S/2,O=w/2-h[m]/2-1,A=y(d[_],O),M=y(d[v],O),N=A,ee=w-h[m]-M,F=w/2-h[m]/2+T,I=E(N,F,ee),L=!c.arrow&&k(i)!=null&&F!==I&&a.reference[m]/2-(F<N?A:M)-h[m]/2<0,R=L?F<N?F-N:F-ee:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),le=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}=D(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=O(r),_=N(o),v=O(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[V(o)]:F(o)),x=p!==`none`;!d&&x&&b.push(...ne(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ee(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==N(t))||T.every(e=>N(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.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=T.filter(e=>{if(x){let t=N(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 ue(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function de(e){return v.some(t=>e[t]>=0)}var fe=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=D(e,t);switch(i){case`referenceHidden`:{let e=ue(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:de(e)}}}case`escaped`:{let e=ue(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:de(e)}}}default:return{}}}}},pe=new Set([`left`,`top`]);async function me(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=O(n),s=k(n),c=N(n)===`y`,l=pe.has(o)?-1:1,u=a&&c?-1:1,d=D(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 he=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 me(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}}}}},ge=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}=D(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=N(O(i)),p=A(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=E(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=E(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}}}}}},_e=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}=D(e,t),u={x:n,y:r},d=N(i),f=A(d),p=u[f],m=u[d],h=D(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=pe.has(O(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}}}},ve=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}=D(e,t),u=await o.detectOverflow(t,l),d=O(i),f=k(i),p=N(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,x=m-u.left-u.right,S=y(h-u[g],v),C=y(m-u[_],x),w=!t.middlewareData.shift,T=S,E=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(E=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=v),w&&!f){let e=b(u.left,0),t=b(u.right,0),n=b(u.top,0),r=b(u.bottom,0);p?E=m-2*(e!==0||t!==0?e+t:b(u.left,u.right)):T=h-2*(n!==0||r!==0?n+r:b(u.top,u.bottom))}await c({...t,availableWidth:E,availableHeight:T});let A=await o.getDimensions(s.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function ye(){return typeof window<`u`}function U(e){return be(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((be(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function be(e){return ye()?e instanceof Node||e instanceof W(e).Node:!1}function K(e){return ye()?e instanceof Element||e instanceof W(e).Element:!1}function q(e){return ye()?e instanceof HTMLElement||e instanceof W(e).HTMLElement:!1}function xe(e){return!ye()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof W(e).ShadowRoot}var Se=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)&&!Se.has(i)}var Ce=new Set([`table`,`td`,`th`]);function we(e){return Ce.has(U(e))}var Te=[`:popover-open`,`:modal`];function Ee(e){return Te.some(t=>{try{return e.matches(t)}catch{return!1}})}var De=[`transform`,`translate`,`scale`,`rotate`,`perspective`],Oe=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],ke=[`paint`,`layout`,`strict`,`content`];function Ae(e){let t=Me(),n=K(e)?X(e):e;return De.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)||Oe.some(e=>(n.willChange||``).includes(e))||ke.some(e=>(n.contain||``).includes(e))}function je(e){let t=Z(e);for(;q(t)&&!Y(t);){if(Ae(t))return t;if(Ee(t))return null;t=Z(t)}return null}function Me(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var Ne=new Set([`html`,`body`,`#document`]);function Y(e){return Ne.has(U(e))}function X(e){return W(e).getComputedStyle(e)}function Pe(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||xe(e)&&e.host||G(e);return xe(t)?t.host:t}function Fe(e){let t=Z(e);return Y(t)?e.ownerDocument?e.ownerDocument.body:e.body:q(t)&&J(t)?t:Fe(t)}function Ie(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Fe(e),i=r===e.ownerDocument?.body,a=W(r);if(i){let e=Le(a);return t.concat(a,a.visualViewport||[],J(r)?r:[],e&&n?Ie(e):[])}return t.concat(r,Ie(r,[],n))}function Le(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Re(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=x(n)!==a||x(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ze(e){return K(e)?e:e.contextElement}function Q(e){let t=ze(e);if(!q(t))return C(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Re(t),o=(a?x(n.width):n.width)/r,s=(a?x(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Be=C(0);function Ve(e){let t=W(e);return!Me()||!t.visualViewport?Be:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function He(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=ze(e),o=C(1);t&&(r?K(r)&&(o=Q(r)):o=Q(e));let s=He(a,n,r)?Ve(a):C(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=Le(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=Le(n)}}return H({width:u,height:d,x:c,y:l})}function Ue(e,t){let n=Pe(e).scrollLeft;return t?t.left+n:$(G(e)).left+n}function We(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ue(e,n),y:n.top+t.scrollTop}}function Ge(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=G(r),s=t?Ee(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=C(1),u=C(0),d=q(r);if((d||!d&&!a)&&((U(r)!==`body`||J(o))&&(c=Pe(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?We(o,c):C(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 Ke(e){return Array.from(e.getClientRects())}function qe(e){let t=G(e),n=Pe(e),r=e.ownerDocument.body,i=b(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=b(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Ue(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=b(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Je=25;function Ye(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=Me();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Ue(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<=Je&&(a-=o)}else l<=Je&&(a+=l);return{width:a,height:o,x:s,y:c}}var Xe=new Set([`absolute`,`fixed`]);function Ze(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=q(e)?Q(e):C(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Qe(e,t,n){let r;if(t===`viewport`)r=Ye(e,n);else if(t===`document`)r=qe(G(e));else if(K(t))r=Ze(t,n);else{let n=Ve(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return H(r)}function $e(e,t){let n=Z(e);return n===t||!K(n)||Y(n)?!1:X(n).position===`fixed`||$e(n,t)}function et(e,t){let n=t.get(e);if(n)return n;let r=Ie(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=Ae(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Xe.has(i.position)||J(o)&&!n&&$e(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function tt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ee(t)?[]:et(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=Qe(t,n,i);return e.top=b(r.top,e.top),e.right=y(r.right,e.right),e.bottom=y(r.bottom,e.bottom),e.left=b(r.left,e.left),e},Qe(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function nt(e){let{width:t,height:n}=Re(e);return{width:t,height:n}}function rt(e,t,n){let r=q(t),i=G(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=C(0);function l(){c.x=Ue(i)}if(r||!r&&!a)if((U(t)!==`body`||J(i))&&(s=Pe(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?We(i,s):C(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 it(e){return X(e).position===`static`}function at(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 ot(e,t){let n=W(e);if(Ee(e))return n;if(!q(e)){let t=Z(e);for(;t&&!Y(t);){if(K(t)&&!it(t))return t;t=Z(t)}return n}let r=at(e,t);for(;r&&we(r)&&it(r);)r=at(r,t);return r&&Y(r)&&it(r)&&!Ae(r)?n:r||je(e)||n}var st=async function(e){let t=this.getOffsetParent||ot,n=this.getDimensions,r=await n(e.floating);return{reference:rt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ct(e){return X(e).direction===`rtl`}var lt={convertOffsetParentRelativeRectToViewportRelativeRect:Ge,getDocumentElement:G,getClippingRect:tt,getOffsetParent:ot,getElementRects:st,getClientRects:Ke,getDimensions:nt,getScale:Q,isElement:K,isRTL:ct};function ut(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dt(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=S(d),h=S(i.clientWidth-(u+f)),g=S(i.clientHeight-(d+p)),_=S(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:b(0,y(1,c))||1},x=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!x)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!ut(l,e.getBoundingClientRect())&&o(),x=!1}try{n=new IntersectionObserver(C,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,v)}n.observe(e)}return o(!0),a}function ft(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=ze(e),u=i||a?[...l?Ie(l):[],...Ie(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?dt(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&&!ut(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 pt=he,mt=ge,ht=le,gt=ve,_t=fe,vt=ce,yt=_e,bt=(e,t,n)=>{let r=new Map,i={platform:lt,...n},a={...i.platform,_c:r};return se(e,t,{...i,platform:a})},xt=r(o(),1),St=typeof document<`u`?f.useLayoutEffect:function(){};function Ct(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(!Ct(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)&&!Ct(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function wt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Tt(e,t){let n=wt(e);return Math.round(t*n)/n}function Et(e){let t=f.useRef(e);return St(()=>{t.current=e}),t}function Dt(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,[u,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=f.useState(r);Ct(p,r)||m(r);let[h,g]=f.useState(null),[_,v]=f.useState(null),y=f.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=f.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=f.useRef(null),w=f.useRef(null),T=f.useRef(u),E=c!=null,D=Et(c),O=Et(i),k=Et(l),A=f.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),bt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Ct(T.current,t)&&(T.current=t,xt.flushSync(()=>{d(t)}))})},[p,t,n,O,k]);St(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=f.useRef(!1);St(()=>(j.current=!0,()=>{j.current=!1}),[]),St(()=>{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=f.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=f.useMemo(()=>({reference:x,floating:S}),[x,S]),P=f.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Tt(N.floating,u.x),r=Tt(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...wt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Ot=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?{}:vt({element:r.current,padding:i}).fn(n):r?vt({element:r,padding:i}).fn(n):{}}}},kt=(e,t)=>({...pt(e),options:[e,t]}),At=(e,t)=>({...mt(e),options:[e,t]}),jt=(e,t)=>({...yt(e),options:[e,t]}),Mt=(e,t)=>({...ht(e),options:[e,t]}),Nt=(e,t)=>({...gt(e),options:[e,t]}),Pt=(e,t)=>({..._t(e),options:[e,t]}),Ft=(e,t)=>({...Ot(e),options:[e,t]}),It=`Arrow`,Lt=f.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,p.jsx)(c.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,p.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Lt.displayName=It;var Rt=Lt,zt=`Popper`,[Bt,Vt]=a(zt),[Ht,Ut]=Bt(zt),Wt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=f.useState(null);return(0,p.jsx)(Ht,{scope:t,anchor:r,onAnchorChange:i,children:n})};Wt.displayName=zt;var Gt=`PopperAnchor`,Kt=f.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:i,...a}=e,o=Ut(Gt,r),s=f.useRef(null),l=n(t,s),u=f.useRef(null);return f.useEffect(()=>{let e=u.current;u.current=i?.current||s.current,e!==u.current&&o.onAnchorChange(u.current)}),i?null:(0,p.jsx)(c.div,{...a,ref:l})});Kt.displayName=Gt;var qt=`PopperContent`,[Jt,Yt]=Bt(qt),Xt=f.forwardRef((e,t)=>{let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:d=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=Ut(qt,r),[w,T]=f.useState(null),E=n(t,e=>T(e)),[D,O]=f.useState(null),k=u(D),A=k?.width??0,j=k?.height??0,M=i+(o===`center`?``:`-`+o),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],ee=P.length>0,F={padding:N,boundary:P.filter(en),altBoundary:ee},{refs:I,floatingStyles:L,placement:R,isPositioned:z,middlewareData:B}=Dt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>ft(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[kt({mainAxis:a+j,alignmentAxis:d}),h&&At({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?jt():void 0,...F}),h&&Mt({...F}),Nt({...F,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&&Ft({element:D,padding:m}),tn({arrowWidth:A,arrowHeight:j}),y&&Pt({strategy:`referenceHidden`,...F})]}),[te,ne]=nn(R),V=l(x);s(()=>{z&&V?.()},[z,V]);let re=B.arrow?.x,ie=B.arrow?.y,H=B.arrow?.centerOffset!==0,[ae,oe]=f.useState();return s(()=>{w&&oe(window.getComputedStyle(w).zIndex)},[w]),(0,p.jsx)(`div`,{ref:I.setFloating,"data-radix-popper-content-wrapper":``,style:{...L,transform:z?L.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(` `),...B.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,p.jsx)(Jt,{scope:r,placedSide:te,onArrowChange:O,arrowX:re,arrowY:ie,shouldHideArrow:H,children:(0,p.jsx)(c.div,{"data-side":te,"data-align":ne,...S,ref:E,style:{...S.style,animation:z?void 0:`none`}})})})});Xt.displayName=qt;var Zt=`PopperArrow`,Qt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},$t=f.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Yt(Zt,n),a=Qt[i.placedSide];return(0,p.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,p.jsx)(Rt,{...r,ref:t,style:{...r.style,display:`block`}})})});$t.displayName=Zt;function en(e){return e!==null}var tn=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]=nn(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 nn(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var rn=Wt,an=Kt,on=Xt,sn=$t;export{Vt as a,d as c,rn as i,sn as n,_ as o,on as r,m as s,an as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,p as t}from"./button-BFNlGZ5p.js";import{n}from"./dist-CFZ4xMSF.js";var r=t(e(),1),i=r.useId||(()=>void 0),a=0;function o(e){let[t,o]=r.useState(i());return n(()=>{e||o(e=>e??String(a++))},[e]),e||(t?`radix-${t}`:``)}function s(e){let t=r.useRef(e);return r.useEffect(()=>{t.current=e}),r.useMemo(()=>(...e)=>t.current?.(...e),[])}export{o as n,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e,d as t,f as n,p as r,r as i}from"./button-BFNlGZ5p.js";var a=n((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),o=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=a()})),s=r(t(),1),c=r(o(),1),l=e(),u=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=i(`Primitive.${t}`),r=s.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,l.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function d(e,t){e&&c.flushSync(()=>e.dispatchEvent(t))}function f(e,t){let n=s.createContext(t),r=e=>{let{children:t,...r}=e,i=s.useMemo(()=>r,Object.values(r));return(0,l.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=s.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function p(e,t=[]){let n=[];function r(t,r){let i=s.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,c=n?.[e]?.[a]||i,u=s.useMemo(()=>o,Object.values(o));return(0,l.jsx)(c.Provider,{value:u,children:r})};o.displayName=t+`Provider`;function c(n,o){let c=o?.[e]?.[a]||i,l=s.useContext(c);if(l)return l;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,c]}let i=()=>{let t=n.map(e=>s.createContext(e));return function(n){let r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,m(i,...t)]}function m(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function h(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var g=globalThis?.document?s.useLayoutEffect:()=>{},_=s.useInsertionEffect||g;function v({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=y({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:i;{let t=s.useRef(e!==void 0);s.useEffect(()=>{let e=t.current;if(e!==c){let t=e?`controlled`:`uncontrolled`,n=c?`controlled`:`uncontrolled`;console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=c},[c,r])}return[l,s.useCallback(t=>{if(c){let n=b(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[c,e,a,o])]}function y({defaultProp:e,onChange:t}){let[n,r]=s.useState(e),i=s.useRef(n),a=s.useRef(t);return _(()=>{a.current=t},[t]),s.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function b(e){return typeof e==`function`}export{p as a,o as c,f as i,g as n,u as o,h as r,d as s,v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,o as t,p as n}from"./button-BFNlGZ5p.js";import{n as r}from"./dist-CFZ4xMSF.js";var i=n(e(),1);function a(e,t){return i.useReducer((e,n)=>t[e][n]??e,e)}var o=e=>{let{present:n,children:r}=e,a=s(n),o=typeof r==`function`?r({present:a.isPresent}):i.Children.only(r),c=t(a.ref,l(o));return typeof r==`function`||a.isPresent?i.cloneElement(o,{ref:c}):null};o.displayName=`Presence`;function s(e){let[t,n]=i.useState(),o=i.useRef(null),s=i.useRef(e),l=i.useRef(`none`),[u,d]=a(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return i.useEffect(()=>{let e=c(o.current);l.current=u===`mounted`?e:`none`},[u]),r(()=>{let t=o.current,n=s.current;if(n!==e){let r=l.current,i=c(t);e?d(`MOUNT`):i===`none`||t?.display===`none`?d(`UNMOUNT`):d(n&&r!==i?`ANIMATION_OUT`:`UNMOUNT`),s.current=e}},[e,d]),r(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,r=r=>{let i=c(o.current).includes(CSS.escape(r.animationName));if(r.target===t&&i&&(d(`ANIMATION_END`),!s.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},i=e=>{e.target===t&&(l.current=c(o.current))};return t.addEventListener(`animationstart`,i),t.addEventListener(`animationcancel`,r),t.addEventListener(`animationend`,r),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,i),t.removeEventListener(`animationcancel`,r),t.removeEventListener(`animationend`,r)}}else d(`ANIMATION_END`)},[t,d]),{isPresent:[`mounted`,`unmountSuspended`].includes(u),ref:i.useCallback(e=>{o.current=e?getComputedStyle(e):null,n(e)},[])}}function c(e){return e?.animationName||`none`}function l(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}export{o as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
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{a as p,i as m,n as h,o as g,r as _,t as v}from"./es2015-DPJTBYa9.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)(h,{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)(p,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:o,children:(0,x.jsx)(g,{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
2
|
|
|
3
3
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e,d as t,o as n,p as r,r as i}from"./button-BFNlGZ5p.js";import{a}from"./dist-CFZ4xMSF.js";var o=r(t(),1),s=e();function c(e){let t=e+`CollectionProvider`,[r,c]=a(t),[l,u]=r(t,{collectionRef:{current:null},itemMap:new Map}),d=e=>{let{scope:t,children:n}=e,r=o.useRef(null),i=o.useRef(new Map).current;return(0,s.jsx)(l,{scope:t,itemMap:i,collectionRef:r,children:n})};d.displayName=t;let f=e+`CollectionSlot`,p=i(f),m=o.forwardRef((e,t)=>{let{scope:r,children:i}=e;return(0,s.jsx)(p,{ref:n(t,u(f,r).collectionRef),children:i})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=i(h),v=o.forwardRef((e,t)=>{let{scope:r,children:i,...a}=e,c=o.useRef(null),l=n(t,c),d=u(h,r);return o.useEffect(()=>(d.itemMap.set(c,{ref:c,...a}),()=>void d.itemMap.delete(c))),(0,s.jsx)(_,{[g]:``,ref:l,children:i})});v.displayName=h;function y(t){let n=u(e+`CollectionConsumer`,t);return o.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:d,Slot:m,ItemSlot:v},y,c]}var l=o.createContext(void 0);function u(e){let t=o.useContext(l);return e||t||`ltr`}export{c as n,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,p as t}from"./button-BFNlGZ5p.js";import{n}from"./dist-CFZ4xMSF.js";var r=t(e(),1);function i(e){let t=r.useRef({value:e,previous:e});return r.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function a(e){let[t,i]=r.useState(void 0);return n(()=>{if(e){i({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let n=t[0],r,a;if(`borderBoxSize`in n){let e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,a=t.blockSize}else r=e.offsetWidth,a=e.offsetHeight;i({width:r,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else i(void 0)},[e]),t}export{i as n,a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e,d as t,o as n,p as r}from"./button-BFNlGZ5p.js";import{a as i,o as a,r as o,t as s}from"./dist-CFZ4xMSF.js";import{n as c,t as l}from"./dist-LiAcI8CK.js";import{n as u,t as d}from"./dist-C-E2R2jk.js";var f=r(t(),1),p=e(),m=`rovingFocusGroup.onEntryFocus`,h={bubbles:!1,cancelable:!0},g=`RovingFocusGroup`,[_,v,y]=c(g),[b,x]=i(g,[y]),[S,C]=b(g),w=f.forwardRef((e,t)=>(0,p.jsx)(_.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,p.jsx)(_.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,p.jsx)(T,{...e,ref:t})})}));w.displayName=g;var T=f.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:r,orientation:i,loop:c=!1,dir:u,currentTabStopId:_,defaultCurrentTabStopId:y,onCurrentTabStopIdChange:b,onEntryFocus:x,preventScrollOnEntryFocus:C=!1,...w}=e,T=f.useRef(null),E=n(t,T),D=l(u),[O,k]=s({prop:_,defaultProp:y??null,onChange:b,caller:g}),[A,M]=f.useState(!1),N=d(x),P=v(r),F=f.useRef(!1),[I,L]=f.useState(0);return f.useEffect(()=>{let e=T.current;if(e)return e.addEventListener(m,N),()=>e.removeEventListener(m,N)},[N]),(0,p.jsx)(S,{scope:r,orientation:i,dir:D,loop:c,currentTabStopId:O,onItemFocus:f.useCallback(e=>k(e),[k]),onItemShiftTab:f.useCallback(()=>M(!0),[]),onFocusableItemAdd:f.useCallback(()=>L(e=>e+1),[]),onFocusableItemRemove:f.useCallback(()=>L(e=>e-1),[]),children:(0,p.jsx)(a.div,{tabIndex:A||I===0?-1:0,"data-orientation":i,...w,ref:E,style:{outline:`none`,...e.style},onMouseDown:o(e.onMouseDown,()=>{F.current=!0}),onFocus:o(e.onFocus,e=>{let t=!F.current;if(e.target===e.currentTarget&&t&&!A){let t=new CustomEvent(m,h);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=P().filter(e=>e.focusable);j([e.find(e=>e.active),e.find(e=>e.id===O),...e].filter(Boolean).map(e=>e.ref.current),C)}}F.current=!1}),onBlur:o(e.onBlur,()=>M(!1))})})}),E=`RovingFocusGroupItem`,D=f.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:c,...l}=e,d=u(),m=s||d,h=C(E,n),g=h.currentTabStopId===m,y=v(n),{onFocusableItemAdd:b,onFocusableItemRemove:x,currentTabStopId:S}=h;return f.useEffect(()=>{if(r)return b(),()=>x()},[r,b,x]),(0,p.jsx)(_.ItemSlot,{scope:n,id:m,focusable:r,active:i,children:(0,p.jsx)(a.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...l,ref:t,onMouseDown:o(e.onMouseDown,e=>{r?h.onItemFocus(m):e.preventDefault()}),onFocus:o(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:o(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){h.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=A(e,h.orientation,h.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=y().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=h.loop?M(n,r+1):n.slice(r+1)}setTimeout(()=>j(n))}}),children:typeof c==`function`?c({isCurrentTabStop:g,hasTabStop:S!=null}):c})})});D.displayName=E;var O={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function k(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function A(e,t,n){let r=k(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return O[r]}function j(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function M(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var N=w,P=D;export{N as n,x as r,P as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,d as t,p as n}from"./button-BFNlGZ5p.js";import{c as r}from"./dist-CFZ4xMSF.js";var i=n(t(),1),a=n(r(),1),o=e(),s=(0,i.createContext)(null);function c({host:e,registerDismiss:t,children:n}){return(0,o.jsx)(s.Provider,{value:{host:e,registerDismiss:t},children:n})}function l(){return(0,i.useContext)(s)!==null}function u(e){let t=(0,i.useContext)(s)?.registerDismiss,n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{if(t)return t(()=>n.current()),()=>t(null)},[t])}function d({children:e,className:t}){let n=(0,i.useContext)(s);return n?n.host?(0,a.createPortal)((0,o.jsx)(o.Fragment,{children:e}),n.host):null:(0,o.jsx)(`div`,{className:t,children:e})}export{l as i,c as n,u as r,d as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,f as t,s as n,u as r}from"./button-BTToMaBW.js";import{c as i,n as a,o,r as s,s as c}from"./dist-C6eaYCUo.js";import{t as l}from"./dist-CEd_wnRC.js";var u=t(r(),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),ee=D.indexOf(O),k=y?D.indexOf(y):-1,te=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=ee,j=S(e=>{let t=e.target,n=[...g.branches].some(e=>e.contains(t));!A||n||(a?.(e),l?.(e),e.defaultPrevented||p?.())},x),M=C(e=>{let t=e.target;[...g.branches].some(e=>e.contains(t))||(c?.(e),l?.(e),e.defaultPrevented||p?.())},x);return d(e=>{k===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:te?A?`auto`:`none`:void 0,...e.style},onFocusCapture:s(e.onFocusCapture,M.onFocusCapture),onBlurCapture:s(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:s(e.onPointerDownCapture,j.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=`focusScope.autoFocusOnMount`,D=`focusScope.autoFocusOnUnmount`,O={bubbles:!1,cancelable:!0},ee=`FocusScope`,k=u.forwardRef((e,t)=>{let{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...c}=e,[d,p]=u.useState(null),m=l(a),h=l(s),g=u.useRef(null),_=n(t,e=>p(e)),v=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(i){let e=function(e){if(v.paused||!d)return;let t=e.target;d.contains(t)?g.current=t:N(g.current,{select:!0})},t=function(e){if(v.paused||!d)return;let t=e.relatedTarget;t!==null&&(d.contains(t)||N(g.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&N(d)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return d&&r.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[i,d,v.paused]),u.useEffect(()=>{if(d){ie.add(v);let e=document.activeElement;if(!d.contains(e)){let t=new CustomEvent(E,O);d.addEventListener(E,m),d.dispatchEvent(t),t.defaultPrevented||(te(se(j(d)),{select:!0}),document.activeElement===e&&N(d))}return()=>{d.removeEventListener(E,m),setTimeout(()=>{let t=new CustomEvent(D,O);d.addEventListener(D,h),d.dispatchEvent(t),t.defaultPrevented||N(e??document.body,{select:!0}),d.removeEventListener(D,h),ie.remove(v)},0)}}},[d,m,h,v]);let y=u.useCallback(e=>{if(!r&&!i||v.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]=A(t);i&&a?!e.shiftKey&&n===a?(e.preventDefault(),r&&N(i,{select:!0})):e.shiftKey&&n===i&&(e.preventDefault(),r&&N(a,{select:!0})):n===t&&e.preventDefault()}},[r,i,v.paused]);return(0,f.jsx)(o.div,{tabIndex:-1,...c,ref:_,onKeyDown:y})});k.displayName=ee;function te(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(N(r,{select:t}),document.activeElement!==n)return}function A(e){let t=j(e);return[M(t,e),M(t.reverse(),e)]}function j(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 M(e,t){for(let n of e)if(!ne(n,{upTo:t}))return n}function ne(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 re(e){return e instanceof HTMLInputElement&&`select`in e}function N(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&re(e)&&t&&e.select()}}var ie=ae();function ae(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=oe(e,t),e.unshift(t)},remove(t){e=oe(e,t),e[0]?.resume()}}}function oe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function se(e){return e.filter(e=>e.tagName!==`A`)}var ce=t(i(),1),le=`Portal`,ue=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?ce.createPortal((0,f.jsx)(o.div,{...r,ref:t}),c):null});ue.displayName=le;var P=0;function de(){u.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??fe()),document.body.insertAdjacentElement(`beforeend`,e[1]??fe()),P++,()=>{P===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),P--}},[])}function fe(){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 F=function(){return F=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},F.apply(this,arguments)};function I(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 pe(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 L=`right-scroll-bar-position`,R=`width-before-scroll-bar`,me=`with-scroll-bars-hidden`,he=`--removed-body-scroll-bar-size`;function z(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ge(e,t){var n=(0,u.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 _e=typeof window<`u`?u.useLayoutEffect:u.useEffect,ve=new WeakMap;function ye(e,t){var n=ge(t||null,function(t){return e.forEach(function(e){return z(e,t)})});return _e(function(){var t=ve.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||z(e,null)}),i.forEach(function(e){r.has(e)||z(e,a)})}ve.set(n,e)},[e]),n}function be(e){return e}function xe(e,t){t===void 0&&(t=be);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 Se(e){e===void 0&&(e={});var t=xe(null);return t.options=F({async:!0,ssr:!1},e),t}var Ce=function(e){var t=e.sideCar,n=I(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 u.createElement(r,F({},n))};Ce.isSideCarExport=!0;function we(e,t){return e.useMedium(t),Ce}var Te=Se(),B=function(){},V=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:B,onWheelCapture:B,onTouchMoveCapture:B}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=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=I(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=ye([n,t]),w=F(F({},x),i);return u.createElement(u.Fragment,null,d&&u.createElement(S,{sideCar:Te,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?u.cloneElement(u.Children.only(s),F(F({},w),{ref:C})):u.createElement(y,F({},w,{className:c,ref:C}),s))});V.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},V.classNames={fullWidth:R,zeroRight:L};var Ee,De=function(){if(Ee)return Ee;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Oe(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=De();return t&&e.setAttribute(`nonce`,t),e}function ke(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ae(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var je=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Oe())&&(ke(t,n),Ae(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Me=function(){var e=je();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ne=function(){var e=Me();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Pe={left:0,top:0,right:0,gap:0},H=function(e){return parseInt(e||``,10)||0},Fe=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[H(n),H(r),H(i)]},Ie=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Pe;var t=Fe(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])}},Le=Ne(),U=`data-scroll-locked`,Re=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
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),ee=D.indexOf(O),k=y?D.indexOf(y):-1,te=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=ee,j=S(e=>{let t=e.target,n=[...g.branches].some(e=>e.contains(t));!A||n||(a?.(e),l?.(e),e.defaultPrevented||p?.())},x),M=C(e=>{let t=e.target;[...g.branches].some(e=>e.contains(t))||(c?.(e),l?.(e),e.defaultPrevented||p?.())},x);return d(e=>{k===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:te?A?`auto`:`none`:void 0,...e.style},onFocusCapture:s(e.onFocusCapture,M.onFocusCapture),onBlurCapture:s(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:s(e.onPointerDownCapture,j.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=`focusScope.autoFocusOnMount`,D=`focusScope.autoFocusOnUnmount`,O={bubbles:!1,cancelable:!0},ee=`FocusScope`,k=u.forwardRef((e,t)=>{let{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...c}=e,[d,p]=u.useState(null),m=l(a),h=l(s),g=u.useRef(null),_=n(t,e=>p(e)),v=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(i){let e=function(e){if(v.paused||!d)return;let t=e.target;d.contains(t)?g.current=t:N(g.current,{select:!0})},t=function(e){if(v.paused||!d)return;let t=e.relatedTarget;t!==null&&(d.contains(t)||N(g.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&N(d)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return d&&r.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[i,d,v.paused]),u.useEffect(()=>{if(d){ie.add(v);let e=document.activeElement;if(!d.contains(e)){let t=new CustomEvent(E,O);d.addEventListener(E,m),d.dispatchEvent(t),t.defaultPrevented||(te(se(j(d)),{select:!0}),document.activeElement===e&&N(d))}return()=>{d.removeEventListener(E,m),setTimeout(()=>{let t=new CustomEvent(D,O);d.addEventListener(D,h),d.dispatchEvent(t),t.defaultPrevented||N(e??document.body,{select:!0}),d.removeEventListener(D,h),ie.remove(v)},0)}}},[d,m,h,v]);let y=u.useCallback(e=>{if(!r&&!i||v.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]=A(t);i&&a?!e.shiftKey&&n===a?(e.preventDefault(),r&&N(i,{select:!0})):e.shiftKey&&n===i&&(e.preventDefault(),r&&N(a,{select:!0})):n===t&&e.preventDefault()}},[r,i,v.paused]);return(0,f.jsx)(o.div,{tabIndex:-1,...c,ref:_,onKeyDown:y})});k.displayName=ee;function te(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(N(r,{select:t}),document.activeElement!==n)return}function A(e){let t=j(e);return[M(t,e),M(t.reverse(),e)]}function j(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 M(e,t){for(let n of e)if(!ne(n,{upTo:t}))return n}function ne(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 re(e){return e instanceof HTMLInputElement&&`select`in e}function N(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&re(e)&&t&&e.select()}}var ie=ae();function ae(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=oe(e,t),e.unshift(t)},remove(t){e=oe(e,t),e[0]?.resume()}}}function oe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function se(e){return e.filter(e=>e.tagName!==`A`)}var ce=r(i(),1),le=`Portal`,ue=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?ce.createPortal((0,f.jsx)(o.div,{...r,ref:t}),c):null});ue.displayName=le;var P=0;function de(){u.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??fe()),document.body.insertAdjacentElement(`beforeend`,e[1]??fe()),P++,()=>{P===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),P--}},[])}function fe(){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 F=function(){return F=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},F.apply(this,arguments)};function I(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 pe(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 L=`right-scroll-bar-position`,R=`width-before-scroll-bar`,me=`with-scroll-bars-hidden`,he=`--removed-body-scroll-bar-size`;function z(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ge(e,t){var n=(0,u.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 _e=typeof window<`u`?u.useLayoutEffect:u.useEffect,ve=new WeakMap;function ye(e,t){var n=ge(t||null,function(t){return e.forEach(function(e){return z(e,t)})});return _e(function(){var t=ve.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||z(e,null)}),i.forEach(function(e){r.has(e)||z(e,a)})}ve.set(n,e)},[e]),n}function be(e){return e}function xe(e,t){t===void 0&&(t=be);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 Se(e){e===void 0&&(e={});var t=xe(null);return t.options=F({async:!0,ssr:!1},e),t}var Ce=function(e){var t=e.sideCar,n=I(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 u.createElement(r,F({},n))};Ce.isSideCarExport=!0;function we(e,t){return e.useMedium(t),Ce}var Te=Se(),B=function(){},V=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:B,onWheelCapture:B,onTouchMoveCapture:B}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=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=I(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=ye([n,t]),w=F(F({},x),i);return u.createElement(u.Fragment,null,d&&u.createElement(S,{sideCar:Te,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?u.cloneElement(u.Children.only(s),F(F({},w),{ref:C})):u.createElement(y,F({},w,{className:c,ref:C}),s))});V.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},V.classNames={fullWidth:R,zeroRight:L};var Ee,De=function(){if(Ee)return Ee;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Oe(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=De();return t&&e.setAttribute(`nonce`,t),e}function ke(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ae(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var je=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Oe())&&(ke(t,n),Ae(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Me=function(){var e=je();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ne=function(){var e=Me();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Pe={left:0,top:0,right:0,gap:0},H=function(e){return parseInt(e||``,10)||0},Fe=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[H(n),H(r),H(i)]},Ie=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Pe;var t=Fe(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])}},Le=Ne(),U=`data-scroll-locked`,Re=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
2
|
.${me} {
|
|
3
3
|
overflow: hidden ${r};
|
|
4
4
|
padding-right: ${s}px ${r};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
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-alert-zMagrFuI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p}from"./dist-DLQKRjuW.js";import"./es2015-DPJTBYa9.js";import{i as m,o as h,r as g}from"./ai-config-store-C8D_PUGV.js";import{$ as _,At as v,Q as y,St as b,jt as x,mt as S,r as C}from"./index-B-6nUrqW.js";var w=a(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),T=a(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),E=a(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),D=a(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),O=r(t(),1);function k(){let e=g(),t=m(e);return t?{...e,provider:t.provider,apiKey:t.apiKey,baseUrl:t.baseUrl,model:t.model}:e}async function A(e){let t=await e.json();if(!e.ok)throw Error(t.error||`请求失败: ${e.status}`);return t}function j(e){let t=e.split(`
|
|
2
2
|
`);return{event:t.find(e=>e.startsWith(`event:`))?.slice(6).trim()||`message`,data:t.filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
|
|
3
3
|
`)}}async function M(e,t={},n){let r=k();if(!h(r))throw Error(`请先在系统设置中启用并填写可用的 AI 配置。`);let i=await fetch(`/api/agent/chat-stream`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:e,aiConfig:r,...n?{conversationId:n}:{}})});if(!i.ok||!i.body)return A(i);let a=i.body.getReader(),o=new TextDecoder,s=``,c=e=>{let{event:n,data:r}=j(e);if(!r)return null;let i=JSON.parse(r);if(n===`start`)return t.onStart?.(),null;if(n===`delta`){let e=typeof i.delta==`string`?i.delta:``;return e&&t.onDelta?.(e),null}if(n===`error`)throw Error(typeof i.error==`string`?i.error:`AI 请求失败`);return n===`done`?i:null};for(;;){let{value:e,done:t}=await a.read();s+=o.decode(e||new Uint8Array,{stream:!t});let n=s.split(/\n\n/);s=n.pop()||``;for(let e of n){let t=c(e);if(t)return t}if(t)break}if(s.trim()){let e=c(s);if(e)return e}throw Error(`AI 流式响应未返回完成事件`)}async function N(e,t){return A(await fetch(`/api/agent/confirm`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({confirmationId:e,approved:t})}))}function P(e){return e.trim().toLowerCase()}function F(e,t){if(!e)return 1;let n=P(e),r=P(t);if(!n)return 1;if(!r)return 0;if(r===n)return 120;if(r.startsWith(n))return 100-Math.min(r.length-n.length,30);if(r.includes(n))return 80-Math.min(r.indexOf(n),30);let i=0,a=0;for(let e=0;e<r.length&&i<n.length;e++)n[i]===r[e]&&(i+=1,a+=4);return i===n.length?a:0}function I(e,t){let n=[t.title,t.description||``,t.section,...t.keywords||[]];return Math.max(...n.map(t=>F(e,t)))}function L(e,t){return(0,O.useMemo)(()=>{let n=e.map(e=>({command:e,score:I(t,e)})).filter(e=>e.score>0);return n.sort((e,t)=>e.command.disabled===t.command.disabled?t.score===e.score?e.command.title.localeCompare(t.command.title,`zh-Hans-CN`):t.score-e.score:e.command.disabled?1:-1),n.map(e=>e.command)},[e,t])}function R(){let e=(0,O.useContext)(C);if(!e)throw Error(`useGlobalPanel must be used inside GlobalPanelProvider`);return e}var z=e(),B={command:`w-[min(760px,calc(100vw-32px))] h-[min(760px,calc(100vh-48px))]`,md:`w-[min(760px,calc(100vw-32px))] h-[min(720px,calc(100vh-48px))]`,lg:`w-[min(1040px,calc(100vw-32px))] h-[min(780px,calc(100vh-48px))]`,xl:`w-[min(1240px,calc(100vw-32px))] h-[min(860px,calc(100vh-32px))]`,fullscreen:`w-[calc(100vw-32px)] h-[calc(100vh-32px)]`},V={md:{width:760,height:720},lg:{width:1040,height:780},xl:{width:1240,height:860},fullscreen:{width:1/0,height:1/0}};function H(){let e=typeof window>`u`?1280:window.innerWidth,t=typeof window>`u`?900:window.innerHeight,n=Math.max(320,e-32),r=Math.max(360,t-32);return{minWidth:Math.min(560,n),minHeight:Math.min(420,r),maxWidth:n,maxHeight:r}}function U(e){let t=H();return{width:Math.min(t.maxWidth,Math.max(t.minWidth,e.width)),height:Math.min(t.maxHeight,Math.max(t.minHeight,e.height))}}function W(e){let t=H(),n=V[e]||V.lg;return e===`fullscreen`?{width:t.maxWidth,height:t.maxHeight}:U(n)}function G(e){if(typeof window>`u`)return null;try{let t=window.localStorage.getItem(`global-panel-size:${e}`);if(!t)return null;let n=JSON.parse(t);return typeof n.width!=`number`||typeof n.height!=`number`?null:U({width:n.width,height:n.height})}catch{return null}}function K(e){let t=[],n=/(`[^`]+`|\*\*[^*]+\*\*)/g,r=0,i;for(;i=n.exec(e);){i.index>r&&t.push(e.slice(r,i.index));let n=i[0];n.startsWith("`")?t.push((0,z.jsx)(`code`,{className:`rounded bg-muted/70 px-1 py-0.5 font-mono text-[0.92em]`,children:n.slice(1,-1)},`${i.index}-code`)):t.push((0,z.jsx)(`strong`,{children:n.slice(2,-2)},`${i.index}-strong`)),r=i.index+n.length}return r<e.length&&t.push(e.slice(r)),t}function q(e){return/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}function J(e){return e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim())}function Y({content:e}){let t=e.replace(/\r\n/g,`
|
|
4
4
|
`).split(`
|
|
5
|
-
`),
|
|
6
|
-
`)})})]},`code-${i}`));continue}let o=e.match(/^(#{1,4})\s+(.+)$/);if(o){let e=o[1].length,t=r(`font-semibold leading-6 text-foreground`,e<=2?`mt-2 text-sm`:`text-[13px]`),a=K(o[2]);n.push(e===1?(0,z.jsx)(`h3`,{className:t,children:a},`heading-${i}`):e===2?(0,z.jsx)(`h4`,{className:t,children:a},`heading-${i}`):(0,z.jsx)(`h5`,{className:t,children:a},`heading-${i}`)),i+=1;continue}if(/^---+$/.test(e)){n.push((0,z.jsx)(`div`,{className:`h-px bg-border/70`},`hr-${i}`)),i+=1;continue}if(e.includes(`|`)&&i+1<t.length&&q(t[i+1])){let r=J(e),a=[];for(i+=2;i<t.length&&t[i].trim().includes(`|`);)a.push(J(t[i])),i+=1;n.push((0,z.jsx)(`div`,{className:`overflow-auto rounded-md border`,children:(0,z.jsxs)(`table`,{className:`w-full min-w-max border-collapse text-xs`,children:[(0,z.jsx)(`thead`,{className:`bg-muted/50 text-muted-foreground`,children:(0,z.jsx)(`tr`,{children:r.map((e,t)=>(0,z.jsx)(`th`,{className:`border-b px-2 py-1.5 text-left font-medium`,children:K(e)},`${e}-${t}`))})}),(0,z.jsx)(`tbody`,{children:a.map((e,t)=>(0,z.jsx)(`tr`,{className:`border-b last:border-0`,children:e.map((e,n)=>(0,z.jsx)(`td`,{className:`px-2 py-1.5 align-top`,children:K(e)},`${t}-${n}`))},t))})]})},`table-${i}`));continue}if(/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)){let a=/^\d+\.\s+/.test(e),o=[];for(;i<t.length;){let e=t[i].trim(),n=a?e.match(/^\d+\.\s+(.+)$/):e.match(/^[-*]\s+(.+)$/);if(!n)break;o.push(n[1]),i+=1}let s=a?`ol`:`ul`;n.push((0,z.jsx)(s,{className:r(`space-y-1 pl-5`,a?`list-decimal`:`list-disc`),children:o.map((e,t)=>(0,z.jsx)(`li`,{children:K(e)},t))},`list-${i}`));continue}let s=[e];for(i+=1;i<t.length;){let e=t[i].trim();if(!e||e.startsWith("```")||/^#{1,4}\s+/.test(e)||/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^---+$/.test(e)||e.includes(`|`)&&i+1<t.length&&q(t[i+1]))break;s.push(e),i+=1}n.push((0,z.jsx)(`p`,{className:`leading-6 text-foreground/90`,children:K(s.join(` `))},`p-${i}`))}return(0,z.jsx)(`div`,{className:`agent-markdown-content space-y-3 text-sm`,children:n})}function X({commands:e}){let t=R(),[n,a]=(0,O.useState)(``),[s,c]=(0,O.useState)(0),[l,u]=(0,O.useState)(null),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(null),[h,g]=(0,O.useState)(!1),[C,T]=(0,O.useState)(null),[E,D]=(0,O.useState)(null),[k,A]=(0,O.useState)([]),[j,P]=(0,O.useState)(``),[F,I]=(0,O.useState)(null),B=(0,O.useRef)(null),V=(0,O.useRef)(null),H=(0,O.useRef)(null),U=(0,O.useRef)(null),W=L(e,n),G=n.trim(),K=!!(p||d||h||k.length>0);(0,O.useEffect)(()=>{let e=requestAnimationFrame(()=>B.current?.focus());return()=>cancelAnimationFrame(e)},[]),(0,O.useEffect)(()=>{c(0)},[n]),(0,O.useEffect)(()=>{let e=V.current;!e||!K||(e.scrollTop=e.scrollHeight)},[p,h,d?.message,k,K]);let q=W[s];(0,O.useLayoutEffect)(()=>{let e=H.current,t=U.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();n.top<r.top+12?t.scrollTop-=r.top+12-n.top:n.bottom>r.bottom-12&&(t.scrollTop+=n.bottom-(r.bottom-12))},[s,W]);let J=(0,O.useMemo)(()=>{let e=new Map;return W.forEach(t=>{e.has(t.section)||e.set(t.section,[]),e.get(t.section)?.push(t)}),Array.from(e.entries())},[W]),X=async e=>{if(!(!e||e.disabled)&&!(e.confirm&&!window.confirm(e.confirm))){u(e.id);try{await e.run(),e.closeOnRun!==!1&&t.close()}finally{u(null)}}},Z=async(e,t)=>{if(!e||h)return;g(!0),m(null),f(null),I(e),t||(D(null),A([]));let n=``;try{let r=await M(e,{onDelta:e=>{n+=e,f({runId:`streaming`,message:n,pendingConfirmations:[],toolResults:[],conversationId:t||``})}},t);f(r),D(r.conversationId),A(t=>[...t,{userMessage:e,aiMessage:r.message}])}catch(e){m(e.message)}finally{g(!1),I(null)}},Q=async()=>{let e=j.trim();!e||h||!E||(P(``),await Z(e,E))},$=async(e,t)=>{T(e),m(null);try{let n=await N(e,t),r=(n.result&&typeof n.result==`object`?n.result:null)?.message||n.message;f(t=>({runId:t?.runId||e,message:r,pendingConfirmations:[],toolResults:n.result?[n.result]:[],conversationId:t?.conversationId||``})),A(e=>e.length===0?e:e.map((t,n)=>n===e.length-1?{...t,aiMessage:r}:t))}catch(e){m(e.message)}finally{T(null)}};return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,z.jsxs)(`div`,{className:`global-panel-topbar flex items-center gap-3 border-b px-4 py-3`,children:[(0,z.jsx)(_,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(S,{ref:B,value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),c(e=>Math.min(e+1,Math.max(W.length-1,0)))):e.key===`ArrowUp`?(e.preventDefault(),c(e=>Math.max(e-1,0))):e.key===`Enter`?(e.preventDefault(),q?X(q):G&&Z(G)):e.key===`Escape`&&!n&&t.close()},placeholder:`搜索命令,或直接描述你想让 AI 完成的操作...`,className:`h-9 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0 dark:bg-transparent`}),(0,z.jsx)(v,{variant:`outline`,className:`hidden shrink-0 text-[11px] font-normal sm:inline-flex`,children:`⌘K`})]}),(0,z.jsxs)(`div`,{ref:U,className:`min-h-0 flex-1 overflow-y-auto`,children:[G&&(0,z.jsx)(`div`,{className:`p-3 pb-0`,children:(0,z.jsxs)(`button`,{type:`button`,className:`global-command-action flex w-full items-center gap-3 rounded-md border px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-60`,disabled:h,onClick:()=>void Z(G),children:[(0,z.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-background/55 backdrop-blur`,children:h?(0,z.jsx)(b,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(w,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`font-medium`,children:`让 AI 处理`}),(0,z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:G})]})]})}),(p||d||h||k.length>0)&&(0,z.jsx)(`div`,{className:`p-3 pb-0`,children:(0,z.jsxs)(`div`,{className:r(`overflow-hidden rounded-md border text-sm`,p?`border-destructive/40 bg-destructive/5`:`bg-background/35 backdrop-blur`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-background/35 px-3 py-2`,children:[p?(0,z.jsx)(o,{className:`h-4 w-4 shrink-0 text-destructive`}):h?(0,z.jsx)(b,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):(0,z.jsx)(y,{className:`h-4 w-4 shrink-0 text-emerald-500`}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1 font-medium`,children:p?`AI 请求失败`:h?`AI 正在处理`:`AI 响应`})]}),(0,z.jsx)(`div`,{ref:V,className:`max-h-[min(520px,calc(100vh-220px))] overflow-y-auto overscroll-contain`,children:(0,z.jsxs)(`div`,{className:`px-3 py-3`,children:[p&&k.length===0?(0,z.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6 text-destructive`,children:p}):null,k.map((e,t)=>(0,z.jsxs)(`div`,{className:r(t>0&&`mt-4 border-t pt-4`),children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`你`}),(0,z.jsx)(`div`,{className:`mb-3 whitespace-pre-wrap break-words leading-6 text-foreground/90`,children:e.userMessage}),(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`AI`}),(0,z.jsx)(Y,{content:e.aiMessage})]},t)),F&&(0,z.jsxs)(`div`,{className:r(k.length>0&&`mt-4 border-t pt-4`),children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`你`}),(0,z.jsx)(`div`,{className:`mb-3 whitespace-pre-wrap break-words leading-6 text-foreground/90`,children:F}),(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`AI`}),h&&!d?.message?(0,z.jsx)(`div`,{className:`leading-6 text-muted-foreground`,children:`正在分析你的请求并调用可用工具...`}):d?.message?(0,z.jsx)(Y,{content:d.message}):null,p?(0,z.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6 text-destructive`,children:p}):null]}),d?.pendingConfirmations.map(e=>(0,z.jsxs)(`div`,{className:`mt-3 rounded-md border bg-background/55 p-3 backdrop-blur`,children:[(0,z.jsx)(`div`,{className:`font-medium`,children:e.summary}),e.diff&&(0,z.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-auto rounded border bg-muted/40 p-2 text-xs leading-5 text-muted-foreground`,children:e.diff}),(0,z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,z.jsx)(i,{variant:`ghost`,size:`sm`,disabled:C===e.id,onClick:()=>void $(e.id,!1),children:`取消`}),(0,z.jsxs)(i,{size:`sm`,disabled:C===e.id,onClick:()=>void $(e.id,!0),children:[C===e.id?(0,z.jsx)(b,{className:`mr-1 h-3.5 w-3.5 animate-spin`}):null,`确认执行`]})]})]},e.id))]})}),E&&!h&&d&&d.pendingConfirmations.length===0&&(0,z.jsx)(`div`,{className:`border-t px-3 py-2`,children:(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(S,{value:j,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q())},placeholder:`继续对话...`,className:`h-8 text-sm`}),(0,z.jsx)(i,{size:`sm`,disabled:!j.trim()||h,onClick:()=>void Q(),children:`发送`})]})})]})}),W.length===0&&!K?(0,z.jsxs)(`div`,{className:`flex h-64 flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground`,children:[(0,z.jsx)(x,{className:`h-8 w-8 opacity-50`}),(0,z.jsx)(`div`,{className:`text-sm`,children:`没有找到匹配的操作`})]}):W.length>0?(0,z.jsx)(`div`,{className:`space-y-4 p-3`,children:J.map(([e,t])=>(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),t.map(e=>{let t=W.findIndex(t=>t.id===e.id),n=e.icon,i=t===s,a=l===e.id;return(0,z.jsxs)(`button`,{ref:i?H:void 0,type:`button`,"data-selected":i?`true`:void 0,className:r(`flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-sm transition-colors`,i?`bg-accent/70 text-accent-foreground shadow-sm`:`hover:bg-accent/45`,e.disabled&&`cursor-not-allowed opacity-50`,e.danger&&!e.disabled&&`text-destructive`),onMouseEnter:()=>c(t),onClick:()=>void X(e),disabled:a,children:[(0,z.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-background/55 backdrop-blur`,children:a?(0,z.jsx)(b,{className:`h-4 w-4 animate-spin`}):n?(0,z.jsx)(n,{className:`h-4 w-4`}):(0,z.jsx)(x,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate font-medium`,children:e.title}),(e.description||e.disabledReason)&&(0,z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.disabled&&e.disabledReason||e.description})]}),e.shortcut&&(0,z.jsx)(v,{variant:`secondary`,className:`shrink-0 text-[10px] font-normal`,children:e.shortcut})]},e.id)})]},e))}):null]})]})}function Z({commands:e,renderPanel:t}){let n=R(),a=n.currentRoute,o=a?.size||`command`,m=a?.id,h=a?.size,[g,_]=(0,O.useState)(null),[v,y]=(0,O.useState)(!1),[b,x]=(0,O.useState)(!1),S=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{if(!m){_(null),y(!1),x(!1);return}_(G(m)||W(h||`lg`)),y(h===`fullscreen`),x(!1)});return()=>window.cancelAnimationFrame(e)},[m,h]),(0,O.useEffect)(()=>{if(!m)return;let e=()=>{_(e=>e&&U(e))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[m]);let C=e=>{!a||v||typeof window>`u`||window.localStorage.setItem(`global-panel-size:${a.id}`,JSON.stringify(e))},w=e=>{if(!a||!g||v)return;e.preventDefault(),x(!0);let t=e.pointerId,n=e.clientX,r=e.clientY,i=g,o=e.currentTarget;o.setPointerCapture(t);let s=e=>{_(U({width:i.width+(e.clientX-n)*2,height:i.height+(e.clientY-r)}))},c=()=>{o.hasPointerCapture(t)&&o.releasePointerCapture(t),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),x(!1),_(e=>(e&&C(e),e))};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},k=()=>{if(!(!a||!g)){if(v){_(U(S.current||G(a.id)||W(a.size||`lg`))),y(!1);return}S.current=g,_(W(`fullscreen`)),y(!0)}},A=a&&g?{width:`${g.width}px`,height:`${g.height}px`}:void 0;return(0,z.jsx)(d,{open:n.open,onOpenChange:e=>{e||n.close()},children:(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{className:`global-panel-overlay fixed inset-0 z-[80]`}),(0,z.jsx)(u,{style:A,className:r(`global-panel-content global-panel-surface fixed left-1/2 top-4 z-[81] flex flex-col overflow-hidden rounded-lg border outline-none`,a&&!b&&`transition-[width,height] duration-200 ease-out`,!a&&B[o]),children:a?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`global-panel-topbar flex items-center gap-2 border-b px-4 py-3`,children:[n.stack.length>1&&(0,z.jsx)(i,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:n.back,title:`返回上一级`,children:(0,z.jsx)(T,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(p,{className:`truncate text-sm font-semibold`,children:a.title}),a.description&&(0,z.jsx)(f,{className:`truncate text-xs text-muted-foreground`,children:a.description})]}),(0,z.jsx)(i,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:k,title:v?`还原尺寸`:`最大化`,children:v?(0,z.jsx)(D,{className:`h-4 w-4`}):(0,z.jsx)(E,{className:`h-4 w-4`})}),(0,z.jsx)(i,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:n.close,title:`关闭`,children:(0,z.jsx)(c,{className:`h-4 w-4`})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:t(a)}),!v&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`调整面板尺寸`,title:`拖拽调整面板尺寸`,className:`absolute bottom-0 right-0 h-6 w-6 cursor-nwse-resize rounded-tl-md text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,onPointerDown:w,children:(0,z.jsx)(`span`,{className:`pointer-events-none absolute bottom-1 right-1 h-3 w-3 border-b border-r border-current`})})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(p,{className:`sr-only`,children:`全局操作面板`}),(0,z.jsx)(f,{className:`sr-only`,children:`搜索并执行 Meddle 的页面、设置和功能操作。`}),(0,z.jsx)(X,{commands:e})]})})]})})}export{Z as GlobalPanelShell};
|
|
5
|
+
`),r=[],i=0;for(;i<t.length;){let e=t[i].trim();if(!e){i+=1;continue}let a=e.match(/^```(\w+)?/);if(a){let e=a[1],n=[];for(i+=1;i<t.length&&!t[i].trim().startsWith("```");)n.push(t[i]),i+=1;i+=1,r.push((0,z.jsxs)(`div`,{className:`overflow-hidden rounded-md border bg-muted/45`,children:[e&&(0,z.jsx)(`div`,{className:`border-b bg-background/45 px-3 py-1 text-[11px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,z.jsx)(`pre`,{className:`max-h-64 overflow-auto p-3 text-xs leading-5`,children:(0,z.jsx)(`code`,{children:n.join(`
|
|
6
|
+
`)})})]},`code-${i}`));continue}let o=e.match(/^(#{1,4})\s+(.+)$/);if(o){let e=o[1].length,t=n(`font-semibold leading-6 text-foreground`,e<=2?`mt-2 text-sm`:`text-[13px]`),a=K(o[2]);r.push(e===1?(0,z.jsx)(`h3`,{className:t,children:a},`heading-${i}`):e===2?(0,z.jsx)(`h4`,{className:t,children:a},`heading-${i}`):(0,z.jsx)(`h5`,{className:t,children:a},`heading-${i}`)),i+=1;continue}if(/^---+$/.test(e)){r.push((0,z.jsx)(`div`,{className:`h-px bg-border/70`},`hr-${i}`)),i+=1;continue}if(e.includes(`|`)&&i+1<t.length&&q(t[i+1])){let n=J(e),a=[];for(i+=2;i<t.length&&t[i].trim().includes(`|`);)a.push(J(t[i])),i+=1;r.push((0,z.jsx)(`div`,{className:`overflow-auto rounded-md border`,children:(0,z.jsxs)(`table`,{className:`w-full min-w-max border-collapse text-xs`,children:[(0,z.jsx)(`thead`,{className:`bg-muted/50 text-muted-foreground`,children:(0,z.jsx)(`tr`,{children:n.map((e,t)=>(0,z.jsx)(`th`,{className:`border-b px-2 py-1.5 text-left font-medium`,children:K(e)},`${e}-${t}`))})}),(0,z.jsx)(`tbody`,{children:a.map((e,t)=>(0,z.jsx)(`tr`,{className:`border-b last:border-0`,children:e.map((e,n)=>(0,z.jsx)(`td`,{className:`px-2 py-1.5 align-top`,children:K(e)},`${t}-${n}`))},t))})]})},`table-${i}`));continue}if(/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)){let a=/^\d+\.\s+/.test(e),o=[];for(;i<t.length;){let e=t[i].trim(),n=a?e.match(/^\d+\.\s+(.+)$/):e.match(/^[-*]\s+(.+)$/);if(!n)break;o.push(n[1]),i+=1}let s=a?`ol`:`ul`;r.push((0,z.jsx)(s,{className:n(`space-y-1 pl-5`,a?`list-decimal`:`list-disc`),children:o.map((e,t)=>(0,z.jsx)(`li`,{children:K(e)},t))},`list-${i}`));continue}let s=[e];for(i+=1;i<t.length;){let e=t[i].trim();if(!e||e.startsWith("```")||/^#{1,4}\s+/.test(e)||/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^---+$/.test(e)||e.includes(`|`)&&i+1<t.length&&q(t[i+1]))break;s.push(e),i+=1}r.push((0,z.jsx)(`p`,{className:`leading-6 text-foreground/90`,children:K(s.join(` `))},`p-${i}`))}return(0,z.jsx)(`div`,{className:`agent-markdown-content space-y-3 text-sm`,children:r})}function X({commands:e}){let t=R(),[r,a]=(0,O.useState)(``),[s,c]=(0,O.useState)(0),[l,u]=(0,O.useState)(null),[d,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(null),[h,g]=(0,O.useState)(!1),[C,w]=(0,O.useState)(null),[E,D]=(0,O.useState)(null),[k,A]=(0,O.useState)([]),[j,P]=(0,O.useState)(``),[F,I]=(0,O.useState)(null),B=(0,O.useRef)(null),V=(0,O.useRef)(null),H=(0,O.useRef)(null),U=(0,O.useRef)(null),W=L(e,r),G=r.trim(),K=!!(p||d||h||k.length>0);(0,O.useEffect)(()=>{let e=requestAnimationFrame(()=>B.current?.focus());return()=>cancelAnimationFrame(e)},[]),(0,O.useEffect)(()=>{c(0)},[r]),(0,O.useEffect)(()=>{let e=V.current;!e||!K||(e.scrollTop=e.scrollHeight)},[p,h,d?.message,k,K]);let q=W[s];(0,O.useLayoutEffect)(()=>{let e=H.current,t=U.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();n.top<r.top+12?t.scrollTop-=r.top+12-n.top:n.bottom>r.bottom-12&&(t.scrollTop+=n.bottom-(r.bottom-12))},[s,W]);let J=(0,O.useMemo)(()=>{let e=new Map;return W.forEach(t=>{e.has(t.section)||e.set(t.section,[]),e.get(t.section)?.push(t)}),Array.from(e.entries())},[W]),X=async e=>{if(!(!e||e.disabled)&&!(e.confirm&&!window.confirm(e.confirm))){u(e.id);try{await e.run(),e.closeOnRun!==!1&&t.close()}finally{u(null)}}},Z=async(e,t)=>{if(!e||h)return;g(!0),m(null),f(null),I(e),t||(D(null),A([]));let n=``;try{let r=await M(e,{onDelta:e=>{n+=e,f({runId:`streaming`,message:n,pendingConfirmations:[],toolResults:[],conversationId:t||``})}},t);f(r),D(r.conversationId),A(t=>[...t,{userMessage:e,aiMessage:r.message}])}catch(e){m(e.message)}finally{g(!1),I(null)}},Q=async()=>{let e=j.trim();!e||h||!E||(P(``),await Z(e,E))},$=async(e,t)=>{w(e),m(null);try{let n=await N(e,t),r=(n.result&&typeof n.result==`object`?n.result:null)?.message||n.message;f(t=>({runId:t?.runId||e,message:r,pendingConfirmations:[],toolResults:n.result?[n.result]:[],conversationId:t?.conversationId||``})),A(e=>e.length===0?e:e.map((t,n)=>n===e.length-1?{...t,aiMessage:r}:t))}catch(e){m(e.message)}finally{w(null)}};return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,z.jsxs)(`div`,{className:`global-panel-topbar flex items-center gap-3 border-b px-4 py-3`,children:[(0,z.jsx)(S,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(_,{ref:B,value:r,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),c(e=>Math.min(e+1,Math.max(W.length-1,0)))):e.key===`ArrowUp`?(e.preventDefault(),c(e=>Math.max(e-1,0))):e.key===`Enter`?(e.preventDefault(),q?X(q):G&&Z(G)):e.key===`Escape`&&!r&&t.close()},placeholder:`搜索命令,或直接描述你想让 AI 完成的操作…`,className:`h-9 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0 dark:bg-transparent`}),(0,z.jsx)(y,{variant:`outline`,className:`hidden shrink-0 text-[11px] font-normal sm:inline-flex`,children:`⌘K`})]}),(0,z.jsxs)(`div`,{ref:U,className:`min-h-0 flex-1 overflow-y-auto`,children:[G&&(0,z.jsx)(`div`,{className:`p-3 pb-0`,children:(0,z.jsxs)(`button`,{type:`button`,className:`global-command-action flex w-full items-center gap-3 rounded-md border px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-60`,disabled:h,onClick:()=>void Z(G),children:[(0,z.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-background/55 backdrop-blur`,children:h?(0,z.jsx)(b,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(x,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`font-medium`,children:`让 AI 处理`}),(0,z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:G})]})]})}),(p||d||h||k.length>0)&&(0,z.jsx)(`div`,{className:`p-3 pb-0`,children:(0,z.jsxs)(`div`,{className:n(`overflow-hidden rounded-md border text-sm`,p?`border-destructive/40 bg-destructive/5`:`bg-background/35 backdrop-blur`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-background/35 px-3 py-2`,children:[p?(0,z.jsx)(o,{className:`h-4 w-4 shrink-0 text-destructive`}):h?(0,z.jsx)(b,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):(0,z.jsx)(v,{className:`h-4 w-4 shrink-0 text-emerald-500`}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1 font-medium`,children:p?`AI 请求失败`:h?`AI 正在处理`:`AI 响应`})]}),(0,z.jsx)(`div`,{ref:V,className:`max-h-[min(520px,calc(100vh-220px))] overflow-y-auto overscroll-contain`,children:(0,z.jsxs)(`div`,{className:`px-3 py-3`,children:[p&&k.length===0?(0,z.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6 text-destructive`,children:p}):null,k.map((e,t)=>(0,z.jsxs)(`div`,{className:n(t>0&&`mt-4 border-t pt-4`),children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`你`}),(0,z.jsx)(`div`,{className:`mb-3 whitespace-pre-wrap break-words leading-6 text-foreground/90`,children:e.userMessage}),(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`AI`}),(0,z.jsx)(Y,{content:e.aiMessage})]},t)),F&&(0,z.jsxs)(`div`,{className:n(k.length>0&&`mt-4 border-t pt-4`),children:[(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`你`}),(0,z.jsx)(`div`,{className:`mb-3 whitespace-pre-wrap break-words leading-6 text-foreground/90`,children:F}),(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`AI`}),h&&!d?.message?(0,z.jsx)(`div`,{className:`leading-6 text-muted-foreground`,children:`正在分析你的请求并调用可用工具…`}):d?.message?(0,z.jsx)(Y,{content:d.message}):null,p?(0,z.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6 text-destructive`,children:p}):null]}),d?.pendingConfirmations.map(e=>(0,z.jsxs)(`div`,{className:`mt-3 rounded-md border bg-background/55 p-3 backdrop-blur`,children:[(0,z.jsx)(`div`,{className:`font-medium`,children:e.summary}),e.diff&&(0,z.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-auto rounded border bg-muted/40 p-2 text-xs leading-5 text-muted-foreground`,children:e.diff}),(0,z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,z.jsx)(i,{variant:`ghost`,size:`sm`,disabled:C===e.id,onClick:()=>void $(e.id,!1),children:`取消`}),(0,z.jsxs)(i,{size:`sm`,disabled:C===e.id,onClick:()=>void $(e.id,!0),children:[C===e.id?(0,z.jsx)(b,{className:`mr-1 h-3.5 w-3.5 animate-spin`}):null,`确认执行`]})]})]},e.id))]})}),E&&!h&&d&&d.pendingConfirmations.length===0&&(0,z.jsx)(`div`,{className:`border-t px-3 py-2`,children:(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(_,{value:j,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q())},placeholder:`继续对话…`,className:`h-8 text-sm`}),(0,z.jsx)(i,{size:`sm`,disabled:!j.trim()||h,onClick:()=>void Q(),children:`发送`})]})})]})}),W.length===0&&!K?(0,z.jsxs)(`div`,{className:`flex h-64 flex-col items-center justify-center gap-2 px-6 text-center text-muted-foreground`,children:[(0,z.jsx)(T,{className:`h-8 w-8 opacity-50`}),(0,z.jsx)(`div`,{className:`text-sm`,children:`没有找到匹配的操作`})]}):W.length>0?(0,z.jsx)(`div`,{className:`space-y-4 p-3`,children:J.map(([e,t])=>(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e}),t.map(e=>{let t=W.findIndex(t=>t.id===e.id),r=e.icon,i=t===s,a=l===e.id;return(0,z.jsxs)(`button`,{ref:i?H:void 0,type:`button`,"data-selected":i?`true`:void 0,className:n(`flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-sm transition-colors`,i?`bg-accent/70 text-accent-foreground shadow-sm`:`hover:bg-accent/45`,e.disabled&&`cursor-not-allowed opacity-50`,e.danger&&!e.disabled&&`text-destructive`),onMouseEnter:()=>c(t),onClick:()=>void X(e),disabled:a,children:[(0,z.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-background/55 backdrop-blur`,children:a?(0,z.jsx)(b,{className:`h-4 w-4 animate-spin`}):r?(0,z.jsx)(r,{className:`h-4 w-4`}):(0,z.jsx)(T,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate font-medium`,children:e.title}),(e.description||e.disabledReason)&&(0,z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.disabled&&e.disabledReason||e.description})]}),e.shortcut&&(0,z.jsx)(y,{variant:`secondary`,className:`shrink-0 text-[10px] font-normal`,children:e.shortcut})]},e.id)})]},e))}):null]})]})}function Z({commands:e,renderPanel:t}){let r=R(),a=r.currentRoute,o=a?.size||`command`,m=a?.id,h=a?.size,[g,_]=(0,O.useState)(null),[v,y]=(0,O.useState)(!1),[b,x]=(0,O.useState)(!1),S=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{if(!m){_(null),y(!1),x(!1);return}_(G(m)||W(h||`lg`)),y(h===`fullscreen`),x(!1)});return()=>window.cancelAnimationFrame(e)},[m,h]),(0,O.useEffect)(()=>{if(!m)return;let e=()=>{_(e=>e&&U(e))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[m]);let C=e=>{!a||v||typeof window>`u`||window.localStorage.setItem(`global-panel-size:${a.id}`,JSON.stringify(e))},T=e=>{if(!a||!g||v)return;e.preventDefault(),x(!0);let t=e.pointerId,n=e.clientX,r=e.clientY,i=g,o=e.currentTarget;o.setPointerCapture(t);let s=e=>{_(U({width:i.width+(e.clientX-n)*2,height:i.height+(e.clientY-r)}))},c=()=>{o.hasPointerCapture(t)&&o.releasePointerCapture(t),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),x(!1),_(e=>(e&&C(e),e))};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},k=()=>{if(!(!a||!g)){if(v){_(U(S.current||G(a.id)||W(a.size||`lg`))),y(!1);return}S.current=g,_(W(`fullscreen`)),y(!0)}},A=a&&g?{width:`${g.width}px`,height:`${g.height}px`}:void 0;return(0,z.jsx)(d,{open:r.open,onOpenChange:e=>{e||r.close()},children:(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{className:`global-panel-overlay fixed inset-0 z-[80]`}),(0,z.jsx)(u,{style:A,className:n(`global-panel-content global-panel-surface fixed left-1/2 top-4 z-[81] flex flex-col overflow-hidden rounded-lg border outline-none`,a&&!b&&`transition-[width,height] duration-200 ease-out`,!a&&B[o]),children:a?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`global-panel-topbar flex items-center gap-2 border-b px-4 py-3`,children:[r.stack.length>1&&(0,z.jsx)(i,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:r.back,title:`返回上一级`,children:(0,z.jsx)(w,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(p,{className:`truncate text-sm font-semibold`,children:a.title}),a.description&&(0,z.jsx)(f,{className:`truncate text-xs text-muted-foreground`,children:a.description})]}),(0,z.jsx)(i,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:k,title:v?`还原尺寸`:`最大化`,children:v?(0,z.jsx)(D,{className:`h-4 w-4`}):(0,z.jsx)(E,{className:`h-4 w-4`})}),(0,z.jsx)(i,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:r.close,title:`关闭`,children:(0,z.jsx)(c,{className:`h-4 w-4`})})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:t(a)}),!v&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`调整面板尺寸`,title:`拖拽调整面板尺寸`,className:`absolute bottom-0 right-0 h-6 w-6 cursor-nwse-resize rounded-tl-md text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground`,onPointerDown:T,children:(0,z.jsx)(`span`,{className:`pointer-events-none absolute bottom-1 right-1 h-3 w-3 border-b border-r border-current`})})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(p,{className:`sr-only`,children:`全局操作面板`}),(0,z.jsx)(f,{className:`sr-only`,children:`搜索并执行 Meddle 的页面、设置和功能操作。`}),(0,z.jsx)(X,{commands:e})]})})]})})}export{Z as GlobalPanelShell};
|
|
@@ -0,0 +1 @@
|
|
|
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-Cjj_Br1u.js";import{t as d}from"./switch-94vgsMHm.js";import{At as f,B as p,H as m,Q as h,R as g,U as _,V as v,at as y,et as b,it as x,lt as te,nt as ne,ot as S,rt as C,st as w,tt as T,wt as re}from"./index-B-6nUrqW.js";import{n as E,r as D,t as O}from"./alert-B514Frte.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./table-DaXD6jJv.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)(h,{variant:e===`critical`?`destructive`:e===`degraded`?`secondary`:`default`,children:[e===`ok`?(0,B.jsx)(f,{}):e===`degraded`?(0,B.jsx)(w,{}):(0,B.jsx)(o,{}),V[e]]})}function oe({icon:e,label:t,value:n,detail:r}){return(0,B.jsxs)(T,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsx)(y,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:(0,B.jsxs)(S,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(e,{}),t]})}),(0,B.jsxs)(C,{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)(b,{className:`h-7 w-40`}),(0,B.jsx)(b,{className:`h-4 w-64`})]}),(0,B.jsx)(b,{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)(b,{className:`h-32 w-full`},t))}),(0,B.jsx)(b,{className:`h-80 w-full`})]})}function Z(){let[e,t]=(0,z.useState)(null),[r,a]=(0,z.useState)(!0),[o,f]=(0,z.useState)(!1),[b,V]=(0,z.useState)(``),[H,Z]=(0,z.useState)(!0),Q=(0,z.useCallback)(async(e=!1)=>{e?f(!0):a(!0),V(``);try{t(await U())}catch(e){V(e instanceof Error?e.message:`无法读取健康状态`)}finally{a(!1),f(!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:b||`无法读取健康状态`})]}),(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:te,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`)}),`刷新`]})]})]}),b&&(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`刷新失败`}),(0,B.jsx)(E,{children:b})]}),(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)(T,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(y,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(S,{className:`flex items-center gap-2`,children:[(0,B.jsx)(re,{}),`健康检查`]}),(0,B.jsx)(x,{children:`阈值来自当前进程的 MEDDLE_WATCHDOG 配置。`})]}),(0,B.jsx)(C,{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)(T,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(y,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(S,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ee,{}),`守护策略`]}),(0,B.jsx)(x,{children:`连续命中严重阈值后按策略处理。`}),(0,B.jsx)(ne,{children:(0,B.jsx)(h,{variant:e.watchdog.config.enabled?`default`:`secondary`,children:e.watchdog.config.enabled?`已启用`:`已关闭`})})]}),(0,B.jsxs)(C,{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)(w,{}),(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)(T,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(y,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(S,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{}),`MITM 服务池`]}),(0,B.jsxs)(x,{children:[e.mitmServers.count,` 个动态 HTTPS 服务。`]})]}),(0,B.jsx)(C,{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)(v,{children:[(0,B.jsx)(m,{variant:`icon`,children:(0,B.jsx)(c,{})}),(0,B.jsx)(_,{children:`暂无动态 HTTPS 服务`}),(0,B.jsx)(p,{children:`当前没有活跃的 MITM 目标。`})]})})})]}),(0,B.jsxs)(T,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(y,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(S,{className:`flex items-center gap-2`,children:[(0,B.jsx)(s,{}),`日志限流`]}),(0,B.jsxs)(x,{children:[`已抑制 `,$?.suppressedTotal??0,` 条重复日志。`]})]}),(0,B.jsx)(C,{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)(h,{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)(v,{children:[(0,B.jsx)(m,{variant:`icon`,children:(0,B.jsx)(s,{})}),(0,B.jsx)(_,{children:`暂无限流记录`}),(0,B.jsx)(p,{children:`当前没有被抑制的重复日志。`})]})})})]})]})]})}export{Z as HealthPanel};
|