blade-code 0.10.7 → 0.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/chunk-1w6azndv.js +1 -0
  3. package/dist/chunk-2gwaqpge.js +1 -0
  4. package/dist/chunk-2pjd4cys.js +1 -0
  5. package/dist/{chunk-vafn0spm.js → chunk-2thg3fq1.js} +1 -1
  6. package/dist/chunk-2zn5en0w.js +1 -0
  7. package/dist/{chunk-1v7hpr34.js → chunk-33ave20b.js} +1 -1
  8. package/dist/chunk-3w1z6fwm.js +1 -0
  9. package/dist/chunk-43x4qbvt.js +1 -0
  10. package/dist/{chunk-e9ckf8e7.js → chunk-4h9ff923.js} +1 -1
  11. package/dist/chunk-52csdk21.js +3 -0
  12. package/dist/{chunk-ahxc3n3g.js → chunk-66hb7kxm.js} +2 -2
  13. package/dist/chunk-6j8wgp2s.js +2 -0
  14. package/dist/chunk-6vsszvgg.js +2 -0
  15. package/dist/chunk-7evtr0yr.js +10 -0
  16. package/dist/{chunk-tp9zk241.js → chunk-7hbw6q6d.js} +1 -1
  17. package/dist/chunk-7zsyejr1.js +22 -0
  18. package/dist/{chunk-x3780wpy.js → chunk-8gcg2z3y.js} +16 -16
  19. package/dist/{chunk-p3ahf1fh.js → chunk-8gcvpmwk.js} +1 -1
  20. package/dist/{chunk-w01sec4f.js → chunk-8gnfj89a.js} +2 -2
  21. package/dist/{chunk-7a200q5g.js → chunk-8h0yxh6y.js} +2 -2
  22. package/dist/chunk-8sfycn3y.js +194 -0
  23. package/dist/{chunk-847e0sk9.js → chunk-954vmnrn.js} +1 -1
  24. package/dist/chunk-a8h3fymk.js +100 -0
  25. package/dist/chunk-b5szbtmp.js +5 -0
  26. package/dist/chunk-bxm2hq0m.js +1 -0
  27. package/dist/chunk-c8da4b3d.js +1 -0
  28. package/dist/{chunk-tc83e1b0.js → chunk-cbpqcdga.js} +1 -1
  29. package/dist/{chunk-qycwavck.js → chunk-cf8e7e92.js} +2 -2
  30. package/dist/{chunk-kqpwz9b7.js → chunk-d0g4t8fw.js} +2 -2
  31. package/dist/{chunk-1sw9z975.js → chunk-eq2qj9ja.js} +1 -1
  32. package/dist/{chunk-p0j8994h.js → chunk-fj8v7pep.js} +1 -1
  33. package/dist/{chunk-tcc3v4n2.js → chunk-fxpq9nh6.js} +1 -1
  34. package/dist/chunk-g00wj2we.js +4 -0
  35. package/dist/{chunk-3fdyzgpv.js → chunk-h28ptrrt.js} +1 -1
  36. package/dist/{chunk-qk2z6gag.js → chunk-h421wzbm.js} +2 -2
  37. package/dist/{chunk-4hhkbyja.js → chunk-j4tttsaz.js} +2 -2
  38. package/dist/{chunk-wrbm6rch.js → chunk-kagpk2x5.js} +2 -2
  39. package/dist/chunk-kvnwhwx3.js +1 -0
  40. package/dist/{chunk-mt4328yf.js → chunk-m2xrx1je.js} +1 -1
  41. package/dist/{chunk-g3wgzyhx.js → chunk-nhc49pan.js} +48 -48
  42. package/dist/{chunk-jpy61wna.js → chunk-nymm525r.js} +1 -1
  43. package/dist/{chunk-rz9yh6e4.js → chunk-nz57y1ad.js} +3 -3
  44. package/dist/{chunk-wmdgb5pz.js → chunk-p2m56new.js} +2 -2
  45. package/dist/{chunk-43j2f1b5.js → chunk-pv9sw79c.js} +1 -1
  46. package/dist/chunk-qgp08qmz.js +6 -0
  47. package/dist/{chunk-7pkrwh10.js → chunk-r7tsa2zv.js} +1 -1
  48. package/dist/{chunk-zjf1z27e.js → chunk-rkvfsx8e.js} +1 -1
  49. package/dist/{chunk-y573s5r8.js → chunk-rxqft6td.js} +2 -2
  50. package/dist/{chunk-rn908m3v.js → chunk-s9aj3p11.js} +2 -2
  51. package/dist/{chunk-0z7q89w7.js → chunk-senkwdh6.js} +1 -1
  52. package/dist/chunk-v1c58sm6.js +1 -0
  53. package/dist/{chunk-m86ekqp0.js → chunk-v8pq6qmv.js} +2 -2
  54. package/dist/chunk-van4ysq6.js +1466 -0
  55. package/dist/chunk-vgp8m9fg.js +2 -0
  56. package/dist/{chunk-ne7zdjrh.js → chunk-vsg8f0e6.js} +1 -1
  57. package/dist/{chunk-0n04bmta.js → chunk-w0nscjd2.js} +2 -2
  58. package/dist/chunk-w26jhcj9.js +1 -0
  59. package/dist/{chunk-qqwgb9ja.js → chunk-wmnszjmv.js} +2 -2
  60. package/dist/chunk-x6wgh726.js +1 -0
  61. package/dist/{chunk-yyvx1avz.js → chunk-xa05phpw.js} +3 -3
  62. package/dist/{chunk-0xm8hn2h.js → chunk-xmcsn7y0.js} +2 -2
  63. package/dist/{chunk-az4b6106.js → chunk-y4c3wwpa.js} +1 -1
  64. package/dist/{chunk-vcq624qv.js → chunk-yfs9tq3y.js} +2 -2
  65. package/dist/chunk-ymzcxryf.js +1 -0
  66. package/dist/{chunk-akev4wsz.js → chunk-zknv3d6y.js} +1 -1
  67. package/dist/chunk-zp4x2mwj.js +1 -0
  68. package/dist/chunk-zvk3g177.js +9 -0
  69. package/dist/web/assets/ChatView-Fqy97qw9.js +7 -0
  70. package/dist/web/assets/{CodeBlockHighlighter-CC4e9nFc.js → CodeBlockHighlighter-EgdsVoMQ.js} +1 -1
  71. package/dist/web/assets/{FilePreview-C3HEoLYS.js → FilePreview-xicd9-Sl.js} +1 -1
  72. package/dist/web/assets/{MarkdownRenderer-COycrGUX.js → MarkdownRenderer-DBSjC_z3.js} +18 -18
  73. package/dist/web/assets/SettingsModal-Bkh5rMAJ.js +5 -0
  74. package/dist/web/assets/TaskSwitcher-DXcj0iJ_.js +1 -0
  75. package/dist/web/assets/{TerminalPanel-DqQ-7CTG.js → TerminalPanel-DWVY-Elm.js} +1 -1
  76. package/dist/web/assets/index-Bi5ijAQP.css +1 -0
  77. package/dist/web/assets/index-CxEh32hc.js +32 -0
  78. package/dist/web/assets/{vendor-icons-D_AkWmWB.js → vendor-icons-Cv18Q6rW.js} +72 -67
  79. package/dist/web/assets/{vendor-radix-DBy9B2DN.js → vendor-radix-DXRuAJHH.js} +1 -1
  80. package/dist/web/index.html +4 -4
  81. package/package.json +3 -1
  82. package/dist/chunk-4rhssb85.js +0 -2
  83. package/dist/chunk-598egka3.js +0 -22
  84. package/dist/chunk-5ak9tw83.js +0 -100
  85. package/dist/chunk-738pkjf8.js +0 -1
  86. package/dist/chunk-7xfmzvxp.js +0 -1
  87. package/dist/chunk-867rz2ss.js +0 -1
  88. package/dist/chunk-a3e97syg.js +0 -3
  89. package/dist/chunk-f7854pbx.js +0 -187
  90. package/dist/chunk-fwt0kje3.js +0 -1
  91. package/dist/chunk-g1q27q6q.js +0 -2
  92. package/dist/chunk-g4snq0dx.js +0 -1
  93. package/dist/chunk-ggm04adj.js +0 -1
  94. package/dist/chunk-hpytxsge.js +0 -1
  95. package/dist/chunk-htr91q9c.js +0 -1
  96. package/dist/chunk-hwcp940f.js +0 -1
  97. package/dist/chunk-j5ysjbyr.js +0 -10
  98. package/dist/chunk-m8k1mv0j.js +0 -4
  99. package/dist/chunk-pt659n0v.js +0 -1466
  100. package/dist/chunk-q1gfeadm.js +0 -1
  101. package/dist/chunk-rk1w5pry.js +0 -2
  102. package/dist/chunk-rz2ftt6h.js +0 -5
  103. package/dist/chunk-tzh4ahry.js +0 -6
  104. package/dist/chunk-v0rn831t.js +0 -1
  105. package/dist/chunk-vynsgc2g.js +0 -1
  106. package/dist/chunk-w0ena7fe.js +0 -9
  107. package/dist/chunk-ydwjttdz.js +0 -1
  108. package/dist/chunk-z9fsh3kn.js +0 -1
  109. package/dist/web/assets/ChatView-BYfHmxKJ.js +0 -7
  110. package/dist/web/assets/McpModal-CDgr9kVq.js +0 -5
  111. package/dist/web/assets/SettingsModal-CvdVIbeG.js +0 -1
  112. package/dist/web/assets/SkillsModal-lSX1ZKTu.js +0 -1
  113. package/dist/web/assets/TaskSwitcher-peKi9KvN.js +0 -1
  114. package/dist/web/assets/index-BF5HEN_f.js +0 -32
  115. package/dist/web/assets/index-BrkTYxtS.css +0 -1
  116. package/dist/web/assets/useRequest-BvqVDnKl.js +0 -1
@@ -42,4 +42,4 @@ import{r as a,R as Pt,j as m,a as Rn,b as uo}from"./vendor-react-DG5dkZ_t.js";fu
42
42
 
43
43
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
44
44
 
45
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return a.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ji="DialogDescriptionWarning",es=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tr(Ji).contentName}}.`;return a.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ra=Bn,Aa=Un,Ta=Yn,Oa=Xn,Da=Kn,_a=qn,Na=Jn,ts=a.createContext(void 0);function ns(e){const t=a.useContext(ts);return e||t||"ltr"}function rs(e,[t,n]){return Math.min(n,Math.max(t,e))}function os(e,t){return a.useReducer((n,r)=>t[n][r]??n,e)}var Lt="ScrollArea",[nr]=Ae(Lt),[is,z]=nr(Lt),rr=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...s}=e,[c,u]=a.useState(null),[l,f]=a.useState(null),[d,p]=a.useState(null),[h,g]=a.useState(null),[v,y]=a.useState(null),[w,b]=a.useState(0),[C,x]=a.useState(0),[S,P]=a.useState(!1),[E,O]=a.useState(!1),R=F(t,D=>u(D)),A=ns(o);return m.jsx(is,{scope:n,type:r,dir:A,scrollHideDelay:i,scrollArea:c,viewport:l,onViewportChange:f,content:d,onContentChange:p,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:S,onScrollbarXEnabledChange:P,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:O,onCornerWidthChange:b,onCornerHeightChange:x,children:m.jsx(L.div,{dir:A,...s,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});rr.displayName=Lt;var or="ScrollAreaViewport",ir=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,s=z(or,n),c=a.useRef(null),u=F(t,c,s.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),m.jsx(L.div,{"data-radix-scroll-area-viewport":"",...i,ref:u,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:m.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});ir.displayName=or;var ee="ScrollAreaScrollbar",ss=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=z(ee,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=o,c=e.orientation==="horizontal";return a.useEffect(()=>(c?i(!0):s(!0),()=>{c?i(!1):s(!1)}),[c,i,s]),o.type==="hover"?m.jsx(cs,{...r,ref:t,forceMount:n}):o.type==="scroll"?m.jsx(as,{...r,ref:t,forceMount:n}):o.type==="auto"?m.jsx(sr,{...r,ref:t,forceMount:n}):o.type==="always"?m.jsx(Mt,{...r,ref:t}):null});ss.displayName=ee;var cs=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=z(ee,e.__scopeScrollArea),[i,s]=a.useState(!1);return a.useEffect(()=>{const c=o.scrollArea;let u=0;if(c){const l=()=>{window.clearTimeout(u),s(!0)},f=()=>{u=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",l),c.addEventListener("pointerleave",f),()=>{window.clearTimeout(u),c.removeEventListener("pointerenter",l),c.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),m.jsx(X,{present:n||i,children:m.jsx(sr,{"data-state":i?"visible":"hidden",...r,ref:t})})}),as=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=z(ee,e.__scopeScrollArea),i=e.orientation==="horizontal",s=Je(()=>u("SCROLL_END"),100),[c,u]=os("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return a.useEffect(()=>{if(c==="idle"){const l=window.setTimeout(()=>u("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(l)}},[c,o.scrollHideDelay,u]),a.useEffect(()=>{const l=o.viewport,f=i?"scrollLeft":"scrollTop";if(l){let d=l[f];const p=()=>{const h=l[f];d!==h&&(u("SCROLL"),s()),d=h};return l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[o.viewport,i,u,s]),m.jsx(X,{present:n||c!=="hidden",children:m.jsx(Mt,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:_(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:_(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),sr=a.forwardRef((e,t)=>{const n=z(ee,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,s]=a.useState(!1),c=e.orientation==="horizontal",u=Je(()=>{if(n.viewport){const l=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;s(c?l:f)}},10);return me(n.viewport,u),me(n.content,u),m.jsx(X,{present:r||i,children:m.jsx(Mt,{"data-state":i?"visible":"hidden",...o,ref:t})})}),Mt=a.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=z(ee,e.__scopeScrollArea),i=a.useRef(null),s=a.useRef(0),[c,u]=a.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=ur(c.viewport,c.content),f={...r,sizes:c,onSizesChange:u,hasThumb:l>0&&l<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function d(p,h){return vs(p,s.current,c,h)}return n==="horizontal"?m.jsx(ls,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,h=hn(p,c,o.dir);i.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=d(p,o.dir))}}):n==="vertical"?m.jsx(us,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,h=hn(p,c);i.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=d(p))}}):null}),ls=a.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=z(ee,e.__scopeScrollArea),[s,c]=a.useState(),u=a.useRef(null),l=F(t,u,i.onScrollbarXChange);return a.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),m.jsx(ar,{"data-orientation":"horizontal",...o,ref:l,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qe(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,d)=>{if(i.viewport){const p=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),dr(p,d)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&s&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:ze(s.paddingLeft),paddingEnd:ze(s.paddingRight)}})}})}),us=a.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=z(ee,e.__scopeScrollArea),[s,c]=a.useState(),u=a.useRef(null),l=F(t,u,i.onScrollbarYChange);return a.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),m.jsx(ar,{"data-orientation":"vertical",...o,ref:l,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qe(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,d)=>{if(i.viewport){const p=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),dr(p,d)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&s&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:ze(s.paddingTop),paddingEnd:ze(s.paddingBottom)}})}})}),[fs,cr]=nr(ee),ar=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:c,onThumbPositionChange:u,onDragScroll:l,onWheelScroll:f,onResize:d,...p}=e,h=z(ee,n),[g,v]=a.useState(null),y=F(t,R=>v(R)),w=a.useRef(null),b=a.useRef(""),C=h.viewport,x=r.content-r.viewport,S=B(f),P=B(u),E=Je(d,10);function O(R){if(w.current){const A=R.clientX-w.current.left,D=R.clientY-w.current.top;l({x:A,y:D})}}return a.useEffect(()=>{const R=A=>{const D=A.target;(g==null?void 0:g.contains(D))&&S(A,x)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,g,x,S]),a.useEffect(P,[r,P]),me(g,E),me(h.content,E),m.jsx(fs,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:B(i),onThumbPointerUp:B(s),onThumbPositionChange:P,onThumbPointerDown:B(c),children:m.jsx(L.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:_(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),w.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),O(R))}),onPointerMove:_(e.onPointerMove,O),onPointerUp:_(e.onPointerUp,R=>{const A=R.target;A.hasPointerCapture(R.pointerId)&&A.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Ve="ScrollAreaThumb",ds=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=cr(Ve,e.__scopeScrollArea);return m.jsx(X,{present:n||o.hasThumb,children:m.jsx(ps,{ref:t,...r})})}),ps=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=z(Ve,n),s=cr(Ve,n),{onThumbPositionChange:c}=s,u=F(t,d=>s.onThumbChange(d)),l=a.useRef(void 0),f=Je(()=>{l.current&&(l.current(),l.current=void 0)},100);return a.useEffect(()=>{const d=i.viewport;if(d){const p=()=>{if(f(),!l.current){const h=ms(d,c);l.current=h,c()}};return c(),d.addEventListener("scroll",p),()=>d.removeEventListener("scroll",p)}},[i.viewport,f,c]),m.jsx(L.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:_(e.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),g=d.clientX-h.left,v=d.clientY-h.top;s.onThumbPointerDown({x:g,y:v})}),onPointerUp:_(e.onPointerUp,s.onThumbPointerUp)})});ds.displayName=Ve;var It="ScrollAreaCorner",lr=a.forwardRef((e,t)=>{const n=z(It,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?m.jsx(hs,{...e,ref:t}):null});lr.displayName=It;var hs=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=z(It,n),[i,s]=a.useState(0),[c,u]=a.useState(0),l=!!(i&&c);return me(o.scrollbarX,()=>{var d;const f=((d=o.scrollbarX)==null?void 0:d.offsetHeight)||0;o.onCornerHeightChange(f),u(f)}),me(o.scrollbarY,()=>{var d;const f=((d=o.scrollbarY)==null?void 0:d.offsetWidth)||0;o.onCornerWidthChange(f),s(f)}),l?m.jsx(L.div,{...r,ref:t,style:{width:i,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ze(e){return e?parseInt(e,10):0}function ur(e,t){const n=e/t;return isNaN(n)?0:n}function Qe(e){const t=ur(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function vs(e,t,n,r="ltr"){const o=Qe(n),i=o/2,s=t||i,c=o-s,u=n.scrollbar.paddingStart+s,l=n.scrollbar.size-n.scrollbar.paddingEnd-c,f=n.content-n.viewport,d=r==="ltr"?[0,f]:[f*-1,0];return fr([u,l],d)(e)}function hn(e,t,n="ltr"){const r=Qe(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,c=i-r,u=n==="ltr"?[0,s]:[s*-1,0],l=rs(e,u);return fr([0,s],[0,c])(l)}function fr(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function dr(e,t){return e>0&&e<t}var ms=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const i={left:e.scrollLeft,top:e.scrollTop},s=n.left!==i.left,c=n.top!==i.top;(s||c)&&t(),n=i,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Je(e,t){const n=B(e),r=a.useRef(0);return a.useEffect(()=>()=>window.clearTimeout(r.current),[]),a.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function me(e,t){const n=B(t);ne(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var La=rr,Ma=ir,Ia=lr;const gs=["top","right","bottom","left"],se=Math.min,H=Math.max,Ue=Math.round,ke=Math.floor,Q=e=>({x:e,y:e}),ys={left:"right",right:"left",bottom:"top",top:"bottom"},ws={start:"end",end:"start"};function bt(e,t,n){return H(e,se(t,n))}function re(e,t){return typeof e=="function"?e(t):e}function oe(e){return e.split("-")[0]}function be(e){return e.split("-")[1]}function jt(e){return e==="x"?"y":"x"}function kt(e){return e==="y"?"height":"width"}const bs=new Set(["top","bottom"]);function q(e){return bs.has(oe(e))?"y":"x"}function Ft(e){return jt(q(e))}function xs(e,t,n){n===void 0&&(n=!1);const r=be(e),o=Ft(e),i=kt(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Ye(s)),[s,Ye(s)]}function Cs(e){const t=Ye(e);return[xt(e),t,xt(t)]}function xt(e){return e.replace(/start|end/g,t=>ws[t])}const vn=["left","right"],mn=["right","left"],Ss=["top","bottom"],Es=["bottom","top"];function Ps(e,t,n){switch(e){case"top":case"bottom":return n?t?mn:vn:t?vn:mn;case"left":case"right":return t?Ss:Es;default:return[]}}function Rs(e,t,n,r){const o=be(e);let i=Ps(oe(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(xt)))),i}function Ye(e){return e.replace(/left|right|bottom|top/g,t=>ys[t])}function As(e){return{top:0,right:0,bottom:0,left:0,...e}}function pr(e){return typeof e!="number"?As(e):{top:e,right:e,bottom:e,left:e}}function Xe(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function gn(e,t,n){let{reference:r,floating:o}=e;const i=q(t),s=Ft(t),c=kt(s),u=oe(t),l=i==="y",f=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,p=r[c]/2-o[c]/2;let h;switch(u){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(be(t)){case"start":h[s]-=p*(n&&l?-1:1);break;case"end":h[s]+=p*(n&&l?-1:1);break}return h}async function Ts(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:c,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=re(t,e),g=pr(h),y=c[p?d==="floating"?"reference":"floating":d],w=Xe(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:u})),b=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),x=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},S=Xe(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:C,strategy:u}):b);return{top:(w.top-S.top+g.top)/x.y,bottom:(S.bottom-w.bottom+g.bottom)/x.y,left:(w.left-S.left+g.left)/x.x,right:(S.right-w.right+g.right)/x.x}}const Os=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,c=i.filter(Boolean),u=await(s.isRTL==null?void 0:s.isRTL(t));let l=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:d}=gn(l,r,u),p=r,h={},g=0;for(let y=0;y<c.length;y++){var v;const{name:w,fn:b}=c[y],{x:C,y:x,data:S,reset:P}=await b({x:f,y:d,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:l,platform:{...s,detectOverflow:(v=s.detectOverflow)!=null?v:Ts},elements:{reference:e,floating:t}});f=C??f,d=x??d,h={...h,[w]:{...h[w],...S}},P&&g<=50&&(g++,typeof P=="object"&&(P.placement&&(p=P.placement),P.rects&&(l=P.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):P.rects),{x:f,y:d}=gn(l,p,u)),y=-1)}return{x:f,y:d,placement:p,strategy:o,middlewareData:h}},Ds=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:c,middlewareData:u}=t,{element:l,padding:f=0}=re(e,t)||{};if(l==null)return{};const d=pr(f),p={x:n,y:r},h=Ft(o),g=kt(h),v=await s.getDimensions(l),y=h==="y",w=y?"top":"left",b=y?"bottom":"right",C=y?"clientHeight":"clientWidth",x=i.reference[g]+i.reference[h]-p[h]-i.floating[g],S=p[h]-i.reference[h],P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let E=P?P[C]:0;(!E||!await(s.isElement==null?void 0:s.isElement(P)))&&(E=c.floating[C]||i.floating[g]);const O=x/2-S/2,R=E/2-v[g]/2-1,A=se(d[w],R),D=se(d[b],R),M=A,I=E-v[g]-D,N=E/2-v[g]/2+O,$=bt(M,N,I),j=!u.arrow&&be(o)!=null&&N!==$&&i.reference[g]/2-(N<M?A:D)-v[g]/2<0,k=j?N<M?N-M:N-I:0;return{[h]:p[h]+k,data:{[h]:$,centerOffset:N-$-k,...j&&{alignmentOffset:k}},reset:j}}}),_s=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:c,platform:u,elements:l}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...y}=re(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=oe(o),b=q(c),C=oe(c)===c,x=await(u.isRTL==null?void 0:u.isRTL(l.floating)),S=p||(C||!v?[Ye(c)]:Cs(c)),P=g!=="none";!p&&P&&S.push(...Rs(c,v,g,x));const E=[c,...S],O=await u.detectOverflow(t,y),R=[];let A=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&R.push(O[w]),d){const N=xs(o,s,x);R.push(O[N[0]],O[N[1]])}if(A=[...A,{placement:o,overflows:R}],!R.every(N=>N<=0)){var D,M;const N=(((D=i.flip)==null?void 0:D.index)||0)+1,$=E[N];if($&&(!(d==="alignment"?b!==q($):!1)||A.every(T=>q(T.placement)===b?T.overflows[0]>0:!0)))return{data:{index:N,overflows:A},reset:{placement:$}};let j=(M=A.filter(k=>k.overflows[0]<=0).sort((k,T)=>k.overflows[1]-T.overflows[1])[0])==null?void 0:M.placement;if(!j)switch(h){case"bestFit":{var I;const k=(I=A.filter(T=>{if(P){const W=q(T.placement);return W===b||W==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(W=>W>0).reduce((W,K)=>W+K,0)]).sort((T,W)=>T[1]-W[1])[0])==null?void 0:I[0];k&&(j=k);break}case"initialPlacement":j=c;break}if(o!==j)return{reset:{placement:j}}}return{}}}};function yn(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wn(e){return gs.some(t=>e[t]>=0)}const Ns=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=re(e,t);switch(o){case"referenceHidden":{const s=await r.detectOverflow(t,{...i,elementContext:"reference"}),c=yn(s,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:wn(c)}}}case"escaped":{const s=await r.detectOverflow(t,{...i,altBoundary:!0}),c=yn(s,n.floating);return{data:{escapedOffsets:c,escaped:wn(c)}}}default:return{}}}}},hr=new Set(["left","top"]);async function Ls(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=oe(n),c=be(n),u=q(n)==="y",l=hr.has(s)?-1:1,f=i&&u?-1:1,d=re(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),u?{x:h*f,y:p*l}:{x:p*l,y:h*f}}const Ms=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:c}=t,u=await Ls(t,e);return s===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},Is=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:s=!0,crossAxis:c=!1,limiter:u={fn:w=>{let{x:b,y:C}=w;return{x:b,y:C}}},...l}=re(e,t),f={x:n,y:r},d=await i.detectOverflow(t,l),p=q(oe(o)),h=jt(p);let g=f[h],v=f[p];if(s){const w=h==="y"?"top":"left",b=h==="y"?"bottom":"right",C=g+d[w],x=g-d[b];g=bt(C,g,x)}if(c){const w=p==="y"?"top":"left",b=p==="y"?"bottom":"right",C=v+d[w],x=v-d[b];v=bt(C,v,x)}const y=u.fn({...t,[h]:g,[p]:v});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[p]:c}}}}}},js=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:c=0,mainAxis:u=!0,crossAxis:l=!0}=re(e,t),f={x:n,y:r},d=q(o),p=jt(d);let h=f[p],g=f[d];const v=re(c,t),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const C=p==="y"?"height":"width",x=i.reference[p]-i.floating[C]+y.mainAxis,S=i.reference[p]+i.reference[C]-y.mainAxis;h<x?h=x:h>S&&(h=S)}if(l){var w,b;const C=p==="y"?"width":"height",x=hr.has(oe(o)),S=i.reference[d]-i.floating[C]+(x&&((w=s.offset)==null?void 0:w[d])||0)+(x?0:y.crossAxis),P=i.reference[d]+i.reference[C]+(x?0:((b=s.offset)==null?void 0:b[d])||0)-(x?y.crossAxis:0);g<S?g=S:g>P&&(g=P)}return{[p]:h,[d]:g}}}},ks=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:c}=t,{apply:u=()=>{},...l}=re(e,t),f=await s.detectOverflow(t,l),d=oe(o),p=be(o),h=q(o)==="y",{width:g,height:v}=i.floating;let y,w;d==="top"||d==="bottom"?(y=d,w=p===(await(s.isRTL==null?void 0:s.isRTL(c.floating))?"start":"end")?"left":"right"):(w=d,y=p==="end"?"top":"bottom");const b=v-f.top-f.bottom,C=g-f.left-f.right,x=se(v-f[y],b),S=se(g-f[w],C),P=!t.middlewareData.shift;let E=x,O=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),P&&!p){const A=H(f.left,0),D=H(f.right,0),M=H(f.top,0),I=H(f.bottom,0);h?O=g-2*(A!==0||D!==0?A+D:H(f.left,f.right)):E=v-2*(M!==0||I!==0?M+I:H(f.top,f.bottom))}await u({...t,availableWidth:O,availableHeight:E});const R=await s.getDimensions(c.floating);return g!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function et(){return typeof window<"u"}function xe(e){return vr(e)?(e.nodeName||"").toLowerCase():"#document"}function V(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function te(e){var t;return(t=(vr(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vr(e){return et()?e instanceof Node||e instanceof V(e).Node:!1}function U(e){return et()?e instanceof Element||e instanceof V(e).Element:!1}function J(e){return et()?e instanceof HTMLElement||e instanceof V(e).HTMLElement:!1}function bn(e){return!et()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof V(e).ShadowRoot}const Fs=new Set(["inline","contents"]);function Te(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Fs.has(o)}const Ws=new Set(["table","td","th"]);function $s(e){return Ws.has(xe(e))}const Hs=[":popover-open",":modal"];function tt(e){return Hs.some(t=>{try{return e.matches(t)}catch{return!1}})}const Bs=["transform","translate","scale","rotate","perspective"],Vs=["transform","translate","scale","rotate","perspective","filter"],zs=["paint","layout","strict","content"];function Wt(e){const t=$t(),n=U(e)?Y(e):e;return Bs.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Vs.some(r=>(n.willChange||"").includes(r))||zs.some(r=>(n.contain||"").includes(r))}function Us(e){let t=ce(e);for(;J(t)&&!ge(t);){if(Wt(t))return t;if(tt(t))return null;t=ce(t)}return null}function $t(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ys=new Set(["html","body","#document"]);function ge(e){return Ys.has(xe(e))}function Y(e){return V(e).getComputedStyle(e)}function nt(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ce(e){if(xe(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bn(e)&&e.host||te(e);return bn(t)?t.host:t}function mr(e){const t=ce(e);return ge(t)?e.ownerDocument?e.ownerDocument.body:e.body:J(t)&&Te(t)?t:mr(t)}function Ee(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=mr(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=V(o);if(i){const c=Ct(s);return t.concat(s,s.visualViewport||[],Te(o)?o:[],c&&n?Ee(c):[])}return t.concat(o,Ee(o,[],n))}function Ct(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gr(e){const t=Y(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=J(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,c=Ue(n)!==i||Ue(r)!==s;return c&&(n=i,r=s),{width:n,height:r,$:c}}function Ht(e){return U(e)?e:e.contextElement}function ve(e){const t=Ht(e);if(!J(t))return Q(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=gr(t);let s=(i?Ue(n.width):n.width)/r,c=(i?Ue(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const Xs=Q(0);function yr(e){const t=V(e);return!$t()||!t.visualViewport?Xs:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Gs(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==V(e)?!1:t}function ue(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Ht(e);let s=Q(1);t&&(r?U(r)&&(s=ve(r)):s=ve(e));const c=Gs(i,n,r)?yr(i):Q(0);let u=(o.left+c.x)/s.x,l=(o.top+c.y)/s.y,f=o.width/s.x,d=o.height/s.y;if(i){const p=V(i),h=r&&U(r)?V(r):r;let g=p,v=Ct(g);for(;v&&r&&h!==g;){const y=ve(v),w=v.getBoundingClientRect(),b=Y(v),C=w.left+(v.clientLeft+parseFloat(b.paddingLeft))*y.x,x=w.top+(v.clientTop+parseFloat(b.paddingTop))*y.y;u*=y.x,l*=y.y,f*=y.x,d*=y.y,u+=C,l+=x,g=V(v),v=Ct(g)}}return Xe({width:f,height:d,x:u,y:l})}function rt(e,t){const n=nt(e).scrollLeft;return t?t.left+n:ue(te(e)).left+n}function wr(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-rt(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ks(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=te(r),c=t?tt(t.floating):!1;if(r===s||c&&i)return n;let u={scrollLeft:0,scrollTop:0},l=Q(1);const f=Q(0),d=J(r);if((d||!d&&!i)&&((xe(r)!=="body"||Te(s))&&(u=nt(r)),J(r))){const h=ue(r);l=ve(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const p=s&&!d&&!i?wr(s,u):Q(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+f.x+p.x,y:n.y*l.y-u.scrollTop*l.y+f.y+p.y}}function Zs(e){return Array.from(e.getClientRects())}function qs(e){const t=te(e),n=nt(e),r=e.ownerDocument.body,o=H(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=H(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+rt(e);const c=-n.scrollTop;return Y(r).direction==="rtl"&&(s+=H(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:c}}const xn=25;function Qs(e,t){const n=V(e),r=te(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,c=0,u=0;if(o){i=o.width,s=o.height;const f=$t();(!f||f&&t==="fixed")&&(c=o.offsetLeft,u=o.offsetTop)}const l=rt(r);if(l<=0){const f=r.ownerDocument,d=f.body,p=getComputedStyle(d),h=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-d.clientWidth-h);g<=xn&&(i-=g)}else l<=xn&&(i+=l);return{width:i,height:s,x:c,y:u}}const Js=new Set(["absolute","fixed"]);function ec(e,t){const n=ue(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=J(e)?ve(e):Q(1),s=e.clientWidth*i.x,c=e.clientHeight*i.y,u=o*i.x,l=r*i.y;return{width:s,height:c,x:u,y:l}}function Cn(e,t,n){let r;if(t==="viewport")r=Qs(e,n);else if(t==="document")r=qs(te(e));else if(U(t))r=ec(t,n);else{const o=yr(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Xe(r)}function br(e,t){const n=ce(e);return n===t||!U(n)||ge(n)?!1:Y(n).position==="fixed"||br(n,t)}function tc(e,t){const n=t.get(e);if(n)return n;let r=Ee(e,[],!1).filter(c=>U(c)&&xe(c)!=="body"),o=null;const i=Y(e).position==="fixed";let s=i?ce(e):e;for(;U(s)&&!ge(s);){const c=Y(s),u=Wt(s);!u&&c.position==="fixed"&&(o=null),(i?!u&&!o:!u&&c.position==="static"&&!!o&&Js.has(o.position)||Te(s)&&!u&&br(e,s))?r=r.filter(f=>f!==s):o=c,s=ce(s)}return t.set(e,r),r}function nc(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?tt(t)?[]:tc(t,this._c):[].concat(n),r],c=s[0],u=s.reduce((l,f)=>{const d=Cn(t,f,o);return l.top=H(d.top,l.top),l.right=se(d.right,l.right),l.bottom=se(d.bottom,l.bottom),l.left=H(d.left,l.left),l},Cn(t,c,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function rc(e){const{width:t,height:n}=gr(e);return{width:t,height:n}}function oc(e,t,n){const r=J(t),o=te(t),i=n==="fixed",s=ue(e,!0,i,t);let c={scrollLeft:0,scrollTop:0};const u=Q(0);function l(){u.x=rt(o)}if(r||!r&&!i)if((xe(t)!=="body"||Te(o))&&(c=nt(t)),r){const h=ue(t,!0,i,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&l();i&&!r&&o&&l();const f=o&&!r&&!i?wr(o,c):Q(0),d=s.left+c.scrollLeft-u.x-f.x,p=s.top+c.scrollTop-u.y-f.y;return{x:d,y:p,width:s.width,height:s.height}}function mt(e){return Y(e).position==="static"}function Sn(e,t){if(!J(e)||Y(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return te(e)===n&&(n=n.ownerDocument.body),n}function xr(e,t){const n=V(e);if(tt(e))return n;if(!J(e)){let o=ce(e);for(;o&&!ge(o);){if(U(o)&&!mt(o))return o;o=ce(o)}return n}let r=Sn(e,t);for(;r&&$s(r)&&mt(r);)r=Sn(r,t);return r&&ge(r)&&mt(r)&&!Wt(r)?n:r||Us(e)||n}const ic=async function(e){const t=this.getOffsetParent||xr,n=this.getDimensions,r=await n(e.floating);return{reference:oc(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sc(e){return Y(e).direction==="rtl"}const cc={convertOffsetParentRelativeRectToViewportRelativeRect:Ks,getDocumentElement:te,getClippingRect:nc,getOffsetParent:xr,getElementRects:ic,getClientRects:Zs,getDimensions:rc,getScale:ve,isElement:U,isRTL:sc};function Cr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ac(e,t){let n=null,r;const o=te(e);function i(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function s(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),i();const l=e.getBoundingClientRect(),{left:f,top:d,width:p,height:h}=l;if(c||t(),!p||!h)return;const g=ke(d),v=ke(o.clientWidth-(f+p)),y=ke(o.clientHeight-(d+h)),w=ke(f),C={rootMargin:-g+"px "+-v+"px "+-y+"px "+-w+"px",threshold:H(0,se(1,u))||1};let x=!0;function S(P){const E=P[0].intersectionRatio;if(E!==u){if(!x)return s();E?s(!1,E):r=setTimeout(()=>{s(!1,1e-7)},1e3)}E===1&&!Cr(l,e.getBoundingClientRect())&&s(),x=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return s(!0),i}function lc(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=Ht(e),f=o||i?[...l?Ee(l):[],...Ee(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const d=l&&c?ac(l,n):null;let p=-1,h=null;s&&(h=new ResizeObserver(w=>{let[b]=w;b&&b.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=h)==null||C.observe(t)})),n()}),l&&!u&&h.observe(l),h.observe(t));let g,v=u?ue(e):null;u&&y();function y(){const w=ue(e);v&&!Cr(v,w)&&n(),v=w,g=requestAnimationFrame(y)}return n(),()=>{var w;f.forEach(b=>{o&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),d==null||d(),(w=h)==null||w.disconnect(),h=null,u&&cancelAnimationFrame(g)}}const uc=Ms,fc=Is,dc=_s,pc=ks,hc=Ns,En=Ds,vc=js,mc=(e,t,n)=>{const r=new Map,o={platform:cc,...n},i={...o.platform,_c:r};return Os(e,t,{...o,platform:i})};var gc=typeof document<"u",yc=function(){},$e=gc?a.useLayoutEffect:yc;function Ge(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,o;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(!Ge(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ge(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Sr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pn(e,t){const n=Sr(e);return Math.round(t*n)/n}function gt(e){const t=a.useRef(e);return $e(()=>{t.current=e}),t}function wc(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:c=!0,whileElementsMounted:u,open:l}=e,[f,d]=a.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=a.useState(r);Ge(p,r)||h(r);const[g,v]=a.useState(null),[y,w]=a.useState(null),b=a.useCallback(T=>{T!==P.current&&(P.current=T,v(T))},[]),C=a.useCallback(T=>{T!==E.current&&(E.current=T,w(T))},[]),x=i||g,S=s||y,P=a.useRef(null),E=a.useRef(null),O=a.useRef(f),R=u!=null,A=gt(u),D=gt(o),M=gt(l),I=a.useCallback(()=>{if(!P.current||!E.current)return;const T={placement:t,strategy:n,middleware:p};D.current&&(T.platform=D.current),mc(P.current,E.current,T).then(W=>{const K={...W,isPositioned:M.current!==!1};N.current&&!Ge(O.current,K)&&(O.current=K,Rn.flushSync(()=>{d(K)}))})},[p,t,n,D,M]);$e(()=>{l===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(T=>({...T,isPositioned:!1})))},[l]);const N=a.useRef(!1);$e(()=>(N.current=!0,()=>{N.current=!1}),[]),$e(()=>{if(x&&(P.current=x),S&&(E.current=S),x&&S){if(A.current)return A.current(x,S,I);I()}},[x,S,I,A,R]);const $=a.useMemo(()=>({reference:P,floating:E,setReference:b,setFloating:C}),[b,C]),j=a.useMemo(()=>({reference:x,floating:S}),[x,S]),k=a.useMemo(()=>{const T={position:n,left:0,top:0};if(!j.floating)return T;const W=Pn(j.floating,f.x),K=Pn(j.floating,f.y);return c?{...T,transform:"translate("+W+"px, "+K+"px)",...Sr(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:K}},[n,c,j.floating,f.x,f.y]);return a.useMemo(()=>({...f,update:I,refs:$,elements:j,floatingStyles:k}),[f,I,$,j,k])}const bc=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?En({element:r.current,padding:o}).fn(n):{}:r?En({element:r,padding:o}).fn(n):{}}}},xc=(e,t)=>({...uc(e),options:[e,t]}),Cc=(e,t)=>({...fc(e),options:[e,t]}),Sc=(e,t)=>({...vc(e),options:[e,t]}),Ec=(e,t)=>({...dc(e),options:[e,t]}),Pc=(e,t)=>({...pc(e),options:[e,t]}),Rc=(e,t)=>({...hc(e),options:[e,t]}),Ac=(e,t)=>({...bc(e),options:[e,t]});var Tc="Arrow",Er=a.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return m.jsx(L.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});Er.displayName=Tc;var Oc=Er;function Dc(e){const[t,n]=a.useState(void 0);return ne(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,c;if("borderBoxSize"in i){const u=i.borderBoxSize,l=Array.isArray(u)?u[0]:u;s=l.inlineSize,c=l.blockSize}else s=e.offsetWidth,c=e.offsetHeight;n({width:s,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Bt="Popper",[Pr,ot]=Ae(Bt),[_c,Rr]=Pr(Bt),Ar=e=>{const{__scopePopper:t,children:n}=e,[r,o]=a.useState(null);return m.jsx(_c,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ar.displayName=Bt;var Tr="PopperAnchor",Or=a.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Rr(Tr,n),s=a.useRef(null),c=F(t,s),u=a.useRef(null);return a.useEffect(()=>{const l=u.current;u.current=(r==null?void 0:r.current)||s.current,l!==u.current&&i.onAnchorChange(u.current)}),r?null:m.jsx(L.div,{...o,ref:c})});Or.displayName=Tr;var Vt="PopperContent",[Nc,Lc]=Pr(Vt),Dr=a.forwardRef((e,t)=>{var Xt,Gt,Kt,Zt,qt,Qt;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:g,...v}=e,y=Rr(Vt,n),[w,b]=a.useState(null),C=F(t,Ce=>b(Ce)),[x,S]=a.useState(null),P=Dc(x),E=(P==null?void 0:P.width)??0,O=(P==null?void 0:P.height)??0,R=r+(i!=="center"?"-"+i:""),A=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},D=Array.isArray(l)?l:[l],M=D.length>0,I={padding:A,boundary:D.filter(Ic),altBoundary:M},{refs:N,floatingStyles:$,placement:j,isPositioned:k,middlewareData:T}=wc({strategy:"fixed",placement:R,whileElementsMounted:(...Ce)=>lc(...Ce,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[xc({mainAxis:o+O,alignmentAxis:s}),u&&Cc({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Sc():void 0,...I}),u&&Ec({...I}),Pc({...I,apply:({elements:Ce,rects:Jt,availableWidth:so,availableHeight:co})=>{const{width:ao,height:lo}=Jt.reference,_e=Ce.floating.style;_e.setProperty("--radix-popper-available-width",`${so}px`),_e.setProperty("--radix-popper-available-height",`${co}px`),_e.setProperty("--radix-popper-anchor-width",`${ao}px`),_e.setProperty("--radix-popper-anchor-height",`${lo}px`)}}),x&&Ac({element:x,padding:c}),jc({arrowWidth:E,arrowHeight:O}),p&&Rc({strategy:"referenceHidden",...I})]}),[W,K]=Lr(j),De=B(g);ne(()=>{k&&(De==null||De())},[k,De]);const to=(Xt=T.arrow)==null?void 0:Xt.x,no=(Gt=T.arrow)==null?void 0:Gt.y,ro=((Kt=T.arrow)==null?void 0:Kt.centerOffset)!==0,[oo,io]=a.useState();return ne(()=>{w&&io(window.getComputedStyle(w).zIndex)},[w]),m.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:k?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oo,"--radix-popper-transform-origin":[(Zt=T.transformOrigin)==null?void 0:Zt.x,(qt=T.transformOrigin)==null?void 0:qt.y].join(" "),...((Qt=T.hide)==null?void 0:Qt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(Nc,{scope:n,placedSide:W,onArrowChange:S,arrowX:to,arrowY:no,shouldHideArrow:ro,children:m.jsx(L.div,{"data-side":W,"data-align":K,...v,ref:C,style:{...v.style,animation:k?void 0:"none"}})})})});Dr.displayName=Vt;var _r="PopperArrow",Mc={top:"bottom",right:"left",bottom:"top",left:"right"},Nr=a.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Lc(_r,r),s=Mc[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]: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:m.jsx(Oc,{...o,ref:n,style:{...o.style,display:"block"}})})});Nr.displayName=_r;function Ic(e){return e!==null}var jc=e=>({name:"transformOrigin",options:e,fn(t){var y,w,b;const{placement:n,rects:r,middlewareData:o}=t,s=((y=o.arrow)==null?void 0:y.centerOffset)!==0,c=s?0:e.arrowWidth,u=s?0:e.arrowHeight,[l,f]=Lr(n),d={start:"0%",center:"50%",end:"100%"}[f],p=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+u/2;let g="",v="";return l==="bottom"?(g=s?d:`${p}px`,v=`${-u}px`):l==="top"?(g=s?d:`${p}px`,v=`${r.floating.height+u}px`):l==="right"?(g=`${-u}px`,v=s?d:`${h}px`):l==="left"&&(g=`${r.floating.width+u}px`,v=s?d:`${h}px`),{data:{x:g,y:v}}}});function Lr(e){const[t,n="center"]=e.split("-");return[t,n]}var Mr=Ar,zt=Or,Ir=Dr,jr=Nr;function kc(e){const t=Fc(e),n=a.forwardRef((r,o)=>{const{children:i,...s}=r,c=a.Children.toArray(i),u=c.find($c);if(u){const l=u.props.children,f=c.map(d=>d===u?a.Children.count(l)>1?a.Children.only(null):a.isValidElement(l)?l.props.children:null:d);return m.jsx(t,{...s,ref:o,children:a.isValidElement(l)?a.cloneElement(l,void 0,f):null})}return m.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function Fc(e){const t=a.forwardRef((n,r)=>{const{children:o,...i}=n;if(a.isValidElement(o)){const s=Bc(o),c=Hc(i,o.props);return o.type!==a.Fragment&&(c.ref=r?Re(r,s):s),a.cloneElement(o,c)}return a.Children.count(o)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Wc=Symbol("radix.slottable");function $c(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Wc}function Hc(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...c)=>{const u=i(...c);return o(...c),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Bc(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var it="Popover",[kr]=Ae(it,[ot]),Oe=ot(),[Vc,ae]=kr(it),Fr=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,c=Oe(t),u=a.useRef(null),[l,f]=a.useState(!1),[d,p]=Rt({prop:r,defaultProp:o??!1,onChange:i,caller:it});return m.jsx(Mr,{...c,children:m.jsx(Vc,{scope:t,contentId:Se(),triggerRef:u,open:d,onOpenChange:p,onOpenToggle:a.useCallback(()=>p(h=>!h),[p]),hasCustomAnchor:l,onCustomAnchorAdd:a.useCallback(()=>f(!0),[]),onCustomAnchorRemove:a.useCallback(()=>f(!1),[]),modal:s,children:n})})};Fr.displayName=it;var Wr="PopoverAnchor",zc=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ae(Wr,n),i=Oe(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:c}=o;return a.useEffect(()=>(s(),()=>c()),[s,c]),m.jsx(zt,{...i,...r,ref:t})});zc.displayName=Wr;var $r="PopoverTrigger",Hr=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ae($r,n),i=Oe(n),s=F(t,o.triggerRef),c=m.jsx(L.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Yr(o.open),...r,ref:s,onClick:_(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:m.jsx(zt,{asChild:!0,...i,children:c})});Hr.displayName=$r;var Ut="PopoverPortal",[Uc,Yc]=kr(Ut,{forceMount:void 0}),Br=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=ae(Ut,t);return m.jsx(Uc,{scope:t,forceMount:n,children:m.jsx(X,{present:n||i.open,children:m.jsx(Tt,{asChild:!0,container:o,children:r})})})};Br.displayName=Ut;var ye="PopoverContent",Vr=a.forwardRef((e,t)=>{const n=Yc(ye,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=ae(ye,e.__scopePopover);return m.jsx(X,{present:r||i.open,children:i.modal?m.jsx(Gc,{...o,ref:t}):m.jsx(Kc,{...o,ref:t})})});Vr.displayName=ye;var Xc=kc("PopoverContent.RemoveScroll"),Gc=a.forwardRef((e,t)=>{const n=ae(ye,e.__scopePopover),r=a.useRef(null),o=F(t,r),i=a.useRef(!1);return a.useEffect(()=>{const s=r.current;if(s)return $n(s)},[]),m.jsx(Ot,{as:Xc,allowPinchZoom:!0,children:m.jsx(zr,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:_(e.onCloseAutoFocus,s=>{var c;s.preventDefault(),i.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:_(e.onPointerDownOutside,s=>{const c=s.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,l=c.button===2||u;i.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:_(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Kc=a.forwardRef((e,t)=>{const n=ae(ye,e.__scopePopover),r=a.useRef(!1),o=a.useRef(!1);return m.jsx(zr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,c;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var u,l;(u=e.onInteractOutside)==null||u.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((l=n.triggerRef.current)==null?void 0:l.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),zr=a.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:l,onInteractOutside:f,...d}=e,p=ae(ye,n),h=Oe(n);return _n(),m.jsx(At,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:m.jsx(Ke,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1),children:m.jsx(Ir,{"data-state":Yr(p.open),role:"dialog",id:p.contentId,...h,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Ur="PopoverClose",Zc=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ae(Ur,n);return m.jsx(L.button,{type:"button",...r,ref:t,onClick:_(e.onClick,()=>o.onOpenChange(!1))})});Zc.displayName=Ur;var qc="PopoverArrow",Qc=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oe(n);return m.jsx(jr,{...o,...r,ref:t})});Qc.displayName=qc;function Yr(e){return e?"open":"closed"}var ja=Fr,ka=Hr,Fa=Br,Wa=Vr,Jc=Symbol("radix.slottable");function ea(e){const t=({children:n})=>m.jsx(m.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Jc,t}var ta=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"}),na="VisuallyHidden",Xr=a.forwardRef((e,t)=>m.jsx(L.span,{...e,ref:t,style:{...ta,...e.style}}));Xr.displayName=na;var ra=Xr,[st]=Ae("Tooltip",[ot]),ct=ot(),Gr="TooltipProvider",oa=700,St="tooltip.open",[ia,Yt]=st(Gr),Kr=e=>{const{__scopeTooltip:t,delayDuration:n=oa,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,s=a.useRef(!0),c=a.useRef(!1),u=a.useRef(0);return a.useEffect(()=>{const l=u.current;return()=>window.clearTimeout(l)},[]),m.jsx(ia,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:a.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:a.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:a.useCallback(l=>{c.current=l},[]),disableHoverableContent:o,children:i})};Kr.displayName=Gr;var Pe="Tooltip",[sa,at]=st(Pe),Zr=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=Yt(Pe,e.__scopeTooltip),l=ct(t),[f,d]=a.useState(null),p=Se(),h=a.useRef(0),g=s??u.disableHoverableContent,v=c??u.delayDuration,y=a.useRef(!1),[w,b]=Rt({prop:r,defaultProp:o??!1,onChange:E=>{E?(u.onOpen(),document.dispatchEvent(new CustomEvent(St))):u.onClose(),i==null||i(E)},caller:Pe}),C=a.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),x=a.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,b(!0)},[b]),S=a.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),P=a.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,b(!0),h.current=0},v)},[v,b]);return a.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),m.jsx(Mr,{...l,children:m.jsx(sa,{scope:t,contentId:p,open:w,stateAttribute:C,trigger:f,onTriggerChange:d,onTriggerEnter:a.useCallback(()=>{u.isOpenDelayedRef.current?P():x()},[u.isOpenDelayedRef,P,x]),onTriggerLeave:a.useCallback(()=>{g?S():(window.clearTimeout(h.current),h.current=0)},[S,g]),onOpen:x,onClose:S,disableHoverableContent:g,children:n})})};Zr.displayName=Pe;var Et="TooltipTrigger",qr=a.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=at(Et,n),i=Yt(Et,n),s=ct(n),c=a.useRef(null),u=F(t,c,o.onTriggerChange),l=a.useRef(!1),f=a.useRef(!1),d=a.useCallback(()=>l.current=!1,[]);return a.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(zt,{asChild:!0,...s,children:m.jsx(L.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:_(e.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:_(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:_(e.onPointerDown,()=>{o.open&&o.onClose(),l.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:_(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:_(e.onBlur,o.onClose),onClick:_(e.onClick,o.onClose)})})});qr.displayName=Et;var ca="TooltipPortal",[$a,aa]=st(ca,{forceMount:void 0}),we="TooltipContent",Qr=a.forwardRef((e,t)=>{const n=aa(we,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=at(we,e.__scopeTooltip);return m.jsx(X,{present:r||s.open,children:s.disableHoverableContent?m.jsx(Jr,{side:o,...i,ref:t}):m.jsx(la,{side:o,...i,ref:t})})}),la=a.forwardRef((e,t)=>{const n=at(we,e.__scopeTooltip),r=Yt(we,e.__scopeTooltip),o=a.useRef(null),i=F(t,o),[s,c]=a.useState(null),{trigger:u,onClose:l}=n,f=o.current,{onPointerInTransitChange:d}=r,p=a.useCallback(()=>{c(null),d(!1)},[d]),h=a.useCallback((g,v)=>{const y=g.currentTarget,w={x:g.clientX,y:g.clientY},b=ha(w,y.getBoundingClientRect()),C=va(w,b),x=ma(v.getBoundingClientRect()),S=ya([...C,...x]);c(S),d(!0)},[d]);return a.useEffect(()=>()=>p(),[p]),a.useEffect(()=>{if(u&&f){const g=y=>h(y,f),v=y=>h(y,u);return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",v)}}},[u,f,h,p]),a.useEffect(()=>{if(s){const g=v=>{const y=v.target,w={x:v.clientX,y:v.clientY},b=(u==null?void 0:u.contains(y))||(f==null?void 0:f.contains(y)),C=!ga(w,s);b?p():C&&(p(),l())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[u,f,s,l,p]),m.jsx(Jr,{...e,ref:i})}),[ua,fa]=st(Pe,{isInside:!1}),da=ea("TooltipContent"),Jr=a.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=at(we,n),l=ct(n),{onClose:f}=u;return a.useEffect(()=>(document.addEventListener(St,f),()=>document.removeEventListener(St,f)),[f]),a.useEffect(()=>{if(u.trigger){const d=p=>{const h=p.target;h!=null&&h.contains(u.trigger)&&f()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[u.trigger,f]),m.jsx(Ke,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:d=>d.preventDefault(),onDismiss:f,children:m.jsxs(Ir,{"data-state":u.stateAttribute,...l,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(da,{children:r}),m.jsx(ua,{scope:n,isInside:!0,children:m.jsx(ra,{id:u.contentId,role:"tooltip",children:o||r})})]})})});Qr.displayName=we;var eo="TooltipArrow",pa=a.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ct(n);return fa(eo,n).isInside?null:m.jsx(jr,{...o,...r,ref:t})});pa.displayName=eo;function ha(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function va(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ma(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function ga(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],l=c.x,f=c.y,d=u.x,p=u.y;f>r!=p>r&&n<(d-l)*(r-f)/(p-f)+l&&(o=!o)}return o}function ya(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),wa(t)}function wa(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Ha=Kr,Ba=Zr,Va=qr,za=Qr;export{Oa as C,_a as D,Ta as O,Aa as P,Ra as R,xa as S,Da as T,Ma as V,ei as _,Na as a,La as b,Ia as c,ss as d,ds as e,Fa as f,Wa as g,ja as h,ka as i,Ha as j,Ba as k,Va as l,za as m,Ea as n,Ca as o,Sa as p,Z as q,Nn as r};
45
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return a.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ji="DialogDescriptionWarning",es=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tr(Ji).contentName}}.`;return a.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ra=Bn,Aa=Un,Ta=Yn,Oa=Xn,Da=Kn,_a=qn,Na=Jn,ts=a.createContext(void 0);function ns(e){const t=a.useContext(ts);return e||t||"ltr"}function rs(e,[t,n]){return Math.min(n,Math.max(t,e))}function os(e,t){return a.useReducer((n,r)=>t[n][r]??n,e)}var Lt="ScrollArea",[nr]=Ae(Lt),[is,z]=nr(Lt),rr=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...s}=e,[c,u]=a.useState(null),[l,f]=a.useState(null),[d,p]=a.useState(null),[h,g]=a.useState(null),[v,y]=a.useState(null),[w,b]=a.useState(0),[C,x]=a.useState(0),[S,P]=a.useState(!1),[E,O]=a.useState(!1),R=F(t,D=>u(D)),A=ns(o);return m.jsx(is,{scope:n,type:r,dir:A,scrollHideDelay:i,scrollArea:c,viewport:l,onViewportChange:f,content:d,onContentChange:p,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:S,onScrollbarXEnabledChange:P,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:O,onCornerWidthChange:b,onCornerHeightChange:x,children:m.jsx(L.div,{dir:A,...s,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});rr.displayName=Lt;var or="ScrollAreaViewport",ir=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,s=z(or,n),c=a.useRef(null),u=F(t,c,s.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),m.jsx(L.div,{"data-radix-scroll-area-viewport":"",...i,ref:u,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:m.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});ir.displayName=or;var ee="ScrollAreaScrollbar",ss=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=z(ee,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=o,c=e.orientation==="horizontal";return a.useEffect(()=>(c?i(!0):s(!0),()=>{c?i(!1):s(!1)}),[c,i,s]),o.type==="hover"?m.jsx(cs,{...r,ref:t,forceMount:n}):o.type==="scroll"?m.jsx(as,{...r,ref:t,forceMount:n}):o.type==="auto"?m.jsx(sr,{...r,ref:t,forceMount:n}):o.type==="always"?m.jsx(Mt,{...r,ref:t}):null});ss.displayName=ee;var cs=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=z(ee,e.__scopeScrollArea),[i,s]=a.useState(!1);return a.useEffect(()=>{const c=o.scrollArea;let u=0;if(c){const l=()=>{window.clearTimeout(u),s(!0)},f=()=>{u=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",l),c.addEventListener("pointerleave",f),()=>{window.clearTimeout(u),c.removeEventListener("pointerenter",l),c.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),m.jsx(X,{present:n||i,children:m.jsx(sr,{"data-state":i?"visible":"hidden",...r,ref:t})})}),as=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=z(ee,e.__scopeScrollArea),i=e.orientation==="horizontal",s=Je(()=>u("SCROLL_END"),100),[c,u]=os("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return a.useEffect(()=>{if(c==="idle"){const l=window.setTimeout(()=>u("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(l)}},[c,o.scrollHideDelay,u]),a.useEffect(()=>{const l=o.viewport,f=i?"scrollLeft":"scrollTop";if(l){let d=l[f];const p=()=>{const h=l[f];d!==h&&(u("SCROLL"),s()),d=h};return l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[o.viewport,i,u,s]),m.jsx(X,{present:n||c!=="hidden",children:m.jsx(Mt,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:_(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:_(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),sr=a.forwardRef((e,t)=>{const n=z(ee,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,s]=a.useState(!1),c=e.orientation==="horizontal",u=Je(()=>{if(n.viewport){const l=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;s(c?l:f)}},10);return me(n.viewport,u),me(n.content,u),m.jsx(X,{present:r||i,children:m.jsx(Mt,{"data-state":i?"visible":"hidden",...o,ref:t})})}),Mt=a.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=z(ee,e.__scopeScrollArea),i=a.useRef(null),s=a.useRef(0),[c,u]=a.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=ur(c.viewport,c.content),f={...r,sizes:c,onSizesChange:u,hasThumb:l>0&&l<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function d(p,h){return vs(p,s.current,c,h)}return n==="horizontal"?m.jsx(ls,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,h=hn(p,c,o.dir);i.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=d(p,o.dir))}}):n==="vertical"?m.jsx(us,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,h=hn(p,c);i.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=d(p))}}):null}),ls=a.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=z(ee,e.__scopeScrollArea),[s,c]=a.useState(),u=a.useRef(null),l=F(t,u,i.onScrollbarXChange);return a.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),m.jsx(ar,{"data-orientation":"horizontal",...o,ref:l,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qe(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,d)=>{if(i.viewport){const p=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),dr(p,d)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&s&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:ze(s.paddingLeft),paddingEnd:ze(s.paddingRight)}})}})}),us=a.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=z(ee,e.__scopeScrollArea),[s,c]=a.useState(),u=a.useRef(null),l=F(t,u,i.onScrollbarYChange);return a.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),m.jsx(ar,{"data-orientation":"vertical",...o,ref:l,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qe(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,d)=>{if(i.viewport){const p=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),dr(p,d)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&s&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:ze(s.paddingTop),paddingEnd:ze(s.paddingBottom)}})}})}),[fs,cr]=nr(ee),ar=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:c,onThumbPositionChange:u,onDragScroll:l,onWheelScroll:f,onResize:d,...p}=e,h=z(ee,n),[g,v]=a.useState(null),y=F(t,R=>v(R)),w=a.useRef(null),b=a.useRef(""),C=h.viewport,x=r.content-r.viewport,S=B(f),P=B(u),E=Je(d,10);function O(R){if(w.current){const A=R.clientX-w.current.left,D=R.clientY-w.current.top;l({x:A,y:D})}}return a.useEffect(()=>{const R=A=>{const D=A.target;(g==null?void 0:g.contains(D))&&S(A,x)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,g,x,S]),a.useEffect(P,[r,P]),me(g,E),me(h.content,E),m.jsx(fs,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:B(i),onThumbPointerUp:B(s),onThumbPositionChange:P,onThumbPointerDown:B(c),children:m.jsx(L.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:_(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),w.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),O(R))}),onPointerMove:_(e.onPointerMove,O),onPointerUp:_(e.onPointerUp,R=>{const A=R.target;A.hasPointerCapture(R.pointerId)&&A.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Ve="ScrollAreaThumb",ds=a.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=cr(Ve,e.__scopeScrollArea);return m.jsx(X,{present:n||o.hasThumb,children:m.jsx(ps,{ref:t,...r})})}),ps=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=z(Ve,n),s=cr(Ve,n),{onThumbPositionChange:c}=s,u=F(t,d=>s.onThumbChange(d)),l=a.useRef(void 0),f=Je(()=>{l.current&&(l.current(),l.current=void 0)},100);return a.useEffect(()=>{const d=i.viewport;if(d){const p=()=>{if(f(),!l.current){const h=ms(d,c);l.current=h,c()}};return c(),d.addEventListener("scroll",p),()=>d.removeEventListener("scroll",p)}},[i.viewport,f,c]),m.jsx(L.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:_(e.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),g=d.clientX-h.left,v=d.clientY-h.top;s.onThumbPointerDown({x:g,y:v})}),onPointerUp:_(e.onPointerUp,s.onThumbPointerUp)})});ds.displayName=Ve;var It="ScrollAreaCorner",lr=a.forwardRef((e,t)=>{const n=z(It,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?m.jsx(hs,{...e,ref:t}):null});lr.displayName=It;var hs=a.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=z(It,n),[i,s]=a.useState(0),[c,u]=a.useState(0),l=!!(i&&c);return me(o.scrollbarX,()=>{var d;const f=((d=o.scrollbarX)==null?void 0:d.offsetHeight)||0;o.onCornerHeightChange(f),u(f)}),me(o.scrollbarY,()=>{var d;const f=((d=o.scrollbarY)==null?void 0:d.offsetWidth)||0;o.onCornerWidthChange(f),s(f)}),l?m.jsx(L.div,{...r,ref:t,style:{width:i,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ze(e){return e?parseInt(e,10):0}function ur(e,t){const n=e/t;return isNaN(n)?0:n}function Qe(e){const t=ur(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function vs(e,t,n,r="ltr"){const o=Qe(n),i=o/2,s=t||i,c=o-s,u=n.scrollbar.paddingStart+s,l=n.scrollbar.size-n.scrollbar.paddingEnd-c,f=n.content-n.viewport,d=r==="ltr"?[0,f]:[f*-1,0];return fr([u,l],d)(e)}function hn(e,t,n="ltr"){const r=Qe(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,c=i-r,u=n==="ltr"?[0,s]:[s*-1,0],l=rs(e,u);return fr([0,s],[0,c])(l)}function fr(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function dr(e,t){return e>0&&e<t}var ms=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const i={left:e.scrollLeft,top:e.scrollTop},s=n.left!==i.left,c=n.top!==i.top;(s||c)&&t(),n=i,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Je(e,t){const n=B(e),r=a.useRef(0);return a.useEffect(()=>()=>window.clearTimeout(r.current),[]),a.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function me(e,t){const n=B(t);ne(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var La=rr,Ma=ir,Ia=lr;const gs=["top","right","bottom","left"],se=Math.min,H=Math.max,Ue=Math.round,ke=Math.floor,Q=e=>({x:e,y:e}),ys={left:"right",right:"left",bottom:"top",top:"bottom"},ws={start:"end",end:"start"};function bt(e,t,n){return H(e,se(t,n))}function re(e,t){return typeof e=="function"?e(t):e}function oe(e){return e.split("-")[0]}function be(e){return e.split("-")[1]}function jt(e){return e==="x"?"y":"x"}function kt(e){return e==="y"?"height":"width"}const bs=new Set(["top","bottom"]);function q(e){return bs.has(oe(e))?"y":"x"}function Ft(e){return jt(q(e))}function xs(e,t,n){n===void 0&&(n=!1);const r=be(e),o=Ft(e),i=kt(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Ye(s)),[s,Ye(s)]}function Cs(e){const t=Ye(e);return[xt(e),t,xt(t)]}function xt(e){return e.replace(/start|end/g,t=>ws[t])}const vn=["left","right"],mn=["right","left"],Ss=["top","bottom"],Es=["bottom","top"];function Ps(e,t,n){switch(e){case"top":case"bottom":return n?t?mn:vn:t?vn:mn;case"left":case"right":return t?Ss:Es;default:return[]}}function Rs(e,t,n,r){const o=be(e);let i=Ps(oe(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(xt)))),i}function Ye(e){return e.replace(/left|right|bottom|top/g,t=>ys[t])}function As(e){return{top:0,right:0,bottom:0,left:0,...e}}function pr(e){return typeof e!="number"?As(e):{top:e,right:e,bottom:e,left:e}}function Xe(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function gn(e,t,n){let{reference:r,floating:o}=e;const i=q(t),s=Ft(t),c=kt(s),u=oe(t),l=i==="y",f=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,p=r[c]/2-o[c]/2;let h;switch(u){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(be(t)){case"start":h[s]-=p*(n&&l?-1:1);break;case"end":h[s]+=p*(n&&l?-1:1);break}return h}async function Ts(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:c,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=re(t,e),g=pr(h),y=c[p?d==="floating"?"reference":"floating":d],w=Xe(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:u})),b=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),x=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},S=Xe(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:C,strategy:u}):b);return{top:(w.top-S.top+g.top)/x.y,bottom:(S.bottom-w.bottom+g.bottom)/x.y,left:(w.left-S.left+g.left)/x.x,right:(S.right-w.right+g.right)/x.x}}const Os=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,c=i.filter(Boolean),u=await(s.isRTL==null?void 0:s.isRTL(t));let l=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:d}=gn(l,r,u),p=r,h={},g=0;for(let y=0;y<c.length;y++){var v;const{name:w,fn:b}=c[y],{x:C,y:x,data:S,reset:P}=await b({x:f,y:d,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:l,platform:{...s,detectOverflow:(v=s.detectOverflow)!=null?v:Ts},elements:{reference:e,floating:t}});f=C??f,d=x??d,h={...h,[w]:{...h[w],...S}},P&&g<=50&&(g++,typeof P=="object"&&(P.placement&&(p=P.placement),P.rects&&(l=P.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):P.rects),{x:f,y:d}=gn(l,p,u)),y=-1)}return{x:f,y:d,placement:p,strategy:o,middlewareData:h}},Ds=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:c,middlewareData:u}=t,{element:l,padding:f=0}=re(e,t)||{};if(l==null)return{};const d=pr(f),p={x:n,y:r},h=Ft(o),g=kt(h),v=await s.getDimensions(l),y=h==="y",w=y?"top":"left",b=y?"bottom":"right",C=y?"clientHeight":"clientWidth",x=i.reference[g]+i.reference[h]-p[h]-i.floating[g],S=p[h]-i.reference[h],P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let E=P?P[C]:0;(!E||!await(s.isElement==null?void 0:s.isElement(P)))&&(E=c.floating[C]||i.floating[g]);const O=x/2-S/2,R=E/2-v[g]/2-1,A=se(d[w],R),D=se(d[b],R),M=A,I=E-v[g]-D,N=E/2-v[g]/2+O,$=bt(M,N,I),j=!u.arrow&&be(o)!=null&&N!==$&&i.reference[g]/2-(N<M?A:D)-v[g]/2<0,k=j?N<M?N-M:N-I:0;return{[h]:p[h]+k,data:{[h]:$,centerOffset:N-$-k,...j&&{alignmentOffset:k}},reset:j}}}),_s=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:c,platform:u,elements:l}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...y}=re(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=oe(o),b=q(c),C=oe(c)===c,x=await(u.isRTL==null?void 0:u.isRTL(l.floating)),S=p||(C||!v?[Ye(c)]:Cs(c)),P=g!=="none";!p&&P&&S.push(...Rs(c,v,g,x));const E=[c,...S],O=await u.detectOverflow(t,y),R=[];let A=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&R.push(O[w]),d){const N=xs(o,s,x);R.push(O[N[0]],O[N[1]])}if(A=[...A,{placement:o,overflows:R}],!R.every(N=>N<=0)){var D,M;const N=(((D=i.flip)==null?void 0:D.index)||0)+1,$=E[N];if($&&(!(d==="alignment"?b!==q($):!1)||A.every(T=>q(T.placement)===b?T.overflows[0]>0:!0)))return{data:{index:N,overflows:A},reset:{placement:$}};let j=(M=A.filter(k=>k.overflows[0]<=0).sort((k,T)=>k.overflows[1]-T.overflows[1])[0])==null?void 0:M.placement;if(!j)switch(h){case"bestFit":{var I;const k=(I=A.filter(T=>{if(P){const W=q(T.placement);return W===b||W==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(W=>W>0).reduce((W,K)=>W+K,0)]).sort((T,W)=>T[1]-W[1])[0])==null?void 0:I[0];k&&(j=k);break}case"initialPlacement":j=c;break}if(o!==j)return{reset:{placement:j}}}return{}}}};function yn(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wn(e){return gs.some(t=>e[t]>=0)}const Ns=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=re(e,t);switch(o){case"referenceHidden":{const s=await r.detectOverflow(t,{...i,elementContext:"reference"}),c=yn(s,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:wn(c)}}}case"escaped":{const s=await r.detectOverflow(t,{...i,altBoundary:!0}),c=yn(s,n.floating);return{data:{escapedOffsets:c,escaped:wn(c)}}}default:return{}}}}},hr=new Set(["left","top"]);async function Ls(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=oe(n),c=be(n),u=q(n)==="y",l=hr.has(s)?-1:1,f=i&&u?-1:1,d=re(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),u?{x:h*f,y:p*l}:{x:p*l,y:h*f}}const Ms=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:c}=t,u=await Ls(t,e);return s===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},Is=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:s=!0,crossAxis:c=!1,limiter:u={fn:w=>{let{x:b,y:C}=w;return{x:b,y:C}}},...l}=re(e,t),f={x:n,y:r},d=await i.detectOverflow(t,l),p=q(oe(o)),h=jt(p);let g=f[h],v=f[p];if(s){const w=h==="y"?"top":"left",b=h==="y"?"bottom":"right",C=g+d[w],x=g-d[b];g=bt(C,g,x)}if(c){const w=p==="y"?"top":"left",b=p==="y"?"bottom":"right",C=v+d[w],x=v-d[b];v=bt(C,v,x)}const y=u.fn({...t,[h]:g,[p]:v});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[p]:c}}}}}},js=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:c=0,mainAxis:u=!0,crossAxis:l=!0}=re(e,t),f={x:n,y:r},d=q(o),p=jt(d);let h=f[p],g=f[d];const v=re(c,t),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const C=p==="y"?"height":"width",x=i.reference[p]-i.floating[C]+y.mainAxis,S=i.reference[p]+i.reference[C]-y.mainAxis;h<x?h=x:h>S&&(h=S)}if(l){var w,b;const C=p==="y"?"width":"height",x=hr.has(oe(o)),S=i.reference[d]-i.floating[C]+(x&&((w=s.offset)==null?void 0:w[d])||0)+(x?0:y.crossAxis),P=i.reference[d]+i.reference[C]+(x?0:((b=s.offset)==null?void 0:b[d])||0)-(x?y.crossAxis:0);g<S?g=S:g>P&&(g=P)}return{[p]:h,[d]:g}}}},ks=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:c}=t,{apply:u=()=>{},...l}=re(e,t),f=await s.detectOverflow(t,l),d=oe(o),p=be(o),h=q(o)==="y",{width:g,height:v}=i.floating;let y,w;d==="top"||d==="bottom"?(y=d,w=p===(await(s.isRTL==null?void 0:s.isRTL(c.floating))?"start":"end")?"left":"right"):(w=d,y=p==="end"?"top":"bottom");const b=v-f.top-f.bottom,C=g-f.left-f.right,x=se(v-f[y],b),S=se(g-f[w],C),P=!t.middlewareData.shift;let E=x,O=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),P&&!p){const A=H(f.left,0),D=H(f.right,0),M=H(f.top,0),I=H(f.bottom,0);h?O=g-2*(A!==0||D!==0?A+D:H(f.left,f.right)):E=v-2*(M!==0||I!==0?M+I:H(f.top,f.bottom))}await u({...t,availableWidth:O,availableHeight:E});const R=await s.getDimensions(c.floating);return g!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function et(){return typeof window<"u"}function xe(e){return vr(e)?(e.nodeName||"").toLowerCase():"#document"}function V(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function te(e){var t;return(t=(vr(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vr(e){return et()?e instanceof Node||e instanceof V(e).Node:!1}function U(e){return et()?e instanceof Element||e instanceof V(e).Element:!1}function J(e){return et()?e instanceof HTMLElement||e instanceof V(e).HTMLElement:!1}function bn(e){return!et()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof V(e).ShadowRoot}const Fs=new Set(["inline","contents"]);function Te(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Fs.has(o)}const Ws=new Set(["table","td","th"]);function $s(e){return Ws.has(xe(e))}const Hs=[":popover-open",":modal"];function tt(e){return Hs.some(t=>{try{return e.matches(t)}catch{return!1}})}const Bs=["transform","translate","scale","rotate","perspective"],Vs=["transform","translate","scale","rotate","perspective","filter"],zs=["paint","layout","strict","content"];function Wt(e){const t=$t(),n=U(e)?Y(e):e;return Bs.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Vs.some(r=>(n.willChange||"").includes(r))||zs.some(r=>(n.contain||"").includes(r))}function Us(e){let t=ce(e);for(;J(t)&&!ge(t);){if(Wt(t))return t;if(tt(t))return null;t=ce(t)}return null}function $t(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ys=new Set(["html","body","#document"]);function ge(e){return Ys.has(xe(e))}function Y(e){return V(e).getComputedStyle(e)}function nt(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ce(e){if(xe(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bn(e)&&e.host||te(e);return bn(t)?t.host:t}function mr(e){const t=ce(e);return ge(t)?e.ownerDocument?e.ownerDocument.body:e.body:J(t)&&Te(t)?t:mr(t)}function Ee(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=mr(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=V(o);if(i){const c=Ct(s);return t.concat(s,s.visualViewport||[],Te(o)?o:[],c&&n?Ee(c):[])}return t.concat(o,Ee(o,[],n))}function Ct(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gr(e){const t=Y(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=J(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,c=Ue(n)!==i||Ue(r)!==s;return c&&(n=i,r=s),{width:n,height:r,$:c}}function Ht(e){return U(e)?e:e.contextElement}function ve(e){const t=Ht(e);if(!J(t))return Q(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=gr(t);let s=(i?Ue(n.width):n.width)/r,c=(i?Ue(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const Xs=Q(0);function yr(e){const t=V(e);return!$t()||!t.visualViewport?Xs:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Gs(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==V(e)?!1:t}function ue(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Ht(e);let s=Q(1);t&&(r?U(r)&&(s=ve(r)):s=ve(e));const c=Gs(i,n,r)?yr(i):Q(0);let u=(o.left+c.x)/s.x,l=(o.top+c.y)/s.y,f=o.width/s.x,d=o.height/s.y;if(i){const p=V(i),h=r&&U(r)?V(r):r;let g=p,v=Ct(g);for(;v&&r&&h!==g;){const y=ve(v),w=v.getBoundingClientRect(),b=Y(v),C=w.left+(v.clientLeft+parseFloat(b.paddingLeft))*y.x,x=w.top+(v.clientTop+parseFloat(b.paddingTop))*y.y;u*=y.x,l*=y.y,f*=y.x,d*=y.y,u+=C,l+=x,g=V(v),v=Ct(g)}}return Xe({width:f,height:d,x:u,y:l})}function rt(e,t){const n=nt(e).scrollLeft;return t?t.left+n:ue(te(e)).left+n}function wr(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-rt(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ks(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=te(r),c=t?tt(t.floating):!1;if(r===s||c&&i)return n;let u={scrollLeft:0,scrollTop:0},l=Q(1);const f=Q(0),d=J(r);if((d||!d&&!i)&&((xe(r)!=="body"||Te(s))&&(u=nt(r)),J(r))){const h=ue(r);l=ve(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const p=s&&!d&&!i?wr(s,u):Q(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+f.x+p.x,y:n.y*l.y-u.scrollTop*l.y+f.y+p.y}}function Zs(e){return Array.from(e.getClientRects())}function qs(e){const t=te(e),n=nt(e),r=e.ownerDocument.body,o=H(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=H(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+rt(e);const c=-n.scrollTop;return Y(r).direction==="rtl"&&(s+=H(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:c}}const xn=25;function Qs(e,t){const n=V(e),r=te(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,c=0,u=0;if(o){i=o.width,s=o.height;const f=$t();(!f||f&&t==="fixed")&&(c=o.offsetLeft,u=o.offsetTop)}const l=rt(r);if(l<=0){const f=r.ownerDocument,d=f.body,p=getComputedStyle(d),h=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-d.clientWidth-h);g<=xn&&(i-=g)}else l<=xn&&(i+=l);return{width:i,height:s,x:c,y:u}}const Js=new Set(["absolute","fixed"]);function ec(e,t){const n=ue(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=J(e)?ve(e):Q(1),s=e.clientWidth*i.x,c=e.clientHeight*i.y,u=o*i.x,l=r*i.y;return{width:s,height:c,x:u,y:l}}function Cn(e,t,n){let r;if(t==="viewport")r=Qs(e,n);else if(t==="document")r=qs(te(e));else if(U(t))r=ec(t,n);else{const o=yr(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Xe(r)}function br(e,t){const n=ce(e);return n===t||!U(n)||ge(n)?!1:Y(n).position==="fixed"||br(n,t)}function tc(e,t){const n=t.get(e);if(n)return n;let r=Ee(e,[],!1).filter(c=>U(c)&&xe(c)!=="body"),o=null;const i=Y(e).position==="fixed";let s=i?ce(e):e;for(;U(s)&&!ge(s);){const c=Y(s),u=Wt(s);!u&&c.position==="fixed"&&(o=null),(i?!u&&!o:!u&&c.position==="static"&&!!o&&Js.has(o.position)||Te(s)&&!u&&br(e,s))?r=r.filter(f=>f!==s):o=c,s=ce(s)}return t.set(e,r),r}function nc(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?tt(t)?[]:tc(t,this._c):[].concat(n),r],c=s[0],u=s.reduce((l,f)=>{const d=Cn(t,f,o);return l.top=H(d.top,l.top),l.right=se(d.right,l.right),l.bottom=se(d.bottom,l.bottom),l.left=H(d.left,l.left),l},Cn(t,c,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function rc(e){const{width:t,height:n}=gr(e);return{width:t,height:n}}function oc(e,t,n){const r=J(t),o=te(t),i=n==="fixed",s=ue(e,!0,i,t);let c={scrollLeft:0,scrollTop:0};const u=Q(0);function l(){u.x=rt(o)}if(r||!r&&!i)if((xe(t)!=="body"||Te(o))&&(c=nt(t)),r){const h=ue(t,!0,i,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&l();i&&!r&&o&&l();const f=o&&!r&&!i?wr(o,c):Q(0),d=s.left+c.scrollLeft-u.x-f.x,p=s.top+c.scrollTop-u.y-f.y;return{x:d,y:p,width:s.width,height:s.height}}function mt(e){return Y(e).position==="static"}function Sn(e,t){if(!J(e)||Y(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return te(e)===n&&(n=n.ownerDocument.body),n}function xr(e,t){const n=V(e);if(tt(e))return n;if(!J(e)){let o=ce(e);for(;o&&!ge(o);){if(U(o)&&!mt(o))return o;o=ce(o)}return n}let r=Sn(e,t);for(;r&&$s(r)&&mt(r);)r=Sn(r,t);return r&&ge(r)&&mt(r)&&!Wt(r)?n:r||Us(e)||n}const ic=async function(e){const t=this.getOffsetParent||xr,n=this.getDimensions,r=await n(e.floating);return{reference:oc(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sc(e){return Y(e).direction==="rtl"}const cc={convertOffsetParentRelativeRectToViewportRelativeRect:Ks,getDocumentElement:te,getClippingRect:nc,getOffsetParent:xr,getElementRects:ic,getClientRects:Zs,getDimensions:rc,getScale:ve,isElement:U,isRTL:sc};function Cr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ac(e,t){let n=null,r;const o=te(e);function i(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function s(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),i();const l=e.getBoundingClientRect(),{left:f,top:d,width:p,height:h}=l;if(c||t(),!p||!h)return;const g=ke(d),v=ke(o.clientWidth-(f+p)),y=ke(o.clientHeight-(d+h)),w=ke(f),C={rootMargin:-g+"px "+-v+"px "+-y+"px "+-w+"px",threshold:H(0,se(1,u))||1};let x=!0;function S(P){const E=P[0].intersectionRatio;if(E!==u){if(!x)return s();E?s(!1,E):r=setTimeout(()=>{s(!1,1e-7)},1e3)}E===1&&!Cr(l,e.getBoundingClientRect())&&s(),x=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return s(!0),i}function lc(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=Ht(e),f=o||i?[...l?Ee(l):[],...Ee(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const d=l&&c?ac(l,n):null;let p=-1,h=null;s&&(h=new ResizeObserver(w=>{let[b]=w;b&&b.target===l&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=h)==null||C.observe(t)})),n()}),l&&!u&&h.observe(l),h.observe(t));let g,v=u?ue(e):null;u&&y();function y(){const w=ue(e);v&&!Cr(v,w)&&n(),v=w,g=requestAnimationFrame(y)}return n(),()=>{var w;f.forEach(b=>{o&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),d==null||d(),(w=h)==null||w.disconnect(),h=null,u&&cancelAnimationFrame(g)}}const uc=Ms,fc=Is,dc=_s,pc=ks,hc=Ns,En=Ds,vc=js,mc=(e,t,n)=>{const r=new Map,o={platform:cc,...n},i={...o.platform,_c:r};return Os(e,t,{...o,platform:i})};var gc=typeof document<"u",yc=function(){},$e=gc?a.useLayoutEffect:yc;function Ge(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,o;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(!Ge(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ge(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Sr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pn(e,t){const n=Sr(e);return Math.round(t*n)/n}function gt(e){const t=a.useRef(e);return $e(()=>{t.current=e}),t}function wc(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:c=!0,whileElementsMounted:u,open:l}=e,[f,d]=a.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=a.useState(r);Ge(p,r)||h(r);const[g,v]=a.useState(null),[y,w]=a.useState(null),b=a.useCallback(T=>{T!==P.current&&(P.current=T,v(T))},[]),C=a.useCallback(T=>{T!==E.current&&(E.current=T,w(T))},[]),x=i||g,S=s||y,P=a.useRef(null),E=a.useRef(null),O=a.useRef(f),R=u!=null,A=gt(u),D=gt(o),M=gt(l),I=a.useCallback(()=>{if(!P.current||!E.current)return;const T={placement:t,strategy:n,middleware:p};D.current&&(T.platform=D.current),mc(P.current,E.current,T).then(W=>{const K={...W,isPositioned:M.current!==!1};N.current&&!Ge(O.current,K)&&(O.current=K,Rn.flushSync(()=>{d(K)}))})},[p,t,n,D,M]);$e(()=>{l===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(T=>({...T,isPositioned:!1})))},[l]);const N=a.useRef(!1);$e(()=>(N.current=!0,()=>{N.current=!1}),[]),$e(()=>{if(x&&(P.current=x),S&&(E.current=S),x&&S){if(A.current)return A.current(x,S,I);I()}},[x,S,I,A,R]);const $=a.useMemo(()=>({reference:P,floating:E,setReference:b,setFloating:C}),[b,C]),j=a.useMemo(()=>({reference:x,floating:S}),[x,S]),k=a.useMemo(()=>{const T={position:n,left:0,top:0};if(!j.floating)return T;const W=Pn(j.floating,f.x),K=Pn(j.floating,f.y);return c?{...T,transform:"translate("+W+"px, "+K+"px)",...Sr(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:K}},[n,c,j.floating,f.x,f.y]);return a.useMemo(()=>({...f,update:I,refs:$,elements:j,floatingStyles:k}),[f,I,$,j,k])}const bc=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?En({element:r.current,padding:o}).fn(n):{}:r?En({element:r,padding:o}).fn(n):{}}}},xc=(e,t)=>({...uc(e),options:[e,t]}),Cc=(e,t)=>({...fc(e),options:[e,t]}),Sc=(e,t)=>({...vc(e),options:[e,t]}),Ec=(e,t)=>({...dc(e),options:[e,t]}),Pc=(e,t)=>({...pc(e),options:[e,t]}),Rc=(e,t)=>({...hc(e),options:[e,t]}),Ac=(e,t)=>({...bc(e),options:[e,t]});var Tc="Arrow",Er=a.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return m.jsx(L.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});Er.displayName=Tc;var Oc=Er;function Dc(e){const[t,n]=a.useState(void 0);return ne(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,c;if("borderBoxSize"in i){const u=i.borderBoxSize,l=Array.isArray(u)?u[0]:u;s=l.inlineSize,c=l.blockSize}else s=e.offsetWidth,c=e.offsetHeight;n({width:s,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Bt="Popper",[Pr,ot]=Ae(Bt),[_c,Rr]=Pr(Bt),Ar=e=>{const{__scopePopper:t,children:n}=e,[r,o]=a.useState(null);return m.jsx(_c,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ar.displayName=Bt;var Tr="PopperAnchor",Or=a.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Rr(Tr,n),s=a.useRef(null),c=F(t,s),u=a.useRef(null);return a.useEffect(()=>{const l=u.current;u.current=(r==null?void 0:r.current)||s.current,l!==u.current&&i.onAnchorChange(u.current)}),r?null:m.jsx(L.div,{...o,ref:c})});Or.displayName=Tr;var Vt="PopperContent",[Nc,Lc]=Pr(Vt),Dr=a.forwardRef((e,t)=>{var Xt,Gt,Kt,Zt,qt,Qt;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:g,...v}=e,y=Rr(Vt,n),[w,b]=a.useState(null),C=F(t,Ce=>b(Ce)),[x,S]=a.useState(null),P=Dc(x),E=(P==null?void 0:P.width)??0,O=(P==null?void 0:P.height)??0,R=r+(i!=="center"?"-"+i:""),A=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},D=Array.isArray(l)?l:[l],M=D.length>0,I={padding:A,boundary:D.filter(Ic),altBoundary:M},{refs:N,floatingStyles:$,placement:j,isPositioned:k,middlewareData:T}=wc({strategy:"fixed",placement:R,whileElementsMounted:(...Ce)=>lc(...Ce,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[xc({mainAxis:o+O,alignmentAxis:s}),u&&Cc({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Sc():void 0,...I}),u&&Ec({...I}),Pc({...I,apply:({elements:Ce,rects:Jt,availableWidth:so,availableHeight:co})=>{const{width:ao,height:lo}=Jt.reference,_e=Ce.floating.style;_e.setProperty("--radix-popper-available-width",`${so}px`),_e.setProperty("--radix-popper-available-height",`${co}px`),_e.setProperty("--radix-popper-anchor-width",`${ao}px`),_e.setProperty("--radix-popper-anchor-height",`${lo}px`)}}),x&&Ac({element:x,padding:c}),jc({arrowWidth:E,arrowHeight:O}),p&&Rc({strategy:"referenceHidden",...I})]}),[W,K]=Lr(j),De=B(g);ne(()=>{k&&(De==null||De())},[k,De]);const to=(Xt=T.arrow)==null?void 0:Xt.x,no=(Gt=T.arrow)==null?void 0:Gt.y,ro=((Kt=T.arrow)==null?void 0:Kt.centerOffset)!==0,[oo,io]=a.useState();return ne(()=>{w&&io(window.getComputedStyle(w).zIndex)},[w]),m.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:k?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oo,"--radix-popper-transform-origin":[(Zt=T.transformOrigin)==null?void 0:Zt.x,(qt=T.transformOrigin)==null?void 0:qt.y].join(" "),...((Qt=T.hide)==null?void 0:Qt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(Nc,{scope:n,placedSide:W,onArrowChange:S,arrowX:to,arrowY:no,shouldHideArrow:ro,children:m.jsx(L.div,{"data-side":W,"data-align":K,...v,ref:C,style:{...v.style,animation:k?void 0:"none"}})})})});Dr.displayName=Vt;var _r="PopperArrow",Mc={top:"bottom",right:"left",bottom:"top",left:"right"},Nr=a.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=Lc(_r,r),s=Mc[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]: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:m.jsx(Oc,{...o,ref:n,style:{...o.style,display:"block"}})})});Nr.displayName=_r;function Ic(e){return e!==null}var jc=e=>({name:"transformOrigin",options:e,fn(t){var y,w,b;const{placement:n,rects:r,middlewareData:o}=t,s=((y=o.arrow)==null?void 0:y.centerOffset)!==0,c=s?0:e.arrowWidth,u=s?0:e.arrowHeight,[l,f]=Lr(n),d={start:"0%",center:"50%",end:"100%"}[f],p=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+u/2;let g="",v="";return l==="bottom"?(g=s?d:`${p}px`,v=`${-u}px`):l==="top"?(g=s?d:`${p}px`,v=`${r.floating.height+u}px`):l==="right"?(g=`${-u}px`,v=s?d:`${h}px`):l==="left"&&(g=`${r.floating.width+u}px`,v=s?d:`${h}px`),{data:{x:g,y:v}}}});function Lr(e){const[t,n="center"]=e.split("-");return[t,n]}var Mr=Ar,zt=Or,Ir=Dr,jr=Nr;function kc(e){const t=Fc(e),n=a.forwardRef((r,o)=>{const{children:i,...s}=r,c=a.Children.toArray(i),u=c.find($c);if(u){const l=u.props.children,f=c.map(d=>d===u?a.Children.count(l)>1?a.Children.only(null):a.isValidElement(l)?l.props.children:null:d);return m.jsx(t,{...s,ref:o,children:a.isValidElement(l)?a.cloneElement(l,void 0,f):null})}return m.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function Fc(e){const t=a.forwardRef((n,r)=>{const{children:o,...i}=n;if(a.isValidElement(o)){const s=Bc(o),c=Hc(i,o.props);return o.type!==a.Fragment&&(c.ref=r?Re(r,s):s),a.cloneElement(o,c)}return a.Children.count(o)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Wc=Symbol("radix.slottable");function $c(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Wc}function Hc(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...c)=>{const u=i(...c);return o(...c),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Bc(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var it="Popover",[kr]=Ae(it,[ot]),Oe=ot(),[Vc,ae]=kr(it),Fr=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,c=Oe(t),u=a.useRef(null),[l,f]=a.useState(!1),[d,p]=Rt({prop:r,defaultProp:o??!1,onChange:i,caller:it});return m.jsx(Mr,{...c,children:m.jsx(Vc,{scope:t,contentId:Se(),triggerRef:u,open:d,onOpenChange:p,onOpenToggle:a.useCallback(()=>p(h=>!h),[p]),hasCustomAnchor:l,onCustomAnchorAdd:a.useCallback(()=>f(!0),[]),onCustomAnchorRemove:a.useCallback(()=>f(!1),[]),modal:s,children:n})})};Fr.displayName=it;var Wr="PopoverAnchor",zc=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ae(Wr,n),i=Oe(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:c}=o;return a.useEffect(()=>(s(),()=>c()),[s,c]),m.jsx(zt,{...i,...r,ref:t})});zc.displayName=Wr;var $r="PopoverTrigger",Hr=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ae($r,n),i=Oe(n),s=F(t,o.triggerRef),c=m.jsx(L.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Yr(o.open),...r,ref:s,onClick:_(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:m.jsx(zt,{asChild:!0,...i,children:c})});Hr.displayName=$r;var Ut="PopoverPortal",[Uc,Yc]=kr(Ut,{forceMount:void 0}),Br=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=ae(Ut,t);return m.jsx(Uc,{scope:t,forceMount:n,children:m.jsx(X,{present:n||i.open,children:m.jsx(Tt,{asChild:!0,container:o,children:r})})})};Br.displayName=Ut;var ye="PopoverContent",Vr=a.forwardRef((e,t)=>{const n=Yc(ye,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=ae(ye,e.__scopePopover);return m.jsx(X,{present:r||i.open,children:i.modal?m.jsx(Gc,{...o,ref:t}):m.jsx(Kc,{...o,ref:t})})});Vr.displayName=ye;var Xc=kc("PopoverContent.RemoveScroll"),Gc=a.forwardRef((e,t)=>{const n=ae(ye,e.__scopePopover),r=a.useRef(null),o=F(t,r),i=a.useRef(!1);return a.useEffect(()=>{const s=r.current;if(s)return $n(s)},[]),m.jsx(Ot,{as:Xc,allowPinchZoom:!0,children:m.jsx(zr,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:_(e.onCloseAutoFocus,s=>{var c;s.preventDefault(),i.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:_(e.onPointerDownOutside,s=>{const c=s.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,l=c.button===2||u;i.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:_(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Kc=a.forwardRef((e,t)=>{const n=ae(ye,e.__scopePopover),r=a.useRef(!1),o=a.useRef(!1);return m.jsx(zr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,c;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var u,l;(u=e.onInteractOutside)==null||u.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((l=n.triggerRef.current)==null?void 0:l.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),zr=a.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:l,onInteractOutside:f,...d}=e,p=ae(ye,n),h=Oe(n);return _n(),m.jsx(At,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:m.jsx(Ke,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1),children:m.jsx(Ir,{"data-state":Yr(p.open),role:"dialog",id:p.contentId,...h,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Ur="PopoverClose",Zc=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ae(Ur,n);return m.jsx(L.button,{type:"button",...r,ref:t,onClick:_(e.onClick,()=>o.onOpenChange(!1))})});Zc.displayName=Ur;var qc="PopoverArrow",Qc=a.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oe(n);return m.jsx(jr,{...o,...r,ref:t})});Qc.displayName=qc;function Yr(e){return e?"open":"closed"}var ja=Fr,ka=Hr,Fa=Br,Wa=Vr,Jc=Symbol("radix.slottable");function ea(e){const t=({children:n})=>m.jsx(m.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Jc,t}var ta=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"}),na="VisuallyHidden",Xr=a.forwardRef((e,t)=>m.jsx(L.span,{...e,ref:t,style:{...ta,...e.style}}));Xr.displayName=na;var ra=Xr,[st]=Ae("Tooltip",[ot]),ct=ot(),Gr="TooltipProvider",oa=700,St="tooltip.open",[ia,Yt]=st(Gr),Kr=e=>{const{__scopeTooltip:t,delayDuration:n=oa,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,s=a.useRef(!0),c=a.useRef(!1),u=a.useRef(0);return a.useEffect(()=>{const l=u.current;return()=>window.clearTimeout(l)},[]),m.jsx(ia,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:a.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:a.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:a.useCallback(l=>{c.current=l},[]),disableHoverableContent:o,children:i})};Kr.displayName=Gr;var Pe="Tooltip",[sa,at]=st(Pe),Zr=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=Yt(Pe,e.__scopeTooltip),l=ct(t),[f,d]=a.useState(null),p=Se(),h=a.useRef(0),g=s??u.disableHoverableContent,v=c??u.delayDuration,y=a.useRef(!1),[w,b]=Rt({prop:r,defaultProp:o??!1,onChange:E=>{E?(u.onOpen(),document.dispatchEvent(new CustomEvent(St))):u.onClose(),i==null||i(E)},caller:Pe}),C=a.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),x=a.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,b(!0)},[b]),S=a.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),P=a.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,b(!0),h.current=0},v)},[v,b]);return a.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),m.jsx(Mr,{...l,children:m.jsx(sa,{scope:t,contentId:p,open:w,stateAttribute:C,trigger:f,onTriggerChange:d,onTriggerEnter:a.useCallback(()=>{u.isOpenDelayedRef.current?P():x()},[u.isOpenDelayedRef,P,x]),onTriggerLeave:a.useCallback(()=>{g?S():(window.clearTimeout(h.current),h.current=0)},[S,g]),onOpen:x,onClose:S,disableHoverableContent:g,children:n})})};Zr.displayName=Pe;var Et="TooltipTrigger",qr=a.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=at(Et,n),i=Yt(Et,n),s=ct(n),c=a.useRef(null),u=F(t,c,o.onTriggerChange),l=a.useRef(!1),f=a.useRef(!1),d=a.useCallback(()=>l.current=!1,[]);return a.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(zt,{asChild:!0,...s,children:m.jsx(L.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:_(e.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:_(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:_(e.onPointerDown,()=>{o.open&&o.onClose(),l.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:_(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:_(e.onBlur,o.onClose),onClick:_(e.onClick,o.onClose)})})});qr.displayName=Et;var ca="TooltipPortal",[$a,aa]=st(ca,{forceMount:void 0}),we="TooltipContent",Qr=a.forwardRef((e,t)=>{const n=aa(we,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=at(we,e.__scopeTooltip);return m.jsx(X,{present:r||s.open,children:s.disableHoverableContent?m.jsx(Jr,{side:o,...i,ref:t}):m.jsx(la,{side:o,...i,ref:t})})}),la=a.forwardRef((e,t)=>{const n=at(we,e.__scopeTooltip),r=Yt(we,e.__scopeTooltip),o=a.useRef(null),i=F(t,o),[s,c]=a.useState(null),{trigger:u,onClose:l}=n,f=o.current,{onPointerInTransitChange:d}=r,p=a.useCallback(()=>{c(null),d(!1)},[d]),h=a.useCallback((g,v)=>{const y=g.currentTarget,w={x:g.clientX,y:g.clientY},b=ha(w,y.getBoundingClientRect()),C=va(w,b),x=ma(v.getBoundingClientRect()),S=ya([...C,...x]);c(S),d(!0)},[d]);return a.useEffect(()=>()=>p(),[p]),a.useEffect(()=>{if(u&&f){const g=y=>h(y,f),v=y=>h(y,u);return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",v)}}},[u,f,h,p]),a.useEffect(()=>{if(s){const g=v=>{const y=v.target,w={x:v.clientX,y:v.clientY},b=(u==null?void 0:u.contains(y))||(f==null?void 0:f.contains(y)),C=!ga(w,s);b?p():C&&(p(),l())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[u,f,s,l,p]),m.jsx(Jr,{...e,ref:i})}),[ua,fa]=st(Pe,{isInside:!1}),da=ea("TooltipContent"),Jr=a.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=at(we,n),l=ct(n),{onClose:f}=u;return a.useEffect(()=>(document.addEventListener(St,f),()=>document.removeEventListener(St,f)),[f]),a.useEffect(()=>{if(u.trigger){const d=p=>{const h=p.target;h!=null&&h.contains(u.trigger)&&f()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[u.trigger,f]),m.jsx(Ke,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:d=>d.preventDefault(),onDismiss:f,children:m.jsxs(Ir,{"data-state":u.stateAttribute,...l,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(da,{children:r}),m.jsx(ua,{scope:n,isInside:!0,children:m.jsx(ra,{id:u.contentId,role:"tooltip",children:o||r})})]})})});Qr.displayName=we;var eo="TooltipArrow",pa=a.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ct(n);return fa(eo,n).isInside?null:m.jsx(jr,{...o,...r,ref:t})});pa.displayName=eo;function ha(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function va(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function ma(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function ga(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],l=c.x,f=c.y,d=u.x,p=u.y;f>r!=p>r&&n<(d-l)*(r-f)/(p-f)+l&&(o=!o)}return o}function ya(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),wa(t)}function wa(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Ha=Kr,Ba=Zr,Va=qr,za=Qr;export{Oa as C,_a as D,Ta as O,Aa as P,Ra as R,xa as S,Da as T,Ma as V,ei as _,Na as a,La as b,Ia as c,ss as d,ds as e,Fa as f,Wa as g,ja as h,ka as i,Ha as j,Ba as k,Va as l,za as m,Ea as n,Z as o,Ca as p,Sa as q,Nn as r};
@@ -5,11 +5,11 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>BladeCode</title>
8
- <script type="module" crossorigin src="/assets/index-BF5HEN_f.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CxEh32hc.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DG5dkZ_t.js">
10
- <link rel="modulepreload" crossorigin href="/assets/vendor-radix-DBy9B2DN.js">
11
- <link rel="modulepreload" crossorigin href="/assets/vendor-icons-D_AkWmWB.js">
12
- <link rel="stylesheet" crossorigin href="/assets/index-BrkTYxtS.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/vendor-radix-DXRuAJHH.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/vendor-icons-Cv18Q6rW.js">
12
+ <link rel="stylesheet" crossorigin href="/assets/index-Bi5ijAQP.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blade-code",
3
- "version": "0.10.7",
3
+ "version": "0.10.8",
4
4
  "private": false,
5
5
  "description": "🗡️ Blade Code - 智能代码助手命令行工具",
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "test:unit": "node scripts/test.js unit",
23
23
  "test:integration": "node scripts/test.js integration",
24
24
  "test:real-api": "node scripts/test.js realApi",
25
+ "test:real-api:qualification": "node scripts/test.js realApiQualification",
25
26
  "test:cli": "node scripts/test.js cli",
26
27
  "test:headless-core": "node scripts/test.js headlessCore",
27
28
  "test:e2e": "node scripts/test.js e2e",
@@ -73,6 +74,7 @@
73
74
  "@modelcontextprotocol/sdk": "^1.30.0",
74
75
  "ahooks": "^3.9.7",
75
76
  "ansi-escapes": "^7.3.0",
77
+ "ajv": "^8.17.1",
76
78
  "async-mutex": "^0.5.0",
77
79
  "axios": "^1.19.0",
78
80
  "chalk": "^5.4.1",
@@ -1,2 +0,0 @@
1
- import{Te as d,Ve as h}from"./chunk-g1q27q6q.js";var q={debug:{alias:"d",type:"string",describe:'Enable debug mode with optional category filtering (e.g., "agent,ui" or "!chat,!loop")',group:"Debug Options:"},model:{type:"string",describe:"Override the current run model using a model config ID (TUI / print / headless)",group:"AI Options:"},print:{alias:"p",type:"boolean",describe:"Print response and exit (useful for pipes)",group:"Output Options:"},headless:{type:"boolean",describe:"Run full agent loop without Ink UI and print all events to the terminal",group:"Output Options:"},"output-format":{alias:["outputFormat"],type:"string",choices:["text","json","stream-json","jsonl"],default:"text",describe:"Output format: --print supports text|json|stream-json; --headless supports text|jsonl",group:"Output Options:"},"include-partial-messages":{alias:["includePartialMessages"],type:"boolean",describe:"Include partial message chunks as they arrive",group:"Output Options:"},"input-format":{alias:["inputFormat"],type:"string",choices:["text","stream-json"],default:"text",describe:"Input format",group:"Input Options:"},"replay-user-messages":{alias:["replayUserMessages"],type:"boolean",describe:"Re-emit user messages from stdin",group:"Input Options:"},"allowed-tools":{alias:["allowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to allow",group:"Security Options:"},"disallowed-tools":{alias:["disallowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to deny",group:"Security Options:"},"mcp-config":{alias:["mcpConfig"],type:"array",string:!0,describe:"Load MCP servers from JSON files or strings",group:"MCP Options:"},"system-prompt":{alias:["systemPrompt"],type:"string",describe:"System prompt to use for the session (replaces default)",group:"AI Options:"},"append-system-prompt":{alias:["appendSystemPrompt"],type:"string",describe:"Append a system prompt to the default system prompt",group:"AI Options:"},"max-turns":{alias:["maxTurns"],type:"number",describe:"Maximum conversation turns (-1: unlimited, 0: disable chat, N>0: limit to N turns)",group:"AI Options:",default:void 0},"max-concurrent-tasks":{alias:["maxConcurrentTasks"],type:"number",describe:"Maximum top-level tasks running concurrently in this process",group:"AI Options:",default:void 0},"max-queued-tasks":{alias:["maxQueuedTasks"],type:"number",describe:"Maximum top-level tasks waiting for an admission slot",group:"AI Options:",default:void 0},"permission-mode":{alias:["permissionMode"],type:"string",choices:["default","autoEdit","yolo","plan"],describe:"Permission mode (default: ask for non-read tools, autoEdit: auto-approve edits, yolo: auto-approve all, plan: reserved)",group:"Security Options:"},yolo:{type:"boolean",describe:"Auto-approve all tools (shortcut for --permission-mode=yolo)",group:"Security Options:"},"trust-workspace":{alias:["trustWorkspace"],type:"boolean",describe:"Trust the current workspace before loading project models, MCP, LSP, permissions, or plugins",group:"Security Options:"},continue:{alias:"c",type:"boolean",describe:"Continue the most recent conversation",group:"Session Options:"},resume:{alias:"r",describe:"Resume a conversation - provide a session ID or interactively select a conversation to resume",group:"Session Options:",coerce:(b)=>{if(b===void 0||b===!0||b==="")return"true";return String(b)}},"fork-session":{alias:["forkSession"],type:"boolean",describe:"Create a new session ID when resuming",group:"Session Options:"},settings:{type:"string",describe:"Path to a settings JSON file or JSON string",group:"Configuration:"},"add-dir":{alias:["addDir"],type:"array",string:!0,describe:"Additional directories to allow tool access to",group:"Security Options:"},ide:{type:"boolean",describe:"Automatically connect to IDE on startup",group:"Integration:"},acp:{type:"boolean",describe:"Run in ACP (Agent Client Protocol) mode for IDE integration",group:"Integration:"},"strict-mcp-config":{alias:["strictMcpConfig"],type:"boolean",describe:"Only use MCP servers from --mcp-config",group:"MCP Options:"},"session-id":{alias:["sessionId"],type:"string",describe:"Use a specific session ID for the conversation",group:"Session Options:"},agents:{type:"string",describe:"JSON object defining custom agents",group:"AI Options:"},"setting-sources":{alias:["settingSources"],type:"string",describe:"Comma-separated list of setting sources to load",group:"Configuration:"},"plugin-dir":{alias:["pluginDir"],type:"array",string:!0,describe:"Load plugins from specified directories",group:"Plugin Options:"}},w={scriptName:"blade",usage:"$0 [command] [options]",description:h(),version:d(),locale:"en",showHelpOnFail:!0,demandCommand:!1,recommendCommands:!0,strict:!1};
2
- export{q as Ub,w as Vb};
@@ -1,22 +0,0 @@
1
- import{q as R}from"./chunk-kqpwz9b7.js";import{r as e}from"./chunk-7a200q5g.js";import{$ as m,E as C,H as f,I as u,K as g,Y as c,Z as v,_ as p,u as K}from"./chunk-pt659n0v.js";import{ja as s}from"./chunk-rn908m3v.js";import{Aa as M,Da as k,Oa as S}from"./chunk-f7854pbx.js";import{Za as E}from"./chunk-jpy61wna.js";import{Bb as L,kb as y,tb as b,ub as I,yb as w}from"./chunk-5ak9tw83.js";import"./chunk-wrbm6rch.js";import"./chunk-0xm8hn2h.js";import"./chunk-x3780wpy.js";import"./chunk-tp9zk241.js";import{Hc as n}from"./chunk-3fdyzgpv.js";import"./chunk-rz2ftt6h.js";import"./chunk-qqwgb9ja.js";import{Qc as o}from"./chunk-1sw9z975.js";import"./chunk-y573s5r8.js";import"./chunk-qycwavck.js";import"./chunk-0z7q89w7.js";import{pd as t}from"./chunk-ne7zdjrh.js";import"./chunk-e9ckf8e7.js";import"./chunk-yyvx1avz.js";import"./chunk-tc83e1b0.js";import{Cd as O}from"./chunk-w01sec4f.js";import"./chunk-vcq624qv.js";import"./chunk-akev4wsz.js";import{Ae as P,Be as T,Ce as A}from"./chunk-rk1w5pry.js";import{Ge as i}from"./chunk-az4b6106.js";import"./chunk-m86ekqp0.js";import{Me as r,Pe as a}from"./chunk-p0j8994h.js";import"./chunk-g1q27q6q.js";import"./chunk-0n04bmta.js";import"./chunk-1v7hpr34.js";import"./chunk-ahxc3n3g.js";import"./chunk-847e0sk9.js";import{Readable as DJ,Writable as HJ}from"node:stream";import*as N from"@agentclientprotocol/sdk";import{PROTOCOL_VERSION as YJ}from"@agentclientprotocol/sdk";import l from"node:path";import{nanoid as q}from"nanoid";var j=O("Agent");function x(J){if(!J)return{};return Object.fromEntries(J.map((Z)=>[Z.name,Z.value]))}function ZJ(J){if("command"in J)return{type:"stdio",command:J.command,args:J.args,env:x(J.env)};if("url"in J)return{type:J.type,url:J.url,headers:x("headers"in J?J.headers:void 0)};return null}function $J(J){let Z={};for(let Q of J){let Y=ZJ(Q);if(Y)Z[Q.name]=Y}return Z}function d(J){if(typeof J==="string")return J?[{type:"text",text:J}]:[];return J.flatMap((Z)=>{if(Z.type==="text")return Z.text?[{type:"text",text:Z.text}]:[];let Q=Z.image_url.url,Y=/^data:([^;,]+);base64,(.+)$/s.exec(Q);if(!Y)return[{type:"text",text:"[Image]"}];return[{type:"image",mimeType:Y[1]??"image/png",data:Y[2]??""}]})}function zJ(J){let Z=I(J.metadata);return Z?[{type:"text",text:b(Z)}]:d(J.content)}function WJ(J){return[`Status: ${J.status}`,`Exit code: ${J.exitCode??"null"}`,`Duration: ${(J.durationMs/1000).toFixed(3)} seconds`].join(`
2
- `)}class _{id;cwd;connection;clientCapabilities;options;agent=null;runtime=null;pendingPrompt=null;pendingUserShell=null;pendingResumeRequested=!1;availableCommandsTimer=null;taskStatusUnsubscribe;destroyed=!1;messages;mode;constructor(J,Z,Q,Y,D={}){this.id=J;this.cwd=Z;this.connection=Q;this.clientCapabilities=Y;this.options=D;this.messages=[...D.initialMessages??[]],this.mode=this.mapPermissionModeToMode(D.permissionMode)}mapPermissionModeToMode(J){switch(J){case"yolo":return"yolo";case"autoEdit":return"auto-edit";case"plan":return"plan";case"default":default:return"default"}}createAgent(){if(!this.runtime)throw Error("Session runtime is unavailable");return g.createWithRuntime(this.runtime,{sessionId:this.id,...this.options.taskWorktree?{toolBlacklist:["EnterWorktree","ExitWorktree"]}:{}})}async initialize(){if(j.debug(`[AcpSession ${this.id}] Initializing...`),await L.setSessionPermissionMode(this.id,this.cwd,this.mapModeToPermissionMode()??"default"),K.initializeSession(this.connection,this.id,this.clientCapabilities,this.cwd),j.debug(`[AcpSession ${this.id}] ACP service context initialized`),await S.resolvePendingWithHandler(this.cwd,this.id,{requestConfirmation:(z)=>this.requestPermission(z)}))this.messages=await L.loadSession(this.id,this.cwd);let Z=this.options.mcpServers?$J(this.options.mcpServers):void 0,Q=K.getInstance().getTerminalService(this.id);if(this.runtime=await C.create({sessionId:this.id,workspaceRoot:this.cwd,permissionMode:this.mapModeToPermissionMode(),...Z?{mcpServers:Z}:{},...this.options.taskWorktree?{taskWorktree:this.options.taskWorktree}:{},...this.options.taskIsolation?{taskIsolation:this.options.taskIsolation}:{},userShellExecutor:{execute:async(z,$)=>{let W=await Q.execute(z,{cwd:$.cwd,env:$.env,timeout:$.timeoutMs,signal:$.signal,allowLocalFallback:!1,onOutput:(H)=>$.onOutput?.("stdout",H)});return{exitCode:W.exitCode,stdout:W.stdout,stderr:W.stderr,...W.error?{error:W.error}:{},timedOut:W.error==="Command timed out",aborted:W.error==="Command was aborted"}}},...(this.options.initialMessages?.length??0)>0?{sessionStart:{isResume:!0,resumeSessionId:this.id}}:{}}),await R.recoverInterrupted(this.cwd,this.id,this.runtime))this.messages=await L.loadSession(this.id,this.cwd);this.agent=await this.createAgent(),await v(this.cwd),j.debug(`[AcpSession ${this.id}] Agent created successfully`),this.taskStatusUnsubscribe?.(),this.taskStatusUnsubscribe=k.subscribe((z)=>{if(z.sessionId!==this.id||z.projectPath!==this.cwd)return;if(z.type==="task.delivery"){if(!z.properties.taskDelivery||typeof z.properties.taskDelivery!=="object")return;this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:typeof z.properties.updatedAt==="string"?z.properties.updatedAt:new Date().toISOString(),_meta:{"blade/taskDelivery":z.properties.taskDelivery,...z.properties.taskWorktreeRemoved===!0?{"blade/taskWorktreeRemoved":!0}:{}}});return}if(z.type!=="task.status")return;this.sendUpdate({sessionUpdate:"session_info_update",updatedAt:typeof z.properties.updatedAt==="string"?z.properties.updatedAt:new Date().toISOString(),_meta:{"blade/taskStatus":z.properties.taskStatus,...typeof z.properties.taskStatusReason==="string"?{"blade/taskStatusReason":z.properties.taskStatusReason}:{},...z.properties.taskFailure&&typeof z.properties.taskFailure==="object"?{"blade/taskFailure":z.properties.taskFailure}:{},...typeof z.properties.taskStartedAt==="string"?{"blade/taskStartedAt":z.properties.taskStartedAt}:{},...typeof z.properties.taskCompletedAt==="string"?{"blade/taskCompletedAt":z.properties.taskCompletedAt}:{},...z.properties.taskDiffStat&&typeof z.properties.taskDiffStat==="object"?{"blade/taskDiffStat":z.properties.taskDiffStat}:{},...typeof z.properties.taskQueuePosition==="number"?{"blade/taskQueuePosition":z.properties.taskQueuePosition}:{},...typeof z.properties.taskQueueDepth==="number"?{"blade/taskQueueDepth":z.properties.taskQueueDepth}:{},...typeof z.properties.taskConcurrencyLimit==="number"?{"blade/taskConcurrencyLimit":z.properties.taskConcurrencyLimit}:{},...typeof z.properties.taskInFlight==="number"?{"blade/taskInFlight":z.properties.taskInFlight}:{}}})});let D=await this.runtime.getGoal();if(this.runtime.getPendingSteeringCount()>0||D?.status==="active")if(this.options.initialMessages===void 0)this.schedulePendingResume();else this.pendingResumeRequested=!0}async replayHistory(){for(let J of this.messages){if(!this.canSendUpdates())return;let Z=J.role==="user"?"user_message_chunk":J.role==="assistant"?"agent_message_chunk":void 0;if(!Z)continue;for(let Q of zJ(J)){if(!this.canSendUpdates())return;if(!await this.sendUpdateAndWait({sessionUpdate:Z,content:Q}))return}}if(this.pendingResumeRequested)this.schedulePendingResume()}sendAvailableCommandsDelayed(){if(this.destroyed||this.connection.signal.aborted)return;if(this.availableCommandsTimer!==null)clearTimeout(this.availableCommandsTimer);j.debug(`[AcpSession ${this.id}] Scheduling available commands update (500ms delay)`),this.availableCommandsTimer=setTimeout(()=>{if(this.availableCommandsTimer=null,this.destroyed||this.connection.signal.aborted)return;this.sendAvailableCommands()},500)}async handleSlashCommand(J,Z){try{j.debug(`[AcpSession ${this.id}] Executing slash command: ${J}`);let Q={cwd:this.cwd,surface:"acp",workspaceRoot:this.cwd,sessionId:this.id,messages:[...this.messages],rewind:{listCheckpoints:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.listRewindCheckpoints()},execute:async($)=>{if(!this.runtime)throw Error("Session runtime is unavailable");let W=await this.runtime.rewindSession($);return this.messages=[...W.messages],await this.agent?.destroy(),this.agent=await this.createAgent(),W}},reasoning:{get:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getReasoningConfiguration()},set:async($)=>{if(await this.setReasoningEffort($),!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getReasoningConfiguration()}},serviceTier:{get:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getServiceTierConfiguration()},set:async($)=>{if(await this.setServiceTier($),!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getServiceTierConfiguration()}},responseVerbosity:{get:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getResponseVerbosityConfiguration()},set:async($)=>{if(await this.setResponseVerbosity($),!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getResponseVerbosityConfiguration()}},communicationStyle:{get:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getCommunicationStyleConfiguration()},set:async($)=>{if(await this.setCommunicationStyle($),!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getCommunicationStyleConfiguration()}},subagents:{list:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.listSubagents()},resume:async($,W)=>{if(!this.runtime)throw Error("Session runtime is unavailable");let H=!1,G,X=(V)=>{this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:V.id,status:V.status==="completed"?"completed":"failed",content:[{type:"content",content:{type:"text",text:V.result?.message||V.result?.error||`Subagent ${V.status}`}}]})},F=this.runtime.resumeSubagent({agentId:$,prompt:W,onCompleted:(V)=>{if(H)X(V);else G=V}});if(this.sendUpdate({sessionUpdate:"tool_call",toolCallId:F.session.id,status:"in_progress",title:`Resuming ${F.session.subagentType} subagent`,content:[{type:"content",content:{type:"text",text:`Resumed from ${F.source.id} at depth ${F.session.resumeDepth}`}}],kind:this.mapToolKind("readonly")}),H=!0,G)X(G);return F}},mcp:{getCatalog:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getMcpContentCatalog()},refresh:async($)=>{if(!this.runtime)throw Error("Session runtime is unavailable");await this.runtime.refreshMcpContentCatalogs($)},getPrompt:async($,W,H)=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getMcpPrompt($,W,H)},complete:async($,W,H)=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.completeMcpArgument($,W,H)},listTasks:async($)=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.listMcpTasks($)},getTask:async($)=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getMcpTask($)},cancelTask:async($,W)=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.cancelMcpTask($,W)},getLogs:async($,W)=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getMcpLogs($,W)},setLoggingLevel:async($,W)=>{if(!this.runtime)throw Error("Session runtime is unavailable");await this.runtime.setMcpLoggingLevel($,W)},getInstructions:async()=>{if(!this.runtime)throw Error("Session runtime is unavailable");return this.runtime.getMcpInstructions()}},codeReview:{run:async($,W)=>{if(!this.runtime)throw Error("Session runtime is unavailable");let H=await R.start({sessionId:this.id,projectPath:this.cwd,runtime:this.runtime,request:$,signal:W,onEvent:(F)=>{if(F.kind==="tool_start")this.sendUpdate({sessionUpdate:"tool_call",toolCallId:F.toolCall.id,status:"in_progress",title:`Review: ${F.toolCall.function.name}`,content:[],kind:this.mapToolKind(F.toolKind)});else if(F.kind==="tool_result")this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:F.toolCall.id,status:F.result.success?"completed":"failed",content:[]})}}),G=await H.completion,X=(await R.list(this.cwd,this.id)).find((F)=>F.start.reviewId===H.reviewId);if(!X)throw Error(`Review not found: ${H.reviewId}`);return this.messages=await L.loadSession(this.id,this.cwd),{reviewId:H.reviewId,status:G.status,findings:G.findings.length,content:y(X.start,G)}}},signal:Z,acp:{sendMessage:($)=>{this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:$}})},sendToolStart:($,W,H)=>{let G=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,X=this.mapToolKind(H);this.sendUpdate({sessionUpdate:"tool_call",toolCallId:G,status:"in_progress",title:`${$}`,content:[{type:"content",content:{type:"text",text:JSON.stringify(W,null,2)}}],kind:X})},sendToolResult:($,W)=>{if(W.summary)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:W.summary}})}}},Y=await p(J,Q),D=Y.data?.action;if(D==="start_goal"||D==="resume_goal")this.schedulePendingResume();if(D==="rewind_session"&&Array.isArray(Y.data?.messages))this.messages=[...Y.data.messages];if((Y.message==="compact_completed"||Y.message==="compact_fallback")&&Y.data?.compactedMessages)this.messages=[...Y.data.compactedMessages];let z=Y.content||Y.message;if(z)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:z}});if(Y.error)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`[FAIL] ${Y.error}`}});return{stopReason:Y.success?"end_turn":"cancelled"}}catch(Q){return j.error(`[AcpSession ${this.id}] Slash command error:`,Q),this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`[FAIL] 命令执行失败: ${Q instanceof Error?Q.message:"未知错误"}`}}),{stopReason:"cancelled"}}}async sendAvailableCommands(){try{let J=m(this.cwd),Z=["model","permissions","theme","config","exit","ide"],Y=J.filter((D)=>!Z.includes(D.name)).map((D)=>{let z;if(D.usage){let $=D.usage.replace(/^\/\w+\s*/,"").trim();if($)z=$}if(D.aliases?.length){let $=`Aliases: ${D.aliases.join(", ")}`;z=z?`${z} | ${$}`:$}return{name:D.name,description:D.description,input:z?{hint:z}:void 0}});j.info(`[AcpSession ${this.id}] Sending available commands: ${JSON.stringify(Y.map((D)=>D.name))}`),this.sendUpdate({sessionUpdate:"available_commands_update",availableCommands:Y}),j.info(`[AcpSession ${this.id}] Sent ${Y.length} available commands`)}catch(J){j.error(`[AcpSession ${this.id}] Failed to send available commands:`,J)}}async prompt(J,Z={}){if(K.setCurrentSession(this.id),!this.agent||!this.runtime)throw Error("Session not initialized");let Q=this.resolvePrompt(J.prompt),Y=Q.content,D=Q.displayText;if(D.trimStart().startsWith("!"))return this.handleUserShellCommand(D);if(this.pendingPrompt){if(/^\/goal(?:\s|$)/i.test(D.trim()))return this.handleSlashCommand(D,this.pendingPrompt.signal);let $=await this.runtime.enqueueSteering(Y,{allowBeforeTurn:!0});if(!$.accepted)throw Error($.reason==="queue_full"?"Active turn steering queue is full":"Active turn is no longer steerable");if(j.debug(`[AcpSession ${this.id}] Queued steering for active turn (${$.queued})`),$.delivery==="next_turn")this.schedulePendingResume();return{stopReason:"end_turn"}}let z=new AbortController;this.pendingPrompt=z;try{if(j.debug(`[AcpSession ${this.id}] Received prompt: ${D.slice(0,100)}...`),c(D))return await this.handleSlashCommand(D,z.signal);let $={sessionId:this.id,userId:"acp-user",workspaceRoot:this.cwd,messages:[...this.messages],signal:z.signal,permissionMode:this.mapModeToPermissionMode(),onPermissionModeChange:async(W)=>{this.mode=this.mapPermissionModeToMode(W),this.sendUpdate({sessionUpdate:"current_mode_update",currentModeId:this.mode})},...this.options.taskWorktree?{worktreeActive:!0}:{},confirmationHandler:{requestConfirmation:async(W)=>{return this.requestPermission(W)}}};if(await M(this.agent.chatStream(Y,$,{pendingInputOnly:Z.pendingInputOnly,goalContinuationOnly:Z.goalContinuationOnly}),async(W)=>{switch(W.kind){case"content_delta":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:W.delta}});break;case"thinking_delta":this.sendUpdate({sessionUpdate:"agent_thought_chunk",content:{type:"text",text:W.delta}});break;case"tool_start":{let H=W.toolCall,G=H.function.name,X=this.mapToolKind(W.toolKind),F=`Executing ${G}`;if(G==="Task"&&"function"in H)try{let V=JSON.parse(H.function.arguments),U=V.resume_from??V.resume;if(typeof U==="string")F=`Resuming ${String(V.subagent_type||"subagent")} from ${U}`}catch{}this.sendUpdate({sessionUpdate:"tool_call",toolCallId:H.id,status:"in_progress",title:F,content:[],kind:X});break}case"tool_progress":{let H=W.toolCall;this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:H.id,status:"in_progress",content:[{type:"content",content:{type:"text",text:W.update.message}}]});break}case"tool_result":{let{toolCall:H,result:G}=W,X=[],F=G.metadata;if(F?.kind==="patch"&&Array.isArray(F.changes))for(let U of F.changes){if(!U||typeof U!=="object"||!("path"in U)||typeof U.path!=="string")continue;X.push({type:"diff",path:U.path,oldText:"oldContent"in U&&typeof U.oldContent==="string"?U.oldContent:null,newText:"newContent"in U&&typeof U.newContent==="string"?U.newContent:null})}else if(F?.kind==="edit"&&typeof F.file_path==="string"&&typeof F.oldContent==="string"&&(typeof F.newContent==="string"||F.newContent===void 0))X.push({type:"diff",path:F.file_path,oldText:F.oldContent,newText:F.newContent??null});else{let U=H.function.name,JJ=u(f(U,G));X.push({type:"content",content:{type:"text",text:JJ}})}if(H.function.name==="Task"&&(F?.verificationVerdict==="pass"||F?.verificationVerdict==="fail"||F?.verificationVerdict==="partial"))X.unshift({type:"content",content:{type:"text",text:`Verification result: ${F.verificationVerdict.toUpperCase()}`}});let V=G.success?"completed":"failed";this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:H.id,status:V,content:X});break}case"mcp_catalog_changed":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP catalog r${W.revision} (${W.serverName}): +${W.added.length} -${W.removed.length} ~${W.updated.length}
3
- `}});break;case"mcp_content_changed":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP ${W.contentKind} r${W.revision} (${W.serverName}): +${W.added.length} -${W.removed.length} ~${W.updated.length}
4
- `}});break;case"mcp_resource_updated":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP resource updated r${W.revision} (${W.serverName}): ${W.uri}
5
- `}});break;case"mcp_connection_changed":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP connection r${W.revision} (${W.serverName}): ${W.phase} ${W.attempt}/${W.maxAttempts}
6
- `}});break;case"mcp_log":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP log r${W.revision} (${W.serverName}) ${W.level}${W.logger?` logger=${W.logger}`:""}: ${W.message}
7
- `}});break;case"mcp_instructions_changed":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP instructions r${W.revision} (${W.serverName}): ${W.action}${W.detailsOmitted?" details-omitted":""}
8
- `}});break;case"mcp_task_changed":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`MCP task r${W.revision} ${W.taskId} (${W.serverName}/${W.toolName}): ${W.status}${W.hasResult?" result-available":""}
9
- `}});break;case"project_rules_loaded":this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`Project rules loaded: ${W.files.length}${W.blockedWrite?" (write retry required)":""}
10
- `}});break;case"task_update":this.sendPlanUpdate(W.tasks);break;case"steering_applied":break;case"follow_up_started":for(let H of W.messages){if(!H.recovered||H.persisted)continue;for(let G of d(H.content))this.sendUpdate({sessionUpdate:"user_message_chunk",content:G})}if(W.recovered>0)this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`[Resuming ${W.recovered} queued instruction${W.recovered===1?"":"s"} recovered after restart]
11
- `}});break;case"goal_updated":if(W.goal&&W.goal.status!=="active")this.sendUpdate({sessionUpdate:"agent_message_chunk",content:{type:"text",text:`[Goal ${W.goal.status}: ${W.goal.objective}]
12
- `}});break;case"goal_continuation_started":break;default:break}}),this.messages=[...$.messages],z.signal.aborted)return{stopReason:"cancelled"};return{stopReason:"end_turn"}}catch($){if(z.signal.aborted||$ instanceof Error&&$.name==="AbortError")return{stopReason:"cancelled"};throw j.error(`[AcpSession ${this.id}] Prompt error:`,$),$}finally{if(this.pendingPrompt===z){if(this.pendingPrompt=null,!this.destroyed&&this.pendingResumeRequested)this.schedulePendingResume()}}}async handleUserShellCommand(J){if(!this.runtime)throw Error("Session runtime is unavailable");if(this.pendingUserShell)throw Error("A user shell command is already running");let Z=J.trimStart().slice(1).trim();if(!Z)throw Error("User shell command cannot be empty");let Q=new AbortController;this.pendingUserShell=Q;let Y,D="";try{let z=await this.runtime.executeUserShellCommand(Z,{signal:Q.signal,onEvent:async($)=>{if(Y=$.executionId,$.type==="started"){this.sendUpdate({sessionUpdate:"tool_call",toolCallId:$.executionId,status:"in_progress",title:`! ${$.command}`,content:[],kind:"execute"});return}if($.type==="output"){D+=$.chunk,this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:$.executionId,status:"in_progress",content:[{type:"content",content:{type:"text",text:$.chunk}}]});return}let W=b($.record);this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:$.executionId,status:$.record.status==="completed"?"completed":"failed",content:[{type:"content",content:{type:"text",text:D?WJ($.record):W}}]})}});if(this.messages.push({role:"user",content:z.modelContent,metadata:{userShellCommand:JSON.parse(JSON.stringify(z.record))}}),z.delivery==="next_turn")this.schedulePendingResume();return{stopReason:z.record.status==="aborted"?"cancelled":"end_turn"}}catch(z){if(Y)this.sendUpdate({sessionUpdate:"tool_call_update",toolCallId:Y,status:"failed",content:[{type:"content",content:{type:"text",text:z instanceof Error?z.message:String(z)}}]});if(Q.signal.aborted)return{stopReason:"cancelled"};throw z}finally{if(this.pendingUserShell===Q)this.pendingUserShell=null}}schedulePendingResume(){if(this.destroyed||this.connection.signal.aborted)return;this.pendingResumeRequested=!0,queueMicrotask(()=>{this.resumePendingIfIdle()})}async resumePendingIfIdle(){if(this.destroyed||this.connection.signal.aborted)return;if(this.pendingPrompt||this.pendingUserShell||!this.runtime||!this.agent)return;let J=this.runtime.getPendingSteeringCount()>0,Q=(J?null:await this.runtime.getGoal())?.status==="active";if(!J&&!Q){this.pendingResumeRequested=!1;return}this.pendingResumeRequested=!1,await this.prompt({sessionId:this.id,prompt:[]},{pendingInputOnly:J,goalContinuationOnly:Q}).catch((Y)=>{j.error(`[AcpSession ${this.id}] Failed to resume pending input:`,Y)})}cancel(){j.info(`[AcpSession ${this.id}] Cancel requested`),this.pendingResumeRequested=!1;let J=!1;if(this.pendingPrompt)this.pendingPrompt.abort(),this.pendingPrompt=null,J=!0;if(this.pendingUserShell)this.pendingUserShell.abort(),this.pendingUserShell=null,J=!0;if(!J)j.warn(`[AcpSession ${this.id}] No pending prompt to cancel`)}async setMode(J){let Q=["default","auto-edit","yolo","plan"].includes(J)?J:"default",Y=this.mapModeIdToPermissionMode(Q);await L.setSessionPermissionMode(this.id,this.cwd,Y),this.mode=Q,j.info(`[AcpSession ${this.id}] Mode set to: ${this.mode}`),this.sendUpdate({sessionUpdate:"current_mode_update",currentModeId:this.mode})}mapModeToPermissionMode(){return this.mapModeIdToPermissionMode(this.mode)}mapModeIdToPermissionMode(J){switch(J){case"yolo":return"yolo";case"auto-edit":return"autoEdit";case"plan":return"plan";case"default":default:return"default"}}shouldAutoApprove(J){switch(this.mode){case"yolo":return!0;case"auto-edit":return J==="readonly"||J==="write";case"plan":return J==="readonly";case"default":default:return!1}}async setModel(J){if(j.info(`[AcpSession ${this.id}] Model set to: ${J}`),this.pendingPrompt)throw Error("Cannot switch models while a prompt is active");if(!this.agent)throw Error("Session not initialized");if(!this.runtime)throw Error("Session runtime is unavailable");let Z=this.runtime.getCurrentModelId();await this.agent.switchModel(J);try{try{await L.updateSessionMetadata(this.id,this.cwd,{selectedModelId:J})}catch(Q){if(!(Q instanceof w)&&Q.code!=="ENOENT")throw Q;await L.createSessionMetadata(this.id,this.cwd,{taskStatus:"completed",selectedModelId:J})}}catch(Q){if(Z&&Z!==J)await this.agent.switchModel(Z).catch((Y)=>{j.error(`[AcpSession ${this.id}] Failed to roll back a non-durable model switch:`,Y)});throw Q}}getCurrentModelId(){return this.runtime?.getCurrentModelId()}async setReasoningEffort(J){if(this.pendingPrompt)throw Error("Cannot switch reasoning effort while a prompt is active");if(!this.runtime)throw Error("Session runtime is unavailable");let Z=this.runtime.getReasoningConfiguration();try{this.runtime.resolveReasoningConfiguration(J)}catch(Q){throw Error(Q instanceof Error?Q.message:"Invalid reasoning effort")}if(Z.selection===J)return;await this.runtime.refresh({reasoningEffort:J});try{try{await L.updateSessionMetadata(this.id,this.cwd,{reasoningEffort:J})}catch(Q){if(!(Q instanceof w)&&Q.code!=="ENOENT")throw Q;await L.createSessionMetadata(this.id,this.cwd,{taskStatus:"completed",selectedModelId:this.runtime.getCurrentModelId(),reasoningEffort:J})}}catch(Q){throw await this.runtime.refresh({reasoningEffort:Z.selection}),Q}}async setServiceTier(J){if(this.pendingPrompt)throw Error("Cannot switch service tier while a prompt is active");if(!this.runtime)throw Error("Session runtime is unavailable");let Z=this.runtime.getServiceTierConfiguration();try{this.runtime.resolveServiceTierConfiguration(J)}catch(Q){throw Error(Q instanceof Error?Q.message:"Invalid service tier")}if(Z.selection===J)return;await this.runtime.refresh({serviceTier:J});try{try{await L.updateSessionMetadata(this.id,this.cwd,{serviceTier:J})}catch(Q){if(!(Q instanceof w)&&Q.code!=="ENOENT")throw Q;await L.createSessionMetadata(this.id,this.cwd,{taskStatus:"completed",selectedModelId:this.runtime.getCurrentModelId(),serviceTier:J})}}catch(Q){throw await this.runtime.refresh({serviceTier:Z.selection}),Q}}async setResponseVerbosity(J){if(this.pendingPrompt)throw Error("Cannot switch response verbosity while a prompt is active");if(!this.runtime)throw Error("Session runtime is unavailable");let Z=this.runtime.getResponseVerbosityConfiguration();try{this.runtime.resolveResponseVerbosityConfiguration(J)}catch(Q){throw Error(Q instanceof Error?Q.message:"Invalid response verbosity")}if(Z.selection===J)return;await this.runtime.refresh({responseVerbosity:J});try{try{await L.updateSessionMetadata(this.id,this.cwd,{responseVerbosity:J})}catch(Q){if(!(Q instanceof w)&&Q.code!=="ENOENT")throw Q;await L.createSessionMetadata(this.id,this.cwd,{taskStatus:"completed",selectedModelId:this.runtime.getCurrentModelId(),responseVerbosity:J})}}catch(Q){throw await this.runtime.refresh({responseVerbosity:Z.selection}),Q}}async setCommunicationStyle(J){if(this.pendingPrompt)throw Error("Cannot switch communication style while a prompt is active");if(!this.runtime)throw Error("Session runtime is unavailable");let Z=this.runtime.getCommunicationStyleConfiguration(),Q=this.runtime.resolveCommunicationStyleConfiguration(J);if(Q.source!=="built-in"&&!Q.contentSha256)throw Error("Custom communication style has no provenance");if(Z.selection===J)return;await this.runtime.refresh({communicationStyle:J});try{try{await L.updateSessionMetadata(this.id,this.cwd,{communicationStyle:J,communicationStyleDigest:Q.source==="built-in"?null:Q.contentSha256})}catch(Y){if(!(Y instanceof w)&&Y.code!=="ENOENT")throw Y;await L.createSessionMetadata(this.id,this.cwd,{taskStatus:"completed",selectedModelId:this.runtime.getCurrentModelId(),communicationStyle:J,...Q.source!=="built-in"&&Q.contentSha256?{communicationStyleDigest:Q.contentSha256}:{}})}}catch(Y){throw await this.runtime.refresh({communicationStyle:Z.selection}),Y}}getModelConfiguration(){if(!this.runtime)return;let J=this.runtime.getConfig();return{currentModelId:this.runtime.getCurrentModelId()??J.currentModelId,models:J.models.map((Z)=>structuredClone(Z)),modelProviders:structuredClone(J.modelProviders),reasoning:this.runtime.getReasoningConfiguration(),serviceTier:this.runtime.getServiceTierConfiguration(),responseVerbosity:this.runtime.getResponseVerbosityConfiguration(),communicationStyle:this.runtime.getCommunicationStyleConfiguration()}}getMode(){return this.mode}async destroy(){if(this.destroyed)return;if(this.destroyed=!0,this.availableCommandsTimer!==null)clearTimeout(this.availableCommandsTimer),this.availableCommandsTimer=null;this.taskStatusUnsubscribe?.(),this.taskStatusUnsubscribe=void 0;let J=this.agent,Z=this.runtime;this.agent=null,this.runtime=null;let Q,Y=async(D)=>{try{await D()}catch(z){Q??=z}};if(await Y(()=>this.cancel()),J)await Y(()=>J.destroy());if(Z)await Y(()=>Z.dispose());if(await Y(()=>K.destroySession(this.id)),j.debug(`[AcpSession ${this.id}] Destroyed`),Q!==void 0)throw Q}resolvePrompt(J){let Z=[],Q=[],Y=0,D=0,z=0,$=(H)=>{if(Q.length>0)Q.push({type:"text",text:`
13
- `}),z+=1;if(Q.push(H),H.type==="text")z+=H.text.length};for(let H of J)if(H.type==="text")Z.push(H.text),$({type:"text",text:H.text});else if(H.type==="image"){let G=`data:${H.mimeType};base64,${H.data}`;Y+=1,D+=G.length,Z.push(`[Image: ${H.mimeType}]`),$({type:"image_url",image_url:{url:G}})}else if(H.type==="resource"){let G=H.resource;if("text"in G){let X=`<file path="${G.uri}">
14
- ${G.text}
15
- </file>`;Z.push(X),$({type:"text",text:X})}}else if(H.type==="resource_link"){let G=`[Resource: ${H.uri}]`;Z.push(G),$({type:"text",text:G})}if(Y>P)throw Error(`ACP prompt contains more than ${P} images`);if(D>T)throw Error("ACP prompt images exceed the 5 MiB limit");if(z>A)throw Error(`ACP prompt text exceeds ${A} characters`);let W=Z.join(`
16
- `);return{content:Y>0?Q:W,displayText:W}}canSendUpdates(){return!this.destroyed&&!this.connection.signal.aborted}async sendUpdateAndWait(J){if(!this.canSendUpdates())return!1;return await this.connection.sessionUpdate({sessionId:this.id,update:J}),this.canSendUpdates()}sendUpdate(J){if(!this.canSendUpdates())return;let Z={sessionId:this.id,update:J};this.connection.sessionUpdate(Z).catch((Q)=>{j.warn(`[AcpSession ${this.id}] Failed to send update:`,Q)})}sendPlanUpdate(J){let Z=J.map((Q)=>({content:Q.subject,priority:Q.priority,status:Q.status}));j.debug(`[AcpSession ${this.id}] Sending plan update with ${Z.length} entries`),this.sendUpdate({sessionUpdate:"plan",entries:Z})}async requestPermission(J){let Z=this.pendingPrompt?.signal;if(J.type==="askUserQuestion")return this.requestUserQuestions(J,Z);if(J.type==="mcpElicitation")return this.requestMcpElicitation(J,Z);let Q=J.kind?.toLowerCase()||"execute";if(J.type!=="mcpSampling"&&this.shouldAutoApprove(Q))return j.debug(`[AcpSession ${this.id}] Auto-approving ${Q} in mode: ${this.mode}`),{approved:!0};if(this.mode==="plan"&&(Q==="write"||Q==="execute"))return j.debug(`[AcpSession ${this.id}] Rejecting ${Q} in plan mode`),{approved:!1,reason:"Write and execute operations are not allowed in Plan mode"};try{let Y=q(),D=[];if(J.message)D.push({type:"content",content:{type:"text",text:J.message}});if(J.details)D.push({type:"content",content:{type:"text",text:J.details}});if(J.risks&&J.risks.length>0)D.push({type:"content",content:{type:"text",text:`Risks:
17
- - ${J.risks.join(`
18
- - `)}`}});let z=this.mapToolKind(Q),$={sessionId:this.id,options:J.type==="mcpSampling"?[{optionId:"allow_once",name:"Allow this sampling request",kind:"allow_once"},{optionId:"reject_once",name:"Deny",kind:"reject_once"}]:[{optionId:"allow_once",name:"Allow once",kind:"allow_once"},{optionId:"allow_always",name:"Always allow",kind:"allow_always"},{optionId:"reject_once",name:"Deny once",kind:"reject_once"},{optionId:"reject_always",name:"Always deny",kind:"reject_always"}],toolCall:{toolCallId:Y,status:"pending",title:J.title||"Permission Required",content:D,kind:z}},W=await this.waitForClientInteraction(this.connection.requestPermission($),Z);if(!W)return{approved:!1,reason:E};let H=W.outcome;if(H.outcome==="cancelled")return{approved:!1,reason:"User cancelled the permission request"};let G=H.optionId;if(G==="allow_always")return{approved:!0,scope:"project"};if(G==="reject_always")return{approved:!1,scope:"project",reason:"User permanently denied the permission request"};let X=G==="allow_once";return{approved:X,scope:"once",reason:X?void 0:"User denied the operation"}}catch(Y){return j.warn(`[AcpSession ${this.id}] Permission request failed:`,Y),{approved:!1,reason:"Permission request failed"}}}async requestUserQuestions(J,Z){let Q=J.questions??[];if(Q.length===0)return{approved:!1,reason:"No structured questions were provided"};if(Q.some((D)=>D.multiSelect))return{approved:!1,reason:"ACP does not support multi-select question responses"};let Y={};try{for(let[D,z]of Q.entries()){let $=z.options.map((X,F)=>`answer:${D}:${F}`),W=`answer:${D}:cancel`,H=await this.waitForClientInteraction(this.connection.requestPermission({sessionId:this.id,options:[...z.options.map((X,F)=>({optionId:$[F],name:X.label,kind:"allow_once"})),{optionId:W,name:"Cancel",kind:"reject_once"}],toolCall:{toolCallId:q(),status:"pending",title:z.header,kind:"think",content:[{type:"content",content:{type:"text",text:[z.question,...z.options.map((X)=>`${X.label}: ${X.description}`)].join(`
19
- `)}}]}}),Z);if(!H)return{approved:!1,reason:E};if(H.outcome.outcome!=="selected")return{approved:!1,reason:"User cancelled the question prompt"};let G=$.indexOf(H.outcome.optionId);if(G<0)return{approved:!1,reason:"User cancelled the question prompt"};Y[z.header]=z.options[G].label}return{approved:!0,answers:Y}}catch(D){return j.warn(`[AcpSession ${this.id}] Question request failed:`,D),{approved:!1,reason:"Question request failed"}}}async requestMcpElicitation(J,Z){let Q=J.mcpElicitation;if(!Q)return{approved:!1,reason:"MCP elicitation details are missing",elicitation:{action:"cancel"}};try{if(Q.mode==="url"){let D=await this.requestElicitationChoice("MCP external authorization",[Q.message,`Server: ${Q.serverName}`,`Domain: ${Q.domain??"unknown"}`,`URL: ${Q.url??""}`,"Open this URL yourself only if you trust the MCP server."].join(`
20
- `),[{id:"accept",label:"I will open this URL"},{id:"decline",label:"Decline"}],Z);if(D==="accept")return{approved:!0,elicitation:{action:"accept"}};return{approved:!1,reason:D==="decline"?"User declined URL":"User cancelled",elicitation:{action:D==="decline"?"decline":"cancel"}}}let Y=Object.create(null);for(let D of Q.fields??[]){let z=await this.collectAcpElicitationField(D,Z);if(z.cancelled)return{approved:!1,reason:z.reason,elicitation:{action:"cancel"}};if(z.value!==void 0)Y[D.name]=z.value}return{approved:!0,elicitation:{action:"accept",content:Y}}}catch(Y){return j.warn(`[AcpSession ${this.id}] MCP elicitation failed:`,Y),{approved:!1,reason:"MCP elicitation failed",elicitation:{action:"cancel"}}}}async collectAcpElicitationField(J,Z){if(J.type==="select"||J.type==="boolean"){let Q=J.type==="boolean"?[{id:"true",label:"Yes",value:!0},{id:"false",label:"No",value:!1}]:(J.options??[]).map((z,$)=>({id:`option:${$}`,label:z.label,value:z.value})),Y=await this.requestElicitationChoice(J.title,[J.description,J.required?"Required":"Optional"].filter(Boolean).join(`
21
- `),[...Q.map((z)=>({id:z.id,label:z.label})),...!J.required?[{id:"skip",label:"Skip"}]:[]],Z);if(Y==="skip")return{cancelled:!1};let D=Q.find((z)=>z.id===Y);if(!D)return{cancelled:!0,reason:"User cancelled MCP elicitation"};return{cancelled:!1,value:D.value}}if(J.defaultValue!==void 0){let Q=await this.requestElicitationChoice(J.title,[J.description,`ACP cannot collect ${J.type} input. Use the server default: ${String(J.defaultValue)}?`].filter(Boolean).join(`
22
- `),[{id:"default",label:"Use default"},...!J.required?[{id:"skip",label:"Skip"}]:[]],Z);if(Q==="default")return{cancelled:!1,value:J.defaultValue};if(Q==="skip")return{cancelled:!1};return{cancelled:!0,reason:"User cancelled MCP elicitation"}}if(!J.required)return{cancelled:!1};return{cancelled:!0,reason:`ACP cannot collect required ${J.type} field "${J.name}"`}}async requestElicitationChoice(J,Z,Q,Y){let D=await this.waitForClientInteraction(this.connection.requestPermission({sessionId:this.id,options:[...Q.map((z)=>({optionId:z.id,name:z.label,kind:"allow_once"})),{optionId:"cancel",name:"Cancel",kind:"reject_once"}],toolCall:{toolCallId:q(),status:"pending",title:J,kind:"think",content:[{type:"content",content:{type:"text",text:Z}}]}}),Y);return D?.outcome.outcome==="selected"?D.outcome.optionId:void 0}async waitForClientInteraction(J,Z){if(!Z)return J;if(Z.aborted)return;return new Promise((Q,Y)=>{let D=!1,z=(W)=>{if(D)return;D=!0,Z.removeEventListener("abort",$),W()},$=()=>z(()=>Q(void 0));if(Z.addEventListener("abort",$,{once:!0}),Z.aborted)$();J.then((W)=>z(()=>Q(W)),(W)=>z(()=>Y(W)))})}mapToolKind(J){return{readonly:"read",write:"edit",execute:"execute",read:"read",edit:"edit",delete:"delete",move:"move",search:"search",think:"think",fetch:"fetch"}[J||""]||"other"}}var B=O("Agent");class h{connection;sessions=new Map;sessionLoadQueues=new Map;clientCapabilities;destroyed=!1;constructor(J){this.connection=J}async initialize(J){return B.info("[BladeAgent] Initializing ACP connection"),B.debug(`[BladeAgent] Client capabilities: ${JSON.stringify(J.clientCapabilities)}`),this.clientCapabilities=J.clientCapabilities,{protocolVersion:YJ,agentCapabilities:{loadSession:!0,sessionCapabilities:{list:{},fork:{}},promptCapabilities:{image:!0,audio:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0}}}}async authenticate(J){return}async newSession(J){this.assertNotDestroyed();let Z=n("acp"),Q=J.cwd||i(),Y=J._meta?.["blade/taskIsolation"],D=Y==="local"||Y==="worktree"?Y:void 0,z=J._meta?.["blade/taskPrompt"],$=D?await e.createSessionTask({sessionId:Z,prompt:typeof z==="string"&&z.trim()?z:"ACP task session",sourceProjectPath:Q,isolation:D}):void 0,W=$?.metadata.projectPath??Q;B.info(`[BladeAgent] Creating new session: ${Z}`),B.debug(`[BladeAgent] Session cwd: ${W}`);let H=new _(Z,W,this.connection,this.clientCapabilities,{mcpServers:J.mcpServers,...$?.taskWorktree?{taskWorktree:$.taskWorktree}:{},...$?.metadata.taskIsolation?{taskIsolation:$.metadata.taskIsolation}:{}});try{await H.initialize(),this.assertNotDestroyed()}catch(G){throw await H.destroy().catch(()=>{return}),G}return this.sessions.set(Z,H),B.info(`[BladeAgent] Session ${Z} created, scheduling available commands update`),H.sendAvailableCommandsDelayed(),this.buildChildSessionResponse(Z,$?.metadata,H.getModelConfiguration())}async listSessions(J){if(J.cwd!=null&&!l.isAbsolute(J.cwd))throw Error("ACP session list cwd must be absolute");let Z=await L.listSessionPage({cwd:J.cwd??void 0,cursor:J.cursor??void 0,limit:50,includeSubagents:!1});return{sessions:Z.sessions.map((Q)=>({sessionId:Q.sessionId,cwd:Q.projectPath,title:Q.title??null,updatedAt:Q.lastMessageTime,_meta:{"blade/taskStatus":Q.taskStatus,...Q.taskStatusReason?{"blade/taskStatusReason":Q.taskStatusReason}:{},...Q.taskFailure?{"blade/taskFailure":Q.taskFailure}:{},...Q.taskStartedAt?{"blade/taskStartedAt":Q.taskStartedAt}:{},...Q.taskCompletedAt?{"blade/taskCompletedAt":Q.taskCompletedAt}:{},...Q.taskModelId?{"blade/taskModelId":Q.taskModelId}:{},...Q.taskRetryAvailable?{"blade/taskRetryAvailable":!0}:{},...Q.taskRetriedFrom?{"blade/taskRetriedFrom":Q.taskRetriedFrom}:{},...Q.taskDelivery?{"blade/taskDelivery":Q.taskDelivery}:{},...Q.taskIsolation?{"blade/taskIsolation":Q.taskIsolation}:{},...Q.taskSourceProjectPath?{"blade/taskSourceProjectPath":Q.taskSourceProjectPath}:{},...Q.taskWorktreeBranch?{"blade/taskWorktreeBranch":Q.taskWorktreeBranch}:{},...Q.taskBaseCommit?{"blade/taskBaseCommit":Q.taskBaseCommit}:{},...Q.taskDiffStat?{"blade/taskDiffStat":Q.taskDiffStat}:{},...Q.taskQueuePosition?{"blade/taskQueuePosition":Q.taskQueuePosition}:{},...Q.taskQueueDepth!==void 0?{"blade/taskQueueDepth":Q.taskQueueDepth}:{},...Q.taskConcurrencyLimit!==void 0?{"blade/taskConcurrencyLimit":Q.taskConcurrencyLimit}:{}}})),nextCursor:Z.nextCursor}}async unstable_forkSession(J){if(this.assertNotDestroyed(),!l.isAbsolute(J.cwd))throw Error("ACP session fork cwd must be absolute");let Z=await L.forkSession(J.sessionId,{sourceProjectPath:J.cwd,targetProjectPath:J.cwd});this.assertNotDestroyed();let Q=new _(Z.sessionId,J.cwd,this.connection,this.clientCapabilities,{initialMessages:Z.messages,permissionMode:Z.metadata.permissionMode,mcpServers:J.mcpServers});try{await Q.initialize(),this.assertNotDestroyed()}catch(Y){throw await Q.destroy().catch(()=>{return}),Y}return this.sessions.set(Z.sessionId,Q),Q.sendAvailableCommandsDelayed(),this.buildChildSessionResponse(Z.sessionId,Z.metadata,Q.getModelConfiguration())}async loadSession(J){this.assertNotDestroyed(),B.info(`[BladeAgent] Loading session: ${J.sessionId}`);let Q=(this.sessionLoadQueues.get(J.sessionId)??Promise.resolve()).then(()=>this.replaceSession(J)),Y=Q.then(()=>{return},()=>{return});this.sessionLoadQueues.set(J.sessionId,Y);try{return await Q}finally{if(this.sessionLoadQueues.get(J.sessionId)===Y)this.sessionLoadQueues.delete(J.sessionId)}}async replaceSession(J){this.assertNotDestroyed(),await L.assertSessionWritable(J.sessionId,J.cwd);let Z=this.sessions.get(J.sessionId);if(Z)try{await Z.destroy()}finally{if(this.sessions.get(J.sessionId)===Z)this.sessions.delete(J.sessionId)}let[Q,Y]=await Promise.all([L.loadSession(J.sessionId,J.cwd),L.findSessionMetadata(J.sessionId,J.cwd)]);if(!Y)throw Error(`Session not found: ${J.sessionId}`);let D=new _(J.sessionId,J.cwd,this.connection,this.clientCapabilities,{initialMessages:Q,permissionMode:Y.permissionMode,mcpServers:J.mcpServers});try{await D.initialize(),await D.replayHistory(),this.assertNotDestroyed()}catch(z){throw await D.destroy().catch(()=>{return}),z}return this.sessions.set(J.sessionId,D),D.sendAvailableCommandsDelayed(),this.buildSessionSetup(D.getModelConfiguration(),D.getMode())}buildChildSessionResponse(J,Z,Q){return{sessionId:J,...this.buildSessionSetup(Q,Z?.permissionMode==="autoEdit"?"auto-edit":Z?.permissionMode),...Z?{_meta:{"blade/taskIsolation":Z.taskIsolation,"blade/taskSourceProjectPath":Z.taskSourceProjectPath,"blade/taskProjectPath":Z.projectPath,...Z.taskModelId?{"blade/taskModelId":Z.taskModelId}:{},...Z.taskRetryAvailable?{"blade/taskRetryAvailable":!0}:{},...Z.taskRetriedFrom?{"blade/taskRetriedFrom":Z.taskRetriedFrom}:{},...Z.taskDelivery?{"blade/taskDelivery":Z.taskDelivery}:{},...Z.taskWorktreeBranch?{"blade/taskWorktreeBranch":Z.taskWorktreeBranch}:{},...Z.taskBaseCommit?{"blade/taskBaseCommit":Z.taskBaseCommit}:{}}}:{}}}assertNotDestroyed(){if(this.destroyed)throw Error("BladeAgent is destroyed")}buildSessionSetup(J,Z="default"){let Q=J?.models??[],Y=(J?.currentModelId&&Q.some(($)=>$.id===J.currentModelId)?J.currentModelId:void 0)??Q[0]?.id,D=[{id:"default",name:"Default",description:"Ask for confirmation before all file edits and commands"},{id:"auto-edit",name:"Auto Edit",description:"Auto-approve file edits, ask for shell commands"},{id:"yolo",name:"Full Auto",description:"Auto-approve everything without confirmation"},{id:"plan",name:"Plan Only",description:"Read-only mode, no file changes or commands"}],z=[];if(Q.length>0)z.push({type:"select",id:"model",name:"Model",description:"Active language model",category:"model",currentValue:Y,options:Q.map(($)=>({value:$.id,name:$.displayName??$.model,description:`${J?.modelProviders[$.provider]?.name??$.provider} · ${$.model}`}))});if(J?.reasoning)z.push({type:"select",id:"reasoning_effort",name:"Reasoning effort",description:"Session-owned model reasoning intensity",category:"model",currentValue:J.reasoning.selection,options:[{value:"auto",name:"Auto",description:`Resolve near high for this model (currently ${J.reasoning.effective})`},...J.reasoning.supported.map(($)=>({value:$,name:$[0].toUpperCase()+$.slice(1),description:$==="off"?"Disable model reasoning":`Use ${$} reasoning effort`}))]});if(J?.serviceTier)z.push({type:"select",id:"service_tier",name:"Service tier",description:"Session-owned provider latency and pricing tier",category:"model",currentValue:J.serviceTier.selection,options:[{value:"auto",name:"Auto",description:"Use the provider or model default tier"},...J.serviceTier.supported.map(($)=>({value:$,name:$[0].toUpperCase()+$.slice(1),description:$==="fast"?"Use the provider priority tier":$==="flex"?"Use the lower-cost flexible tier":"Use the standard provider tier"}))]});if(J?.responseVerbosity)z.push({type:"select",id:"response_verbosity",name:"Response verbosity",description:"Session-owned model response detail",category:"model",currentValue:J.responseVerbosity.selection,options:[{value:"auto",name:"Auto",description:"Use the provider or model default verbosity"},...J.responseVerbosity.supported.map(($)=>({value:$,name:$[0].toUpperCase()+$.slice(1),description:`Use ${$} response verbosity`}))]});if(J?.communicationStyle)z.push({type:"select",id:"communication_style",name:"Communication style",description:"Session-owned tone and explanatory framing",category:"model",currentValue:J.communicationStyle.selection,options:J.communicationStyle.supported.map(($)=>({value:$.id,name:$.name,description:`${$.description} · ${$.source}`}))});return{modes:{availableModes:D,currentModeId:Z},configOptions:z.length>0?z:void 0}}async prompt(J){let Z=this.sessions.get(J.sessionId);if(!Z)throw Error(`Session not found: ${J.sessionId}`);return Z.prompt(J)}async cancel(J){B.info(`[BladeAgent] Cancel notification received for session: ${J.sessionId}`);let Z=this.sessions.get(J.sessionId);if(Z)B.info("[BladeAgent] Found session, calling session.cancel()"),Z.cancel();else B.warn(`[BladeAgent] Session not found for cancel: ${J.sessionId}`)}async setSessionMode(J){B.info(`[BladeAgent] Setting session mode: ${J.modeId}`);let Z=this.sessions.get(J.sessionId);if(Z)await Z.setMode(J.modeId);return{}}async setSessionConfigOption(J){let Z=this.sessions.get(J.sessionId);if(!Z)throw Error(`Session not found: ${J.sessionId}`);if(J.configId==="model"&&"value"in J&&typeof J.value==="string")B.info(`[BladeAgent] Setting session model: ${J.value}`),await Z.setModel(J.value);else if(J.configId==="reasoning_effort"&&"value"in J&&o(J.value))B.info(`[BladeAgent] Setting reasoning effort: ${J.value}`),await Z.setReasoningEffort(J.value);else if(J.configId==="service_tier"&&"value"in J&&a(J.value))B.info(`[BladeAgent] Setting service tier: ${J.value}`),await Z.setServiceTier(J.value);else if(J.configId==="response_verbosity"&&"value"in J&&r(J.value))B.info(`[BladeAgent] Setting response verbosity: ${J.value}`),await Z.setResponseVerbosity(J.value);else if(J.configId==="communication_style"&&"value"in J&&t(J.value))B.info(`[BladeAgent] Setting communication style: ${J.value}`),await Z.setCommunicationStyle(J.value);else throw Error(`Invalid session config option: ${J.configId}`);return{configOptions:this.buildSessionSetup(Z.getModelConfiguration(),Z.getMode()).configOptions??[]}}async destroy(){this.destroyed=!0,await Promise.all([...this.sessionLoadQueues.values()]),this.sessionLoadQueues.clear();let J;for(let Z of this.sessions.values())try{await Z.destroy()}catch(Q){J??=Q}this.sessions.clear();try{await s.getInstance().disconnectAll()}catch(Z){J??=Z}if(J!==void 0)throw J}}async function mJ(){let J=HJ.toWeb(process.stdout),Z=DJ.toWeb(process.stdin),Q=N.ndJsonStream(J,Z);await new N.AgentSideConnection((D)=>new h(D),Q).closed}export{mJ as runAcpIntegration};