@jonathanleelx/meddle 0.5.0-beta.17 → 0.5.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/bin/lib/file-access.js +41 -24
  2. package/dist/core/custom-plugin-loader.d.ts.map +1 -1
  3. package/dist/core/custom-plugin-loader.js +2 -0
  4. package/dist/core/custom-plugin-loader.js.map +1 -1
  5. package/dist/core/mock-handler.d.ts +33 -0
  6. package/dist/core/mock-handler.d.ts.map +1 -1
  7. package/dist/core/mock-handler.js +284 -25
  8. package/dist/core/mock-handler.js.map +1 -1
  9. package/dist/core/mock-utils.d.ts +28 -0
  10. package/dist/core/mock-utils.d.ts.map +1 -1
  11. package/dist/core/mock-utils.js +50 -0
  12. package/dist/core/mock-utils.js.map +1 -1
  13. package/dist/core/plugin-bootstrap-runner.d.ts +1 -0
  14. package/dist/core/plugin-bootstrap-runner.d.ts.map +1 -1
  15. package/dist/core/plugin-bootstrap-runner.js +37 -1
  16. package/dist/core/plugin-bootstrap-runner.js.map +1 -1
  17. package/dist/core/plugin-source.d.ts +24 -0
  18. package/dist/core/plugin-source.d.ts.map +1 -0
  19. package/dist/core/plugin-source.js +47 -0
  20. package/dist/core/plugin-source.js.map +1 -0
  21. package/dist/core/types.d.ts +7 -0
  22. package/dist/core/types.d.ts.map +1 -1
  23. package/dist/server/app-info.d.ts +19 -0
  24. package/dist/server/app-info.d.ts.map +1 -0
  25. package/dist/server/app-info.js +84 -0
  26. package/dist/server/app-info.js.map +1 -0
  27. package/dist/server/config.d.ts +1 -0
  28. package/dist/server/config.d.ts.map +1 -1
  29. package/dist/server/config.js +23 -3
  30. package/dist/server/config.js.map +1 -1
  31. package/dist/server/health.d.ts.map +1 -1
  32. package/dist/server/health.js +8 -0
  33. package/dist/server/health.js.map +1 -1
  34. package/dist/server/index.d.ts +14 -0
  35. package/dist/server/index.d.ts.map +1 -1
  36. package/dist/server/index.js +2 -0
  37. package/dist/server/index.js.map +1 -1
  38. package/dist/server/mocks.d.ts +23 -0
  39. package/dist/server/mocks.d.ts.map +1 -1
  40. package/dist/server/mocks.js +107 -13
  41. package/dist/server/mocks.js.map +1 -1
  42. package/dist/server/plugins.d.ts.map +1 -1
  43. package/dist/server/plugins.js +56 -11
  44. package/dist/server/plugins.js.map +1 -1
  45. package/index.js +16 -3
  46. package/package.json +1 -1
  47. package/web/dist/assets/alert-BmsRCcSL.js +1 -0
  48. package/web/dist/assets/arrow-right-BNum_060.js +1 -0
  49. package/web/dist/assets/{body-diff-view-CO4FDdwK.js → body-diff-view-ByCHr9bv.js} +2 -2
  50. package/web/dist/assets/{button-yArHqw81.js → button-BFNlGZ5p.js} +1 -1
  51. package/web/dist/assets/check-BkfHQ6re.js +1 -0
  52. package/web/dist/assets/checkbox-v2kzp7K8.js +1 -0
  53. package/web/dist/assets/chevron-down-DHwUtL4O.js +1 -0
  54. package/web/dist/assets/{circle-alert-DAWy5HuM.js → circle-alert-zMagrFuI.js} +1 -1
  55. package/web/dist/assets/{circle-x-BjSs1hQK.js → circle-x-BEkinhez.js} +1 -1
  56. package/web/dist/assets/code-DD-AYxxu.js +1 -0
  57. package/web/dist/assets/{copy-qMUl4peN.js → copy-BRnscYy1.js} +1 -1
  58. package/web/dist/assets/{detail-panel-Cptbvzot.js → detail-panel-DyvoHlCG.js} +3 -3
  59. package/web/dist/assets/dist-BCvvYbmI.js +1 -0
  60. package/web/dist/assets/dist-BNcjMpca.js +1 -0
  61. package/web/dist/assets/{dist-CjLkNKST.js → dist-C-E2R2jk.js} +1 -1
  62. package/web/dist/assets/{dist-CwP5Ad1_.js → dist-CFZ4xMSF.js} +1 -1
  63. package/web/dist/assets/{dist-DGuRBXW6.js → dist-CRmX_NvH.js} +1 -1
  64. package/web/dist/assets/dist-DD7AvbXP.js +1 -0
  65. package/web/dist/assets/dist-LiAcI8CK.js +1 -0
  66. package/web/dist/assets/dist-UcOFuoN0.js +5 -0
  67. package/web/dist/assets/{dist-D2vbXHYx.js → dist-YM3jbhT-.js} +1 -1
  68. package/web/dist/assets/editor-pane-actions-DN-pxFsl.js +1 -0
  69. package/web/dist/assets/es2015-CRmLuA2o.js +41 -0
  70. package/web/dist/assets/{global-panel-shell-jsVR0yS9.js → global-panel-shell-BJaQ_VLp.js} +4 -4
  71. package/web/dist/assets/health-panel-BnxNCGvw.js +1 -0
  72. package/web/dist/assets/index-Bu3zaxzE.js +18 -0
  73. package/web/dist/assets/index-D9jGD_NA.css +2 -0
  74. package/web/dist/assets/mobile-proxy-panel-BxJ8OmLu.js +8 -0
  75. package/web/dist/assets/mock-config-Dp2D5iiv.js +1 -0
  76. package/web/dist/assets/mock-editor-panel-zqouxTGb.js +20 -0
  77. package/web/dist/assets/mocks-file-missing-note-B8TTBWtG.js +1 -0
  78. package/web/dist/assets/monaco-editor-DeJNlo9k.js +11 -0
  79. package/web/dist/assets/pane-split-Db1aWKUO.js +1 -0
  80. package/web/dist/assets/panel-heading-BAI_lNmT.js +1 -0
  81. package/web/dist/assets/{pencil-line-jiAfwHPx.js → pencil-line-CEZ7D-de.js} +1 -1
  82. package/web/dist/assets/plugin-code-editor-CQqpaaCR.js +2 -0
  83. package/web/dist/assets/plugin-config-CjcRhSZm.js +2 -0
  84. package/web/dist/assets/plugin-generator-Cr_gk3Tp.js +2 -0
  85. package/web/dist/assets/plugin-test-dialog-B5mVM3XE.js +7 -0
  86. package/web/dist/assets/plus-ixZQRprm.js +1 -0
  87. package/web/dist/assets/{refresh-cw-DdzbeDXU.js → refresh-cw-BfLoHqg5.js} +1 -1
  88. package/web/dist/assets/rotate-ccw-CRguJya4.js +1 -0
  89. package/web/dist/assets/route-preview-BZ3vhvsc.js +1 -0
  90. package/web/dist/assets/{rule-ai-assistant-panel-D0nf0ksF.js → rule-ai-assistant-panel-DfivYxZH.js} +2 -2
  91. package/web/dist/assets/rule-config-DSX8bBHe.js +15 -0
  92. package/web/dist/assets/rule-overview-panel-D5gY3akK.js +1 -0
  93. package/web/dist/assets/{server-CktUTlNz.js → server-eYXq3PbE.js} +1 -1
  94. package/web/dist/assets/settings-panel-Bfzfsovk.js +1 -0
  95. package/web/dist/assets/{shield-check-UHsTa1Dy.js → shield-check-hQXjdfZ7.js} +1 -1
  96. package/web/dist/assets/smartphone-D4Q7cQfm.js +1 -0
  97. package/web/dist/assets/switch-DpLnRvOJ.js +1 -0
  98. package/web/dist/assets/{syntax-highlight-DF90eoRG.js → syntax-highlight-EJCxGikd.js} +1 -1
  99. package/web/dist/assets/{table-2-BE3hfnr0.js → table-2-DvGHhMm4.js} +1 -1
  100. package/web/dist/assets/table-C3mgEjkP.js +1 -0
  101. package/web/dist/assets/{textarea-CQWqIFs-.js → textarea-BjWF0pk4.js} +1 -1
  102. package/web/dist/assets/{wand-sparkles-B9ZnNs8E.js → wand-sparkles-DDGjzjnX.js} +1 -1
  103. package/web/dist/assets/{wifi-fTyrNPN8.js → wifi-QkTcTrED.js} +1 -1
  104. package/web/dist/assets/{zap-h2l6wVxY.js → zap-CEVoVkAg.js} +1 -1
  105. package/web/dist/index.html +17 -14
  106. package/web/dist/assets/alert-DO7T3mut.js +0 -1
  107. package/web/dist/assets/arrow-right-DGB2MxsX.js +0 -1
  108. package/web/dist/assets/check-ByTjANaY.js +0 -1
  109. package/web/dist/assets/checkbox-BwiDnRBb.js +0 -1
  110. package/web/dist/assets/chevron-down-vKjBY-BY.js +0 -1
  111. package/web/dist/assets/code-DAB_mRnu.js +0 -1
  112. package/web/dist/assets/dist-BW-gQyc_.js +0 -5
  113. package/web/dist/assets/dist-CymFeFOA.js +0 -1
  114. package/web/dist/assets/es2015-BiaNLfVn.js +0 -41
  115. package/web/dist/assets/health-panel-BlelNpri.js +0 -1
  116. package/web/dist/assets/index-DHO85s04.css +0 -2
  117. package/web/dist/assets/index-qO2TvUmo.js +0 -18
  118. package/web/dist/assets/mobile-proxy-panel-CVK80S9O.js +0 -8
  119. package/web/dist/assets/mock-config-Dhbc1AgO.js +0 -1
  120. package/web/dist/assets/mock-editor-panel-BjhgVrWn.js +0 -20
  121. package/web/dist/assets/monaco-editor-BqDxt08N.js +0 -11
  122. package/web/dist/assets/pane-split-BJpOHSML.js +0 -1
  123. package/web/dist/assets/plugin-code-editor-Bbdqj39s.js +0 -2
  124. package/web/dist/assets/plugin-config-B0QwdqtG.js +0 -1
  125. package/web/dist/assets/plugin-generator-Cmq3dxab.js +0 -2
  126. package/web/dist/assets/plugin-test-dialog-C4m77VMU.js +0 -7
  127. package/web/dist/assets/plus-BdrJey8J.js +0 -1
  128. package/web/dist/assets/rotate-ccw-_UaUgje4.js +0 -1
  129. package/web/dist/assets/route-preview-BMra25Ac.js +0 -1
  130. package/web/dist/assets/rule-config-C8h0ab8H.js +0 -15
  131. package/web/dist/assets/rule-overview-panel-Ddhm3_aw.js +0 -1
  132. package/web/dist/assets/settings-panel-03AFbqGD.js +0 -1
  133. package/web/dist/assets/smartphone-D5HBDIeh.js +0 -1
  134. package/web/dist/assets/switch-Dd7hKJ2O.js +0 -1
  135. package/web/dist/assets/table-BY-pIs96.js +0 -1
  136. package/web/dist/assets/tabs-DnFHv5gb.js +0 -1
  137. /package/web/dist/assets/{ai-config-store-DQXVJVn_.js → ai-config-store-B_VpGvwx.js} +0 -0
  138. /package/web/dist/assets/{babel-DsprIpXZ.js → babel-D1quDdNt.js} +0 -0
  139. /package/web/dist/assets/{clipboard-Dz6MgwV-.js → clipboard-DUgC_tNv.js} +0 -0
  140. /package/web/dist/assets/{dist-DQDFV3o1.js → dist-Bq2klZ3g.js} +0 -0
  141. /package/web/dist/assets/{estree-BP7k0NIt.js → estree--Vq99DGn.js} +0 -0
  142. /package/web/dist/assets/{html-6FIWbqxX.js → html-D2PZBPnP.js} +0 -0
  143. /package/web/dist/assets/{postcss-Dnf30fQU.js → postcss-DfIslWug.js} +0 -0
  144. /package/web/dist/assets/{standalone-CjxtLKw-.js → standalone-D-fjaAIs.js} +0 -0
@@ -0,0 +1 @@
1
+ import{c as e,d as t,o as n,p as r}from"./button-BFNlGZ5p.js";import{a as i,c as a,n as o,o as s}from"./dist-CFZ4xMSF.js";import{t as c}from"./dist-C-E2R2jk.js";import{t as l}from"./dist-BCvvYbmI.js";var u=r(t(),1),d=e(),f=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),p=`VisuallyHidden`,m=u.forwardRef((e,t)=>(0,d.jsx)(s.span,{...e,ref:t,style:{...f,...e.style}}));m.displayName=p;var h=m,g=[`top`,`right`,`bottom`,`left`],_=Math.min,v=Math.max,y=Math.round,b=Math.floor,x=e=>({x:e,y:e}),S={left:`right`,right:`left`,bottom:`top`,top:`bottom`},C={start:`end`,end:`start`};function w(e,t,n){return v(e,_(t,n))}function T(e,t){return typeof e==`function`?e(t):e}function E(e){return e.split(`-`)[0]}function D(e){return e.split(`-`)[1]}function O(e){return e===`x`?`y`:`x`}function k(e){return e===`y`?`height`:`width`}var A=new Set([`top`,`bottom`]);function j(e){return A.has(E(e))?`y`:`x`}function M(e){return O(j(e))}function N(e,t,n){n===void 0&&(n=!1);let r=D(e),i=M(e),a=k(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=H(o)),[o,H(o)]}function P(e){let t=H(e);return[F(e),t,F(t)]}function F(e){return e.replace(/start|end/g,e=>C[e])}var I=[`left`,`right`],L=[`right`,`left`],R=[`top`,`bottom`],z=[`bottom`,`top`];function B(e,t,n){switch(e){case`top`:case`bottom`:return n?t?L:I:t?I:L;case`left`:case`right`:return t?R:z;default:return[]}}function V(e,t,n,r){let i=D(e),a=B(E(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(F)))),a}function H(e){return e.replace(/left|right|bottom|top/g,e=>S[e])}function ee(e){return{top:0,right:0,bottom:0,left:0,...e}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function ne(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function re(e,t,n){let{reference:r,floating:i}=e,a=j(t),o=M(t),s=k(o),c=E(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(D(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ie(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=T(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ne(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ne(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ae=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=re(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:{...o,detectOverflow:o.detectOverflow??ie},elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=re(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},oe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=T(e,t)||{};if(l==null)return{};let d=te(u),f={x:n,y:r},p=M(i),m=k(p),h=await o.getDimensions(l),g=p===`y`,v=g?`top`:`left`,y=g?`bottom`:`right`,b=g?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],S=f[p]-a.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),E=C?C[b]:0;(!E||!await(o.isElement==null?void 0:o.isElement(C)))&&(E=s.floating[b]||a.floating[m]);let O=x/2-S/2,A=E/2-h[m]/2-1,j=_(d[v],A),N=_(d[y],A),P=j,F=E-h[m]-N,I=E/2-h[m]/2+O,L=w(P,I,F),R=!c.arrow&&D(i)!=null&&I!==L&&a.reference[m]/2-(I<P?j:N)-h[m]/2<0,z=R?I<P?I-P:I-F:0;return{[p]:f[p]+z,data:{[p]:L,centerOffset:I-L-z,...R&&{alignmentOffset:z}},reset:R}}}),se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=T(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=E(r),_=j(o),v=E(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[H(o)]:P(o)),x=p!==`none`;!d&&x&&b.push(...V(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],D=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=N(r,a,y);w.push(C[e[0]],C[e[1]])}if(D=[...D,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==j(t))||D.every(e=>j(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=j(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function le(e){return g.some(t=>e[t]>=0)}var ue=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=T(e,t);switch(i){case`referenceHidden`:{let e=ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:le(e)}}}case`escaped`:{let e=ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:le(e)}}}default:return{}}}}},de=new Set([`left`,`top`]);async function fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=E(n),s=D(n),c=j(n)===`y`,l=de.has(o)?-1:1,u=a&&c?-1:1,d=T(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fe(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},me=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=T(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=j(E(i)),p=O(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=w(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=w(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},he=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=T(e,t),u={x:n,y:r},d=j(i),f=O(d),p=u[f],m=u[d],h=T(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=de.has(E(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ge=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=T(e,t),u=await o.detectOverflow(t,l),d=E(i),f=D(i),p=j(i)===`y`,{width:m,height:h}=a.floating,g,y;d===`top`||d===`bottom`?(g=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,g=f===`end`?`top`:`bottom`);let b=h-u.top-u.bottom,x=m-u.left-u.right,S=_(h-u[g],b),C=_(m-u[y],x),w=!t.middlewareData.shift,O=S,k=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(O=b),w&&!f){let e=v(u.left,0),t=v(u.right,0),n=v(u.top,0),r=v(u.bottom,0);p?k=m-2*(e!==0||t!==0?e+t:v(u.left,u.right)):O=h-2*(n!==0||r!==0?n+r:v(u.top,u.bottom))}await c({...t,availableWidth:k,availableHeight:O});let A=await o.getDimensions(s.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function _e(){return typeof window<`u`}function U(e){return ve(e)?(e.nodeName||``).toLowerCase():`#document`}function W(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function G(e){return((ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ve(e){return _e()?e instanceof Node||e instanceof W(e).Node:!1}function K(e){return _e()?e instanceof Element||e instanceof W(e).Element:!1}function q(e){return _e()?e instanceof HTMLElement||e instanceof W(e).HTMLElement:!1}function ye(e){return!_e()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof W(e).ShadowRoot}var be=new Set([`inline`,`contents`]);function J(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!be.has(i)}var xe=new Set([`table`,`td`,`th`]);function Se(e){return xe.has(U(e))}var Ce=[`:popover-open`,`:modal`];function we(e){return Ce.some(t=>{try{return e.matches(t)}catch{return!1}})}var Te=[`transform`,`translate`,`scale`,`rotate`,`perspective`],Ee=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],De=[`paint`,`layout`,`strict`,`content`];function Oe(e){let t=Ae(),n=K(e)?X(e):e;return Te.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||Ee.some(e=>(n.willChange||``).includes(e))||De.some(e=>(n.contain||``).includes(e))}function ke(e){let t=Z(e);for(;q(t)&&!Y(t);){if(Oe(t))return t;if(we(t))return null;t=Z(t)}return null}function Ae(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var je=new Set([`html`,`body`,`#document`]);function Y(e){return je.has(U(e))}function X(e){return W(e).getComputedStyle(e)}function Me(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Z(e){if(U(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||G(e);return ye(t)?t.host:t}function Ne(e){let t=Z(e);return Y(t)?e.ownerDocument?e.ownerDocument.body:e.body:q(t)&&J(t)?t:Ne(t)}function Pe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ne(e),i=r===e.ownerDocument?.body,a=W(r);if(i){let e=Fe(a);return t.concat(a,a.visualViewport||[],J(r)?r:[],e&&n?Pe(e):[])}return t.concat(r,Pe(r,[],n))}function Fe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ie(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=q(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=y(n)!==a||y(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Le(e){return K(e)?e:e.contextElement}function Q(e){let t=Le(e);if(!q(t))return x(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ie(t),o=(a?y(n.width):n.width)/r,s=(a?y(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Re=x(0);function ze(e){let t=W(e);return!Ae()||!t.visualViewport?Re:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Be(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==W(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Le(e),o=x(1);t&&(r?K(r)&&(o=Q(r)):o=Q(e));let s=Be(a,n,r)?ze(a):x(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=W(a),t=r&&K(r)?W(r):r,n=e,i=Fe(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=W(i),i=Fe(n)}}return ne({width:u,height:d,x:c,y:l})}function Ve(e,t){let n=Me(e).scrollLeft;return t?t.left+n:$(G(e)).left+n}function He(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ve(e,n),y:n.top+t.scrollTop}}function Ue(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=G(r),s=t?we(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=x(1),u=x(0),d=q(r);if((d||!d&&!a)&&((U(r)!==`body`||J(o))&&(c=Me(r)),q(r))){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?He(o,c):x(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function We(e){return Array.from(e.getClientRects())}function Ge(e){let t=G(e),n=Me(e),r=e.ownerDocument.body,i=v(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=v(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Ve(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=v(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Ke=25;function qe(e,t){let n=W(e),r=G(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ae();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Ve(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ke&&(a-=o)}else l<=Ke&&(a+=l);return{width:a,height:o,x:s,y:c}}var Je=new Set([`absolute`,`fixed`]);function Ye(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=q(e)?Q(e):x(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Xe(e,t,n){let r;if(t===`viewport`)r=qe(e,n);else if(t===`document`)r=Ge(G(e));else if(K(t))r=Ye(t,n);else{let n=ze(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ne(r)}function Ze(e,t){let n=Z(e);return n===t||!K(n)||Y(n)?!1:X(n).position===`fixed`||Ze(n,t)}function Qe(e,t){let n=t.get(e);if(n)return n;let r=Pe(e,[],!1).filter(e=>K(e)&&U(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?Z(e):e;for(;K(o)&&!Y(o);){let t=X(o),n=Oe(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Je.has(i.position)||J(o)&&!n&&Ze(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function $e(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?we(t)?[]:Qe(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=Xe(t,n,i);return e.top=v(r.top,e.top),e.right=_(r.right,e.right),e.bottom=_(r.bottom,e.bottom),e.left=v(r.left,e.left),e},Xe(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function et(e){let{width:t,height:n}=Ie(e);return{width:t,height:n}}function tt(e,t,n){let r=q(t),i=G(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=x(0);function l(){c.x=Ve(i)}if(r||!r&&!a)if((U(t)!==`body`||J(i))&&(s=Me(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?He(i,s):x(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function nt(e){return X(e).position===`static`}function rt(e,t){if(!q(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return G(e)===n&&(n=n.ownerDocument.body),n}function it(e,t){let n=W(e);if(we(e))return n;if(!q(e)){let t=Z(e);for(;t&&!Y(t);){if(K(t)&&!nt(t))return t;t=Z(t)}return n}let r=rt(e,t);for(;r&&Se(r)&&nt(r);)r=rt(r,t);return r&&Y(r)&&nt(r)&&!Oe(r)?n:r||ke(e)||n}var at=async function(e){let t=this.getOffsetParent||it,n=this.getDimensions,r=await n(e.floating);return{reference:tt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ot(e){return X(e).direction===`rtl`}var st={convertOffsetParentRelativeRectToViewportRelativeRect:Ue,getDocumentElement:G,getClippingRect:$e,getOffsetParent:it,getElementRects:at,getClientRects:We,getDimensions:et,getScale:Q,isElement:K,isRTL:ot};function ct(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lt(e,t){let n=null,r,i=G(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=b(d),h=b(i.clientWidth-(u+f)),g=b(i.clientHeight-(d+p)),y=b(u),x={rootMargin:-m+`px `+-h+`px `+-g+`px `+-y+`px`,threshold:v(0,_(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!ct(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function ut(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Le(e),u=i||a?[...l?Pe(l):[],...Pe(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?lt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!ct(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var dt=pe,ft=me,pt=se,mt=ge,ht=ue,gt=oe,_t=he,vt=(e,t,n)=>{let r=new Map,i={platform:st,...n},a={...i.platform,_c:r};return ae(e,t,{...i,platform:a})},yt=r(a(),1),bt=typeof document<`u`?u.useLayoutEffect:function(){};function xt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!xt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!xt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function St(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ct(e,t){let n=St(e);return Math.round(t*n)/n}function wt(e){let t=u.useRef(e);return bt(()=>{t.current=e}),t}function Tt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[d,f]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=u.useState(r);xt(p,r)||m(r);let[h,g]=u.useState(null),[_,v]=u.useState(null),y=u.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=u.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=u.useRef(null),w=u.useRef(null),T=u.useRef(d),E=c!=null,D=wt(c),O=wt(i),k=wt(l),A=u.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),vt(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!xt(T.current,t)&&(T.current=t,yt.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);bt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[l]);let j=u.useRef(!1);bt(()=>(j.current=!0,()=>{j.current=!1}),[]),bt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=u.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=u.useMemo(()=>({reference:x,floating:S}),[x,S]),P=u.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Ct(N.floating,d.x),r=Ct(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...St(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return u.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var Et=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:gt({element:r.current,padding:i}).fn(n):r?gt({element:r,padding:i}).fn(n):{}}}},Dt=(e,t)=>({...dt(e),options:[e,t]}),Ot=(e,t)=>({...ft(e),options:[e,t]}),kt=(e,t)=>({..._t(e),options:[e,t]}),At=(e,t)=>({...pt(e),options:[e,t]}),jt=(e,t)=>({...mt(e),options:[e,t]}),Mt=(e,t)=>({...ht(e),options:[e,t]}),Nt=(e,t)=>({...Et(e),options:[e,t]}),Pt=`Arrow`,Ft=u.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,d.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,d.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Ft.displayName=Pt;var It=Ft,Lt=`Popper`,[Rt,zt]=i(Lt),[Bt,Vt]=Rt(Lt),Ht=e=>{let{__scopePopper:t,children:n}=e,[r,i]=u.useState(null);return(0,d.jsx)(Bt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ht.displayName=Lt;var Ut=`PopperAnchor`,Wt=u.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:i,...a}=e,o=Vt(Ut,r),c=u.useRef(null),l=n(t,c),f=u.useRef(null);return u.useEffect(()=>{let e=f.current;f.current=i?.current||c.current,e!==f.current&&o.onAnchorChange(f.current)}),i?null:(0,d.jsx)(s.div,{...a,ref:l})});Wt.displayName=Ut;var Gt=`PopperContent`,[Kt,qt]=Rt(Gt),Jt=u.forwardRef((e,t)=>{let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:f=`center`,alignOffset:p=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Vt(Gt,r),[w,T]=u.useState(null),E=n(t,e=>T(e)),[D,O]=u.useState(null),k=l(D),A=k?.width??0,j=k?.height??0,M=i+(f===`center`?``:`-`+f),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],F=P.length>0,I={padding:N,boundary:P.filter(Qt),altBoundary:F},{refs:L,floatingStyles:R,placement:z,isPositioned:B,middlewareData:V}=Tt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>ut(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[Dt({mainAxis:a+j,alignmentAxis:p}),h&&Ot({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?kt():void 0,...I}),h&&At({...I}),jt({...I,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&Nt({element:D,padding:m}),$t({arrowWidth:A,arrowHeight:j}),y&&Mt({strategy:`referenceHidden`,...I})]}),[H,ee]=en(z),te=c(x);o(()=>{B&&te?.()},[B,te]);let ne=V.arrow?.x,re=V.arrow?.y,ie=V.arrow?.centerOffset!==0,[ae,oe]=u.useState();return o(()=>{w&&oe(window.getComputedStyle(w).zIndex)},[w]),(0,d.jsx)(`div`,{ref:L.setFloating,"data-radix-popper-content-wrapper":``,style:{...R,transform:B?R.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(` `),...V.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,d.jsx)(Kt,{scope:r,placedSide:H,onArrowChange:O,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,d.jsx)(s.div,{"data-side":H,"data-align":ee,...S,ref:E,style:{...S.style,animation:B?void 0:`none`}})})})});Jt.displayName=Gt;var Yt=`PopperArrow`,Xt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Zt=u.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=qt(Yt,n),a=Xt[i.placedSide];return(0,d.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,d.jsx)(It,{...r,ref:t,style:{...r.style,display:`block`}})})});Zt.displayName=Yt;function Qt(e){return e!==null}var $t=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=en(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function en(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var tn=Ht,nn=Wt,rn=Jt,an=Zt;export{zt as a,tn as i,an as n,h as o,rn as r,f as s,nn as t};
@@ -0,0 +1 @@
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};
@@ -0,0 +1,5 @@
1
+ import{c as e,d as t,o as n,p as r,r as i,u as a}from"./button-BFNlGZ5p.js";import{a as o,i as s,o as c,r as l,t as u}from"./dist-CFZ4xMSF.js";import{t as d}from"./dist-CRmX_NvH.js";import{n as f}from"./dist-C-E2R2jk.js";import{n as p,t as m}from"./dist-BNcjMpca.js";import{i as h,n as g,r as _,t as v}from"./es2015-CRmLuA2o.js";var y=a(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),b=r(t(),1),x=e(),S=`Dialog`,[C,ee]=o(S),[w,T]=C(S),E=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=b.useRef(null),c=b.useRef(null),[l,d]=u({prop:r,defaultProp:i??!1,onChange:a,caller:S});return(0,x.jsx)(w,{scope:t,triggerRef:s,contentRef:c,contentId:f(),titleId:f(),descriptionId:f(),open:l,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};E.displayName=S;var D=`DialogTrigger`,O=b.forwardRef((e,t)=>{let{__scopeDialog:r,...i}=e,a=T(D,r),o=n(t,a.triggerRef);return(0,x.jsx)(c.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.contentId,"data-state":J(a.open),...i,ref:o,onClick:l(e.onClick,a.onOpenToggle)})});O.displayName=D;var k=`DialogPortal`,[A,j]=C(k,{forceMount:void 0}),M=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=T(k,t);return(0,x.jsx)(A,{scope:t,forceMount:n,children:b.Children.map(r,e=>(0,x.jsx)(d,{present:n||a.open,children:(0,x.jsx)(m,{asChild:!0,container:i,children:e})}))})};M.displayName=k;var N=`DialogOverlay`,P=b.forwardRef((e,t)=>{let n=j(N,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=T(N,e.__scopeDialog);return a.modal?(0,x.jsx)(d,{present:r||a.open,children:(0,x.jsx)(I,{...i,ref:t})}):null});P.displayName=N;var F=i(`DialogOverlay.RemoveScroll`),I=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(N,n);return(0,x.jsx)(g,{as:F,allowPinchZoom:!0,shards:[i.contentRef],children:(0,x.jsx)(c.div,{"data-state":J(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),L=`DialogContent`,R=b.forwardRef((e,t)=>{let n=j(L,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=T(L,e.__scopeDialog);return(0,x.jsx)(d,{present:r||a.open,children:a.modal?(0,x.jsx)(z,{...i,ref:t}):(0,x.jsx)(B,{...i,ref:t})})});R.displayName=L;var z=b.forwardRef((e,t)=>{let r=T(L,e.__scopeDialog),i=b.useRef(null),a=n(t,r.contentRef,i);return b.useEffect(()=>{let e=i.current;if(e)return v(e)},[]),(0,x.jsx)(V,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:l(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:l(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:l(e.onFocusOutside,e=>e.preventDefault())})}),B=b.forwardRef((e,t)=>{let n=T(L,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return(0,x.jsx)(V,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),V=b.forwardRef((e,t)=>{let{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,...s}=e,c=T(L,r),l=b.useRef(null),u=n(t,l);return _(),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(h,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:o,children:(0,x.jsx)(p,{role:`dialog`,id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":J(c.open),...s,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Z,{titleId:c.titleId}),(0,x.jsx)($,{contentRef:l,descriptionId:c.descriptionId})]})]})}),H=`DialogTitle`,U=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(H,n);return(0,x.jsx)(c.h2,{id:i.titleId,...r,ref:t})});U.displayName=H;var W=`DialogDescription`,G=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(W,n);return(0,x.jsx)(c.p,{id:i.descriptionId,...r,ref:t})});G.displayName=W;var K=`DialogClose`,q=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=T(K,n);return(0,x.jsx)(c.button,{type:`button`,...r,ref:t,onClick:l(e.onClick,()=>i.onOpenChange(!1))})});q.displayName=K;function J(e){return e?`open`:`closed`}var Y=`DialogTitleWarning`,[te,X]=s(Y,{contentName:L,titleName:H,docsSlug:`dialog`}),Z=({titleId:e})=>{let t=X(Y),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
2
+
3
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
4
+
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Q=`DialogDescriptionWarning`,$=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${X(Q).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},ne=E,re=M,ie=P,ae=R,oe=U,se=G,ce=q;export{re as a,y as c,ie as i,ae as n,ne as o,se as r,oe as s,ce as t};
@@ -1 +1 @@
1
- import{a as e,f as t,s as n,u as r}from"./button-yArHqw81.js";import{a as i,o as a,r as o,t as s}from"./dist-CwP5Ad1_.js";import{n as c,t as l}from"./dist-CymFeFOA.js";import{n as u,t as d}from"./dist-CjLkNKST.js";var f=t(r(),1),p=n(),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((t,n)=>{let{__scopeRovingFocusGroup:r,orientation:i,loop:c=!1,dir:u,currentTabStopId:_,defaultCurrentTabStopId:y,onCurrentTabStopIdChange:b,onEntryFocus:x,preventScrollOnEntryFocus:C=!1,...w}=t,T=f.useRef(null),E=e(n,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`,...t.style},onMouseDown:o(t.onMouseDown,()=>{F.current=!0}),onFocus:o(t.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(t.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};
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};
@@ -0,0 +1,41 @@
1
+ import{c as e,d as t,o as n,p as r}from"./button-BFNlGZ5p.js";import{o as i}from"./dist-CFZ4xMSF.js";import{t as a}from"./dist-C-E2R2jk.js";var o=r(t(),1),s=e(),c=`focusScope.autoFocusOnMount`,l=`focusScope.autoFocusOnUnmount`,u={bubbles:!1,cancelable:!0},d=`FocusScope`,f=o.forwardRef((e,t)=>{let{loop:r=!1,trapped:d=!1,onMountAutoFocus:f,onUnmountAutoFocus:g,..._}=e,[v,x]=o.useState(null),S=a(f),w=a(g),T=o.useRef(null),E=n(t,e=>x(e)),D=o.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;o.useEffect(()=>{if(d){let e=function(e){if(D.paused||!v)return;let t=e.target;v.contains(t)?T.current=t:y(T.current,{select:!0})},t=function(e){if(D.paused||!v)return;let t=e.relatedTarget;t!==null&&(v.contains(t)||y(T.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&y(v)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return v&&r.observe(v,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[d,v,D.paused]),o.useEffect(()=>{if(v){b.add(D);let e=document.activeElement;if(!v.contains(e)){let t=new CustomEvent(c,u);v.addEventListener(c,S),v.dispatchEvent(t),t.defaultPrevented||(p(C(h(v)),{select:!0}),document.activeElement===e&&y(v))}return()=>{v.removeEventListener(c,S),setTimeout(()=>{let t=new CustomEvent(l,u);v.addEventListener(l,w),v.dispatchEvent(t),t.defaultPrevented||y(e??document.body,{select:!0}),v.removeEventListener(l,w),b.remove(D)},0)}}},[v,S,w,D]);let O=o.useCallback(e=>{if(!r&&!d||D.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){let t=e.currentTarget,[i,a]=m(t);i&&a?!e.shiftKey&&n===a?(e.preventDefault(),r&&y(i,{select:!0})):e.shiftKey&&n===i&&(e.preventDefault(),r&&y(a,{select:!0})):n===t&&e.preventDefault()}},[r,d,D.paused]);return(0,s.jsx)(i.div,{tabIndex:-1,..._,ref:E,onKeyDown:O})});f.displayName=d;function p(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(y(r,{select:t}),document.activeElement!==n)return}function m(e){let t=h(e);return[g(t,e),g(t.reverse(),e)]}function h(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function g(e,t){for(let n of e)if(!_(n,{upTo:t}))return n}function _(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function v(e){return e instanceof HTMLInputElement&&`select`in e}function y(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&v(e)&&t&&e.select()}}var b=x();function x(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=S(e,t),e.unshift(t)},remove(t){e=S(e,t),e[0]?.resume()}}}function S(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function C(e){return e.filter(e=>e.tagName!==`A`)}var w=0;function T(){o.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??E()),document.body.insertAdjacentElement(`beforeend`,e[1]??E()),w++,()=>{w===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),w--}},[])}function E(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var D=function(){return D=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},D.apply(this,arguments)};function O(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ee(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var k=`right-scroll-bar-position`,A=`width-before-scroll-bar`,te=`with-scroll-bars-hidden`,ne=`--removed-body-scroll-bar-size`;function j(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function re(e,t){var n=(0,o.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var ie=typeof window<`u`?o.useLayoutEffect:o.useEffect,M=new WeakMap;function ae(e,t){var n=re(t||null,function(t){return e.forEach(function(e){return j(e,t)})});return ie(function(){var t=M.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||j(e,null)}),i.forEach(function(e){r.has(e)||j(e,a)})}M.set(n,e)},[e]),n}function oe(e){return e}function se(e,t){t===void 0&&(t=oe);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ce(e){e===void 0&&(e={});var t=se(null);return t.options=D({async:!0,ssr:!1},e),t}var N=function(e){var t=e.sideCar,n=O(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return o.createElement(r,D({},n))};N.isSideCarExport=!0;function le(e,t){return e.useMedium(t),N}var P=ce(),F=function(){},I=o.forwardRef(function(e,t){var n=o.useRef(null),r=o.useState({onScrollCapture:F,onWheelCapture:F,onTouchMoveCapture:F}),i=r[0],a=r[1],s=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=O(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=ae([n,t]),w=D(D({},x),i);return o.createElement(o.Fragment,null,d&&o.createElement(S,{sideCar:P,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),s?o.cloneElement(o.Children.only(c),D(D({},w),{ref:C})):o.createElement(y,D({},w,{className:l,ref:C}),c))});I.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},I.classNames={fullWidth:A,zeroRight:k};var L,ue=function(){if(L)return L;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function de(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=ue();return t&&e.setAttribute(`nonce`,t),e}function fe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function pe(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var me=function(){var e=0,t=null;return{add:function(n){e==0&&(t=de())&&(fe(t,n),pe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},he=function(){var e=me();return function(t,n){o.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},R=function(){var e=he();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},ge={left:0,top:0,right:0,gap:0},z=function(e){return parseInt(e||``,10)||0},_e=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[z(n),z(r),z(i)]},ve=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return ge;var t=_e(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ye=R(),B=`data-scroll-locked`,be=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
+ .${te} {
3
+ overflow: hidden ${r};
4
+ padding-right: ${s}px ${r};
5
+ }
6
+ body[${B}] {
7
+ overflow: hidden ${r};
8
+ overscroll-behavior: contain;
9
+ ${[t&&`position: relative ${r};`,n===`margin`&&`
10
+ padding-left: ${i}px;
11
+ padding-top: ${a}px;
12
+ padding-right: ${o}px;
13
+ margin-left:0;
14
+ margin-top:0;
15
+ margin-right: ${s}px ${r};
16
+ `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
17
+ }
18
+
19
+ .${k} {
20
+ right: ${s}px ${r};
21
+ }
22
+
23
+ .${A} {
24
+ margin-right: ${s}px ${r};
25
+ }
26
+
27
+ .${k} .${k} {
28
+ right: 0 ${r};
29
+ }
30
+
31
+ .${A} .${A} {
32
+ margin-right: 0 ${r};
33
+ }
34
+
35
+ body[${B}] {
36
+ ${ne}: ${s}px;
37
+ }
38
+ `},V=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},xe=function(){o.useEffect(function(){return document.body.setAttribute(B,(V()+1).toString()),function(){var e=V()-1;e<=0?document.body.removeAttribute(B):document.body.setAttribute(B,e.toString())}},[])},Se=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;xe();var a=o.useMemo(function(){return ve(i)},[i]);return o.createElement(ye,{styles:be(a,!t,i,n?``:`!important`)})},H=!1;if(typeof window<`u`)try{var U=Object.defineProperty({},`passive`,{get:function(){return H=!0,!0}});window.addEventListener(`test`,U,U),window.removeEventListener(`test`,U,U)}catch{H=!1}var W=H?{passive:!1}:!1,Ce=function(e){return e.tagName===`TEXTAREA`},G=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Ce(e)&&n[t]===`visible`)},we=function(e){return G(e,`overflowY`)},Te=function(e){return G(e,`overflowX`)},K=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),q(e,r)){var i=Oe(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ee=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},De=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},q=function(e,t){return e===`v`?we(t):Te(t)},Oe=function(e,t){return e===`v`?Ee(t):De(t)},ke=function(e,t){return e===`h`&&t===`rtl`?-1:1},Ae=function(e,t,n,r,i){var a=ke(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Oe(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&q(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},J=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},je=function(e){return[e.deltaX,e.deltaY]},Me=function(e){return e&&`current`in e?e.current:e},Ne=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pe=function(e){return`
39
+ .block-interactivity-${e} {pointer-events: none;}
40
+ .allow-interactivity-${e} {pointer-events: all;}
41
+ `},Fe=0,Y=[];function Ie(e){var t=o.useRef([]),n=o.useRef([0,0]),r=o.useRef(),i=o.useState(Fe++)[0],a=o.useState(R)[0],s=o.useRef(e);o.useEffect(function(){s.current=e},[e]),o.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ee([e.lockRef.current],(e.shards||[]).map(Me),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var c=o.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!s.current.allowPinchZoom;var i=J(e),a=n.current,o=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(o)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=K(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=K(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(o||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Ae(h,t,e,h===`h`?o:c,!0)},[]),l=o.useCallback(function(e){var n=e;if(!(!Y.length||Y[Y.length-1]!==a)){var r=`deltaY`in n?je(n):J(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Ne(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var o=(s.current.shards||[]).map(Me).filter(Boolean).filter(function(e){return e.contains(n.target)});(o.length>0?c(n,o[0]):!s.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),u=o.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Le(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=o.useCallback(function(e){n.current=J(e),r.current=void 0},[]),f=o.useCallback(function(t){u(t.type,je(t),t.target,c(t,e.lockRef.current))},[]),p=o.useCallback(function(t){u(t.type,J(t),t.target,c(t,e.lockRef.current))},[]);o.useEffect(function(){return Y.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,l,W),document.addEventListener(`touchmove`,l,W),document.addEventListener(`touchstart`,d,W),function(){Y=Y.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,l,W),document.removeEventListener(`touchmove`,l,W),document.removeEventListener(`touchstart`,d,W)}},[]);var m=e.removeScrollBar,h=e.inert;return o.createElement(o.Fragment,null,h?o.createElement(a,{styles:Pe(i)}):null,m?o.createElement(Se,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Le(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Re=le(P,Ie),ze=o.forwardRef(function(e,t){return o.createElement(I,D({},e,{ref:t,sideCar:Re}))});ze.classNames=I.classNames;var Be=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},X=new WeakMap,Z=new WeakMap,Q={},$=0,Ve=function(e){return e&&(e.host||Ve(e.parentNode))},He=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ve(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Ue=function(e,t,n,r){var i=He(t,Array.isArray(e)?e:[e]);Q[n]||(Q[n]=new WeakMap);var a=Q[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(X.get(e)||0)+1,l=(a.get(e)||0)+1;X.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Z.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),$++,function(){o.forEach(function(e){var t=X.get(e)-1,i=a.get(e)-1;X.set(e,t),a.set(e,i),t||(Z.has(e)||e.removeAttribute(r),Z.delete(e)),i||e.removeAttribute(n)}),$--,$||(X=new WeakMap,X=new WeakMap,Z=new WeakMap,Q={})}},We=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Be(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Ue(r,i,n,`aria-hidden`)):function(){return null}};export{f as i,ze as n,T as r,We as t};
@@ -1,6 +1,6 @@
1
- import{c as e,f as t,l as n,s as r,t as i,u as a}from"./button-yArHqw81.js";import"./dist-CwP5Ad1_.js";import{t as o}from"./circle-alert-DAWy5HuM.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p}from"./dist-BW-gQyc_.js";import"./es2015-BiaNLfVn.js";import{i as m,o as h,r as g}from"./ai-config-store-DQXVJVn_.js";import{B as _,Ct as v,St as y,U as b,at as x,bt as S,pt as C,t as w}from"./index-qO2TvUmo.js";var T=n(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),E=n(`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=n(`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=t(a(),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(`
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-UcOFuoN0.js";import"./es2015-CRmLuA2o.js";import{i as m,o as h,r as g}from"./ai-config-store-B_VpGvwx.js";import{Nt as _,Pt as v,Tt as y,_t as b,et as x,r as S,tt as C}from"./index-Bu3zaxzE.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
- `)}}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)(w);if(!e)throw Error(`useGlobalPanel must be used inside GlobalPanelProvider`);return e}var z=r(),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:t}){let n=t.replace(/\r\n/g,`
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)(S);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
- `),r=[],i=0;for(;i<n.length;){let t=n[i].trim();if(!t){i+=1;continue}let a=t.match(/^```(\w+)?/);if(a){let e=a[1],t=[];for(i+=1;i<n.length&&!n[i].trim().startsWith("```");)t.push(n[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:t.join(`
6
- `)})})]},`code-${i}`));continue}let o=t.match(/^(#{1,4})\s+(.+)$/);if(o){let t=o[1].length,n=e(`font-semibold leading-6 text-foreground`,t<=2?`mt-2 text-sm`:`text-[13px]`),a=K(o[2]);r.push(t===1?(0,z.jsx)(`h3`,{className:n,children:a},`heading-${i}`):t===2?(0,z.jsx)(`h4`,{className:n,children:a},`heading-${i}`):(0,z.jsx)(`h5`,{className:n,children:a},`heading-${i}`)),i+=1;continue}if(/^---+$/.test(t)){r.push((0,z.jsx)(`div`,{className:`h-px bg-border/70`},`hr-${i}`)),i+=1;continue}if(t.includes(`|`)&&i+1<n.length&&q(n[i+1])){let e=J(t),a=[];for(i+=2;i<n.length&&n[i].trim().includes(`|`);)a.push(J(n[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:e.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(t)||/^\d+\.\s+/.test(t)){let a=/^\d+\.\s+/.test(t),o=[];for(;i<n.length;){let e=n[i].trim(),t=a?e.match(/^\d+\.\s+(.+)$/):e.match(/^[-*]\s+(.+)$/);if(!t)break;o.push(t[1]),i+=1}let s=a?`ol`:`ul`;r.push((0,z.jsx)(s,{className:e(`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=[t];for(i+=1;i<n.length;){let e=n[i].trim();if(!e||e.startsWith("```")||/^#{1,4}\s+/.test(e)||/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^---+$/.test(e)||e.includes(`|`)&&i+1<n.length&&q(n[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:t}){let n=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),[w,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(t,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&&n.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)(x,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(b,{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&&n.close()},placeholder:`搜索命令,或直接描述你想让 AI 完成的操作...`,className:`h-9 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0 dark:bg-transparent`}),(0,z.jsx)(_,{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)(C,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(v,{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:e(`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)(C,{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((t,n)=>(0,z.jsxs)(`div`,{className:e(n>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:t.userMessage}),(0,z.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`AI`}),(0,z.jsx)(Y,{content:t.aiMessage})]},n)),F&&(0,z.jsxs)(`div`,{className:e(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:w===e.id,onClick:()=>void $(e.id,!1),children:`取消`}),(0,z.jsxs)(i,{size:`sm`,disabled:w===e.id,onClick:()=>void $(e.id,!0),children:[w===e.id?(0,z.jsx)(C,{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)(b,{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)(S,{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(([t,n])=>(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:t}),n.map(t=>{let n=W.findIndex(e=>e.id===t.id),r=t.icon,i=n===s,a=l===t.id;return(0,z.jsxs)(`button`,{ref:i?H:void 0,type:`button`,"data-selected":i?`true`:void 0,className:e(`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`,t.disabled&&`cursor-not-allowed opacity-50`,t.danger&&!t.disabled&&`text-destructive`),onMouseEnter:()=>c(n),onClick:()=>void X(t),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)(C,{className:`h-4 w-4 animate-spin`}):r?(0,z.jsx)(r,{className:`h-4 w-4`}):(0,z.jsx)(S,{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:t.title}),(t.description||t.disabledReason)&&(0,z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t.disabled&&t.disabledReason||t.description})]}),t.shortcut&&(0,z.jsx)(_,{variant:`secondary`,className:`shrink-0 text-[10px] font-normal`,children:t.shortcut})]},t.id)})]},t))}):null]})]})}function Z({commands:t,renderPanel:n}){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))},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: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:e(`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)(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: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:n(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:t})]})})]})})}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),[S,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)(b,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(C,{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)(x,{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)(y,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(v,{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)(y,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):(0,z.jsx)(_,{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:S===e.id,onClick:()=>void $(e.id,!1),children:`取消`}),(0,z.jsxs)(i,{size:`sm`,disabled:S===e.id,onClick:()=>void $(e.id,!0),children:[S===e.id?(0,z.jsx)(y,{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)(C,{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)(y,{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)(x,{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-QkTcTrED.js";import{t as d}from"./switch-DpLnRvOJ.js";import{B as f,Dt as te,G as p,H as m,Nt as h,U as g,W as _,at as v,ct as y,et as b,ft as ne,it as re,lt as x,nt as S,ot as C,rt as w,st as T}from"./index-Bu3zaxzE.js";import{n as E,r as D,t as O}from"./alert-BmsRCcSL.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./table-C3mgEjkP.js";var F=a(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),I=a(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),L=a(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),R=a(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),z=r(t(),1),B=e(),V={ok:`正常`,degraded:`降级`,critical:`严重`},ie={cpu:`CPU`,rss:`RSS 内存`,connections:`连接数`,mitmServers:`MITM 服务`,eventLoopDelay:`事件循环延迟`,fds:`文件描述符`};function H(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.generatedAt==`number`&&typeof t.status==`string`&&typeof t.pid==`number`&&typeof t.uptimeSec==`number`&&!!t.memory&&!!t.cpu&&!!t.connections&&!!t.mitmServers&&Array.isArray(t.checks)}async function U(){let e=await fetch(`/api/health`,{cache:`no-store`});if(!e.ok)throw Error(`健康接口返回 ${e.status}`);let t=await e.json();if(!H(t))throw Error(`健康接口返回格式不正确`);return t}function W(e){if(!Number.isFinite(e))return`-`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=t[0];for(let e=1;e<t.length&&n>=1024;e+=1)n/=1024,r=t[e];return`${n>=10?n.toFixed(0):n.toFixed(1)} ${r}`}function G(e){if(!Number.isFinite(e)||e<0)return`-`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=Math.floor(e%60);return t>0?`${t}天 ${n}小时`:n>0?`${n}小时 ${r}分钟`:r>0?`${r}分钟 ${i}秒`:`${i}秒`}function K(e){return e?new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(new Date(e)):`-`}function q(e,t){return t===`bytes`?W(e):t===`%`?`${e.toFixed(1)}%`:t===`ms`?`${e.toFixed(1)} ms`:String(e)}function J(e,t){return t===`bytes`?W(e):t===`%`?`${e}%`:t===`ms`?`${e} ms`:String(e)}function ae(e){if(!e||typeof e!=`object`)return null;let t=e;return Array.isArray(t.keys)?{windowMs:Number(t.windowMs)||0,maxPerWindow:Number(t.maxPerWindow)||0,keys:t.keys,suppressedTotal:Number(t.suppressedTotal)||0}:null}function Y({status:e}){return(0,B.jsxs)(b,{variant:e===`critical`?`destructive`:e===`degraded`?`secondary`:`default`,children:[e===`ok`?(0,B.jsx)(h,{}):e===`degraded`?(0,B.jsx)(x,{}):(0,B.jsx)(o,{}),V[e]]})}function oe({icon:e,label:t,value:n,detail:r}){return(0,B.jsxs)(w,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsx)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:(0,B.jsxs)(y,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,B.jsx)(e,{}),t]})}),(0,B.jsxs)(v,{className:`flex flex-col gap-1 p-[var(--ui-page-padding)]`,children:[(0,B.jsx)(`div`,{className:`text-2xl font-semibold tracking-tight`,children:n}),(0,B.jsx)(`div`,{className:`min-h-4 truncate text-xs text-muted-foreground`,title:r,children:r})]})]})}function X({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-lg border bg-background p-[var(--ui-section-gap)]`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsx)(`span`,{className:`truncate text-sm font-medium`,title:t,children:t})]})}function se(){return(0,B.jsxs)(`div`,{className:`app-workspace-content`,"aria-label":`正在读取健康状态`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(S,{className:`h-7 w-40`}),(0,B.jsx)(S,{className:`h-4 w-64`})]}),(0,B.jsx)(S,{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)(S,{className:`h-32 w-full`},t))}),(0,B.jsx)(S,{className:`h-80 w-full`})]})}function Z(){let[e,t]=(0,z.useState)(null),[r,a]=(0,z.useState)(!0),[o,h]=(0,z.useState)(!1),[S,V]=(0,z.useState)(``),[H,Z]=(0,z.useState)(!0),Q=(0,z.useCallback)(async(e=!1)=>{e?h(!0):a(!0),V(``);try{t(await U())}catch(e){V(e instanceof Error?e.message:`无法读取健康状态`)}finally{a(!1),h(!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:S||`无法读取健康状态`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(),children:[(0,B.jsx)(l,{"data-icon":`inline-start`}),`重新检测`]})]});let ce=[{icon:F,label:`CPU`,value:`${e.cpu.percent.toFixed(1)}%`,detail:`${e.cpu.cores} 核 · load ${e.cpu.loadAverage.map(e=>e.toFixed(2)).join(` / `)}`},{icon:L,label:`RSS 内存`,value:W(e.memory.rss),detail:`Heap ${W(e.memory.heapUsed)} / ${W(e.memory.heapTotal)}`},{icon:R,label:`TCP 连接`,value:String(e.connections.total),detail:`代理 ${e.connections.proxySockets} · TLS ${e.connections.mitmTlsSockets} · WS ${e.connections.webSockets}`},{icon:c,label:`MITM 服务`,value:String(e.mitmServers.count),detail:`${e.mitmServers.activeSockets} 个活跃 socket`},{icon:ne,label:`文件描述符`,value:e.process.fdCount==null?`-`:String(e.process.fdCount),detail:`handles ${e.process.activeHandles??`-`} · requests ${e.process.activeRequests??`-`}`},{icon:I,label:`事件循环`,value:`${e.eventLoop.maxMs.toFixed(1)} ms`,detail:`mean ${e.eventLoop.meanMs.toFixed(1)} ms`}];return(0,B.jsxs)(`div`,{className:`meddle-thin-scroll app-workspace-content overflow-y-auto`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`运行健康`}),(0,B.jsx)(Y,{status:e.status})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{children:[`PID `,e.pid]}),(0,B.jsxs)(`span`,{children:[`运行 `,G(e.uptimeSec)]}),(0,B.jsx)(`span`,{children:e.platform}),(0,B.jsxs)(`span`,{children:[`更新 `,K(e.generatedAt)]})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border bg-background px-3 text-sm`,children:[(0,B.jsx)(d,{checked:H,onCheckedChange:Z,"aria-label":`自动刷新健康信息`}),(0,B.jsx)(`span`,{children:`自动刷新`})]}),(0,B.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>void Q(!0),disabled:o,children:[(0,B.jsx)(l,{"data-icon":`inline-start`,className:n(o&&`animate-spin`)}),`刷新`]})]})]}),S&&(0,B.jsxs)(O,{variant:`destructive`,children:[(0,B.jsx)(D,{children:`刷新失败`}),(0,B.jsx)(E,{children:S})]}),(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)(w,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(te,{}),`健康检查`]}),(0,B.jsx)(C,{children:`阈值来自当前进程的 MEDDLE_WATCHDOG 配置。`})]}),(0,B.jsx)(v,{className:`p-0`,children:(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`项目`}),(0,B.jsx)(A,{children:`状态`}),(0,B.jsx)(A,{children:`当前值`}),(0,B.jsx)(A,{children:`阈值`})]})}),(0,B.jsx)(j,{children:e.checks.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`font-medium`,children:ie[e.name]||e.name}),(0,B.jsx)(N,{children:(0,B.jsx)(Y,{status:e.status})}),(0,B.jsx)(N,{children:q(e.value,e.unit)}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:J(e.limit,e.unit)})]},e.name))})]})})]}),(0,B.jsxs)(w,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ee,{}),`守护策略`]}),(0,B.jsx)(C,{children:`连续命中严重阈值后按策略处理。`}),(0,B.jsx)(re,{children:(0,B.jsx)(b,{variant:e.watchdog.config.enabled?`default`:`secondary`,children:e.watchdog.config.enabled?`已启用`:`已关闭`})})]}),(0,B.jsxs)(v,{className:`grid gap-[var(--ui-section-gap)] p-[var(--ui-page-padding)] sm:grid-cols-2`,children:[(0,B.jsx)(X,{label:`动作`,value:e.watchdog.config.action===`exit`?`退出重启`:`仅告警`}),(0,B.jsx)(X,{label:`检测间隔`,value:G(e.watchdog.config.intervalMs/1e3)}),(0,B.jsx)(X,{label:`最小运行时间`,value:G(e.watchdog.config.minUptimeMs/1e3)}),(0,B.jsx)(X,{label:`失败阈值`,value:`${e.watchdog.consecutiveFailures}/${e.watchdog.config.failureThreshold}`}),(0,B.jsx)(X,{label:`CPU 阈值`,value:`${e.watchdog.config.cpuPercent}%`}),(0,B.jsx)(X,{label:`RSS 阈值`,value:W(e.watchdog.config.rssBytes)}),(0,B.jsx)(X,{label:`连接阈值`,value:String(e.watchdog.config.connectionCount)}),(0,B.jsx)(X,{label:`FD 阈值`,value:String(e.watchdog.config.fdCount)}),e.watchdog.lastReason&&(0,B.jsx)(`div`,{className:`sm:col-span-2`,children:(0,B.jsxs)(O,{children:[(0,B.jsx)(x,{}),(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)(w,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(u,{}),`MITM 服务池`]}),(0,B.jsxs)(C,{children:[e.mitmServers.count,` 个动态 HTTPS 服务。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:e.mitmServers.items.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Host`}),(0,B.jsx)(A,{children:`端口`}),(0,B.jsx)(A,{children:`Socket`}),(0,B.jsx)(A,{children:`空闲`})]})}),(0,B.jsx)(j,{children:e.mitmServers.items.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.host,children:e.host}),(0,B.jsx)(N,{children:e.port??`-`}),(0,B.jsxs)(N,{children:[e.activeSockets,` / `,e.webSockets,` WS`]}),(0,B.jsx)(N,{className:`text-muted-foreground`,children:e.idleForMs==null?`-`:G(e.idleForMs/1e3)})]},`${e.host}:${e.port??`dynamic`}`))})]}):(0,B.jsx)(f,{className:`border-0 py-10`,children:(0,B.jsxs)(g,{children:[(0,B.jsx)(_,{variant:`icon`,children:(0,B.jsx)(c,{})}),(0,B.jsx)(p,{children:`暂无动态 HTTPS 服务`}),(0,B.jsx)(m,{children:`当前没有活跃的 MITM 目标。`})]})})})]}),(0,B.jsxs)(w,{className:`gap-0 py-0 shadow-none`,children:[(0,B.jsxs)(T,{className:`border-b px-[var(--ui-section-gap)] py-[var(--ui-section-gap)] [.border-b]:pb-[var(--ui-section-gap)]`,children:[(0,B.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,B.jsx)(s,{}),`日志限流`]}),(0,B.jsxs)(C,{children:[`已抑制 `,$?.suppressedTotal??0,` 条重复日志。`]})]}),(0,B.jsx)(v,{className:`p-0`,children:$&&$.keys.length>0?(0,B.jsxs)(P,{children:[(0,B.jsx)(k,{children:(0,B.jsxs)(M,{children:[(0,B.jsx)(A,{children:`Key`}),(0,B.jsx)(A,{children:`级别`}),(0,B.jsx)(A,{children:`输出 / 抑制`}),(0,B.jsx)(A,{children:`最近`})]})}),(0,B.jsx)(j,{children:$.keys.map(e=>(0,B.jsxs)(M,{children:[(0,B.jsx)(N,{className:`max-w-[260px] truncate font-medium`,title:e.key,children:e.key}),(0,B.jsx)(N,{children:(0,B.jsx)(b,{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)(f,{className:`border-0 py-10`,children:(0,B.jsxs)(g,{children:[(0,B.jsx)(_,{variant:`icon`,children:(0,B.jsx)(s,{})}),(0,B.jsx)(p,{children:`暂无限流记录`}),(0,B.jsx)(m,{children:`当前没有被抑制的重复日志。`})]})})})]})]})]})}export{Z as HealthPanel};