@nextclaw/ui 0.8.0 → 0.9.1

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 (72) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/assets/ChannelsList-DhvjpZcs.js +1 -0
  3. package/dist/assets/ChatPage-B8VBaMQm.js +38 -0
  4. package/dist/assets/{DocBrowser-DDX2HMXW.js → DocBrowser-LpzGe8An.js} +1 -1
  5. package/dist/assets/{LogoBadge-J53F_3JA.js → LogoBadge-Be4lktJN.js} +1 -1
  6. package/dist/assets/{MarketplacePage-0BZ4bza0.js → MarketplacePage-Cx9AI3_h.js} +3 -3
  7. package/dist/assets/{ModelConfig-Wzq9wGHV.js → ModelConfig-DuImUHIX.js} +1 -1
  8. package/dist/assets/ProvidersList-Ccleg25k.js +1 -0
  9. package/dist/assets/{RuntimeConfig-N771_AM6.js → RuntimeConfig-C6iqpJR_.js} +1 -1
  10. package/dist/assets/{SearchConfig-DVt5QVa_.js → SearchConfig-Dvp1TAXu.js} +1 -1
  11. package/dist/assets/{SecretsConfig-CkwauPa8.js → SecretsConfig-D5Ymlvt9.js} +1 -1
  12. package/dist/assets/{SessionsConfig-C3mnHzkZ.js → SessionsConfig-CIA_jA1P.js} +2 -2
  13. package/dist/assets/{chat-message-pxr79GDs.js → chat-message-B60Fh9kI.js} +1 -1
  14. package/dist/assets/index-BiPDnzv0.js +8 -0
  15. package/dist/assets/index-C8GsgIUn.css +1 -0
  16. package/dist/assets/{index-GdpEEKnz.js → index-CPDASUXh.js} +1 -1
  17. package/dist/assets/{label-CmksBHgc.js → label-D4fGx6Wb.js} +1 -1
  18. package/dist/assets/{page-layout-Db0GbnhS.js → page-layout-twy8gmBE.js} +1 -1
  19. package/dist/assets/popover-DYbYpt1j.js +1 -0
  20. package/dist/assets/{security-config-CjLFME5Q.js → security-config-BcIZ4rpb.js} +1 -1
  21. package/dist/assets/skeleton-DypBy7jp.js +1 -0
  22. package/dist/assets/{switch-C24d-UJU.js → switch-DqA6r5XR.js} +1 -1
  23. package/dist/assets/tabs-custom-C6enKKs1.js +1 -0
  24. package/dist/assets/{useConfirmDialog-BeP35LcG.js → useConfirmDialog-CHBf5Of7.js} +1 -1
  25. package/dist/assets/{vendor-psXJBy9u.js → vendor-DKBNiC31.js} +1 -1
  26. package/dist/index.html +3 -3
  27. package/package.json +6 -6
  28. package/src/api/config.ts +9 -38
  29. package/src/api/ncp-session.ts +50 -0
  30. package/src/api/types.ts +1 -0
  31. package/src/components/chat/ChatConversationPanel.test.tsx +65 -0
  32. package/src/components/chat/ChatConversationPanel.tsx +21 -12
  33. package/src/components/chat/ChatSidebar.test.tsx +203 -0
  34. package/src/components/chat/ChatSidebar.tsx +97 -7
  35. package/src/components/chat/adapters/chat-message.adapter.test.ts +132 -82
  36. package/src/components/chat/adapters/chat-message.adapter.ts +27 -9
  37. package/src/components/chat/chat-composer-state.ts +53 -0
  38. package/src/components/chat/chat-page-data.ts +30 -1
  39. package/src/components/chat/chat-page-runtime.test.ts +181 -0
  40. package/src/components/chat/chat-page-runtime.ts +101 -15
  41. package/src/components/chat/chat-session-preference-sync.test.ts +62 -0
  42. package/src/components/chat/chat-session-preference-sync.ts +75 -0
  43. package/src/components/chat/chat-stream/types.ts +3 -0
  44. package/src/components/chat/containers/chat-input-bar.container.tsx +12 -63
  45. package/src/components/chat/containers/chat-message-list.container.tsx +31 -27
  46. package/src/components/chat/legacy/LegacyChatPage.tsx +25 -0
  47. package/src/components/chat/managers/chat-input.manager.ts +48 -13
  48. package/src/components/chat/managers/chat-session-list.manager.test.ts +39 -0
  49. package/src/components/chat/managers/chat-session-list.manager.ts +9 -3
  50. package/src/components/chat/ncp/NcpChatPage.tsx +53 -13
  51. package/src/components/chat/ncp/ncp-chat-input.manager.ts +48 -12
  52. package/src/components/chat/ncp/ncp-chat-page-data.ts +34 -2
  53. package/src/components/chat/ncp/ncp-chat-thread.manager.ts +1 -1
  54. package/src/components/chat/ncp/ncp-session-adapter.test.ts +27 -1
  55. package/src/components/chat/ncp/ncp-session-adapter.ts +20 -0
  56. package/src/components/chat/presenter/chat-presenter-context.tsx +2 -0
  57. package/src/components/chat/stores/chat-input.store.ts +4 -0
  58. package/src/components/chat/stores/chat-thread.store.ts +2 -0
  59. package/src/components/chat/useChatSessionTypeState.test.tsx +58 -0
  60. package/src/components/chat/useChatSessionTypeState.ts +25 -8
  61. package/src/hooks/use-ncp-chat-session-types.ts +11 -0
  62. package/src/hooks/useConfig.ts +2 -4
  63. package/src/hooks/useMarketplace.ts +7 -4
  64. package/src/hooks/useWebSocket.ts +23 -2
  65. package/dist/assets/ChannelsList-DBcoVJRW.js +0 -1
  66. package/dist/assets/ChatPage-CD3cxyyM.js +0 -37
  67. package/dist/assets/ProvidersList-kwzRS8_M.js +0 -1
  68. package/dist/assets/index-BIvFMkN4.js +0 -1
  69. package/dist/assets/index-CzkY1reu.js +0 -8
  70. package/dist/assets/index-RZ0kHHRI.css +0 -1
  71. package/dist/assets/skeleton-CkpQeVWN.js +0 -1
  72. package/dist/assets/tabs-custom-D89bh-fc.js +0 -1
@@ -404,4 +404,4 @@ Please change the parent <Route path="${R}"> to <Route path="${R==="/"?"*":`${R}
404
404
  `)},Gh=function(){var n=parseInt(document.body.getAttribute(ei)||"0",10);return isFinite(n)?n:0},aC=function(){g.useEffect(function(){return document.body.setAttribute(ei,(Gh()+1).toString()),function(){var n=Gh()-1;n<=0?document.body.removeAttribute(ei):document.body.setAttribute(ei,n.toString())}},[])},uC=function(n){var r=n.noRelative,i=n.noImportant,l=n.gapMode,a=l===void 0?"margin":l;aC();var c=g.useMemo(function(){return iC(a)},[a]);return g.createElement(sC,{styles:lC(c,!r,a,i?"":"!important")})},jc=!1;if(typeof window<"u")try{var $l=Object.defineProperty({},"passive",{get:function(){return jc=!0,!0}});window.addEventListener("test",$l,$l),window.removeEventListener("test",$l,$l)}catch{jc=!1}var Go=jc?{passive:!1}:!1,cC=function(n){return n.tagName==="TEXTAREA"},zv=function(n,r){if(!(n instanceof Element))return!1;var i=window.getComputedStyle(n);return i[r]!=="hidden"&&!(i.overflowY===i.overflowX&&!cC(n)&&i[r]==="visible")},dC=function(n){return zv(n,"overflowY")},fC=function(n){return zv(n,"overflowX")},Xh=function(n,r){var i=r.ownerDocument,l=r;do{typeof ShadowRoot<"u"&&l instanceof ShadowRoot&&(l=l.host);var a=jv(n,l);if(a){var c=Bv(n,l),f=c[1],p=c[2];if(f>p)return!0}l=l.parentNode}while(l&&l!==i.body);return!1},pC=function(n){var r=n.scrollTop,i=n.scrollHeight,l=n.clientHeight;return[r,i,l]},hC=function(n){var r=n.scrollLeft,i=n.scrollWidth,l=n.clientWidth;return[r,i,l]},jv=function(n,r){return n==="v"?dC(r):fC(r)},Bv=function(n,r){return n==="v"?pC(r):hC(r)},mC=function(n,r){return n==="h"&&r==="rtl"?-1:1},vC=function(n,r,i,l,a){var c=mC(n,window.getComputedStyle(r).direction),f=c*l,p=i.target,h=r.contains(p),m=!1,w=f>0,x=0,k=0;do{if(!p)break;var y=Bv(n,p),O=y[0],S=y[1],C=y[2],P=S-C-c*O;(O||P)&&jv(n,p)&&(x+=P,k+=O);var T=p.parentNode;p=T&&T.nodeType===Node.DOCUMENT_FRAGMENT_NODE?T.host:T}while(!h&&p!==document.body||h&&(r.contains(p)||r===p));return(w&&Math.abs(x)<1||!w&&Math.abs(k)<1)&&(m=!0),m},Vl=function(n){return"changedTouches"in n?[n.changedTouches[0].clientX,n.changedTouches[0].clientY]:[0,0]},Zh=function(n){return[n.deltaX,n.deltaY]},Jh=function(n){return n&&"current"in n?n.current:n},yC=function(n,r){return n[0]===r[0]&&n[1]===r[1]},gC=function(n){return`
405
405
  .block-interactivity-`.concat(n,` {pointer-events: none;}
406
406
  .allow-interactivity-`).concat(n,` {pointer-events: all;}
407
- `)},wC=0,Xo=[];function xC(n){var r=g.useRef([]),i=g.useRef([0,0]),l=g.useRef(),a=g.useState(wC++)[0],c=g.useState(Fv)[0],f=g.useRef(n);g.useEffect(function(){f.current=n},[n]),g.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(a));var S=U2([n.lockRef.current],(n.shards||[]).map(Jh),!0).filter(Boolean);return S.forEach(function(C){return C.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),S.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(a))})}}},[n.inert,n.lockRef.current,n.shards]);var p=g.useCallback(function(S,C){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!f.current.allowPinchZoom;var P=Vl(S),T=i.current,R="deltaX"in S?S.deltaX:T[0]-P[0],L="deltaY"in S?S.deltaY:T[1]-P[1],z,U=S.target,H=Math.abs(R)>Math.abs(L)?"h":"v";if("touches"in S&&H==="h"&&U.type==="range")return!1;var q=window.getSelection(),Z=q&&q.anchorNode,te=Z?Z===U||Z.contains(U):!1;if(te)return!1;var he=Xh(H,U);if(!he)return!0;if(he?z=H:(z=H==="v"?"h":"v",he=Xh(H,U)),!he)return!1;if(!l.current&&"changedTouches"in S&&(R||L)&&(l.current=z),!z)return!0;var X=l.current||z;return vC(X,C,S,X==="h"?R:L)},[]),h=g.useCallback(function(S){var C=S;if(!(!Xo.length||Xo[Xo.length-1]!==c)){var P="deltaY"in C?Zh(C):Vl(C),T=r.current.filter(function(z){return z.name===C.type&&(z.target===C.target||C.target===z.shadowParent)&&yC(z.delta,P)})[0];if(T&&T.should){C.cancelable&&C.preventDefault();return}if(!T){var R=(f.current.shards||[]).map(Jh).filter(Boolean).filter(function(z){return z.contains(C.target)}),L=R.length>0?p(C,R[0]):!f.current.noIsolation;L&&C.cancelable&&C.preventDefault()}}},[]),m=g.useCallback(function(S,C,P,T){var R={name:S,delta:C,target:P,should:T,shadowParent:SC(P)};r.current.push(R),setTimeout(function(){r.current=r.current.filter(function(L){return L!==R})},1)},[]),w=g.useCallback(function(S){i.current=Vl(S),l.current=void 0},[]),x=g.useCallback(function(S){m(S.type,Zh(S),S.target,p(S,n.lockRef.current))},[]),k=g.useCallback(function(S){m(S.type,Vl(S),S.target,p(S,n.lockRef.current))},[]);g.useEffect(function(){return Xo.push(c),n.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:k}),document.addEventListener("wheel",h,Go),document.addEventListener("touchmove",h,Go),document.addEventListener("touchstart",w,Go),function(){Xo=Xo.filter(function(S){return S!==c}),document.removeEventListener("wheel",h,Go),document.removeEventListener("touchmove",h,Go),document.removeEventListener("touchstart",w,Go)}},[]);var y=n.removeScrollBar,O=n.inert;return g.createElement(g.Fragment,null,O?g.createElement(c,{styles:gC(a)}):null,y?g.createElement(uC,{noRelative:n.noRelative,gapMode:n.gapMode}):null)}function SC(n){for(var r=null;n!==null;)n instanceof ShadowRoot&&(r=n.host,n=n.host),n=n.parentNode;return r}const CC=G2(Dv,xC);var Uv=g.forwardRef(function(n,r){return g.createElement(fa,Ln({},n,{ref:r,sideCar:CC}))});Uv.classNames=fa.classNames;var kC=[" ","Enter","ArrowUp","ArrowDown"],EC=[" ","Enter"],xo="Select",[pa,ha,bC]=zx(xo),[Si]=sd(xo,[bC,Sv]),ma=Sv(),[RC,$r]=Si(xo),[PC,MC]=Si(xo),Hv=n=>{const{__scopeSelect:r,children:i,open:l,defaultOpen:a,onOpenChange:c,value:f,defaultValue:p,onValueChange:h,dir:m,name:w,autoComplete:x,disabled:k,required:y,form:O}=n,S=ma(r),[C,P]=g.useState(null),[T,R]=g.useState(null),[L,z]=g.useState(!1),U=Bx(m),[H,q]=qh({prop:l,defaultProp:a??!1,onChange:c,caller:xo}),[Z,te]=qh({prop:f,defaultProp:p,onChange:h,caller:xo}),he=g.useRef(null),X=C?O||!!C.closest("form"):!0,[ye,ce]=g.useState(new Set),xe=Array.from(ye).map(ae=>ae.props.value).join(";");return ee.jsx(P2,{...S,children:ee.jsxs(RC,{required:y,scope:r,trigger:C,onTriggerChange:P,valueNode:T,onValueNodeChange:R,valueNodeHasChildren:L,onValueNodeHasChildrenChange:z,contentId:ld(),value:Z,onValueChange:te,open:H,onOpenChange:q,dir:U,triggerPointerDownPosRef:he,disabled:k,children:[ee.jsx(pa.Provider,{scope:r,children:ee.jsx(PC,{scope:n.__scopeSelect,onNativeOptionAdd:g.useCallback(ae=>{ce(ie=>new Set(ie).add(ae))},[]),onNativeOptionRemove:g.useCallback(ae=>{ce(ie=>{const j=new Set(ie);return j.delete(ae),j})},[]),children:i})}),X?ee.jsxs(fy,{"aria-hidden":!0,required:y,tabIndex:-1,name:w,autoComplete:x,value:Z,onChange:ae=>te(ae.target.value),disabled:k,form:O,children:[Z===void 0?ee.jsx("option",{value:""}):null,Array.from(ye)]},xe):null]})})};Hv.displayName=xo;var $v="SelectTrigger",Vv=g.forwardRef((n,r)=>{const{__scopeSelect:i,disabled:l=!1,...a}=n,c=ma(i),f=$r($v,i),p=f.disabled||l,h=ct(r,f.onTriggerChange),m=ha(i),w=g.useRef("touch"),[x,k,y]=hy(S=>{const C=m().filter(R=>!R.disabled),P=C.find(R=>R.value===f.value),T=my(C,S,P);T!==void 0&&f.onValueChange(T.value)}),O=S=>{p||(f.onOpenChange(!0),y()),S&&(f.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return ee.jsx(M2,{asChild:!0,...c,children:ee.jsx(Xe.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:p,"data-disabled":p?"":void 0,"data-placeholder":py(f.value)?"":void 0,...a,ref:h,onClick:Je(a.onClick,S=>{S.currentTarget.focus(),w.current!=="mouse"&&O(S)}),onPointerDown:Je(a.onPointerDown,S=>{w.current=S.pointerType;const C=S.target;C.hasPointerCapture(S.pointerId)&&C.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(O(S),S.preventDefault())}),onKeyDown:Je(a.onKeyDown,S=>{const C=x.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&k(S.key),!(C&&S.key===" ")&&kC.includes(S.key)&&(O(),S.preventDefault())})})})});Vv.displayName=$v;var Wv="SelectValue",Qv=g.forwardRef((n,r)=>{const{__scopeSelect:i,className:l,style:a,children:c,placeholder:f="",...p}=n,h=$r(Wv,i),{onValueNodeHasChildrenChange:m}=h,w=c!==void 0,x=ct(r,h.onValueNodeChange);return At(()=>{m(w)},[m,w]),ee.jsx(Xe.span,{...p,ref:x,style:{pointerEvents:"none"},children:py(h.value)?ee.jsx(ee.Fragment,{children:f}):c})});Qv.displayName=Wv;var TC="SelectIcon",Kv=g.forwardRef((n,r)=>{const{__scopeSelect:i,children:l,...a}=n;return ee.jsx(Xe.span,{"aria-hidden":!0,...a,ref:r,children:l||"▼"})});Kv.displayName=TC;var OC="SelectPortal",qv=n=>ee.jsx(Ov,{asChild:!0,...n});qv.displayName=OC;var So="SelectContent",Yv=g.forwardRef((n,r)=>{const i=$r(So,n.__scopeSelect),[l,a]=g.useState();if(At(()=>{a(new DocumentFragment)},[]),!i.open){const c=l;return c?xs.createPortal(ee.jsx(Gv,{scope:n.__scopeSelect,children:ee.jsx(pa.Slot,{scope:n.__scopeSelect,children:ee.jsx("div",{children:n.children})})}),c):null}return ee.jsx(Xv,{...n,ref:r})});Yv.displayName=So;var cn=10,[Gv,Vr]=Si(So),_C="SelectContentImpl",NC=ea("SelectContent.RemoveScroll"),Xv=g.forwardRef((n,r)=>{const{__scopeSelect:i,position:l="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:c,onPointerDownOutside:f,side:p,sideOffset:h,align:m,alignOffset:w,arrowPadding:x,collisionBoundary:k,collisionPadding:y,sticky:O,hideWhenDetached:S,avoidCollisions:C,...P}=n,T=$r(So,i),[R,L]=g.useState(null),[z,U]=g.useState(null),H=ct(r,K=>L(K)),[q,Z]=g.useState(null),[te,he]=g.useState(null),X=ha(i),[ye,ce]=g.useState(!1),xe=g.useRef(!1);g.useEffect(()=>{if(R)return B2(R)},[R]),Xx();const ae=g.useCallback(K=>{const[fe,...Ce]=X().map(Oe=>Oe.ref.current),[be]=Ce.slice(-1),Me=document.activeElement;for(const Oe of K)if(Oe===Me||(Oe==null||Oe.scrollIntoView({block:"nearest"}),Oe===fe&&z&&(z.scrollTop=0),Oe===be&&z&&(z.scrollTop=z.scrollHeight),Oe==null||Oe.focus(),document.activeElement!==Me))return},[X,z]),ie=g.useCallback(()=>ae([q,R]),[ae,q,R]);g.useEffect(()=>{ye&&ie()},[ye,ie]);const{onOpenChange:j,triggerPointerDownPosRef:B}=T;g.useEffect(()=>{if(R){let K={x:0,y:0};const fe=be=>{var Me,Oe;K={x:Math.abs(Math.round(be.pageX)-(((Me=B.current)==null?void 0:Me.x)??0)),y:Math.abs(Math.round(be.pageY)-(((Oe=B.current)==null?void 0:Oe.y)??0))}},Ce=be=>{K.x<=10&&K.y<=10?be.preventDefault():R.contains(be.target)||j(!1),document.removeEventListener("pointermove",fe),B.current=null};return B.current!==null&&(document.addEventListener("pointermove",fe),document.addEventListener("pointerup",Ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",fe),document.removeEventListener("pointerup",Ce,{capture:!0})}}},[R,j,B]),g.useEffect(()=>{const K=()=>j(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[j]);const[W,_]=hy(K=>{const fe=X().filter(Me=>!Me.disabled),Ce=fe.find(Me=>Me.ref.current===document.activeElement),be=my(fe,K,Ce);be&&setTimeout(()=>be.ref.current.focus())}),F=g.useCallback((K,fe,Ce)=>{const be=!xe.current&&!Ce;(T.value!==void 0&&T.value===fe||be)&&(Z(K),be&&(xe.current=!0))},[T.value]),ne=g.useCallback(()=>R==null?void 0:R.focus(),[R]),re=g.useCallback((K,fe,Ce)=>{const be=!xe.current&&!Ce;(T.value!==void 0&&T.value===fe||be)&&he(K)},[T.value]),ve=l==="popper"?Bc:Zv,Se=ve===Bc?{side:p,sideOffset:h,align:m,alignOffset:w,arrowPadding:x,collisionBoundary:k,collisionPadding:y,sticky:O,hideWhenDetached:S,avoidCollisions:C}:{};return ee.jsx(Gv,{scope:i,content:R,viewport:z,onViewportChange:U,itemRefCallback:F,selectedItem:q,onItemLeave:ne,itemTextRefCallback:re,focusSelectedItem:ie,selectedItemText:te,position:l,isPositioned:ye,searchRef:W,children:ee.jsx(Uv,{as:NC,allowPinchZoom:!0,children:ee.jsx(sv,{asChild:!0,trapped:T.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:Je(a,K=>{var fe;(fe=T.trigger)==null||fe.focus({preventScroll:!0}),K.preventDefault()}),children:ee.jsx(ov,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:ee.jsx(ve,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:K=>K.preventDefault(),...P,...Se,onPlaced:()=>ce(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...P.style},onKeyDown:Je(P.onKeyDown,K=>{const fe=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!fe&&K.key.length===1&&_(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let be=X().filter(Me=>!Me.disabled).map(Me=>Me.ref.current);if(["ArrowUp","End"].includes(K.key)&&(be=be.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const Me=K.target,Oe=be.indexOf(Me);be=be.slice(Oe+1)}setTimeout(()=>ae(be)),K.preventDefault()}})})})})})})});Xv.displayName=_C;var LC="SelectItemAlignedPosition",Zv=g.forwardRef((n,r)=>{const{__scopeSelect:i,onPlaced:l,...a}=n,c=$r(So,i),f=Vr(So,i),[p,h]=g.useState(null),[m,w]=g.useState(null),x=ct(r,H=>w(H)),k=ha(i),y=g.useRef(!1),O=g.useRef(!0),{viewport:S,selectedItem:C,selectedItemText:P,focusSelectedItem:T}=f,R=g.useCallback(()=>{if(c.trigger&&c.valueNode&&p&&m&&S&&C&&P){const H=c.trigger.getBoundingClientRect(),q=m.getBoundingClientRect(),Z=c.valueNode.getBoundingClientRect(),te=P.getBoundingClientRect();if(c.dir!=="rtl"){const Me=te.left-q.left,Oe=Z.left-Me,qe=H.left-Oe,dt=H.width+qe,yn=Math.max(dt,q.width),Xt=window.innerWidth-cn,Zt=Mh(Oe,[cn,Math.max(cn,Xt-yn)]);p.style.minWidth=dt+"px",p.style.left=Zt+"px"}else{const Me=q.right-te.right,Oe=window.innerWidth-Z.right-Me,qe=window.innerWidth-H.right-Oe,dt=H.width+qe,yn=Math.max(dt,q.width),Xt=window.innerWidth-cn,Zt=Mh(Oe,[cn,Math.max(cn,Xt-yn)]);p.style.minWidth=dt+"px",p.style.right=Zt+"px"}const he=k(),X=window.innerHeight-cn*2,ye=S.scrollHeight,ce=window.getComputedStyle(m),xe=parseInt(ce.borderTopWidth,10),ae=parseInt(ce.paddingTop,10),ie=parseInt(ce.borderBottomWidth,10),j=parseInt(ce.paddingBottom,10),B=xe+ae+ye+j+ie,W=Math.min(C.offsetHeight*5,B),_=window.getComputedStyle(S),F=parseInt(_.paddingTop,10),ne=parseInt(_.paddingBottom,10),re=H.top+H.height/2-cn,ve=X-re,Se=C.offsetHeight/2,K=C.offsetTop+Se,fe=xe+ae+K,Ce=B-fe;if(fe<=re){const Me=he.length>0&&C===he[he.length-1].ref.current;p.style.bottom="0px";const Oe=m.clientHeight-S.offsetTop-S.offsetHeight,qe=Math.max(ve,Se+(Me?ne:0)+Oe+ie),dt=fe+qe;p.style.height=dt+"px"}else{const Me=he.length>0&&C===he[0].ref.current;p.style.top="0px";const qe=Math.max(re,xe+S.offsetTop+(Me?F:0)+Se)+Ce;p.style.height=qe+"px",S.scrollTop=fe-re+S.offsetTop}p.style.margin=`${cn}px 0`,p.style.minHeight=W+"px",p.style.maxHeight=X+"px",l==null||l(),requestAnimationFrame(()=>y.current=!0)}},[k,c.trigger,c.valueNode,p,m,S,C,P,c.dir,l]);At(()=>R(),[R]);const[L,z]=g.useState();At(()=>{m&&z(window.getComputedStyle(m).zIndex)},[m]);const U=g.useCallback(H=>{H&&O.current===!0&&(R(),T==null||T(),O.current=!1)},[R,T]);return ee.jsx(IC,{scope:i,contentWrapper:p,shouldExpandOnScrollRef:y,onScrollButtonChange:U,children:ee.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:ee.jsx(Xe.div,{...a,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Zv.displayName=LC;var AC="SelectPopperPosition",Bc=g.forwardRef((n,r)=>{const{__scopeSelect:i,align:l="start",collisionPadding:a=cn,...c}=n,f=ma(i);return ee.jsx(T2,{...f,...c,ref:r,align:l,collisionPadding:a,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Bc.displayName=AC;var[IC,vd]=Si(So,{}),Uc="SelectViewport",Jv=g.forwardRef((n,r)=>{const{__scopeSelect:i,nonce:l,...a}=n,c=Vr(Uc,i),f=vd(Uc,i),p=ct(r,c.onViewportChange),h=g.useRef(0);return ee.jsxs(ee.Fragment,{children:[ee.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),ee.jsx(pa.Slot,{scope:i,children:ee.jsx(Xe.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:p,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Je(a.onScroll,m=>{const w=m.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:k}=f;if(k!=null&&k.current&&x){const y=Math.abs(h.current-w.scrollTop);if(y>0){const O=window.innerHeight-cn*2,S=parseFloat(x.style.minHeight),C=parseFloat(x.style.height),P=Math.max(S,C);if(P<O){const T=P+y,R=Math.min(O,T),L=T-R;x.style.height=R+"px",x.style.bottom==="0px"&&(w.scrollTop=L>0?L:0,x.style.justifyContent="flex-end")}}}h.current=w.scrollTop})})})]})});Jv.displayName=Uc;var ey="SelectGroup",[DC,FC]=Si(ey),zC=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n,a=ld();return ee.jsx(DC,{scope:i,id:a,children:ee.jsx(Xe.div,{role:"group","aria-labelledby":a,...l,ref:r})})});zC.displayName=ey;var ty="SelectLabel",ny=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n,a=FC(ty,i);return ee.jsx(Xe.div,{id:a.id,...l,ref:r})});ny.displayName=ty;var ia="SelectItem",[jC,ry]=Si(ia),oy=g.forwardRef((n,r)=>{const{__scopeSelect:i,value:l,disabled:a=!1,textValue:c,...f}=n,p=$r(ia,i),h=Vr(ia,i),m=p.value===l,[w,x]=g.useState(c??""),[k,y]=g.useState(!1),O=ct(r,T=>{var R;return(R=h.itemRefCallback)==null?void 0:R.call(h,T,l,a)}),S=ld(),C=g.useRef("touch"),P=()=>{a||(p.onValueChange(l),p.onOpenChange(!1))};if(l==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return ee.jsx(jC,{scope:i,value:l,disabled:a,textId:S,isSelected:m,onItemTextChange:g.useCallback(T=>{x(R=>R||((T==null?void 0:T.textContent)??"").trim())},[]),children:ee.jsx(pa.ItemSlot,{scope:i,value:l,disabled:a,textValue:w,children:ee.jsx(Xe.div,{role:"option","aria-labelledby":S,"data-highlighted":k?"":void 0,"aria-selected":m&&k,"data-state":m?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...f,ref:O,onFocus:Je(f.onFocus,()=>y(!0)),onBlur:Je(f.onBlur,()=>y(!1)),onClick:Je(f.onClick,()=>{C.current!=="mouse"&&P()}),onPointerUp:Je(f.onPointerUp,()=>{C.current==="mouse"&&P()}),onPointerDown:Je(f.onPointerDown,T=>{C.current=T.pointerType}),onPointerMove:Je(f.onPointerMove,T=>{var R;C.current=T.pointerType,a?(R=h.onItemLeave)==null||R.call(h):C.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Je(f.onPointerLeave,T=>{var R;T.currentTarget===document.activeElement&&((R=h.onItemLeave)==null||R.call(h))}),onKeyDown:Je(f.onKeyDown,T=>{var L;((L=h.searchRef)==null?void 0:L.current)!==""&&T.key===" "||(EC.includes(T.key)&&P(),T.key===" "&&T.preventDefault())})})})})});oy.displayName=ia;var us="SelectItemText",iy=g.forwardRef((n,r)=>{const{__scopeSelect:i,className:l,style:a,...c}=n,f=$r(us,i),p=Vr(us,i),h=ry(us,i),m=MC(us,i),[w,x]=g.useState(null),k=ct(r,P=>x(P),h.onItemTextChange,P=>{var T;return(T=p.itemTextRefCallback)==null?void 0:T.call(p,P,h.value,h.disabled)}),y=w==null?void 0:w.textContent,O=g.useMemo(()=>ee.jsx("option",{value:h.value,disabled:h.disabled,children:y},h.value),[h.disabled,h.value,y]),{onNativeOptionAdd:S,onNativeOptionRemove:C}=m;return At(()=>(S(O),()=>C(O)),[S,C,O]),ee.jsxs(ee.Fragment,{children:[ee.jsx(Xe.span,{id:h.textId,...c,ref:k}),h.isSelected&&f.valueNode&&!f.valueNodeHasChildren?xs.createPortal(c.children,f.valueNode):null]})});iy.displayName=us;var sy="SelectItemIndicator",ly=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n;return ry(sy,i).isSelected?ee.jsx(Xe.span,{"aria-hidden":!0,...l,ref:r}):null});ly.displayName=sy;var Hc="SelectScrollUpButton",ay=g.forwardRef((n,r)=>{const i=Vr(Hc,n.__scopeSelect),l=vd(Hc,n.__scopeSelect),[a,c]=g.useState(!1),f=ct(r,l.onScrollButtonChange);return At(()=>{if(i.viewport&&i.isPositioned){let p=function(){const m=h.scrollTop>0;c(m)};const h=i.viewport;return p(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[i.viewport,i.isPositioned]),a?ee.jsx(cy,{...n,ref:f,onAutoScroll:()=>{const{viewport:p,selectedItem:h}=i;p&&h&&(p.scrollTop=p.scrollTop-h.offsetHeight)}}):null});ay.displayName=Hc;var $c="SelectScrollDownButton",uy=g.forwardRef((n,r)=>{const i=Vr($c,n.__scopeSelect),l=vd($c,n.__scopeSelect),[a,c]=g.useState(!1),f=ct(r,l.onScrollButtonChange);return At(()=>{if(i.viewport&&i.isPositioned){let p=function(){const m=h.scrollHeight-h.clientHeight,w=Math.ceil(h.scrollTop)<m;c(w)};const h=i.viewport;return p(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[i.viewport,i.isPositioned]),a?ee.jsx(cy,{...n,ref:f,onAutoScroll:()=>{const{viewport:p,selectedItem:h}=i;p&&h&&(p.scrollTop=p.scrollTop+h.offsetHeight)}}):null});uy.displayName=$c;var cy=g.forwardRef((n,r)=>{const{__scopeSelect:i,onAutoScroll:l,...a}=n,c=Vr("SelectScrollButton",i),f=g.useRef(null),p=ha(i),h=g.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return g.useEffect(()=>()=>h(),[h]),At(()=>{var w;const m=p().find(x=>x.ref.current===document.activeElement);(w=m==null?void 0:m.ref.current)==null||w.scrollIntoView({block:"nearest"})},[p]),ee.jsx(Xe.div,{"aria-hidden":!0,...a,ref:r,style:{flexShrink:0,...a.style},onPointerDown:Je(a.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(l,50))}),onPointerMove:Je(a.onPointerMove,()=>{var m;(m=c.onItemLeave)==null||m.call(c),f.current===null&&(f.current=window.setInterval(l,50))}),onPointerLeave:Je(a.onPointerLeave,()=>{h()})})}),BC="SelectSeparator",dy=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n;return ee.jsx(Xe.div,{"aria-hidden":!0,...l,ref:r})});dy.displayName=BC;var Vc="SelectArrow",UC=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n,a=ma(i),c=$r(Vc,i),f=Vr(Vc,i);return c.open&&f.position==="popper"?ee.jsx(O2,{...a,...l,ref:r}):null});UC.displayName=Vc;var HC="SelectBubbleInput",fy=g.forwardRef(({__scopeSelect:n,value:r,...i},l)=>{const a=g.useRef(null),c=ct(l,a),f=I2(r);return g.useEffect(()=>{const p=a.current;if(!p)return;const h=window.HTMLSelectElement.prototype,w=Object.getOwnPropertyDescriptor(h,"value").set;if(f!==r&&w){const x=new Event("change",{bubbles:!0});w.call(p,r),p.dispatchEvent(x)}},[f,r]),ee.jsx(Xe.select,{...i,style:{..._v,...i.style},ref:c,defaultValue:r})});fy.displayName=HC;function py(n){return n===""||n===void 0}function hy(n){const r=go(n),i=g.useRef(""),l=g.useRef(0),a=g.useCallback(f=>{const p=i.current+f;r(p),(function h(m){i.current=m,window.clearTimeout(l.current),m!==""&&(l.current=window.setTimeout(()=>h(""),1e3))})(p)},[r]),c=g.useCallback(()=>{i.current="",window.clearTimeout(l.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(l.current),[]),[i,a,c]}function my(n,r,i){const a=r.length>1&&Array.from(r).every(m=>m===r[0])?r[0]:r,c=i?n.indexOf(i):-1;let f=$C(n,Math.max(c,0));a.length===1&&(f=f.filter(m=>m!==i));const h=f.find(m=>m.textValue.toLowerCase().startsWith(a.toLowerCase()));return h!==i?h:void 0}function $C(n,r){return n.map((i,l)=>n[(r+l)%n.length])}var wE=Hv,xE=Vv,SE=Qv,CE=Kv,kE=qv,EE=Yv,bE=Jv,RE=ny,PE=oy,ME=iy,TE=ly,OE=ay,_E=uy,NE=dy;const em=n=>{let r;const i=new Set,l=(m,w)=>{const x=typeof m=="function"?m(r):m;if(!Object.is(x,r)){const k=r;r=w??(typeof x!="object"||x===null)?x:Object.assign({},r,x),i.forEach(y=>y(r,k))}},a=()=>r,p={setState:l,getState:a,getInitialState:()=>h,subscribe:m=>(i.add(m),()=>i.delete(m))},h=r=n(l,a,p);return p},VC=(n=>n?em(n):em),WC=n=>n;function QC(n,r=WC){const i=G.useSyncExternalStore(n.subscribe,G.useCallback(()=>r(n.getState()),[n,r]),G.useCallback(()=>r(n.getInitialState()),[n,r]));return G.useDebugValue(i),i}const tm=n=>{const r=VC(n),i=l=>QC(r,l);return Object.assign(i,r),i},LE=(n=>n?tm(n):tm);export{lk as $,ak as A,hk as B,yk as C,Wk as D,Fk as E,fk as F,Ok as G,Ak as H,CE as I,Hr as J,Dk as K,RE as L,Uk as M,F1 as N,LE as O,kE as P,ek as Q,wE as R,OE as S,xE as T,tk as U,bE as V,XC as W,f1 as X,GC as Y,qC as Z,ZC as _,ok as a,At as a$,wk as a0,Tk as a1,zk as a2,Gk as a3,Hk as a4,fE as a5,dk as a6,Zk as a7,bk as a8,Kk as a9,P2 as aA,ld as aB,ct as aC,Xe as aD,Je as aE,M2 as aF,Sv as aG,Ov as aH,sd as aI,B2 as aJ,Uv as aK,ea as aL,Xx as aM,sv as aN,ov as aO,T2 as aP,O2 as aQ,jk as aR,Lk as aS,aE as aT,eE as aU,Ik as aV,Ck as aW,mE as aX,hE as aY,Vk as aZ,pE as a_,mk as aa,cE as ab,dE as ac,pk as ad,pm as ae,kk as af,lE as ag,_k as ah,Mk as ai,nE as aj,Sk as ak,yE as al,U2 as am,gE as an,vE as ao,uE as ap,Jk as aq,qk as ar,Xk as as,Rm as at,YC as au,Rk as av,Pk as aw,rE as ax,xk as ay,qh as az,Qm as b,Bk as b0,Qk as b1,ck as b2,Nk as b3,Rw as c,rk as d,sk as e,gk as f,_E as g,EE as h,PE as i,ee as j,TE as k,vk as l,ME as m,NE as n,SE as o,Ek as p,sE as q,g as r,tE as s,ik as t,nk as u,$k as v,iE as w,Yk as x,uk as y,oE as z};
407
+ `)},wC=0,Xo=[];function xC(n){var r=g.useRef([]),i=g.useRef([0,0]),l=g.useRef(),a=g.useState(wC++)[0],c=g.useState(Fv)[0],f=g.useRef(n);g.useEffect(function(){f.current=n},[n]),g.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(a));var S=U2([n.lockRef.current],(n.shards||[]).map(Jh),!0).filter(Boolean);return S.forEach(function(C){return C.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),S.forEach(function(C){return C.classList.remove("allow-interactivity-".concat(a))})}}},[n.inert,n.lockRef.current,n.shards]);var p=g.useCallback(function(S,C){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!f.current.allowPinchZoom;var P=Vl(S),T=i.current,R="deltaX"in S?S.deltaX:T[0]-P[0],L="deltaY"in S?S.deltaY:T[1]-P[1],z,U=S.target,H=Math.abs(R)>Math.abs(L)?"h":"v";if("touches"in S&&H==="h"&&U.type==="range")return!1;var q=window.getSelection(),Z=q&&q.anchorNode,te=Z?Z===U||Z.contains(U):!1;if(te)return!1;var he=Xh(H,U);if(!he)return!0;if(he?z=H:(z=H==="v"?"h":"v",he=Xh(H,U)),!he)return!1;if(!l.current&&"changedTouches"in S&&(R||L)&&(l.current=z),!z)return!0;var X=l.current||z;return vC(X,C,S,X==="h"?R:L)},[]),h=g.useCallback(function(S){var C=S;if(!(!Xo.length||Xo[Xo.length-1]!==c)){var P="deltaY"in C?Zh(C):Vl(C),T=r.current.filter(function(z){return z.name===C.type&&(z.target===C.target||C.target===z.shadowParent)&&yC(z.delta,P)})[0];if(T&&T.should){C.cancelable&&C.preventDefault();return}if(!T){var R=(f.current.shards||[]).map(Jh).filter(Boolean).filter(function(z){return z.contains(C.target)}),L=R.length>0?p(C,R[0]):!f.current.noIsolation;L&&C.cancelable&&C.preventDefault()}}},[]),m=g.useCallback(function(S,C,P,T){var R={name:S,delta:C,target:P,should:T,shadowParent:SC(P)};r.current.push(R),setTimeout(function(){r.current=r.current.filter(function(L){return L!==R})},1)},[]),w=g.useCallback(function(S){i.current=Vl(S),l.current=void 0},[]),x=g.useCallback(function(S){m(S.type,Zh(S),S.target,p(S,n.lockRef.current))},[]),k=g.useCallback(function(S){m(S.type,Vl(S),S.target,p(S,n.lockRef.current))},[]);g.useEffect(function(){return Xo.push(c),n.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:k}),document.addEventListener("wheel",h,Go),document.addEventListener("touchmove",h,Go),document.addEventListener("touchstart",w,Go),function(){Xo=Xo.filter(function(S){return S!==c}),document.removeEventListener("wheel",h,Go),document.removeEventListener("touchmove",h,Go),document.removeEventListener("touchstart",w,Go)}},[]);var y=n.removeScrollBar,O=n.inert;return g.createElement(g.Fragment,null,O?g.createElement(c,{styles:gC(a)}):null,y?g.createElement(uC,{noRelative:n.noRelative,gapMode:n.gapMode}):null)}function SC(n){for(var r=null;n!==null;)n instanceof ShadowRoot&&(r=n.host,n=n.host),n=n.parentNode;return r}const CC=G2(Dv,xC);var Uv=g.forwardRef(function(n,r){return g.createElement(fa,Ln({},n,{ref:r,sideCar:CC}))});Uv.classNames=fa.classNames;var kC=[" ","Enter","ArrowUp","ArrowDown"],EC=[" ","Enter"],xo="Select",[pa,ha,bC]=zx(xo),[Si]=sd(xo,[bC,Sv]),ma=Sv(),[RC,$r]=Si(xo),[PC,MC]=Si(xo),Hv=n=>{const{__scopeSelect:r,children:i,open:l,defaultOpen:a,onOpenChange:c,value:f,defaultValue:p,onValueChange:h,dir:m,name:w,autoComplete:x,disabled:k,required:y,form:O}=n,S=ma(r),[C,P]=g.useState(null),[T,R]=g.useState(null),[L,z]=g.useState(!1),U=Bx(m),[H,q]=qh({prop:l,defaultProp:a??!1,onChange:c,caller:xo}),[Z,te]=qh({prop:f,defaultProp:p,onChange:h,caller:xo}),he=g.useRef(null),X=C?O||!!C.closest("form"):!0,[ye,ce]=g.useState(new Set),xe=Array.from(ye).map(ae=>ae.props.value).join(";");return ee.jsx(P2,{...S,children:ee.jsxs(RC,{required:y,scope:r,trigger:C,onTriggerChange:P,valueNode:T,onValueNodeChange:R,valueNodeHasChildren:L,onValueNodeHasChildrenChange:z,contentId:ld(),value:Z,onValueChange:te,open:H,onOpenChange:q,dir:U,triggerPointerDownPosRef:he,disabled:k,children:[ee.jsx(pa.Provider,{scope:r,children:ee.jsx(PC,{scope:n.__scopeSelect,onNativeOptionAdd:g.useCallback(ae=>{ce(ie=>new Set(ie).add(ae))},[]),onNativeOptionRemove:g.useCallback(ae=>{ce(ie=>{const j=new Set(ie);return j.delete(ae),j})},[]),children:i})}),X?ee.jsxs(fy,{"aria-hidden":!0,required:y,tabIndex:-1,name:w,autoComplete:x,value:Z,onChange:ae=>te(ae.target.value),disabled:k,form:O,children:[Z===void 0?ee.jsx("option",{value:""}):null,Array.from(ye)]},xe):null]})})};Hv.displayName=xo;var $v="SelectTrigger",Vv=g.forwardRef((n,r)=>{const{__scopeSelect:i,disabled:l=!1,...a}=n,c=ma(i),f=$r($v,i),p=f.disabled||l,h=ct(r,f.onTriggerChange),m=ha(i),w=g.useRef("touch"),[x,k,y]=hy(S=>{const C=m().filter(R=>!R.disabled),P=C.find(R=>R.value===f.value),T=my(C,S,P);T!==void 0&&f.onValueChange(T.value)}),O=S=>{p||(f.onOpenChange(!0),y()),S&&(f.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return ee.jsx(M2,{asChild:!0,...c,children:ee.jsx(Xe.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:p,"data-disabled":p?"":void 0,"data-placeholder":py(f.value)?"":void 0,...a,ref:h,onClick:Je(a.onClick,S=>{S.currentTarget.focus(),w.current!=="mouse"&&O(S)}),onPointerDown:Je(a.onPointerDown,S=>{w.current=S.pointerType;const C=S.target;C.hasPointerCapture(S.pointerId)&&C.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(O(S),S.preventDefault())}),onKeyDown:Je(a.onKeyDown,S=>{const C=x.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&k(S.key),!(C&&S.key===" ")&&kC.includes(S.key)&&(O(),S.preventDefault())})})})});Vv.displayName=$v;var Wv="SelectValue",Qv=g.forwardRef((n,r)=>{const{__scopeSelect:i,className:l,style:a,children:c,placeholder:f="",...p}=n,h=$r(Wv,i),{onValueNodeHasChildrenChange:m}=h,w=c!==void 0,x=ct(r,h.onValueNodeChange);return At(()=>{m(w)},[m,w]),ee.jsx(Xe.span,{...p,ref:x,style:{pointerEvents:"none"},children:py(h.value)?ee.jsx(ee.Fragment,{children:f}):c})});Qv.displayName=Wv;var TC="SelectIcon",Kv=g.forwardRef((n,r)=>{const{__scopeSelect:i,children:l,...a}=n;return ee.jsx(Xe.span,{"aria-hidden":!0,...a,ref:r,children:l||"▼"})});Kv.displayName=TC;var OC="SelectPortal",qv=n=>ee.jsx(Ov,{asChild:!0,...n});qv.displayName=OC;var So="SelectContent",Yv=g.forwardRef((n,r)=>{const i=$r(So,n.__scopeSelect),[l,a]=g.useState();if(At(()=>{a(new DocumentFragment)},[]),!i.open){const c=l;return c?xs.createPortal(ee.jsx(Gv,{scope:n.__scopeSelect,children:ee.jsx(pa.Slot,{scope:n.__scopeSelect,children:ee.jsx("div",{children:n.children})})}),c):null}return ee.jsx(Xv,{...n,ref:r})});Yv.displayName=So;var cn=10,[Gv,Vr]=Si(So),_C="SelectContentImpl",NC=ea("SelectContent.RemoveScroll"),Xv=g.forwardRef((n,r)=>{const{__scopeSelect:i,position:l="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:c,onPointerDownOutside:f,side:p,sideOffset:h,align:m,alignOffset:w,arrowPadding:x,collisionBoundary:k,collisionPadding:y,sticky:O,hideWhenDetached:S,avoidCollisions:C,...P}=n,T=$r(So,i),[R,L]=g.useState(null),[z,U]=g.useState(null),H=ct(r,K=>L(K)),[q,Z]=g.useState(null),[te,he]=g.useState(null),X=ha(i),[ye,ce]=g.useState(!1),xe=g.useRef(!1);g.useEffect(()=>{if(R)return B2(R)},[R]),Xx();const ae=g.useCallback(K=>{const[fe,...Ce]=X().map(Oe=>Oe.ref.current),[be]=Ce.slice(-1),Me=document.activeElement;for(const Oe of K)if(Oe===Me||(Oe==null||Oe.scrollIntoView({block:"nearest"}),Oe===fe&&z&&(z.scrollTop=0),Oe===be&&z&&(z.scrollTop=z.scrollHeight),Oe==null||Oe.focus(),document.activeElement!==Me))return},[X,z]),ie=g.useCallback(()=>ae([q,R]),[ae,q,R]);g.useEffect(()=>{ye&&ie()},[ye,ie]);const{onOpenChange:j,triggerPointerDownPosRef:B}=T;g.useEffect(()=>{if(R){let K={x:0,y:0};const fe=be=>{var Me,Oe;K={x:Math.abs(Math.round(be.pageX)-(((Me=B.current)==null?void 0:Me.x)??0)),y:Math.abs(Math.round(be.pageY)-(((Oe=B.current)==null?void 0:Oe.y)??0))}},Ce=be=>{K.x<=10&&K.y<=10?be.preventDefault():R.contains(be.target)||j(!1),document.removeEventListener("pointermove",fe),B.current=null};return B.current!==null&&(document.addEventListener("pointermove",fe),document.addEventListener("pointerup",Ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",fe),document.removeEventListener("pointerup",Ce,{capture:!0})}}},[R,j,B]),g.useEffect(()=>{const K=()=>j(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[j]);const[W,_]=hy(K=>{const fe=X().filter(Me=>!Me.disabled),Ce=fe.find(Me=>Me.ref.current===document.activeElement),be=my(fe,K,Ce);be&&setTimeout(()=>be.ref.current.focus())}),F=g.useCallback((K,fe,Ce)=>{const be=!xe.current&&!Ce;(T.value!==void 0&&T.value===fe||be)&&(Z(K),be&&(xe.current=!0))},[T.value]),ne=g.useCallback(()=>R==null?void 0:R.focus(),[R]),re=g.useCallback((K,fe,Ce)=>{const be=!xe.current&&!Ce;(T.value!==void 0&&T.value===fe||be)&&he(K)},[T.value]),ve=l==="popper"?Bc:Zv,Se=ve===Bc?{side:p,sideOffset:h,align:m,alignOffset:w,arrowPadding:x,collisionBoundary:k,collisionPadding:y,sticky:O,hideWhenDetached:S,avoidCollisions:C}:{};return ee.jsx(Gv,{scope:i,content:R,viewport:z,onViewportChange:U,itemRefCallback:F,selectedItem:q,onItemLeave:ne,itemTextRefCallback:re,focusSelectedItem:ie,selectedItemText:te,position:l,isPositioned:ye,searchRef:W,children:ee.jsx(Uv,{as:NC,allowPinchZoom:!0,children:ee.jsx(sv,{asChild:!0,trapped:T.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:Je(a,K=>{var fe;(fe=T.trigger)==null||fe.focus({preventScroll:!0}),K.preventDefault()}),children:ee.jsx(ov,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:f,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:ee.jsx(ve,{role:"listbox",id:T.contentId,"data-state":T.open?"open":"closed",dir:T.dir,onContextMenu:K=>K.preventDefault(),...P,...Se,onPlaced:()=>ce(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...P.style},onKeyDown:Je(P.onKeyDown,K=>{const fe=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!fe&&K.key.length===1&&_(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let be=X().filter(Me=>!Me.disabled).map(Me=>Me.ref.current);if(["ArrowUp","End"].includes(K.key)&&(be=be.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const Me=K.target,Oe=be.indexOf(Me);be=be.slice(Oe+1)}setTimeout(()=>ae(be)),K.preventDefault()}})})})})})})});Xv.displayName=_C;var LC="SelectItemAlignedPosition",Zv=g.forwardRef((n,r)=>{const{__scopeSelect:i,onPlaced:l,...a}=n,c=$r(So,i),f=Vr(So,i),[p,h]=g.useState(null),[m,w]=g.useState(null),x=ct(r,H=>w(H)),k=ha(i),y=g.useRef(!1),O=g.useRef(!0),{viewport:S,selectedItem:C,selectedItemText:P,focusSelectedItem:T}=f,R=g.useCallback(()=>{if(c.trigger&&c.valueNode&&p&&m&&S&&C&&P){const H=c.trigger.getBoundingClientRect(),q=m.getBoundingClientRect(),Z=c.valueNode.getBoundingClientRect(),te=P.getBoundingClientRect();if(c.dir!=="rtl"){const Me=te.left-q.left,Oe=Z.left-Me,qe=H.left-Oe,dt=H.width+qe,yn=Math.max(dt,q.width),Xt=window.innerWidth-cn,Zt=Mh(Oe,[cn,Math.max(cn,Xt-yn)]);p.style.minWidth=dt+"px",p.style.left=Zt+"px"}else{const Me=q.right-te.right,Oe=window.innerWidth-Z.right-Me,qe=window.innerWidth-H.right-Oe,dt=H.width+qe,yn=Math.max(dt,q.width),Xt=window.innerWidth-cn,Zt=Mh(Oe,[cn,Math.max(cn,Xt-yn)]);p.style.minWidth=dt+"px",p.style.right=Zt+"px"}const he=k(),X=window.innerHeight-cn*2,ye=S.scrollHeight,ce=window.getComputedStyle(m),xe=parseInt(ce.borderTopWidth,10),ae=parseInt(ce.paddingTop,10),ie=parseInt(ce.borderBottomWidth,10),j=parseInt(ce.paddingBottom,10),B=xe+ae+ye+j+ie,W=Math.min(C.offsetHeight*5,B),_=window.getComputedStyle(S),F=parseInt(_.paddingTop,10),ne=parseInt(_.paddingBottom,10),re=H.top+H.height/2-cn,ve=X-re,Se=C.offsetHeight/2,K=C.offsetTop+Se,fe=xe+ae+K,Ce=B-fe;if(fe<=re){const Me=he.length>0&&C===he[he.length-1].ref.current;p.style.bottom="0px";const Oe=m.clientHeight-S.offsetTop-S.offsetHeight,qe=Math.max(ve,Se+(Me?ne:0)+Oe+ie),dt=fe+qe;p.style.height=dt+"px"}else{const Me=he.length>0&&C===he[0].ref.current;p.style.top="0px";const qe=Math.max(re,xe+S.offsetTop+(Me?F:0)+Se)+Ce;p.style.height=qe+"px",S.scrollTop=fe-re+S.offsetTop}p.style.margin=`${cn}px 0`,p.style.minHeight=W+"px",p.style.maxHeight=X+"px",l==null||l(),requestAnimationFrame(()=>y.current=!0)}},[k,c.trigger,c.valueNode,p,m,S,C,P,c.dir,l]);At(()=>R(),[R]);const[L,z]=g.useState();At(()=>{m&&z(window.getComputedStyle(m).zIndex)},[m]);const U=g.useCallback(H=>{H&&O.current===!0&&(R(),T==null||T(),O.current=!1)},[R,T]);return ee.jsx(IC,{scope:i,contentWrapper:p,shouldExpandOnScrollRef:y,onScrollButtonChange:U,children:ee.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:ee.jsx(Xe.div,{...a,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Zv.displayName=LC;var AC="SelectPopperPosition",Bc=g.forwardRef((n,r)=>{const{__scopeSelect:i,align:l="start",collisionPadding:a=cn,...c}=n,f=ma(i);return ee.jsx(T2,{...f,...c,ref:r,align:l,collisionPadding:a,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Bc.displayName=AC;var[IC,vd]=Si(So,{}),Uc="SelectViewport",Jv=g.forwardRef((n,r)=>{const{__scopeSelect:i,nonce:l,...a}=n,c=Vr(Uc,i),f=vd(Uc,i),p=ct(r,c.onViewportChange),h=g.useRef(0);return ee.jsxs(ee.Fragment,{children:[ee.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),ee.jsx(pa.Slot,{scope:i,children:ee.jsx(Xe.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:p,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Je(a.onScroll,m=>{const w=m.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:k}=f;if(k!=null&&k.current&&x){const y=Math.abs(h.current-w.scrollTop);if(y>0){const O=window.innerHeight-cn*2,S=parseFloat(x.style.minHeight),C=parseFloat(x.style.height),P=Math.max(S,C);if(P<O){const T=P+y,R=Math.min(O,T),L=T-R;x.style.height=R+"px",x.style.bottom==="0px"&&(w.scrollTop=L>0?L:0,x.style.justifyContent="flex-end")}}}h.current=w.scrollTop})})})]})});Jv.displayName=Uc;var ey="SelectGroup",[DC,FC]=Si(ey),zC=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n,a=ld();return ee.jsx(DC,{scope:i,id:a,children:ee.jsx(Xe.div,{role:"group","aria-labelledby":a,...l,ref:r})})});zC.displayName=ey;var ty="SelectLabel",ny=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n,a=FC(ty,i);return ee.jsx(Xe.div,{id:a.id,...l,ref:r})});ny.displayName=ty;var ia="SelectItem",[jC,ry]=Si(ia),oy=g.forwardRef((n,r)=>{const{__scopeSelect:i,value:l,disabled:a=!1,textValue:c,...f}=n,p=$r(ia,i),h=Vr(ia,i),m=p.value===l,[w,x]=g.useState(c??""),[k,y]=g.useState(!1),O=ct(r,T=>{var R;return(R=h.itemRefCallback)==null?void 0:R.call(h,T,l,a)}),S=ld(),C=g.useRef("touch"),P=()=>{a||(p.onValueChange(l),p.onOpenChange(!1))};if(l==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return ee.jsx(jC,{scope:i,value:l,disabled:a,textId:S,isSelected:m,onItemTextChange:g.useCallback(T=>{x(R=>R||((T==null?void 0:T.textContent)??"").trim())},[]),children:ee.jsx(pa.ItemSlot,{scope:i,value:l,disabled:a,textValue:w,children:ee.jsx(Xe.div,{role:"option","aria-labelledby":S,"data-highlighted":k?"":void 0,"aria-selected":m&&k,"data-state":m?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...f,ref:O,onFocus:Je(f.onFocus,()=>y(!0)),onBlur:Je(f.onBlur,()=>y(!1)),onClick:Je(f.onClick,()=>{C.current!=="mouse"&&P()}),onPointerUp:Je(f.onPointerUp,()=>{C.current==="mouse"&&P()}),onPointerDown:Je(f.onPointerDown,T=>{C.current=T.pointerType}),onPointerMove:Je(f.onPointerMove,T=>{var R;C.current=T.pointerType,a?(R=h.onItemLeave)==null||R.call(h):C.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Je(f.onPointerLeave,T=>{var R;T.currentTarget===document.activeElement&&((R=h.onItemLeave)==null||R.call(h))}),onKeyDown:Je(f.onKeyDown,T=>{var L;((L=h.searchRef)==null?void 0:L.current)!==""&&T.key===" "||(EC.includes(T.key)&&P(),T.key===" "&&T.preventDefault())})})})})});oy.displayName=ia;var us="SelectItemText",iy=g.forwardRef((n,r)=>{const{__scopeSelect:i,className:l,style:a,...c}=n,f=$r(us,i),p=Vr(us,i),h=ry(us,i),m=MC(us,i),[w,x]=g.useState(null),k=ct(r,P=>x(P),h.onItemTextChange,P=>{var T;return(T=p.itemTextRefCallback)==null?void 0:T.call(p,P,h.value,h.disabled)}),y=w==null?void 0:w.textContent,O=g.useMemo(()=>ee.jsx("option",{value:h.value,disabled:h.disabled,children:y},h.value),[h.disabled,h.value,y]),{onNativeOptionAdd:S,onNativeOptionRemove:C}=m;return At(()=>(S(O),()=>C(O)),[S,C,O]),ee.jsxs(ee.Fragment,{children:[ee.jsx(Xe.span,{id:h.textId,...c,ref:k}),h.isSelected&&f.valueNode&&!f.valueNodeHasChildren?xs.createPortal(c.children,f.valueNode):null]})});iy.displayName=us;var sy="SelectItemIndicator",ly=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n;return ry(sy,i).isSelected?ee.jsx(Xe.span,{"aria-hidden":!0,...l,ref:r}):null});ly.displayName=sy;var Hc="SelectScrollUpButton",ay=g.forwardRef((n,r)=>{const i=Vr(Hc,n.__scopeSelect),l=vd(Hc,n.__scopeSelect),[a,c]=g.useState(!1),f=ct(r,l.onScrollButtonChange);return At(()=>{if(i.viewport&&i.isPositioned){let p=function(){const m=h.scrollTop>0;c(m)};const h=i.viewport;return p(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[i.viewport,i.isPositioned]),a?ee.jsx(cy,{...n,ref:f,onAutoScroll:()=>{const{viewport:p,selectedItem:h}=i;p&&h&&(p.scrollTop=p.scrollTop-h.offsetHeight)}}):null});ay.displayName=Hc;var $c="SelectScrollDownButton",uy=g.forwardRef((n,r)=>{const i=Vr($c,n.__scopeSelect),l=vd($c,n.__scopeSelect),[a,c]=g.useState(!1),f=ct(r,l.onScrollButtonChange);return At(()=>{if(i.viewport&&i.isPositioned){let p=function(){const m=h.scrollHeight-h.clientHeight,w=Math.ceil(h.scrollTop)<m;c(w)};const h=i.viewport;return p(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[i.viewport,i.isPositioned]),a?ee.jsx(cy,{...n,ref:f,onAutoScroll:()=>{const{viewport:p,selectedItem:h}=i;p&&h&&(p.scrollTop=p.scrollTop+h.offsetHeight)}}):null});uy.displayName=$c;var cy=g.forwardRef((n,r)=>{const{__scopeSelect:i,onAutoScroll:l,...a}=n,c=Vr("SelectScrollButton",i),f=g.useRef(null),p=ha(i),h=g.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return g.useEffect(()=>()=>h(),[h]),At(()=>{var w;const m=p().find(x=>x.ref.current===document.activeElement);(w=m==null?void 0:m.ref.current)==null||w.scrollIntoView({block:"nearest"})},[p]),ee.jsx(Xe.div,{"aria-hidden":!0,...a,ref:r,style:{flexShrink:0,...a.style},onPointerDown:Je(a.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(l,50))}),onPointerMove:Je(a.onPointerMove,()=>{var m;(m=c.onItemLeave)==null||m.call(c),f.current===null&&(f.current=window.setInterval(l,50))}),onPointerLeave:Je(a.onPointerLeave,()=>{h()})})}),BC="SelectSeparator",dy=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n;return ee.jsx(Xe.div,{"aria-hidden":!0,...l,ref:r})});dy.displayName=BC;var Vc="SelectArrow",UC=g.forwardRef((n,r)=>{const{__scopeSelect:i,...l}=n,a=ma(i),c=$r(Vc,i),f=Vr(Vc,i);return c.open&&f.position==="popper"?ee.jsx(O2,{...a,...l,ref:r}):null});UC.displayName=Vc;var HC="SelectBubbleInput",fy=g.forwardRef(({__scopeSelect:n,value:r,...i},l)=>{const a=g.useRef(null),c=ct(l,a),f=I2(r);return g.useEffect(()=>{const p=a.current;if(!p)return;const h=window.HTMLSelectElement.prototype,w=Object.getOwnPropertyDescriptor(h,"value").set;if(f!==r&&w){const x=new Event("change",{bubbles:!0});w.call(p,r),p.dispatchEvent(x)}},[f,r]),ee.jsx(Xe.select,{...i,style:{..._v,...i.style},ref:c,defaultValue:r})});fy.displayName=HC;function py(n){return n===""||n===void 0}function hy(n){const r=go(n),i=g.useRef(""),l=g.useRef(0),a=g.useCallback(f=>{const p=i.current+f;r(p),(function h(m){i.current=m,window.clearTimeout(l.current),m!==""&&(l.current=window.setTimeout(()=>h(""),1e3))})(p)},[r]),c=g.useCallback(()=>{i.current="",window.clearTimeout(l.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(l.current),[]),[i,a,c]}function my(n,r,i){const a=r.length>1&&Array.from(r).every(m=>m===r[0])?r[0]:r,c=i?n.indexOf(i):-1;let f=$C(n,Math.max(c,0));a.length===1&&(f=f.filter(m=>m!==i));const h=f.find(m=>m.textValue.toLowerCase().startsWith(a.toLowerCase()));return h!==i?h:void 0}function $C(n,r){return n.map((i,l)=>n[(r+l)%n.length])}var wE=Hv,xE=Vv,SE=Qv,CE=Kv,kE=qv,EE=Yv,bE=Jv,RE=ny,PE=oy,ME=iy,TE=ly,OE=ay,_E=uy,NE=dy;const em=n=>{let r;const i=new Set,l=(m,w)=>{const x=typeof m=="function"?m(r):m;if(!Object.is(x,r)){const k=r;r=w??(typeof x!="object"||x===null)?x:Object.assign({},r,x),i.forEach(y=>y(r,k))}},a=()=>r,p={setState:l,getState:a,getInitialState:()=>h,subscribe:m=>(i.add(m),()=>i.delete(m))},h=r=n(l,a,p);return p},VC=(n=>n?em(n):em),WC=n=>n;function QC(n,r=WC){const i=G.useSyncExternalStore(n.subscribe,G.useCallback(()=>r(n.getState()),[n,r]),G.useCallback(()=>r(n.getInitialState()),[n,r]));return G.useDebugValue(i),i}const tm=n=>{const r=VC(n),i=l=>QC(r,l);return Object.assign(i,r),i},LE=(n=>n?tm(n):tm);export{lk as $,ak as A,hk as B,yk as C,Wk as D,Fk as E,fk as F,Ok as G,Ak as H,CE as I,Hr as J,Dk as K,RE as L,Uk as M,F1 as N,LE as O,kE as P,ek as Q,wE as R,OE as S,xE as T,tk as U,bE as V,XC as W,f1 as X,GC as Y,qC as Z,ZC as _,ok as a,At as a$,wk as a0,Tk as a1,zk as a2,dk as a3,Zk as a4,bk as a5,Kk as a6,mk as a7,cE as a8,dE as a9,P2 as aA,ld as aB,ct as aC,Xe as aD,Je as aE,M2 as aF,Sv as aG,Ov as aH,sd as aI,B2 as aJ,Uv as aK,ea as aL,Xx as aM,sv as aN,ov as aO,T2 as aP,O2 as aQ,jk as aR,Lk as aS,aE as aT,eE as aU,Ik as aV,Ck as aW,mE as aX,hE as aY,Vk as aZ,pE as a_,pk as aa,pm as ab,kk as ac,lE as ad,_k as ae,Mk as af,nE as ag,Sk as ah,Gk as ai,Hk as aj,yE as ak,U2 as al,gE as am,vE as an,uE as ao,Jk as ap,qk as aq,Xk as ar,Rm as as,YC as at,Rk as au,Pk as av,fE as aw,rE as ax,xk as ay,qh as az,Qm as b,Bk as b0,Qk as b1,ck as b2,Nk as b3,Rw as c,rk as d,sk as e,gk as f,_E as g,EE as h,PE as i,ee as j,TE as k,vk as l,ME as m,NE as n,SE as o,Ek as p,sE as q,g as r,tE as s,ik as t,nk as u,$k as v,iE as w,Yk as x,uk as y,oE as z};
package/dist/index.html CHANGED
@@ -6,9 +6,9 @@
6
6
  <link rel="icon" type="image/svg+xml" href="/logo.svg" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>NextClaw - 系统配置</title>
9
- <script type="module" crossorigin src="/assets/index-CzkY1reu.js"></script>
10
- <link rel="modulepreload" crossorigin href="/assets/vendor-psXJBy9u.js">
11
- <link rel="stylesheet" crossorigin href="/assets/index-RZ0kHHRI.css">
9
+ <script type="module" crossorigin src="/assets/index-BiPDnzv0.js"></script>
10
+ <link rel="modulepreload" crossorigin href="/assets/vendor-DKBNiC31.js">
11
+ <link rel="stylesheet" crossorigin href="/assets/index-C8GsgIUn.css">
12
12
  </head>
13
13
 
14
14
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/ui",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,11 +27,11 @@
27
27
  "tailwind-merge": "^2.5.4",
28
28
  "zod": "^3.23.8",
29
29
  "zustand": "^5.0.2",
30
- "@nextclaw/ncp-http-agent-client": "0.3.0",
31
- "@nextclaw/ncp-react": "0.3.0",
32
- "@nextclaw/agent-chat-ui": "0.2.0",
33
- "@nextclaw/ncp": "0.3.0",
34
- "@nextclaw/agent-chat": "0.1.1"
30
+ "@nextclaw/agent-chat": "0.1.1",
31
+ "@nextclaw/agent-chat-ui": "0.2.1",
32
+ "@nextclaw/ncp": "0.3.1",
33
+ "@nextclaw/ncp-http-agent-client": "0.3.1",
34
+ "@nextclaw/ncp-react": "0.3.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@testing-library/react": "^16.3.0",
package/src/api/config.ts CHANGED
@@ -24,8 +24,6 @@ import type {
24
24
  ProviderCreateRequest,
25
25
  ProviderCreateResult,
26
26
  ProviderDeleteResult,
27
- NcpSessionMessagesView,
28
- NcpSessionsListView,
29
27
  RuntimeConfigUpdate,
30
28
  SecretsConfigUpdate,
31
29
  SecretsView,
@@ -371,42 +369,6 @@ export async function deleteSession(key: string): Promise<{ deleted: boolean }>
371
369
  return response.data;
372
370
  }
373
371
 
374
- // GET /api/ncp/sessions
375
- export async function fetchNcpSessions(params?: { limit?: number }): Promise<NcpSessionsListView> {
376
- const query = new URLSearchParams();
377
- if (typeof params?.limit === 'number' && Number.isFinite(params.limit)) {
378
- query.set('limit', String(Math.max(1, Math.trunc(params.limit))));
379
- }
380
- const suffix = query.toString();
381
- const response = await api.get<NcpSessionsListView>(suffix ? `/api/ncp/sessions?${suffix}` : '/api/ncp/sessions');
382
- if (!response.ok) {
383
- throw new Error(response.error.message);
384
- }
385
- return response.data;
386
- }
387
-
388
- // GET /api/ncp/sessions/:sessionId/messages
389
- export async function fetchNcpSessionMessages(sessionId: string, limit = 200): Promise<NcpSessionMessagesView> {
390
- const response = await api.get<NcpSessionMessagesView>(
391
- `/api/ncp/sessions/${encodeURIComponent(sessionId)}/messages?limit=${Math.max(1, Math.trunc(limit))}`
392
- );
393
- if (!response.ok) {
394
- throw new Error(response.error.message);
395
- }
396
- return response.data;
397
- }
398
-
399
- // DELETE /api/ncp/sessions/:sessionId
400
- export async function deleteNcpSession(sessionId: string): Promise<{ deleted: boolean; sessionId: string }> {
401
- const response = await api.delete<{ deleted: boolean; sessionId: string }>(
402
- `/api/ncp/sessions/${encodeURIComponent(sessionId)}`
403
- );
404
- if (!response.ok) {
405
- throw new Error(response.error.message);
406
- }
407
- return response.data;
408
- }
409
-
410
372
  // POST /api/chat/turn
411
373
  export async function sendChatTurn(data: ChatTurnRequest): Promise<ChatTurnView> {
412
374
  const response = await api.post<ChatTurnView>('/api/chat/turn', data);
@@ -639,6 +601,15 @@ export async function fetchChatSessionTypes(): Promise<ChatSessionTypesView> {
639
601
  return response.data;
640
602
  }
641
603
 
604
+ // GET /api/ncp/session-types
605
+ export async function fetchNcpChatSessionTypes(): Promise<ChatSessionTypesView> {
606
+ const response = await api.get<ChatSessionTypesView>('/api/ncp/session-types');
607
+ if (!response.ok) {
608
+ throw new Error(response.error.message);
609
+ }
610
+ return response.data;
611
+ }
612
+
642
613
  // POST /api/chat/turn/stop
643
614
  export async function stopChatTurn(data: ChatTurnStopRequest): Promise<ChatTurnStopResult> {
644
615
  const response = await api.post<ChatTurnStopResult>('/api/chat/turn/stop', data);
@@ -0,0 +1,50 @@
1
+ import { api } from './client';
2
+ import type { NcpSessionMessagesView, NcpSessionsListView, NcpSessionSummaryView, SessionPatchUpdate } from './types';
3
+
4
+ // GET /api/ncp/sessions
5
+ export async function fetchNcpSessions(params?: { limit?: number }): Promise<NcpSessionsListView> {
6
+ const query = new URLSearchParams();
7
+ if (typeof params?.limit === 'number' && Number.isFinite(params.limit)) {
8
+ query.set('limit', String(Math.max(1, Math.trunc(params.limit))));
9
+ }
10
+ const suffix = query.toString();
11
+ const response = await api.get<NcpSessionsListView>(suffix ? `/api/ncp/sessions?${suffix}` : '/api/ncp/sessions');
12
+ if (!response.ok) {
13
+ throw new Error(response.error.message);
14
+ }
15
+ return response.data;
16
+ }
17
+
18
+ // GET /api/ncp/sessions/:sessionId/messages
19
+ export async function fetchNcpSessionMessages(sessionId: string, limit = 200): Promise<NcpSessionMessagesView> {
20
+ const response = await api.get<NcpSessionMessagesView>(
21
+ `/api/ncp/sessions/${encodeURIComponent(sessionId)}/messages?limit=${Math.max(1, Math.trunc(limit))}`
22
+ );
23
+ if (!response.ok) {
24
+ throw new Error(response.error.message);
25
+ }
26
+ return response.data;
27
+ }
28
+
29
+ // PUT /api/ncp/sessions/:sessionId
30
+ export async function updateNcpSession(
31
+ sessionId: string,
32
+ data: SessionPatchUpdate
33
+ ): Promise<NcpSessionSummaryView> {
34
+ const response = await api.put<NcpSessionSummaryView>(`/api/ncp/sessions/${encodeURIComponent(sessionId)}`, data);
35
+ if (!response.ok) {
36
+ throw new Error(response.error.message);
37
+ }
38
+ return response.data;
39
+ }
40
+
41
+ // DELETE /api/ncp/sessions/:sessionId
42
+ export async function deleteNcpSession(sessionId: string): Promise<{ deleted: boolean; sessionId: string }> {
43
+ const response = await api.delete<{ deleted: boolean; sessionId: string }>(
44
+ `/api/ncp/sessions/${encodeURIComponent(sessionId)}`
45
+ );
46
+ if (!response.ok) {
47
+ throw new Error(response.error.message);
48
+ }
49
+ return response.data;
50
+ }
package/src/api/types.ts CHANGED
@@ -283,6 +283,7 @@ export type NcpSessionStatusView = NcpSessionStatus;
283
283
  export type SessionPatchUpdate = {
284
284
  label?: string | null;
285
285
  preferredModel?: string | null;
286
+ preferredThinking?: ThinkingLevel | null;
286
287
  sessionType?: string | null;
287
288
  clearHistory?: boolean;
288
289
  };
@@ -0,0 +1,65 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { ChatConversationPanel } from '@/components/chat/ChatConversationPanel';
4
+ import { useChatThreadStore } from '@/components/chat/stores/chat-thread.store';
5
+
6
+ const mocks = vi.hoisted(() => ({
7
+ deleteSession: vi.fn(),
8
+ goToProviders: vi.fn()
9
+ }));
10
+
11
+ vi.mock('@nextclaw/agent-chat-ui', () => ({
12
+ useStickyBottomScroll: () => ({
13
+ onScroll: vi.fn()
14
+ })
15
+ }));
16
+
17
+ vi.mock('@/components/chat/nextclaw', () => ({
18
+ ChatInputBarContainer: () => <div data-testid="chat-input-bar" />,
19
+ ChatMessageListContainer: () => <div data-testid="chat-message-list" />
20
+ }));
21
+
22
+ vi.mock('@/components/chat/ChatWelcome', () => ({
23
+ ChatWelcome: () => <div data-testid="chat-welcome" />
24
+ }));
25
+
26
+ vi.mock('@/components/chat/presenter/chat-presenter-context', () => ({
27
+ usePresenter: () => ({
28
+ chatThreadManager: {
29
+ deleteSession: mocks.deleteSession,
30
+ goToProviders: mocks.goToProviders,
31
+ createSession: vi.fn()
32
+ }
33
+ })
34
+ }));
35
+
36
+ describe('ChatConversationPanel', () => {
37
+ beforeEach(() => {
38
+ mocks.deleteSession.mockReset();
39
+ mocks.goToProviders.mockReset();
40
+ useChatThreadStore.setState({
41
+ snapshot: {
42
+ ...useChatThreadStore.getState().snapshot,
43
+ isProviderStateResolved: true,
44
+ modelOptions: [{ value: 'openai/gpt-5.1', modelLabel: 'gpt-5.1', providerLabel: 'OpenAI' } as never],
45
+ sessionTypeLabel: 'Codex',
46
+ selectedSessionKey: null,
47
+ sessionDisplayName: undefined,
48
+ canDeleteSession: false,
49
+ isDeletePending: false,
50
+ isHistoryLoading: false,
51
+ uiMessages: [],
52
+ isSending: false,
53
+ isAwaitingAssistantOutput: false
54
+ }
55
+ });
56
+ });
57
+
58
+ it('shows the draft session type in the conversation header', () => {
59
+ render(<ChatConversationPanel />);
60
+
61
+ expect(screen.getByText('New Task')).toBeTruthy();
62
+ expect(screen.getByText('Codex')).toBeTruthy();
63
+ expect(screen.queryByRole('button')).toBeNull();
64
+ });
65
+ });
@@ -42,6 +42,8 @@ export function ChatConversationPanel() {
42
42
  const snapshot = useChatThreadStore((state) => state.snapshot);
43
43
  const fallbackThreadRef = useRef<HTMLDivElement | null>(null);
44
44
  const threadRef = snapshot.threadRef ?? fallbackThreadRef;
45
+ const shouldShowSessionHeader = Boolean(snapshot.selectedSessionKey || snapshot.sessionTypeLabel);
46
+ const sessionHeaderTitle = snapshot.sessionDisplayName || snapshot.selectedSessionKey || t('chatSidebarNewTask');
45
47
 
46
48
  const showWelcome = !snapshot.selectedSessionKey && snapshot.uiMessages.length === 0 && !snapshot.isSending;
47
49
  const hasConfiguredModel = snapshot.modelOptions.length > 0;
@@ -68,22 +70,29 @@ export function ChatConversationPanel() {
68
70
  <section className="flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white">
69
71
  <div className={cn(
70
72
  "px-5 border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-all duration-200",
71
- snapshot.selectedSessionKey ? "py-3 opacity-100" : "h-0 py-0 opacity-0 border-b-0"
73
+ shouldShowSessionHeader ? "py-3 opacity-100" : "h-0 py-0 opacity-0 border-b-0"
72
74
  )}>
73
- <div className="min-w-0 flex-1">
75
+ <div className="min-w-0 flex-1 flex items-center gap-2">
74
76
  <span className="text-sm font-medium text-gray-700 truncate">
75
- {snapshot.sessionDisplayName || snapshot.selectedSessionKey}
77
+ {sessionHeaderTitle}
76
78
  </span>
79
+ {snapshot.sessionTypeLabel ? (
80
+ <span className="shrink-0 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">
81
+ {snapshot.sessionTypeLabel}
82
+ </span>
83
+ ) : null}
77
84
  </div>
78
- <Button
79
- variant="ghost"
80
- size="icon"
81
- className="rounded-lg shrink-0 text-gray-400 hover:text-destructive"
82
- onClick={presenter.chatThreadManager.deleteSession}
83
- disabled={!snapshot.canDeleteSession || snapshot.isDeletePending}
84
- >
85
- <Trash2 className="h-4 w-4" />
86
- </Button>
85
+ {snapshot.selectedSessionKey ? (
86
+ <Button
87
+ variant="ghost"
88
+ size="icon"
89
+ className="rounded-lg shrink-0 text-gray-400 hover:text-destructive"
90
+ onClick={presenter.chatThreadManager.deleteSession}
91
+ disabled={!snapshot.canDeleteSession || snapshot.isDeletePending}
92
+ >
93
+ <Trash2 className="h-4 w-4" />
94
+ </Button>
95
+ ) : null}
87
96
  </div>
88
97
 
89
98
  {shouldShowProviderHint && (
@@ -0,0 +1,203 @@
1
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
+ import { ChatSidebar } from '@/components/chat/ChatSidebar';
5
+ import { useChatInputStore } from '@/components/chat/stores/chat-input.store';
6
+ import { useChatRunStatusStore } from '@/components/chat/stores/chat-run-status.store';
7
+ import { useChatSessionListStore } from '@/components/chat/stores/chat-session-list.store';
8
+
9
+ const mocks = vi.hoisted(() => ({
10
+ createSession: vi.fn(),
11
+ setQuery: vi.fn(),
12
+ selectSession: vi.fn(),
13
+ docOpen: vi.fn()
14
+ }));
15
+
16
+ vi.mock('@/components/chat/presenter/chat-presenter-context', () => ({
17
+ usePresenter: () => ({
18
+ chatSessionListManager: {
19
+ createSession: mocks.createSession,
20
+ setQuery: mocks.setQuery,
21
+ selectSession: mocks.selectSession
22
+ }
23
+ })
24
+ }));
25
+
26
+ vi.mock('@/components/doc-browser', () => ({
27
+ useDocBrowser: () => ({
28
+ open: mocks.docOpen
29
+ })
30
+ }));
31
+
32
+ vi.mock('@/components/common/BrandHeader', () => ({
33
+ BrandHeader: () => <div data-testid="brand-header" />
34
+ }));
35
+
36
+ vi.mock('@/components/common/StatusBadge', () => ({
37
+ StatusBadge: () => <div data-testid="status-badge" />
38
+ }));
39
+
40
+ vi.mock('@/components/providers/I18nProvider', () => ({
41
+ useI18n: () => ({
42
+ language: 'en',
43
+ setLanguage: vi.fn()
44
+ })
45
+ }));
46
+
47
+ vi.mock('@/components/providers/ThemeProvider', () => ({
48
+ useTheme: () => ({
49
+ theme: 'warm',
50
+ setTheme: vi.fn()
51
+ })
52
+ }));
53
+
54
+ vi.mock('@/stores/ui.store', () => ({
55
+ useUiStore: (selector: (state: { connectionStatus: string }) => unknown) =>
56
+ selector({ connectionStatus: 'connected' })
57
+ }));
58
+
59
+ describe('ChatSidebar', () => {
60
+ beforeEach(() => {
61
+ mocks.createSession.mockReset();
62
+ mocks.setQuery.mockReset();
63
+ mocks.selectSession.mockReset();
64
+ mocks.docOpen.mockReset();
65
+
66
+ useChatInputStore.setState({
67
+ snapshot: {
68
+ ...useChatInputStore.getState().snapshot,
69
+ defaultSessionType: 'native',
70
+ sessionTypeOptions: [
71
+ { value: 'native', label: 'Native' },
72
+ { value: 'codex', label: 'Codex' }
73
+ ]
74
+ }
75
+ });
76
+ useChatSessionListStore.setState({
77
+ snapshot: {
78
+ ...useChatSessionListStore.getState().snapshot,
79
+ sessions: [],
80
+ query: '',
81
+ isLoading: false
82
+ }
83
+ });
84
+ useChatRunStatusStore.setState({
85
+ snapshot: {
86
+ ...useChatRunStatusStore.getState().snapshot,
87
+ sessionRunStatusByKey: new Map()
88
+ }
89
+ });
90
+ });
91
+
92
+ it('closes the create-session menu after choosing a non-default session type', async () => {
93
+ render(
94
+ <MemoryRouter>
95
+ <ChatSidebar />
96
+ </MemoryRouter>
97
+ );
98
+
99
+ fireEvent.click(screen.getByLabelText('Session Type'));
100
+ fireEvent.click(screen.getByText('Codex'));
101
+
102
+ expect(mocks.createSession).toHaveBeenCalledWith('codex');
103
+ await waitFor(() => {
104
+ expect(screen.queryByText('Codex')).toBeNull();
105
+ });
106
+ });
107
+
108
+ it('shows a session type badge for non-native sessions in the list', () => {
109
+ useChatSessionListStore.setState({
110
+ snapshot: {
111
+ ...useChatSessionListStore.getState().snapshot,
112
+ sessions: [
113
+ {
114
+ key: 'session:codex-1',
115
+ createdAt: '2026-03-19T09:00:00.000Z',
116
+ updatedAt: '2026-03-19T09:05:00.000Z',
117
+ label: 'Codex Task',
118
+ sessionType: 'codex',
119
+ sessionTypeMutable: false,
120
+ messageCount: 2
121
+ }
122
+ ]
123
+ }
124
+ });
125
+
126
+ render(
127
+ <MemoryRouter>
128
+ <ChatSidebar />
129
+ </MemoryRouter>
130
+ );
131
+
132
+ expect(screen.getByText('Codex Task')).not.toBeNull();
133
+ expect(screen.getByText('Codex')).not.toBeNull();
134
+ });
135
+
136
+ it('formats non-native session badges generically when the type is no longer in the available options', () => {
137
+ useChatInputStore.setState({
138
+ snapshot: {
139
+ ...useChatInputStore.getState().snapshot,
140
+ sessionTypeOptions: [{ value: 'native', label: 'Native' }]
141
+ }
142
+ });
143
+ useChatSessionListStore.setState({
144
+ snapshot: {
145
+ ...useChatSessionListStore.getState().snapshot,
146
+ sessions: [
147
+ {
148
+ key: 'session:workspace-agent-1',
149
+ createdAt: '2026-03-19T09:00:00.000Z',
150
+ updatedAt: '2026-03-19T09:05:00.000Z',
151
+ label: 'Workspace Task',
152
+ sessionType: 'workspace-agent',
153
+ sessionTypeMutable: false,
154
+ messageCount: 2
155
+ }
156
+ ]
157
+ }
158
+ });
159
+
160
+ render(
161
+ <MemoryRouter>
162
+ <ChatSidebar />
163
+ </MemoryRouter>
164
+ );
165
+
166
+ expect(screen.getByText('Workspace Task')).not.toBeNull();
167
+ expect(screen.getByText('Workspace Agent')).not.toBeNull();
168
+ });
169
+
170
+ it('does not show a session type badge for native sessions in the list', () => {
171
+ useChatInputStore.setState({
172
+ snapshot: {
173
+ ...useChatInputStore.getState().snapshot,
174
+ sessionTypeOptions: [{ value: 'native', label: 'Native' }]
175
+ }
176
+ });
177
+ useChatSessionListStore.setState({
178
+ snapshot: {
179
+ ...useChatSessionListStore.getState().snapshot,
180
+ sessions: [
181
+ {
182
+ key: 'session:native-1',
183
+ createdAt: '2026-03-19T09:00:00.000Z',
184
+ updatedAt: '2026-03-19T09:05:00.000Z',
185
+ label: 'Native Task',
186
+ sessionType: 'native',
187
+ sessionTypeMutable: false,
188
+ messageCount: 1
189
+ }
190
+ ]
191
+ }
192
+ });
193
+
194
+ render(
195
+ <MemoryRouter>
196
+ <ChatSidebar />
197
+ </MemoryRouter>
198
+ );
199
+
200
+ expect(screen.getByText('Native Task')).not.toBeNull();
201
+ expect(screen.queryByText('Native')).toBeNull();
202
+ });
203
+ });