kanna-code 0.26.8 → 0.26.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{index-BaucHYoH.js → index-DmyPGZQY.js} +1 -1
- package/dist/client/assets/{index-C5RBxQW4.css → index-Dx_Ruzm5.css} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/src/server/agent.ts +21 -17
- package/src/server/event-store.ts +8 -2
- package/src/server/events.ts +1 -0
- package/src/server/server.ts +8 -3
- package/src/server/ws-router.test.ts +10 -2
- package/src/server/ws-router.ts +259 -18
|
@@ -607,7 +607,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
607
607
|
*
|
|
608
608
|
* This source code is licensed under the ISC license.
|
|
609
609
|
* See the LICENSE file in the root directory of this source tree.
|
|
610
|
-
*/const QU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gl=Ae("x",QU),Nh="data-focus-fallback-ignore",v5="data-allow-focus-retain",dg="kanna:restore-chat-input-focus",Mw="data-chat-input",hg="data-chat-selection-zone";function vl(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function _5(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:vl(e,v5):!1}function ZU(e){const t=e;return t!=null&&t.matches?_5(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:vl(e,v5):!1}function tT(e){return!!e.querySelector(`[${Nh}][data-state='open']`)}function JU(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function eV(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${Mw}]`)).filter(a=>!a.disabled);if(n.length===0)return!1;const r=n.indexOf(e),i=r>=0?(r+1)%n.length:0,s=n[i];return s?(s.focus({preventScroll:!0}),!0):!1}function nT(e){const{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return"none";if(e.trigger==="escape")return e.defaultPrevented||vl(t,Mw)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:a,hasActiveSelection:l}=e,u=s??i;return!a||!u||!a.contains(u)||vl(u,Nh)||vl(t,Nh)||l&&(vl(i,hg)||vl(u,hg))||_5(t)?"none":t&&t===u?"restore":ZU(t)?"none":"restore"}const of=Z$,tV=J$,b5=b.forwardRef(({className:e,...t},n)=>m.jsx(r5,{ref:n,className:ke("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));b5.displayName=r5.displayName;const nV={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},Du=b.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(tV,{children:[m.jsx(b5,{}),m.jsxs(i5,{ref:i,[Nh]:"",onCloseAutoFocus:s=>{var a;s.preventDefault(),window.dispatchEvent(new Event(dg)),(a=r.onCloseAutoFocus)==null||a.call(r,s)},className:ke("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",nV[n],e),...r,children:[t,m.jsxs(n9,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[m.jsx(Gl,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Du.displayName=i5.displayName;function rV({className:e,...t}){return m.jsx("div",{className:ke("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function af({className:e,...t}){return m.jsx(e9,{className:ke("text-lg font-medium leading-none tracking-tight",e),...t})}function pv({className:e,...t}){return m.jsx(t9,{className:ke("text-sm text-muted-foreground",e),...t})}function lf({className:e,...t}){return m.jsx("div",{className:ke("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function cf({className:e,...t}){return m.jsx("div",{className:ke("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function iV({className:e,...t}){return m.jsx("button",{className:ke("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground","disabled:pointer-events-none disabled:text-muted-foreground/50",e),...t})}const rs=b.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:ke("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n}));rs.displayName="Input";const y5=b.createContext(null);function sV({children:e}){const[t,n]=b.useState(null),[r,i]=b.useState(""),s=b.useRef(null);b.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var _,y;(_=s.current)==null||_.focus(),(y=s.current)==null||y.select()},0))},[t]);const a=b.useCallback(()=>{n(null),i("")},[]),l=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),a())},[a,t]),u=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),a())},[a,t,r]),d=b.useCallback(_=>new Promise(y=>{n({kind:"confirm",options:_,resolve:y})}),[]),p=b.useCallback(_=>new Promise(y=>{n({kind:"prompt",options:_,resolve:y})}),[]),f=b.useCallback(_=>new Promise(y=>{n({kind:"alert",options:_,resolve:y})}),[]),v=b.useMemo(()=>({confirm:d,prompt:p,alert:f}),[f,d,p]);return m.jsxs(y5.Provider,{value:v,children:[e,m.jsx(of,{open:t!==null,onOpenChange:_=>{_||!t||l()},children:m.jsx(Du,{size:"sm",onKeyDown:_=>{_.key!=="Enter"||_.shiftKey||!t||t.kind!=="confirm"||(_.preventDefault(),u())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(lf,{className:"space-y-4",children:[m.jsx(af,{children:t.options.title}),t.options.description?m.jsx(pv,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(rs,{ref:s,type:"text",value:r,onChange:_=>i(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),u())},placeholder:t.options.placeholder}):null]}),m.jsxs(cf,{children:[m.jsx(Ze,{variant:"ghost",size:"sm",onClick:l,className:t.kind==="alert"?"hidden":void 0,children:"cancelLabel"in t.options?t.options.cancelLabel??"Cancel":"Cancel"}),m.jsx(Ze,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:u,disabled:t.kind==="prompt"&&!r.trim(),children:t.kind==="alert"?t.options.closeLabel??"OK":"confirmLabel"in t.options?t.options.confirmLabel??"Confirm":"Confirm"})]})]}):null})})]})}function x5(){const e=b.useContext(y5);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const oV=["top","right","bottom","left"],Ra=Math.min,ui=Math.max,fg=Math.round,Xp=Math.floor,Os=e=>({x:e,y:e}),aV={left:"right",right:"left",bottom:"top",top:"bottom"};function ux(e,t,n){return ui(e,Ra(t,n))}function yo(e,t){return typeof e=="function"?e(t):e}function xo(e){return e.split("-")[0]}function Ou(e){return e.split("-")[1]}function Lw(e){return e==="x"?"y":"x"}function Dw(e){return e==="y"?"height":"width"}function As(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ow(e){return Lw(As(e))}function lV(e,t,n){n===void 0&&(n=!1);const r=Ou(e),i=Ow(e),s=Dw(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=pg(a)),[a,pg(a)]}function cV(e){const t=pg(e);return[dx(e),t,dx(t)]}function dx(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const rT=["left","right"],iT=["right","left"],uV=["top","bottom"],dV=["bottom","top"];function hV(e,t,n){switch(e){case"top":case"bottom":return n?t?iT:rT:t?rT:iT;case"left":case"right":return t?uV:dV;default:return[]}}function fV(e,t,n,r){const i=Ou(e);let s=hV(xo(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(dx)))),s}function pg(e){const t=xo(e);return aV[t]+e.slice(t.length)}function pV(e){return{top:0,right:0,bottom:0,left:0,...e}}function w5(e){return typeof e!="number"?pV(e):{top:e,right:e,bottom:e,left:e}}function mg(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function sT(e,t,n){let{reference:r,floating:i}=e;const s=As(t),a=Ow(t),l=Dw(a),u=xo(t),d=s==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,v=r[l]/2-i[l]/2;let _;switch(u){case"top":_={x:p,y:r.y-i.height};break;case"bottom":_={x:p,y:r.y+r.height};break;case"right":_={x:r.x+r.width,y:f};break;case"left":_={x:r.x-i.width,y:f};break;default:_={x:r.x,y:r.y}}switch(Ou(t)){case"start":_[a]-=v*(n&&d?-1:1);break;case"end":_[a]+=v*(n&&d?-1:1);break}return _}async function mV(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:v=!1,padding:_=0}=yo(t,e),y=w5(_),C=l[v?f==="floating"?"reference":"floating":f],k=mg(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:u})),E=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},M=mg(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:E,offsetParent:R,strategy:u}):E);return{top:(k.top-M.top+y.top)/T.y,bottom:(M.bottom-k.bottom+y.bottom)/T.y,left:(k.left-M.left+y.left)/T.x,right:(M.right-k.right+y.right)/T.x}}const gV=50,vV=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:mV},u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=sT(d,r,u),v=r,_=0;const y={};for(let w=0;w<s.length;w++){const C=s[w];if(!C)continue;const{name:k,fn:E}=C,{x:R,y:T,data:M,reset:N}=await E({x:p,y:f,initialPlacement:r,placement:v,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});p=R??p,f=T??f,y[k]={...y[k],...M},N&&_<gV&&(_++,typeof N=="object"&&(N.placement&&(v=N.placement),N.rects&&(d=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:p,y:f}=sT(d,v,u)),w=-1)}return{x:p,y:f,placement:v,strategy:i,middlewareData:y}},_V=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:p=0}=yo(e,t)||{};if(d==null)return{};const f=w5(p),v={x:n,y:r},_=Ow(i),y=Dw(_),w=await a.getDimensions(d),C=_==="y",k=C?"top":"left",E=C?"bottom":"right",R=C?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[_]-v[_]-s.floating[y],M=v[_]-s.reference[_],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let L=N?N[R]:0;(!L||!await(a.isElement==null?void 0:a.isElement(N)))&&(L=l.floating[R]||s.floating[y]);const I=T/2-M/2,W=L/2-w[y]/2-1,O=Ra(f[k],W),D=Ra(f[E],W),B=O,$=L-w[y]-D,U=L/2-w[y]/2+I,V=ux(B,U,$),j=!u.arrow&&Ou(i)!=null&&U!==V&&s.reference[y]/2-(U<B?O:D)-w[y]/2<0,G=j?U<B?U-B:U-$:0;return{[_]:v[_]+G,data:{[_]:V,centerOffset:U-V-G,...j&&{alignmentOffset:G}},reset:j}}}),bV=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:v,fallbackStrategy:_="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:w=!0,...C}=yo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const k=xo(i),E=As(l),R=xo(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),M=v||(R||!w?[pg(l)]:cV(l)),N=y!=="none";!v&&N&&M.push(...fV(l,w,y,T));const L=[l,...M],I=await u.detectOverflow(t,C),W=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(p&&W.push(I[k]),f){const U=lV(i,a,T);W.push(I[U[0]],I[U[1]])}if(O=[...O,{placement:i,overflows:W}],!W.every(U=>U<=0)){var D,B;const U=(((D=s.flip)==null?void 0:D.index)||0)+1,V=L[U];if(V&&(!(f==="alignment"?E!==As(V):!1)||O.every(F=>As(F.placement)===E?F.overflows[0]>0:!0)))return{data:{index:U,overflows:O},reset:{placement:V}};let j=(B=O.filter(G=>G.overflows[0]<=0).sort((G,F)=>G.overflows[1]-F.overflows[1])[0])==null?void 0:B.placement;if(!j)switch(_){case"bestFit":{var $;const G=($=O.filter(F=>{if(N){const Y=As(F.placement);return Y===E||Y==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Y=>Y>0).reduce((Y,P)=>Y+P,0)]).sort((F,Y)=>F[1]-Y[1])[0])==null?void 0:$[0];G&&(j=G);break}case"initialPlacement":j=l;break}if(i!==j)return{reset:{placement:j}}}return{}}}};function oT(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function aT(e){return oV.some(t=>e[t]>=0)}const yV=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=yo(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=oT(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:aT(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=oT(a,n.floating);return{data:{escapedOffsets:l,escaped:aT(l)}}}default:return{}}}}},S5=new Set(["left","top"]);async function xV(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=xo(n),l=Ou(n),u=As(n)==="y",d=S5.has(a)?-1:1,p=s&&u?-1:1,f=yo(t,e);let{mainAxis:v,crossAxis:_,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(_=l==="end"?y*-1:y),u?{x:_*p,y:v*d}:{x:v*d,y:_*p}}const wV=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,u=await xV(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:a}}}}},SV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:k=>{let{x:E,y:R}=k;return{x:E,y:R}}},...d}=yo(e,t),p={x:n,y:r},f=await s.detectOverflow(t,d),v=As(xo(i)),_=Lw(v);let y=p[_],w=p[v];if(a){const k=_==="y"?"top":"left",E=_==="y"?"bottom":"right",R=y+f[k],T=y-f[E];y=ux(R,y,T)}if(l){const k=v==="y"?"top":"left",E=v==="y"?"bottom":"right",R=w+f[k],T=w-f[E];w=ux(R,w,T)}const C=u.fn({...t,[_]:y,[v]:w});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[_]:a,[v]:l}}}}}},CV=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=yo(e,t),p={x:n,y:r},f=As(i),v=Lw(f);let _=p[v],y=p[f];const w=yo(l,t),C=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const R=v==="y"?"height":"width",T=s.reference[v]-s.floating[R]+C.mainAxis,M=s.reference[v]+s.reference[R]-C.mainAxis;_<T?_=T:_>M&&(_=M)}if(d){var k,E;const R=v==="y"?"width":"height",T=S5.has(xo(i)),M=s.reference[f]-s.floating[R]+(T&&((k=a.offset)==null?void 0:k[f])||0)+(T?0:C.crossAxis),N=s.reference[f]+s.reference[R]+(T?0:((E=a.offset)==null?void 0:E[f])||0)-(T?C.crossAxis:0);y<M?y=M:y>N&&(y=N)}return{[v]:_,[f]:y}}}},kV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:l}=t,{apply:u=()=>{},...d}=yo(e,t),p=await a.detectOverflow(t,d),f=xo(i),v=Ou(i),_=As(i)==="y",{width:y,height:w}=s.floating;let C,k;f==="top"||f==="bottom"?(C=f,k=v===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(k=f,C=v==="end"?"top":"bottom");const E=w-p.top-p.bottom,R=y-p.left-p.right,T=Ra(w-p[C],E),M=Ra(y-p[k],R),N=!t.middlewareData.shift;let L=T,I=M;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=E),N&&!v){const O=ui(p.left,0),D=ui(p.right,0),B=ui(p.top,0),$=ui(p.bottom,0);_?I=y-2*(O!==0||D!==0?O+D:ui(p.left,p.right)):L=w-2*(B!==0||$!==0?B+$:ui(p.top,p.bottom))}await u({...t,availableWidth:I,availableHeight:L});const W=await a.getDimensions(l.floating);return y!==W.width||w!==W.height?{reset:{rects:!0}}:{}}}};function mv(){return typeof window<"u"}function Pu(e){return C5(e)?(e.nodeName||"").toLowerCase():"#document"}function di(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zs(e){var t;return(t=(C5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function C5(e){return mv()?e instanceof Node||e instanceof di(e).Node:!1}function ls(e){return mv()?e instanceof Element||e instanceof di(e).Element:!1}function Eo(e){return mv()?e instanceof HTMLElement||e instanceof di(e).HTMLElement:!1}function lT(e){return!mv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof di(e).ShadowRoot}function uf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=cs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function EV(e){return/^(table|td|th)$/.test(Pu(e))}function gv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const RV=/transform|translate|scale|rotate|perspective|filter/,TV=/paint|layout|strict|content/,ll=e=>!!e&&e!=="none";let N0;function Pw(e){const t=ls(e)?cs(e):e;return ll(t.transform)||ll(t.translate)||ll(t.scale)||ll(t.rotate)||ll(t.perspective)||!Iw()&&(ll(t.backdropFilter)||ll(t.filter))||RV.test(t.willChange||"")||TV.test(t.contain||"")}function AV(e){let t=Ta(e);for(;Eo(t)&&!_u(t);){if(Pw(t))return t;if(gv(t))return null;t=Ta(t)}return null}function Iw(){return N0==null&&(N0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),N0}function _u(e){return/^(html|body|#document)$/.test(Pu(e))}function cs(e){return di(e).getComputedStyle(e)}function vv(e){return ls(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ta(e){if(Pu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||lT(e)&&e.host||zs(e);return lT(t)?t.host:t}function k5(e){const t=Ta(e);return _u(t)?e.ownerDocument?e.ownerDocument.body:e.body:Eo(t)&&uf(t)?t:k5(t)}function Mh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=k5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=di(i);if(s){const l=hx(a);return t.concat(a,a.visualViewport||[],uf(i)?i:[],l&&n?Mh(l):[])}else return t.concat(i,Mh(i,[],n))}function hx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function E5(e){const t=cs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Eo(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=fg(n)!==s||fg(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function jw(e){return ls(e)?e:e.contextElement}function lu(e){const t=jw(e);if(!Eo(t))return Os(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=E5(t);let a=(s?fg(n.width):n.width)/r,l=(s?fg(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const NV=Os(0);function R5(e){const t=di(e);return!Iw()||!t.visualViewport?NV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function MV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==di(e)?!1:t}function Pl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=jw(e);let a=Os(1);t&&(r?ls(r)&&(a=lu(r)):a=lu(e));const l=MV(s,n,r)?R5(s):Os(0);let u=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,p=i.width/a.x,f=i.height/a.y;if(s){const v=di(s),_=r&&ls(r)?di(r):r;let y=v,w=hx(y);for(;w&&r&&_!==y;){const C=lu(w),k=w.getBoundingClientRect(),E=cs(w),R=k.left+(w.clientLeft+parseFloat(E.paddingLeft))*C.x,T=k.top+(w.clientTop+parseFloat(E.paddingTop))*C.y;u*=C.x,d*=C.y,p*=C.x,f*=C.y,u+=R,d+=T,y=di(w),w=hx(y)}}return mg({width:p,height:f,x:u,y:d})}function _v(e,t){const n=vv(e).scrollLeft;return t?t.left+n:Pl(zs(e)).left+n}function T5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-_v(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function LV(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=zs(r),l=t?gv(t.floating):!1;if(r===a||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=Os(1);const p=Os(0),f=Eo(r);if((f||!f&&!s)&&((Pu(r)!=="body"||uf(a))&&(u=vv(r)),f)){const _=Pl(r);d=lu(r),p.x=_.x+r.clientLeft,p.y=_.y+r.clientTop}const v=a&&!f&&!s?T5(a,u):Os(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+p.x+v.x,y:n.y*d.y-u.scrollTop*d.y+p.y+v.y}}function DV(e){return Array.from(e.getClientRects())}function OV(e){const t=zs(e),n=vv(e),r=e.ownerDocument.body,i=ui(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=ui(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+_v(e);const l=-n.scrollTop;return cs(r).direction==="rtl"&&(a+=ui(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const cT=25;function PV(e,t){const n=di(e),r=zs(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,u=0;if(i){s=i.width,a=i.height;const p=Iw();(!p||p&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=_v(r);if(d<=0){const p=r.ownerDocument,f=p.body,v=getComputedStyle(f),_=p.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-_);y<=cT&&(s-=y)}else d<=cT&&(s+=d);return{width:s,height:a,x:l,y:u}}function IV(e,t){const n=Pl(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Eo(e)?lu(e):Os(1),a=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:a,height:l,x:u,y:d}}function uT(e,t,n){let r;if(t==="viewport")r=PV(e,n);else if(t==="document")r=OV(zs(e));else if(ls(t))r=IV(t,n);else{const i=R5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return mg(r)}function A5(e,t){const n=Ta(e);return n===t||!ls(n)||_u(n)?!1:cs(n).position==="fixed"||A5(n,t)}function jV(e,t){const n=t.get(e);if(n)return n;let r=Mh(e,[],!1).filter(l=>ls(l)&&Pu(l)!=="body"),i=null;const s=cs(e).position==="fixed";let a=s?Ta(e):e;for(;ls(a)&&!_u(a);){const l=cs(a),u=Pw(a);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||uf(a)&&!u&&A5(e,a))?r=r.filter(p=>p!==a):i=l,a=Ta(a)}return t.set(e,r),r}function zV(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?gv(t)?[]:jV(t,this._c):[].concat(n),r],l=uT(t,a[0],i);let u=l.top,d=l.right,p=l.bottom,f=l.left;for(let v=1;v<a.length;v++){const _=uT(t,a[v],i);u=ui(_.top,u),d=Ra(_.right,d),p=Ra(_.bottom,p),f=ui(_.left,f)}return{width:d-f,height:p-u,x:f,y:u}}function BV(e){const{width:t,height:n}=E5(e);return{width:t,height:n}}function HV(e,t,n){const r=Eo(t),i=zs(t),s=n==="fixed",a=Pl(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=Os(0);function d(){u.x=_v(i)}if(r||!r&&!s)if((Pu(t)!=="body"||uf(i))&&(l=vv(t)),r){const _=Pl(t,!0,s,t);u.x=_.x+t.clientLeft,u.y=_.y+t.clientTop}else i&&d();s&&!r&&i&&d();const p=i&&!r&&!s?T5(i,l):Os(0),f=a.left+l.scrollLeft-u.x-p.x,v=a.top+l.scrollTop-u.y-p.y;return{x:f,y:v,width:a.width,height:a.height}}function M0(e){return cs(e).position==="static"}function dT(e,t){if(!Eo(e)||cs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return zs(e)===n&&(n=n.ownerDocument.body),n}function N5(e,t){const n=di(e);if(gv(e))return n;if(!Eo(e)){let i=Ta(e);for(;i&&!_u(i);){if(ls(i)&&!M0(i))return i;i=Ta(i)}return n}let r=dT(e,t);for(;r&&EV(r)&&M0(r);)r=dT(r,t);return r&&_u(r)&&M0(r)&&!Pw(r)?n:r||AV(e)||n}const $V=async function(e){const t=this.getOffsetParent||N5,n=this.getDimensions,r=await n(e.floating);return{reference:HV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function FV(e){return cs(e).direction==="rtl"}const UV={convertOffsetParentRelativeRectToViewportRelativeRect:LV,getDocumentElement:zs,getClippingRect:zV,getOffsetParent:N5,getElementRects:$V,getClientRects:DV,getDimensions:BV,getScale:lu,isElement:ls,isRTL:FV};function M5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function VV(e,t){let n=null,r;const i=zs(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:p,top:f,width:v,height:_}=d;if(l||t(),!v||!_)return;const y=Xp(f),w=Xp(i.clientWidth-(p+v)),C=Xp(i.clientHeight-(f+_)),k=Xp(p),R={rootMargin:-y+"px "+-w+"px "+-C+"px "+-k+"px",threshold:ui(0,Ra(1,u))||1};let T=!0;function M(N){const L=N[0].intersectionRatio;if(L!==u){if(!T)return a();L?a(!1,L):r=setTimeout(()=>{a(!1,1e-7)},1e3)}L===1&&!M5(d,e.getBoundingClientRect())&&a(),T=!1}try{n=new IntersectionObserver(M,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(M,R)}n.observe(e)}return a(!0),s}function WV(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=jw(e),p=i||s?[...d?Mh(d):[],...t?Mh(t):[]]:[];p.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),s&&k.addEventListener("resize",n)});const f=d&&l?VV(d,n):null;let v=-1,_=null;a&&(_=new ResizeObserver(k=>{let[E]=k;E&&E.target===d&&_&&t&&(_.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=_)==null||R.observe(t)})),n()}),d&&!u&&_.observe(d),t&&_.observe(t));let y,w=u?Pl(e):null;u&&C();function C(){const k=Pl(e);w&&!M5(w,k)&&n(),w=k,y=requestAnimationFrame(C)}return n(),()=>{var k;p.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),f==null||f(),(k=_)==null||k.disconnect(),_=null,u&&cancelAnimationFrame(y)}}const GV=wV,qV=SV,KV=bV,YV=kV,XV=yV,hT=_V,QV=CV,ZV=(e,t,n)=>{const r=new Map,i={platform:UV,...n},s={...i.platform,_c:r};return vV(e,t,{...i,platform:s})};var JV=typeof document<"u",eW=function(){},Hm=JV?b.useLayoutEffect:eW;function gg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!gg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!gg(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function L5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fT(e,t){const n=L5(e);return Math.round(t*n)/n}function L0(e){const t=b.useRef(e);return Hm(()=>{t.current=e}),t}function tW(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[p,f]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,_]=b.useState(r);gg(v,r)||_(r);const[y,w]=b.useState(null),[C,k]=b.useState(null),E=b.useCallback(F=>{F!==N.current&&(N.current=F,w(F))},[]),R=b.useCallback(F=>{F!==L.current&&(L.current=F,k(F))},[]),T=s||y,M=a||C,N=b.useRef(null),L=b.useRef(null),I=b.useRef(p),W=u!=null,O=L0(u),D=L0(i),B=L0(d),$=b.useCallback(()=>{if(!N.current||!L.current)return;const F={placement:t,strategy:n,middleware:v};D.current&&(F.platform=D.current),ZV(N.current,L.current,F).then(Y=>{const P={...Y,isPositioned:B.current!==!1};U.current&&!gg(I.current,P)&&(I.current=P,ns.flushSync(()=>{f(P)}))})},[v,t,n,D,B]);Hm(()=>{d===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,f(F=>({...F,isPositioned:!1})))},[d]);const U=b.useRef(!1);Hm(()=>(U.current=!0,()=>{U.current=!1}),[]),Hm(()=>{if(T&&(N.current=T),M&&(L.current=M),T&&M){if(O.current)return O.current(T,M,$);$()}},[T,M,$,O,W]);const V=b.useMemo(()=>({reference:N,floating:L,setReference:E,setFloating:R}),[E,R]),j=b.useMemo(()=>({reference:T,floating:M}),[T,M]),G=b.useMemo(()=>{const F={position:n,left:0,top:0};if(!j.floating)return F;const Y=fT(j.floating,p.x),P=fT(j.floating,p.y);return l?{...F,transform:"translate("+Y+"px, "+P+"px)",...L5(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:P}},[n,l,j.floating,p.x,p.y]);return b.useMemo(()=>({...p,update:$,refs:V,elements:j,floatingStyles:G}),[p,$,V,j,G])}const nW=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?hT({element:r.current,padding:i}).fn(n):{}:r?hT({element:r,padding:i}).fn(n):{}}}},rW=(e,t)=>{const n=GV(e);return{name:n.name,fn:n.fn,options:[e,t]}},iW=(e,t)=>{const n=qV(e);return{name:n.name,fn:n.fn,options:[e,t]}},sW=(e,t)=>({fn:QV(e).fn,options:[e,t]}),oW=(e,t)=>{const n=KV(e);return{name:n.name,fn:n.fn,options:[e,t]}},aW=(e,t)=>{const n=YV(e);return{name:n.name,fn:n.fn,options:[e,t]}},lW=(e,t)=>{const n=XV(e);return{name:n.name,fn:n.fn,options:[e,t]}},cW=(e,t)=>{const n=nW(e);return{name:n.name,fn:n.fn,options:[e,t]}};var uW="Arrow",D5=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(Et.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});D5.displayName=uW;var dW=D5;function hW(e){const[t,n]=b.useState(void 0);return Nr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var zw="Popper",[O5,Da]=ko(zw),[fW,P5]=O5(zw),I5=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return m.jsx(fW,{scope:t,anchor:r,onAnchorChange:i,children:n})};I5.displayName=zw;var j5="PopperAnchor",z5=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=P5(j5,n),a=b.useRef(null),l=Vt(t,a),u=b.useRef(null);return b.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||a.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(Et.div,{...i,ref:l})});z5.displayName=j5;var Bw="PopperContent",[pW,mW]=O5(Bw),B5=b.forwardRef((e,t)=>{var ce,fe,ie,_e,ge,ye;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:y,...w}=e,C=P5(Bw,n),[k,E]=b.useState(null),R=Vt(t,Re=>E(Re)),[T,M]=b.useState(null),N=hW(T),L=(N==null?void 0:N.width)??0,I=(N==null?void 0:N.height)??0,W=r+(s!=="center"?"-"+s:""),O=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},D=Array.isArray(d)?d:[d],B=D.length>0,$={padding:O,boundary:D.filter(vW),altBoundary:B},{refs:U,floatingStyles:V,placement:j,isPositioned:G,middlewareData:F}=tW({strategy:"fixed",placement:W,whileElementsMounted:(...Re)=>WV(...Re,{animationFrame:_==="always"}),elements:{reference:C.anchor},middleware:[rW({mainAxis:i+I,alignmentAxis:a}),u&&iW({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?sW():void 0,...$}),u&&oW({...$}),aW({...$,apply:({elements:Re,rects:Le,availableWidth:Ke,availableHeight:bt})=>{const{width:Wt,height:Dt}=Le.reference,Bt=Re.floating.style;Bt.setProperty("--radix-popper-available-width",`${Ke}px`),Bt.setProperty("--radix-popper-available-height",`${bt}px`),Bt.setProperty("--radix-popper-anchor-width",`${Wt}px`),Bt.setProperty("--radix-popper-anchor-height",`${Dt}px`)}}),T&&cW({element:T,padding:l}),_W({arrowWidth:L,arrowHeight:I}),v&&lW({strategy:"referenceHidden",...$})]}),[Y,P]=F5(j),K=as(y);Nr(()=>{G&&(K==null||K())},[G,K]);const Z=(ce=F.arrow)==null?void 0:ce.x,z=(fe=F.arrow)==null?void 0:fe.y,de=((ie=F.arrow)==null?void 0:ie.centerOffset)!==0,[ve,ne]=b.useState();return Nr(()=>{k&&ne(window.getComputedStyle(k).zIndex)},[k]),m.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:G?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ve,"--radix-popper-transform-origin":[(_e=F.transformOrigin)==null?void 0:_e.x,(ge=F.transformOrigin)==null?void 0:ge.y].join(" "),...((ye=F.hide)==null?void 0:ye.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(pW,{scope:n,placedSide:Y,onArrowChange:M,arrowX:Z,arrowY:z,shouldHideArrow:de,children:m.jsx(Et.div,{"data-side":Y,"data-align":P,...w,ref:R,style:{...w.style,animation:G?void 0:"none"}})})})});B5.displayName=Bw;var H5="PopperArrow",gW={top:"bottom",right:"left",bottom:"top",left:"right"},$5=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=mW(H5,r),a=gW[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(dW,{...i,ref:n,style:{...i.style,display:"block"}})})});$5.displayName=H5;function vW(e){return e!==null}var _W=e=>({name:"transformOrigin",options:e,fn(t){var C,k,E;const{placement:n,rects:r,middlewareData:i}=t,a=((C=i.arrow)==null?void 0:C.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,p]=F5(n),f={start:"0%",center:"50%",end:"100%"}[p],v=(((k=i.arrow)==null?void 0:k.x)??0)+l/2,_=(((E=i.arrow)==null?void 0:E.y)??0)+u/2;let y="",w="";return d==="bottom"?(y=a?f:`${v}px`,w=`${-u}px`):d==="top"?(y=a?f:`${v}px`,w=`${r.floating.height+u}px`):d==="right"?(y=`${-u}px`,w=a?f:`${_}px`):d==="left"&&(y=`${r.floating.width+u}px`,w=a?f:`${_}px`),{data:{x:y,y:w}}}});function F5(e){const[t,n="center"]=e.split("-");return[t,n]}var bv=I5,df=z5,yv=B5,xv=$5,U5=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"}),bW="VisuallyHidden",V5=b.forwardRef((e,t)=>m.jsx(Et.span,{...e,ref:t,style:{...U5,...e.style}}));V5.displayName=bW;var yW=V5,[wv]=ko("Tooltip",[Da]),Sv=Da(),W5="TooltipProvider",xW=700,fx="tooltip.open",[wW,Hw]=wv(W5),G5=e=>{const{__scopeTooltip:t,delayDuration:n=xW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(wW,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};G5.displayName=W5;var Lh="Tooltip",[SW,hf]=wv(Lh),q5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,u=Hw(Lh,e.__scopeTooltip),d=Sv(t),[p,f]=b.useState(null),v=vo(),_=b.useRef(0),y=a??u.disableHoverableContent,w=l??u.delayDuration,C=b.useRef(!1),[k,E]=vu({prop:r,defaultProp:i??!1,onChange:L=>{L?(u.onOpen(),document.dispatchEvent(new CustomEvent(fx))):u.onClose(),s==null||s(L)},caller:Lh}),R=b.useMemo(()=>k?C.current?"delayed-open":"instant-open":"closed",[k]),T=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C.current=!1,E(!0)},[E]),M=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,E(!1)},[E]),N=b.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{C.current=!0,E(!0),_.current=0},w)},[w,E]);return b.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),m.jsx(bv,{...d,children:m.jsx(SW,{scope:t,contentId:v,open:k,stateAttribute:R,trigger:p,onTriggerChange:f,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?N():T()},[u.isOpenDelayedRef,N,T]),onTriggerLeave:b.useCallback(()=>{y?M():(window.clearTimeout(_.current),_.current=0)},[M,y]),onOpen:T,onClose:M,disableHoverableContent:y,children:n})})};q5.displayName=Lh;var px="TooltipTrigger",K5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=hf(px,n),s=Hw(px,n),a=Sv(n),l=b.useRef(null),u=Vt(t,l,i.onTriggerChange),d=b.useRef(!1),p=b.useRef(!1),f=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),m.jsx(df,{asChild:!0,...a,children:m.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:Be(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),p.current=!0)}),onPointerLeave:Be(e.onPointerLeave,()=>{i.onTriggerLeave(),p.current=!1}),onPointerDown:Be(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Be(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Be(e.onBlur,i.onClose),onClick:Be(e.onClick,i.onClose)})})});K5.displayName=px;var $w="TooltipPortal",[CW,kW]=wv($w,{forceMount:void 0}),Y5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=hf($w,t);return m.jsx(CW,{scope:t,forceMount:n,children:m.jsx($i,{present:n||s.open,children:m.jsx(Lu,{asChild:!0,container:i,children:r})})})};Y5.displayName=$w;var bu="TooltipContent",X5=b.forwardRef((e,t)=>{const n=kW(bu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,a=hf(bu,e.__scopeTooltip);return m.jsx($i,{present:r||a.open,children:a.disableHoverableContent?m.jsx(Q5,{side:i,...s,ref:t}):m.jsx(EW,{side:i,...s,ref:t})})}),EW=b.forwardRef((e,t)=>{const n=hf(bu,e.__scopeTooltip),r=Hw(bu,e.__scopeTooltip),i=b.useRef(null),s=Vt(t,i),[a,l]=b.useState(null),{trigger:u,onClose:d}=n,p=i.current,{onPointerInTransitChange:f}=r,v=b.useCallback(()=>{l(null),f(!1)},[f]),_=b.useCallback((y,w)=>{const C=y.currentTarget,k={x:y.clientX,y:y.clientY},E=MW(k,C.getBoundingClientRect()),R=LW(k,E),T=DW(w.getBoundingClientRect()),M=PW([...R,...T]);l(M),f(!0)},[f]);return b.useEffect(()=>()=>v(),[v]),b.useEffect(()=>{if(u&&p){const y=C=>_(C,p),w=C=>_(C,u);return u.addEventListener("pointerleave",y),p.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",w)}}},[u,p,_,v]),b.useEffect(()=>{if(a){const y=w=>{const C=w.target,k={x:w.clientX,y:w.clientY},E=(u==null?void 0:u.contains(C))||(p==null?void 0:p.contains(C)),R=!OW(k,a);E?v():R&&(v(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,p,a,d,v]),m.jsx(Q5,{...e,ref:s})}),[RW,TW]=wv(Lh,{isInside:!1}),AW=DH("TooltipContent"),Q5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,u=hf(bu,n),d=Sv(n),{onClose:p}=u;return b.useEffect(()=>(document.addEventListener(fx,p),()=>document.removeEventListener(fx,p)),[p]),b.useEffect(()=>{if(u.trigger){const f=v=>{const _=v.target;_!=null&&_.contains(u.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[u.trigger,p]),m.jsx(Mu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:m.jsxs(yv,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.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(AW,{children:r}),m.jsx(RW,{scope:n,isInside:!0,children:m.jsx(yW,{id:u.contentId,role:"tooltip",children:i||r})})]})})});X5.displayName=bu;var Z5="TooltipArrow",NW=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Sv(n);return TW(Z5,n).isInside?null:m.jsx(xv,{...i,...r,ref:t})});NW.displayName=Z5;function MW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function LW(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 DW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function OW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const l=t[s],u=t[a],d=l.x,p=l.y,f=u.x,v=u.y;p>r!=v>r&&n<(f-d)*(r-p)/(v-p)+d&&(i=!i)}return i}function PW(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),IW(t)}function IW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}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 jW=G5,J5=q5,eO=K5,tO=Y5,Fw=X5;function nO({className:e,...t}){return m.jsx("kbd",{className:ke("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",e),...t})}function zW({className:e,...t}){return m.jsx("span",{className:ke("inline-flex items-center gap-0.5",e),...t})}const BW="z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",HW=jW,Aa=J5,Na=eO,wo=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(tO,{children:m.jsx(Fw,{ref:r,sideOffset:t,className:ke("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));wo.displayName=Fw.displayName;const ih=J5,sh=eO;function rO(e){return e.toUpperCase()}function $W(e){const t=e.split("+");return m.jsx(zW,{children:t.map((n,r)=>m.jsx(nO,{children:rO(n)},`${n}-${r}`))})}const Zc=b.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const a=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(tO,{children:m.jsx(Fw,{ref:s,sideOffset:t,className:ke(BW,e),...i,children:a?$W(a):m.jsx("span",{children:typeof n=="string"?rO(n):n})})})});Zc.displayName="HotkeyTooltipContent";const FW="0.26.8",UW={version:FW},$n="Kanna",pT="kanna",VW=".kanna",WW=".kanna-dev",GW="KANNA_RUNTIME_PROFILE",Uw=`kanna/${UW.version}`,qW="[kanna]",KW=`~/${$n}`;function Cv(){var t;return(t=globalThis.process)==null?void 0:t.env}function YW(e=Cv()){var t;return((t=e==null?void 0:e[GW])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function XW(e=Cv()){return YW(e)==="dev"?WW:VW}function QW(e=Cv()){return`~/${XW(e)}`}function ZW(e=Cv()){return`${QW(e)}/keybindings.json`}function Qp(e){return e?`${pT} ${e}`:pT}const mT=e=>{let t;const n=new Set,r=(d,p)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const v=t;t=p??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,v))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=t=e(r,i,l);return l},JW=(e=>e?mT(e):mT),eG=e=>e;function tG(e,t=eG){const n=ln.useSyncExternalStore(e.subscribe,ln.useCallback(()=>t(e.getState()),[e,t]),ln.useCallback(()=>t(e.getInitialState()),[e,t]));return ln.useDebugValue(n),n}const nG=e=>{const t=JW(e),n=r=>tG(t,r);return Object.assign(n,t),n},Oa=(e=>nG);function rG(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const a=u=>u===null?null:JSON.parse(u,void 0),l=(s=n.getItem(i))!=null?s:null;return l instanceof Promise?l.then(a):a(l)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const mx=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return mx(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return mx(r)(n)}}}},iG=(e,t)=>(n,r,i)=>{let s={storage:rG(()=>window.localStorage),partialize:C=>C,version:0,merge:(C,k)=>({...k,...C}),...t},a=!1,l=0;const u=new Set,d=new Set;let p=s.storage;if(!p)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...C)},r,i);const f=()=>{const C=s.partialize({...r()});return p.setItem(s.name,{state:C,version:s.version})},v=i.setState;i.setState=(C,k)=>(v(C,k),f());const _=e((...C)=>(n(...C),f()),r,i);i.getInitialState=()=>_;let y;const w=()=>{var C,k;if(!p)return;const E=++l;a=!1,u.forEach(T=>{var M;return T((M=r())!=null?M:_)});const R=((k=s.onRehydrateStorage)==null?void 0:k.call(s,(C=r())!=null?C:_))||void 0;return mx(p.getItem.bind(p))(s.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==s.version){if(s.migrate){const M=s.migrate(T.state,T.version);return M instanceof Promise?M.then(N=>[!0,N]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var M;if(E!==l)return;const[N,L]=T;if(y=s.merge(L,(M=r())!=null?M:_),n(y,!0),N)return f()}).then(()=>{E===l&&(R==null||R(y,void 0),y=r(),a=!0,d.forEach(T=>T(y)))}).catch(T=>{E===l&&(R==null||R(void 0,T))})};return i.persist={setOptions:C=>{s={...s,...C},C.storage&&(p=C.storage)},clearStorage:()=>{p==null||p.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>w(),hasHydrated:()=>a,onHydrate:C=>(u.add(C),()=>{u.delete(C)}),onFinishHydration:C=>(d.add(C),()=>{d.delete(C)})},s.skipHydration||w(),y||_},Pa=iG,iO="always",sO="funk",sG=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function gT(e){switch(e){case"never":case"unfocused":case"always":return e;default:return iO}}function vT(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return sO}}const Jc=Oa()(Pa(e=>({chatSoundPreference:iO,chatSoundId:sO,setChatSoundPreference:t=>e({chatSoundPreference:gT(t)}),setChatSoundId:t=>e({chatSoundId:vT(t)})}),{name:"chat-sound-preferences",version:2,migrate:e=>{const t=e;return{chatSoundPreference:gT(t==null?void 0:t.chatSoundPreference),chatSoundId:vT(t==null?void 0:t.chatSoundId)}}})),oG={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function aG(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function lG(e){const t=new Audio(oG[e]);return t.preload="auto",t.play()}async function gx(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{lG(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function cG(e,t=document){return e==="never"?!1:e==="always"?!0:aG(t)}function uG(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function _T(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function dG(e,t){if(!e)return 0;const n=_T(e),r=_T(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const a of r.waitingChatIds)n.waitingChatIds.has(a)||(s+=1);return i+s}function vx(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const hG=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function fG(e){const t=e.trim();for(const n of hG){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function oO(e){return e.split("/").pop()||e}const aO=1440*6e4;function pG(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=aO,a=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<a?`${Math.floor(n/s)}d`:`${Math.floor(n/a)}w`}function Vw(e){return e.lastMessageAt??e._creationTime}function mG(e,t){return e.every(n=>!cO(Vw(n),t))}function lO(e,t,n){const r=e.filter(l=>cO(Vw(l),n)),i=r.length>0?r.slice(0,t):e.slice(0,Math.min(5,e.length)),s=new Set(i.map(l=>l.chatId)),a=e.filter(l=>!s.has(l.chatId));return{collapsedChats:i,remainingChats:a}}function cO(e,t){return e===void 0?!1:Math.max(0,t-e)<aO}const Iu=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>m.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:ke("mx-auto max-w-md text-foreground/50",r?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],t),...i,children:e}),gG=new Set(["starting","running"]);function vG({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onDeleteChat:a}){const l=pG(Vw(e),n),u=i&&r?r:l,d=i&&!!r,p=CH(e.chatId);return m.jsxs("div",{"data-chat-id":p,className:ke("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===p?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>s(e.chatId),children:[gG.has(e.status)?m.jsx(pn,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):e.unread?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,m.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?m.jsx(Iu,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),m.jsxs("div",{className:"relative h-7 w-7 mr-[2px] shrink-0",children:[u?d?m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity group-hover:opacity-0",children:m.jsx(nO,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50 transition-opacity group-hover:opacity-0",children:u}):null,m.jsx(Ze,{variant:"ghost",size:"icon",className:ke("absolute inset-0 h-7 w-7 opacity-100 cursor-pointer rounded-sm hover:!bg-transparent !border-0",u?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),onClick:f=>{f.stopPropagation(),a(e.chatId)},title:"Delete chat",children:m.jsx(c9,{className:"size-3.5"})})]})]},e._id)}const _G=b.memo(vG);function bG(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const kv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ju(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ww(e){return"nodeType"in e}function Xr(e){var t,n;return e?ju(e)?e:Ww(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Gw(e){const{Document:t}=Xr(e);return e instanceof t}function ff(e){return ju(e)?!1:e instanceof Xr(e).HTMLElement}function uO(e){return e instanceof Xr(e).SVGElement}function zu(e){return e?ju(e)?e.document:Ww(e)?Gw(e)?e:ff(e)||uO(e)?e.ownerDocument:document:document:document}const Is=kv?b.useLayoutEffect:b.useEffect;function qw(e){const t=b.useRef(e);return Is(()=>{t.current=e}),b.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function yG(){const e=b.useRef(null),t=b.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Dh(e,t){t===void 0&&(t=[e]);const n=b.useRef(e);return Is(()=>{n.current!==e&&(n.current=e)},t),n}function pf(e,t){const n=b.useRef();return b.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function vg(e){const t=qw(e),n=b.useRef(null),r=b.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function _x(e){const t=b.useRef();return b.useEffect(()=>{t.current=e},[e]),t.current}let D0={};function mf(e,t){return b.useMemo(()=>{if(t)return t;const n=D0[e]==null?0:D0[e]+1;return D0[e]=n,e+"-"+n},[e,t])}function dO(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const l=Object.entries(a);for(const[u,d]of l){const p=s[u];p!=null&&(s[u]=p+e*d)}return s},{...t})}}const cu=dO(1),_g=dO(-1);function xG(e){return"clientX"in e&&"clientY"in e}function Kw(e){if(!e)return!1;const{KeyboardEvent:t}=Xr(e.target);return t&&e instanceof t}function wG(e){if(!e)return!1;const{TouchEvent:t}=Xr(e.target);return t&&e instanceof t}function bx(e){if(wG(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return xG(e)?{x:e.clientX,y:e.clientY}:null}const Oh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Oh.Translate.toString(e),Oh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),bT="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function SG(e){return e.matches(bT)?e:e.querySelector(bT)}const CG={display:"none"};function kG(e){let{id:t,value:n}=e;return ln.createElement("div",{id:t,style:CG},n)}function EG(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ln.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function RG(){const[e,t]=b.useState("");return{announce:b.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const hO=b.createContext(null);function TG(e){const t=b.useContext(hO);b.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function AG(){const[e]=b.useState(()=>new Set),t=b.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[b.useCallback(r=>{let{type:i,event:s}=r;e.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,s)})},[e]),t]}const NG={draggable:`
|
|
610
|
+
*/const QU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gl=Ae("x",QU),Nh="data-focus-fallback-ignore",v5="data-allow-focus-retain",dg="kanna:restore-chat-input-focus",Mw="data-chat-input",hg="data-chat-selection-zone";function vl(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function _5(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:vl(e,v5):!1}function ZU(e){const t=e;return t!=null&&t.matches?_5(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:vl(e,v5):!1}function tT(e){return!!e.querySelector(`[${Nh}][data-state='open']`)}function JU(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function eV(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${Mw}]`)).filter(a=>!a.disabled);if(n.length===0)return!1;const r=n.indexOf(e),i=r>=0?(r+1)%n.length:0,s=n[i];return s?(s.focus({preventScroll:!0}),!0):!1}function nT(e){const{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return"none";if(e.trigger==="escape")return e.defaultPrevented||vl(t,Mw)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:a,hasActiveSelection:l}=e,u=s??i;return!a||!u||!a.contains(u)||vl(u,Nh)||vl(t,Nh)||l&&(vl(i,hg)||vl(u,hg))||_5(t)?"none":t&&t===u?"restore":ZU(t)?"none":"restore"}const of=Z$,tV=J$,b5=b.forwardRef(({className:e,...t},n)=>m.jsx(r5,{ref:n,className:ke("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));b5.displayName=r5.displayName;const nV={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},Du=b.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(tV,{children:[m.jsx(b5,{}),m.jsxs(i5,{ref:i,[Nh]:"",onCloseAutoFocus:s=>{var a;s.preventDefault(),window.dispatchEvent(new Event(dg)),(a=r.onCloseAutoFocus)==null||a.call(r,s)},className:ke("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",nV[n],e),...r,children:[t,m.jsxs(n9,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[m.jsx(Gl,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Du.displayName=i5.displayName;function rV({className:e,...t}){return m.jsx("div",{className:ke("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function af({className:e,...t}){return m.jsx(e9,{className:ke("text-lg font-medium leading-none tracking-tight",e),...t})}function pv({className:e,...t}){return m.jsx(t9,{className:ke("text-sm text-muted-foreground",e),...t})}function lf({className:e,...t}){return m.jsx("div",{className:ke("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function cf({className:e,...t}){return m.jsx("div",{className:ke("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function iV({className:e,...t}){return m.jsx("button",{className:ke("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground","disabled:pointer-events-none disabled:text-muted-foreground/50",e),...t})}const rs=b.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:ke("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n}));rs.displayName="Input";const y5=b.createContext(null);function sV({children:e}){const[t,n]=b.useState(null),[r,i]=b.useState(""),s=b.useRef(null);b.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var _,y;(_=s.current)==null||_.focus(),(y=s.current)==null||y.select()},0))},[t]);const a=b.useCallback(()=>{n(null),i("")},[]),l=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),a())},[a,t]),u=b.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),a())},[a,t,r]),d=b.useCallback(_=>new Promise(y=>{n({kind:"confirm",options:_,resolve:y})}),[]),p=b.useCallback(_=>new Promise(y=>{n({kind:"prompt",options:_,resolve:y})}),[]),f=b.useCallback(_=>new Promise(y=>{n({kind:"alert",options:_,resolve:y})}),[]),v=b.useMemo(()=>({confirm:d,prompt:p,alert:f}),[f,d,p]);return m.jsxs(y5.Provider,{value:v,children:[e,m.jsx(of,{open:t!==null,onOpenChange:_=>{_||!t||l()},children:m.jsx(Du,{size:"sm",onKeyDown:_=>{_.key!=="Enter"||_.shiftKey||!t||t.kind!=="confirm"||(_.preventDefault(),u())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(lf,{className:"space-y-4",children:[m.jsx(af,{children:t.options.title}),t.options.description?m.jsx(pv,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(rs,{ref:s,type:"text",value:r,onChange:_=>i(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),u())},placeholder:t.options.placeholder}):null]}),m.jsxs(cf,{children:[m.jsx(Ze,{variant:"ghost",size:"sm",onClick:l,className:t.kind==="alert"?"hidden":void 0,children:"cancelLabel"in t.options?t.options.cancelLabel??"Cancel":"Cancel"}),m.jsx(Ze,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:u,disabled:t.kind==="prompt"&&!r.trim(),children:t.kind==="alert"?t.options.closeLabel??"OK":"confirmLabel"in t.options?t.options.confirmLabel??"Confirm":"Confirm"})]})]}):null})})]})}function x5(){const e=b.useContext(y5);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const oV=["top","right","bottom","left"],Ra=Math.min,ui=Math.max,fg=Math.round,Xp=Math.floor,Os=e=>({x:e,y:e}),aV={left:"right",right:"left",bottom:"top",top:"bottom"};function ux(e,t,n){return ui(e,Ra(t,n))}function yo(e,t){return typeof e=="function"?e(t):e}function xo(e){return e.split("-")[0]}function Ou(e){return e.split("-")[1]}function Lw(e){return e==="x"?"y":"x"}function Dw(e){return e==="y"?"height":"width"}function As(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ow(e){return Lw(As(e))}function lV(e,t,n){n===void 0&&(n=!1);const r=Ou(e),i=Ow(e),s=Dw(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=pg(a)),[a,pg(a)]}function cV(e){const t=pg(e);return[dx(e),t,dx(t)]}function dx(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const rT=["left","right"],iT=["right","left"],uV=["top","bottom"],dV=["bottom","top"];function hV(e,t,n){switch(e){case"top":case"bottom":return n?t?iT:rT:t?rT:iT;case"left":case"right":return t?uV:dV;default:return[]}}function fV(e,t,n,r){const i=Ou(e);let s=hV(xo(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(dx)))),s}function pg(e){const t=xo(e);return aV[t]+e.slice(t.length)}function pV(e){return{top:0,right:0,bottom:0,left:0,...e}}function w5(e){return typeof e!="number"?pV(e):{top:e,right:e,bottom:e,left:e}}function mg(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function sT(e,t,n){let{reference:r,floating:i}=e;const s=As(t),a=Ow(t),l=Dw(a),u=xo(t),d=s==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,v=r[l]/2-i[l]/2;let _;switch(u){case"top":_={x:p,y:r.y-i.height};break;case"bottom":_={x:p,y:r.y+r.height};break;case"right":_={x:r.x+r.width,y:f};break;case"left":_={x:r.x-i.width,y:f};break;default:_={x:r.x,y:r.y}}switch(Ou(t)){case"start":_[a]-=v*(n&&d?-1:1);break;case"end":_[a]+=v*(n&&d?-1:1);break}return _}async function mV(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:v=!1,padding:_=0}=yo(t,e),y=w5(_),C=l[v?f==="floating"?"reference":"floating":f],k=mg(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:u})),E=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},M=mg(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:E,offsetParent:R,strategy:u}):E);return{top:(k.top-M.top+y.top)/T.y,bottom:(M.bottom-k.bottom+y.bottom)/T.y,left:(k.left-M.left+y.left)/T.x,right:(M.right-k.right+y.right)/T.x}}const gV=50,vV=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:mV},u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=sT(d,r,u),v=r,_=0;const y={};for(let w=0;w<s.length;w++){const C=s[w];if(!C)continue;const{name:k,fn:E}=C,{x:R,y:T,data:M,reset:N}=await E({x:p,y:f,initialPlacement:r,placement:v,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});p=R??p,f=T??f,y[k]={...y[k],...M},N&&_<gV&&(_++,typeof N=="object"&&(N.placement&&(v=N.placement),N.rects&&(d=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:p,y:f}=sT(d,v,u)),w=-1)}return{x:p,y:f,placement:v,strategy:i,middlewareData:y}},_V=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:p=0}=yo(e,t)||{};if(d==null)return{};const f=w5(p),v={x:n,y:r},_=Ow(i),y=Dw(_),w=await a.getDimensions(d),C=_==="y",k=C?"top":"left",E=C?"bottom":"right",R=C?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[_]-v[_]-s.floating[y],M=v[_]-s.reference[_],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let L=N?N[R]:0;(!L||!await(a.isElement==null?void 0:a.isElement(N)))&&(L=l.floating[R]||s.floating[y]);const I=T/2-M/2,W=L/2-w[y]/2-1,O=Ra(f[k],W),D=Ra(f[E],W),B=O,$=L-w[y]-D,U=L/2-w[y]/2+I,V=ux(B,U,$),j=!u.arrow&&Ou(i)!=null&&U!==V&&s.reference[y]/2-(U<B?O:D)-w[y]/2<0,G=j?U<B?U-B:U-$:0;return{[_]:v[_]+G,data:{[_]:V,centerOffset:U-V-G,...j&&{alignmentOffset:G}},reset:j}}}),bV=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:v,fallbackStrategy:_="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:w=!0,...C}=yo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const k=xo(i),E=As(l),R=xo(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),M=v||(R||!w?[pg(l)]:cV(l)),N=y!=="none";!v&&N&&M.push(...fV(l,w,y,T));const L=[l,...M],I=await u.detectOverflow(t,C),W=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(p&&W.push(I[k]),f){const U=lV(i,a,T);W.push(I[U[0]],I[U[1]])}if(O=[...O,{placement:i,overflows:W}],!W.every(U=>U<=0)){var D,B;const U=(((D=s.flip)==null?void 0:D.index)||0)+1,V=L[U];if(V&&(!(f==="alignment"?E!==As(V):!1)||O.every(F=>As(F.placement)===E?F.overflows[0]>0:!0)))return{data:{index:U,overflows:O},reset:{placement:V}};let j=(B=O.filter(G=>G.overflows[0]<=0).sort((G,F)=>G.overflows[1]-F.overflows[1])[0])==null?void 0:B.placement;if(!j)switch(_){case"bestFit":{var $;const G=($=O.filter(F=>{if(N){const Y=As(F.placement);return Y===E||Y==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Y=>Y>0).reduce((Y,P)=>Y+P,0)]).sort((F,Y)=>F[1]-Y[1])[0])==null?void 0:$[0];G&&(j=G);break}case"initialPlacement":j=l;break}if(i!==j)return{reset:{placement:j}}}return{}}}};function oT(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function aT(e){return oV.some(t=>e[t]>=0)}const yV=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=yo(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=oT(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:aT(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=oT(a,n.floating);return{data:{escapedOffsets:l,escaped:aT(l)}}}default:return{}}}}},S5=new Set(["left","top"]);async function xV(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=xo(n),l=Ou(n),u=As(n)==="y",d=S5.has(a)?-1:1,p=s&&u?-1:1,f=yo(t,e);let{mainAxis:v,crossAxis:_,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(_=l==="end"?y*-1:y),u?{x:_*p,y:v*d}:{x:v*d,y:_*p}}const wV=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,u=await xV(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:a}}}}},SV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:k=>{let{x:E,y:R}=k;return{x:E,y:R}}},...d}=yo(e,t),p={x:n,y:r},f=await s.detectOverflow(t,d),v=As(xo(i)),_=Lw(v);let y=p[_],w=p[v];if(a){const k=_==="y"?"top":"left",E=_==="y"?"bottom":"right",R=y+f[k],T=y-f[E];y=ux(R,y,T)}if(l){const k=v==="y"?"top":"left",E=v==="y"?"bottom":"right",R=w+f[k],T=w-f[E];w=ux(R,w,T)}const C=u.fn({...t,[_]:y,[v]:w});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[_]:a,[v]:l}}}}}},CV=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=yo(e,t),p={x:n,y:r},f=As(i),v=Lw(f);let _=p[v],y=p[f];const w=yo(l,t),C=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const R=v==="y"?"height":"width",T=s.reference[v]-s.floating[R]+C.mainAxis,M=s.reference[v]+s.reference[R]-C.mainAxis;_<T?_=T:_>M&&(_=M)}if(d){var k,E;const R=v==="y"?"width":"height",T=S5.has(xo(i)),M=s.reference[f]-s.floating[R]+(T&&((k=a.offset)==null?void 0:k[f])||0)+(T?0:C.crossAxis),N=s.reference[f]+s.reference[R]+(T?0:((E=a.offset)==null?void 0:E[f])||0)-(T?C.crossAxis:0);y<M?y=M:y>N&&(y=N)}return{[v]:_,[f]:y}}}},kV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:l}=t,{apply:u=()=>{},...d}=yo(e,t),p=await a.detectOverflow(t,d),f=xo(i),v=Ou(i),_=As(i)==="y",{width:y,height:w}=s.floating;let C,k;f==="top"||f==="bottom"?(C=f,k=v===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(k=f,C=v==="end"?"top":"bottom");const E=w-p.top-p.bottom,R=y-p.left-p.right,T=Ra(w-p[C],E),M=Ra(y-p[k],R),N=!t.middlewareData.shift;let L=T,I=M;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=E),N&&!v){const O=ui(p.left,0),D=ui(p.right,0),B=ui(p.top,0),$=ui(p.bottom,0);_?I=y-2*(O!==0||D!==0?O+D:ui(p.left,p.right)):L=w-2*(B!==0||$!==0?B+$:ui(p.top,p.bottom))}await u({...t,availableWidth:I,availableHeight:L});const W=await a.getDimensions(l.floating);return y!==W.width||w!==W.height?{reset:{rects:!0}}:{}}}};function mv(){return typeof window<"u"}function Pu(e){return C5(e)?(e.nodeName||"").toLowerCase():"#document"}function di(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zs(e){var t;return(t=(C5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function C5(e){return mv()?e instanceof Node||e instanceof di(e).Node:!1}function ls(e){return mv()?e instanceof Element||e instanceof di(e).Element:!1}function Eo(e){return mv()?e instanceof HTMLElement||e instanceof di(e).HTMLElement:!1}function lT(e){return!mv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof di(e).ShadowRoot}function uf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=cs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function EV(e){return/^(table|td|th)$/.test(Pu(e))}function gv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const RV=/transform|translate|scale|rotate|perspective|filter/,TV=/paint|layout|strict|content/,ll=e=>!!e&&e!=="none";let N0;function Pw(e){const t=ls(e)?cs(e):e;return ll(t.transform)||ll(t.translate)||ll(t.scale)||ll(t.rotate)||ll(t.perspective)||!Iw()&&(ll(t.backdropFilter)||ll(t.filter))||RV.test(t.willChange||"")||TV.test(t.contain||"")}function AV(e){let t=Ta(e);for(;Eo(t)&&!_u(t);){if(Pw(t))return t;if(gv(t))return null;t=Ta(t)}return null}function Iw(){return N0==null&&(N0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),N0}function _u(e){return/^(html|body|#document)$/.test(Pu(e))}function cs(e){return di(e).getComputedStyle(e)}function vv(e){return ls(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ta(e){if(Pu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||lT(e)&&e.host||zs(e);return lT(t)?t.host:t}function k5(e){const t=Ta(e);return _u(t)?e.ownerDocument?e.ownerDocument.body:e.body:Eo(t)&&uf(t)?t:k5(t)}function Mh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=k5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=di(i);if(s){const l=hx(a);return t.concat(a,a.visualViewport||[],uf(i)?i:[],l&&n?Mh(l):[])}else return t.concat(i,Mh(i,[],n))}function hx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function E5(e){const t=cs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Eo(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=fg(n)!==s||fg(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function jw(e){return ls(e)?e:e.contextElement}function lu(e){const t=jw(e);if(!Eo(t))return Os(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=E5(t);let a=(s?fg(n.width):n.width)/r,l=(s?fg(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const NV=Os(0);function R5(e){const t=di(e);return!Iw()||!t.visualViewport?NV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function MV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==di(e)?!1:t}function Pl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=jw(e);let a=Os(1);t&&(r?ls(r)&&(a=lu(r)):a=lu(e));const l=MV(s,n,r)?R5(s):Os(0);let u=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,p=i.width/a.x,f=i.height/a.y;if(s){const v=di(s),_=r&&ls(r)?di(r):r;let y=v,w=hx(y);for(;w&&r&&_!==y;){const C=lu(w),k=w.getBoundingClientRect(),E=cs(w),R=k.left+(w.clientLeft+parseFloat(E.paddingLeft))*C.x,T=k.top+(w.clientTop+parseFloat(E.paddingTop))*C.y;u*=C.x,d*=C.y,p*=C.x,f*=C.y,u+=R,d+=T,y=di(w),w=hx(y)}}return mg({width:p,height:f,x:u,y:d})}function _v(e,t){const n=vv(e).scrollLeft;return t?t.left+n:Pl(zs(e)).left+n}function T5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-_v(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function LV(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=zs(r),l=t?gv(t.floating):!1;if(r===a||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=Os(1);const p=Os(0),f=Eo(r);if((f||!f&&!s)&&((Pu(r)!=="body"||uf(a))&&(u=vv(r)),f)){const _=Pl(r);d=lu(r),p.x=_.x+r.clientLeft,p.y=_.y+r.clientTop}const v=a&&!f&&!s?T5(a,u):Os(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+p.x+v.x,y:n.y*d.y-u.scrollTop*d.y+p.y+v.y}}function DV(e){return Array.from(e.getClientRects())}function OV(e){const t=zs(e),n=vv(e),r=e.ownerDocument.body,i=ui(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=ui(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+_v(e);const l=-n.scrollTop;return cs(r).direction==="rtl"&&(a+=ui(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const cT=25;function PV(e,t){const n=di(e),r=zs(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,u=0;if(i){s=i.width,a=i.height;const p=Iw();(!p||p&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=_v(r);if(d<=0){const p=r.ownerDocument,f=p.body,v=getComputedStyle(f),_=p.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-_);y<=cT&&(s-=y)}else d<=cT&&(s+=d);return{width:s,height:a,x:l,y:u}}function IV(e,t){const n=Pl(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Eo(e)?lu(e):Os(1),a=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:a,height:l,x:u,y:d}}function uT(e,t,n){let r;if(t==="viewport")r=PV(e,n);else if(t==="document")r=OV(zs(e));else if(ls(t))r=IV(t,n);else{const i=R5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return mg(r)}function A5(e,t){const n=Ta(e);return n===t||!ls(n)||_u(n)?!1:cs(n).position==="fixed"||A5(n,t)}function jV(e,t){const n=t.get(e);if(n)return n;let r=Mh(e,[],!1).filter(l=>ls(l)&&Pu(l)!=="body"),i=null;const s=cs(e).position==="fixed";let a=s?Ta(e):e;for(;ls(a)&&!_u(a);){const l=cs(a),u=Pw(a);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||uf(a)&&!u&&A5(e,a))?r=r.filter(p=>p!==a):i=l,a=Ta(a)}return t.set(e,r),r}function zV(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?gv(t)?[]:jV(t,this._c):[].concat(n),r],l=uT(t,a[0],i);let u=l.top,d=l.right,p=l.bottom,f=l.left;for(let v=1;v<a.length;v++){const _=uT(t,a[v],i);u=ui(_.top,u),d=Ra(_.right,d),p=Ra(_.bottom,p),f=ui(_.left,f)}return{width:d-f,height:p-u,x:f,y:u}}function BV(e){const{width:t,height:n}=E5(e);return{width:t,height:n}}function HV(e,t,n){const r=Eo(t),i=zs(t),s=n==="fixed",a=Pl(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=Os(0);function d(){u.x=_v(i)}if(r||!r&&!s)if((Pu(t)!=="body"||uf(i))&&(l=vv(t)),r){const _=Pl(t,!0,s,t);u.x=_.x+t.clientLeft,u.y=_.y+t.clientTop}else i&&d();s&&!r&&i&&d();const p=i&&!r&&!s?T5(i,l):Os(0),f=a.left+l.scrollLeft-u.x-p.x,v=a.top+l.scrollTop-u.y-p.y;return{x:f,y:v,width:a.width,height:a.height}}function M0(e){return cs(e).position==="static"}function dT(e,t){if(!Eo(e)||cs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return zs(e)===n&&(n=n.ownerDocument.body),n}function N5(e,t){const n=di(e);if(gv(e))return n;if(!Eo(e)){let i=Ta(e);for(;i&&!_u(i);){if(ls(i)&&!M0(i))return i;i=Ta(i)}return n}let r=dT(e,t);for(;r&&EV(r)&&M0(r);)r=dT(r,t);return r&&_u(r)&&M0(r)&&!Pw(r)?n:r||AV(e)||n}const $V=async function(e){const t=this.getOffsetParent||N5,n=this.getDimensions,r=await n(e.floating);return{reference:HV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function FV(e){return cs(e).direction==="rtl"}const UV={convertOffsetParentRelativeRectToViewportRelativeRect:LV,getDocumentElement:zs,getClippingRect:zV,getOffsetParent:N5,getElementRects:$V,getClientRects:DV,getDimensions:BV,getScale:lu,isElement:ls,isRTL:FV};function M5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function VV(e,t){let n=null,r;const i=zs(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:p,top:f,width:v,height:_}=d;if(l||t(),!v||!_)return;const y=Xp(f),w=Xp(i.clientWidth-(p+v)),C=Xp(i.clientHeight-(f+_)),k=Xp(p),R={rootMargin:-y+"px "+-w+"px "+-C+"px "+-k+"px",threshold:ui(0,Ra(1,u))||1};let T=!0;function M(N){const L=N[0].intersectionRatio;if(L!==u){if(!T)return a();L?a(!1,L):r=setTimeout(()=>{a(!1,1e-7)},1e3)}L===1&&!M5(d,e.getBoundingClientRect())&&a(),T=!1}try{n=new IntersectionObserver(M,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(M,R)}n.observe(e)}return a(!0),s}function WV(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=jw(e),p=i||s?[...d?Mh(d):[],...t?Mh(t):[]]:[];p.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),s&&k.addEventListener("resize",n)});const f=d&&l?VV(d,n):null;let v=-1,_=null;a&&(_=new ResizeObserver(k=>{let[E]=k;E&&E.target===d&&_&&t&&(_.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=_)==null||R.observe(t)})),n()}),d&&!u&&_.observe(d),t&&_.observe(t));let y,w=u?Pl(e):null;u&&C();function C(){const k=Pl(e);w&&!M5(w,k)&&n(),w=k,y=requestAnimationFrame(C)}return n(),()=>{var k;p.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),f==null||f(),(k=_)==null||k.disconnect(),_=null,u&&cancelAnimationFrame(y)}}const GV=wV,qV=SV,KV=bV,YV=kV,XV=yV,hT=_V,QV=CV,ZV=(e,t,n)=>{const r=new Map,i={platform:UV,...n},s={...i.platform,_c:r};return vV(e,t,{...i,platform:s})};var JV=typeof document<"u",eW=function(){},Hm=JV?b.useLayoutEffect:eW;function gg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!gg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!gg(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function L5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fT(e,t){const n=L5(e);return Math.round(t*n)/n}function L0(e){const t=b.useRef(e);return Hm(()=>{t.current=e}),t}function tW(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[p,f]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[v,_]=b.useState(r);gg(v,r)||_(r);const[y,w]=b.useState(null),[C,k]=b.useState(null),E=b.useCallback(F=>{F!==N.current&&(N.current=F,w(F))},[]),R=b.useCallback(F=>{F!==L.current&&(L.current=F,k(F))},[]),T=s||y,M=a||C,N=b.useRef(null),L=b.useRef(null),I=b.useRef(p),W=u!=null,O=L0(u),D=L0(i),B=L0(d),$=b.useCallback(()=>{if(!N.current||!L.current)return;const F={placement:t,strategy:n,middleware:v};D.current&&(F.platform=D.current),ZV(N.current,L.current,F).then(Y=>{const P={...Y,isPositioned:B.current!==!1};U.current&&!gg(I.current,P)&&(I.current=P,ns.flushSync(()=>{f(P)}))})},[v,t,n,D,B]);Hm(()=>{d===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,f(F=>({...F,isPositioned:!1})))},[d]);const U=b.useRef(!1);Hm(()=>(U.current=!0,()=>{U.current=!1}),[]),Hm(()=>{if(T&&(N.current=T),M&&(L.current=M),T&&M){if(O.current)return O.current(T,M,$);$()}},[T,M,$,O,W]);const V=b.useMemo(()=>({reference:N,floating:L,setReference:E,setFloating:R}),[E,R]),j=b.useMemo(()=>({reference:T,floating:M}),[T,M]),G=b.useMemo(()=>{const F={position:n,left:0,top:0};if(!j.floating)return F;const Y=fT(j.floating,p.x),P=fT(j.floating,p.y);return l?{...F,transform:"translate("+Y+"px, "+P+"px)",...L5(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:P}},[n,l,j.floating,p.x,p.y]);return b.useMemo(()=>({...p,update:$,refs:V,elements:j,floatingStyles:G}),[p,$,V,j,G])}const nW=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?hT({element:r.current,padding:i}).fn(n):{}:r?hT({element:r,padding:i}).fn(n):{}}}},rW=(e,t)=>{const n=GV(e);return{name:n.name,fn:n.fn,options:[e,t]}},iW=(e,t)=>{const n=qV(e);return{name:n.name,fn:n.fn,options:[e,t]}},sW=(e,t)=>({fn:QV(e).fn,options:[e,t]}),oW=(e,t)=>{const n=KV(e);return{name:n.name,fn:n.fn,options:[e,t]}},aW=(e,t)=>{const n=YV(e);return{name:n.name,fn:n.fn,options:[e,t]}},lW=(e,t)=>{const n=XV(e);return{name:n.name,fn:n.fn,options:[e,t]}},cW=(e,t)=>{const n=nW(e);return{name:n.name,fn:n.fn,options:[e,t]}};var uW="Arrow",D5=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(Et.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});D5.displayName=uW;var dW=D5;function hW(e){const[t,n]=b.useState(void 0);return Nr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var zw="Popper",[O5,Da]=ko(zw),[fW,P5]=O5(zw),I5=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return m.jsx(fW,{scope:t,anchor:r,onAnchorChange:i,children:n})};I5.displayName=zw;var j5="PopperAnchor",z5=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=P5(j5,n),a=b.useRef(null),l=Vt(t,a),u=b.useRef(null);return b.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||a.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(Et.div,{...i,ref:l})});z5.displayName=j5;var Bw="PopperContent",[pW,mW]=O5(Bw),B5=b.forwardRef((e,t)=>{var ce,fe,ie,_e,ge,ye;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:y,...w}=e,C=P5(Bw,n),[k,E]=b.useState(null),R=Vt(t,Re=>E(Re)),[T,M]=b.useState(null),N=hW(T),L=(N==null?void 0:N.width)??0,I=(N==null?void 0:N.height)??0,W=r+(s!=="center"?"-"+s:""),O=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},D=Array.isArray(d)?d:[d],B=D.length>0,$={padding:O,boundary:D.filter(vW),altBoundary:B},{refs:U,floatingStyles:V,placement:j,isPositioned:G,middlewareData:F}=tW({strategy:"fixed",placement:W,whileElementsMounted:(...Re)=>WV(...Re,{animationFrame:_==="always"}),elements:{reference:C.anchor},middleware:[rW({mainAxis:i+I,alignmentAxis:a}),u&&iW({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?sW():void 0,...$}),u&&oW({...$}),aW({...$,apply:({elements:Re,rects:Le,availableWidth:Ke,availableHeight:bt})=>{const{width:Wt,height:Dt}=Le.reference,Bt=Re.floating.style;Bt.setProperty("--radix-popper-available-width",`${Ke}px`),Bt.setProperty("--radix-popper-available-height",`${bt}px`),Bt.setProperty("--radix-popper-anchor-width",`${Wt}px`),Bt.setProperty("--radix-popper-anchor-height",`${Dt}px`)}}),T&&cW({element:T,padding:l}),_W({arrowWidth:L,arrowHeight:I}),v&&lW({strategy:"referenceHidden",...$})]}),[Y,P]=F5(j),K=as(y);Nr(()=>{G&&(K==null||K())},[G,K]);const Z=(ce=F.arrow)==null?void 0:ce.x,z=(fe=F.arrow)==null?void 0:fe.y,de=((ie=F.arrow)==null?void 0:ie.centerOffset)!==0,[ve,ne]=b.useState();return Nr(()=>{k&&ne(window.getComputedStyle(k).zIndex)},[k]),m.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:G?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ve,"--radix-popper-transform-origin":[(_e=F.transformOrigin)==null?void 0:_e.x,(ge=F.transformOrigin)==null?void 0:ge.y].join(" "),...((ye=F.hide)==null?void 0:ye.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(pW,{scope:n,placedSide:Y,onArrowChange:M,arrowX:Z,arrowY:z,shouldHideArrow:de,children:m.jsx(Et.div,{"data-side":Y,"data-align":P,...w,ref:R,style:{...w.style,animation:G?void 0:"none"}})})})});B5.displayName=Bw;var H5="PopperArrow",gW={top:"bottom",right:"left",bottom:"top",left:"right"},$5=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=mW(H5,r),a=gW[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(dW,{...i,ref:n,style:{...i.style,display:"block"}})})});$5.displayName=H5;function vW(e){return e!==null}var _W=e=>({name:"transformOrigin",options:e,fn(t){var C,k,E;const{placement:n,rects:r,middlewareData:i}=t,a=((C=i.arrow)==null?void 0:C.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,p]=F5(n),f={start:"0%",center:"50%",end:"100%"}[p],v=(((k=i.arrow)==null?void 0:k.x)??0)+l/2,_=(((E=i.arrow)==null?void 0:E.y)??0)+u/2;let y="",w="";return d==="bottom"?(y=a?f:`${v}px`,w=`${-u}px`):d==="top"?(y=a?f:`${v}px`,w=`${r.floating.height+u}px`):d==="right"?(y=`${-u}px`,w=a?f:`${_}px`):d==="left"&&(y=`${r.floating.width+u}px`,w=a?f:`${_}px`),{data:{x:y,y:w}}}});function F5(e){const[t,n="center"]=e.split("-");return[t,n]}var bv=I5,df=z5,yv=B5,xv=$5,U5=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"}),bW="VisuallyHidden",V5=b.forwardRef((e,t)=>m.jsx(Et.span,{...e,ref:t,style:{...U5,...e.style}}));V5.displayName=bW;var yW=V5,[wv]=ko("Tooltip",[Da]),Sv=Da(),W5="TooltipProvider",xW=700,fx="tooltip.open",[wW,Hw]=wv(W5),G5=e=>{const{__scopeTooltip:t,delayDuration:n=xW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(wW,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};G5.displayName=W5;var Lh="Tooltip",[SW,hf]=wv(Lh),q5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,u=Hw(Lh,e.__scopeTooltip),d=Sv(t),[p,f]=b.useState(null),v=vo(),_=b.useRef(0),y=a??u.disableHoverableContent,w=l??u.delayDuration,C=b.useRef(!1),[k,E]=vu({prop:r,defaultProp:i??!1,onChange:L=>{L?(u.onOpen(),document.dispatchEvent(new CustomEvent(fx))):u.onClose(),s==null||s(L)},caller:Lh}),R=b.useMemo(()=>k?C.current?"delayed-open":"instant-open":"closed",[k]),T=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C.current=!1,E(!0)},[E]),M=b.useCallback(()=>{window.clearTimeout(_.current),_.current=0,E(!1)},[E]),N=b.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{C.current=!0,E(!0),_.current=0},w)},[w,E]);return b.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),m.jsx(bv,{...d,children:m.jsx(SW,{scope:t,contentId:v,open:k,stateAttribute:R,trigger:p,onTriggerChange:f,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?N():T()},[u.isOpenDelayedRef,N,T]),onTriggerLeave:b.useCallback(()=>{y?M():(window.clearTimeout(_.current),_.current=0)},[M,y]),onOpen:T,onClose:M,disableHoverableContent:y,children:n})})};q5.displayName=Lh;var px="TooltipTrigger",K5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=hf(px,n),s=Hw(px,n),a=Sv(n),l=b.useRef(null),u=Vt(t,l,i.onTriggerChange),d=b.useRef(!1),p=b.useRef(!1),f=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),m.jsx(df,{asChild:!0,...a,children:m.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:Be(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),p.current=!0)}),onPointerLeave:Be(e.onPointerLeave,()=>{i.onTriggerLeave(),p.current=!1}),onPointerDown:Be(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Be(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Be(e.onBlur,i.onClose),onClick:Be(e.onClick,i.onClose)})})});K5.displayName=px;var $w="TooltipPortal",[CW,kW]=wv($w,{forceMount:void 0}),Y5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=hf($w,t);return m.jsx(CW,{scope:t,forceMount:n,children:m.jsx($i,{present:n||s.open,children:m.jsx(Lu,{asChild:!0,container:i,children:r})})})};Y5.displayName=$w;var bu="TooltipContent",X5=b.forwardRef((e,t)=>{const n=kW(bu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,a=hf(bu,e.__scopeTooltip);return m.jsx($i,{present:r||a.open,children:a.disableHoverableContent?m.jsx(Q5,{side:i,...s,ref:t}):m.jsx(EW,{side:i,...s,ref:t})})}),EW=b.forwardRef((e,t)=>{const n=hf(bu,e.__scopeTooltip),r=Hw(bu,e.__scopeTooltip),i=b.useRef(null),s=Vt(t,i),[a,l]=b.useState(null),{trigger:u,onClose:d}=n,p=i.current,{onPointerInTransitChange:f}=r,v=b.useCallback(()=>{l(null),f(!1)},[f]),_=b.useCallback((y,w)=>{const C=y.currentTarget,k={x:y.clientX,y:y.clientY},E=MW(k,C.getBoundingClientRect()),R=LW(k,E),T=DW(w.getBoundingClientRect()),M=PW([...R,...T]);l(M),f(!0)},[f]);return b.useEffect(()=>()=>v(),[v]),b.useEffect(()=>{if(u&&p){const y=C=>_(C,p),w=C=>_(C,u);return u.addEventListener("pointerleave",y),p.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",y),p.removeEventListener("pointerleave",w)}}},[u,p,_,v]),b.useEffect(()=>{if(a){const y=w=>{const C=w.target,k={x:w.clientX,y:w.clientY},E=(u==null?void 0:u.contains(C))||(p==null?void 0:p.contains(C)),R=!OW(k,a);E?v():R&&(v(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,p,a,d,v]),m.jsx(Q5,{...e,ref:s})}),[RW,TW]=wv(Lh,{isInside:!1}),AW=DH("TooltipContent"),Q5=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,u=hf(bu,n),d=Sv(n),{onClose:p}=u;return b.useEffect(()=>(document.addEventListener(fx,p),()=>document.removeEventListener(fx,p)),[p]),b.useEffect(()=>{if(u.trigger){const f=v=>{const _=v.target;_!=null&&_.contains(u.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[u.trigger,p]),m.jsx(Mu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:m.jsxs(yv,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.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(AW,{children:r}),m.jsx(RW,{scope:n,isInside:!0,children:m.jsx(yW,{id:u.contentId,role:"tooltip",children:i||r})})]})})});X5.displayName=bu;var Z5="TooltipArrow",NW=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Sv(n);return TW(Z5,n).isInside?null:m.jsx(xv,{...i,...r,ref:t})});NW.displayName=Z5;function MW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function LW(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 DW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function OW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const l=t[s],u=t[a],d=l.x,p=l.y,f=u.x,v=u.y;p>r!=v>r&&n<(f-d)*(r-p)/(v-p)+d&&(i=!i)}return i}function PW(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),IW(t)}function IW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}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 jW=G5,J5=q5,eO=K5,tO=Y5,Fw=X5;function nO({className:e,...t}){return m.jsx("kbd",{className:ke("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",e),...t})}function zW({className:e,...t}){return m.jsx("span",{className:ke("inline-flex items-center gap-0.5",e),...t})}const BW="z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",HW=jW,Aa=J5,Na=eO,wo=b.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(tO,{children:m.jsx(Fw,{ref:r,sideOffset:t,className:ke("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));wo.displayName=Fw.displayName;const ih=J5,sh=eO;function rO(e){return e.toUpperCase()}function $W(e){const t=e.split("+");return m.jsx(zW,{children:t.map((n,r)=>m.jsx(nO,{children:rO(n)},`${n}-${r}`))})}const Zc=b.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const a=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(tO,{children:m.jsx(Fw,{ref:s,sideOffset:t,className:ke(BW,e),...i,children:a?$W(a):m.jsx("span",{children:typeof n=="string"?rO(n):n})})})});Zc.displayName="HotkeyTooltipContent";const FW="0.26.10",UW={version:FW},$n="Kanna",pT="kanna",VW=".kanna",WW=".kanna-dev",GW="KANNA_RUNTIME_PROFILE",Uw=`kanna/${UW.version}`,qW="[kanna]",KW=`~/${$n}`;function Cv(){var t;return(t=globalThis.process)==null?void 0:t.env}function YW(e=Cv()){var t;return((t=e==null?void 0:e[GW])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function XW(e=Cv()){return YW(e)==="dev"?WW:VW}function QW(e=Cv()){return`~/${XW(e)}`}function ZW(e=Cv()){return`${QW(e)}/keybindings.json`}function Qp(e){return e?`${pT} ${e}`:pT}const mT=e=>{let t;const n=new Set,r=(d,p)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const v=t;t=p??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,v))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=t=e(r,i,l);return l},JW=(e=>e?mT(e):mT),eG=e=>e;function tG(e,t=eG){const n=ln.useSyncExternalStore(e.subscribe,ln.useCallback(()=>t(e.getState()),[e,t]),ln.useCallback(()=>t(e.getInitialState()),[e,t]));return ln.useDebugValue(n),n}const nG=e=>{const t=JW(e),n=r=>tG(t,r);return Object.assign(n,t),n},Oa=(e=>nG);function rG(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const a=u=>u===null?null:JSON.parse(u,void 0),l=(s=n.getItem(i))!=null?s:null;return l instanceof Promise?l.then(a):a(l)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const mx=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return mx(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return mx(r)(n)}}}},iG=(e,t)=>(n,r,i)=>{let s={storage:rG(()=>window.localStorage),partialize:C=>C,version:0,merge:(C,k)=>({...k,...C}),...t},a=!1,l=0;const u=new Set,d=new Set;let p=s.storage;if(!p)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...C)},r,i);const f=()=>{const C=s.partialize({...r()});return p.setItem(s.name,{state:C,version:s.version})},v=i.setState;i.setState=(C,k)=>(v(C,k),f());const _=e((...C)=>(n(...C),f()),r,i);i.getInitialState=()=>_;let y;const w=()=>{var C,k;if(!p)return;const E=++l;a=!1,u.forEach(T=>{var M;return T((M=r())!=null?M:_)});const R=((k=s.onRehydrateStorage)==null?void 0:k.call(s,(C=r())!=null?C:_))||void 0;return mx(p.getItem.bind(p))(s.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==s.version){if(s.migrate){const M=s.migrate(T.state,T.version);return M instanceof Promise?M.then(N=>[!0,N]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,T.state];return[!1,void 0]}).then(T=>{var M;if(E!==l)return;const[N,L]=T;if(y=s.merge(L,(M=r())!=null?M:_),n(y,!0),N)return f()}).then(()=>{E===l&&(R==null||R(y,void 0),y=r(),a=!0,d.forEach(T=>T(y)))}).catch(T=>{E===l&&(R==null||R(void 0,T))})};return i.persist={setOptions:C=>{s={...s,...C},C.storage&&(p=C.storage)},clearStorage:()=>{p==null||p.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>w(),hasHydrated:()=>a,onHydrate:C=>(u.add(C),()=>{u.delete(C)}),onFinishHydration:C=>(d.add(C),()=>{d.delete(C)})},s.skipHydration||w(),y||_},Pa=iG,iO="always",sO="funk",sG=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function gT(e){switch(e){case"never":case"unfocused":case"always":return e;default:return iO}}function vT(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return sO}}const Jc=Oa()(Pa(e=>({chatSoundPreference:iO,chatSoundId:sO,setChatSoundPreference:t=>e({chatSoundPreference:gT(t)}),setChatSoundId:t=>e({chatSoundId:vT(t)})}),{name:"chat-sound-preferences",version:2,migrate:e=>{const t=e;return{chatSoundPreference:gT(t==null?void 0:t.chatSoundPreference),chatSoundId:vT(t==null?void 0:t.chatSoundId)}}})),oG={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function aG(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function lG(e){const t=new Audio(oG[e]);return t.preload="auto",t.play()}async function gx(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{lG(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function cG(e,t=document){return e==="never"?!1:e==="always"?!0:aG(t)}function uG(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function _T(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function dG(e,t){if(!e)return 0;const n=_T(e),r=_T(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const a of r.waitingChatIds)n.waitingChatIds.has(a)||(s+=1);return i+s}function vx(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const hG=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function fG(e){const t=e.trim();for(const n of hG){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function oO(e){return e.split("/").pop()||e}const aO=1440*6e4;function pG(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=aO,a=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<a?`${Math.floor(n/s)}d`:`${Math.floor(n/a)}w`}function Vw(e){return e.lastMessageAt??e._creationTime}function mG(e,t){return e.every(n=>!cO(Vw(n),t))}function lO(e,t,n){const r=e.filter(l=>cO(Vw(l),n)),i=r.length>0?r.slice(0,t):e.slice(0,Math.min(5,e.length)),s=new Set(i.map(l=>l.chatId)),a=e.filter(l=>!s.has(l.chatId));return{collapsedChats:i,remainingChats:a}}function cO(e,t){return e===void 0?!1:Math.max(0,t-e)<aO}const Iu=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>m.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:ke("mx-auto max-w-md text-foreground/50",r?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],t),...i,children:e}),gG=new Set(["starting","running"]);function vG({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onDeleteChat:a}){const l=pG(Vw(e),n),u=i&&r?r:l,d=i&&!!r,p=CH(e.chatId);return m.jsxs("div",{"data-chat-id":p,className:ke("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===p?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>s(e.chatId),children:[gG.has(e.status)?m.jsx(pn,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):e.unread?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,m.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?m.jsx(Iu,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),m.jsxs("div",{className:"relative h-7 w-7 mr-[2px] shrink-0",children:[u?d?m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity group-hover:opacity-0",children:m.jsx(nO,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50 transition-opacity group-hover:opacity-0",children:u}):null,m.jsx(Ze,{variant:"ghost",size:"icon",className:ke("absolute inset-0 h-7 w-7 opacity-100 cursor-pointer rounded-sm hover:!bg-transparent !border-0",u?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),onClick:f=>{f.stopPropagation(),a(e.chatId)},title:"Delete chat",children:m.jsx(c9,{className:"size-3.5"})})]})]},e._id)}const _G=b.memo(vG);function bG(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return b.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const kv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ju(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ww(e){return"nodeType"in e}function Xr(e){var t,n;return e?ju(e)?e:Ww(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Gw(e){const{Document:t}=Xr(e);return e instanceof t}function ff(e){return ju(e)?!1:e instanceof Xr(e).HTMLElement}function uO(e){return e instanceof Xr(e).SVGElement}function zu(e){return e?ju(e)?e.document:Ww(e)?Gw(e)?e:ff(e)||uO(e)?e.ownerDocument:document:document:document}const Is=kv?b.useLayoutEffect:b.useEffect;function qw(e){const t=b.useRef(e);return Is(()=>{t.current=e}),b.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function yG(){const e=b.useRef(null),t=b.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Dh(e,t){t===void 0&&(t=[e]);const n=b.useRef(e);return Is(()=>{n.current!==e&&(n.current=e)},t),n}function pf(e,t){const n=b.useRef();return b.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function vg(e){const t=qw(e),n=b.useRef(null),r=b.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function _x(e){const t=b.useRef();return b.useEffect(()=>{t.current=e},[e]),t.current}let D0={};function mf(e,t){return b.useMemo(()=>{if(t)return t;const n=D0[e]==null?0:D0[e]+1;return D0[e]=n,e+"-"+n},[e,t])}function dO(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const l=Object.entries(a);for(const[u,d]of l){const p=s[u];p!=null&&(s[u]=p+e*d)}return s},{...t})}}const cu=dO(1),_g=dO(-1);function xG(e){return"clientX"in e&&"clientY"in e}function Kw(e){if(!e)return!1;const{KeyboardEvent:t}=Xr(e.target);return t&&e instanceof t}function wG(e){if(!e)return!1;const{TouchEvent:t}=Xr(e.target);return t&&e instanceof t}function bx(e){if(wG(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return xG(e)?{x:e.clientX,y:e.clientY}:null}const Oh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Oh.Translate.toString(e),Oh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),bT="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function SG(e){return e.matches(bT)?e:e.querySelector(bT)}const CG={display:"none"};function kG(e){let{id:t,value:n}=e;return ln.createElement("div",{id:t,style:CG},n)}function EG(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ln.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function RG(){const[e,t]=b.useState("");return{announce:b.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const hO=b.createContext(null);function TG(e){const t=b.useContext(hO);b.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function AG(){const[e]=b.useState(()=>new Set),t=b.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[b.useCallback(r=>{let{type:i,event:s}=r;e.forEach(a=>{var l;return(l=a[i])==null?void 0:l.call(a,s)})},[e]),t]}const NG={draggable:`
|
|
611
611
|
To pick up a draggable item, press the space bar.
|
|
612
612
|
While dragging, use the arrow keys to move the item.
|
|
613
613
|
Press space again to drop the item in its new position, or press escape to cancel.
|