kanna-code 0.33.6 → 0.33.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -145,7 +145,7 @@ bun run dev --password my-secret
145
145
  ```
146
146
 
147
147
  Kanna verifies the password once, then sets a browser-session cookie. The password itself is not stored in the browser.
148
- When password protection is enabled, the backend requires authentication for API routes, `/health`, and `/ws`. The SPA shell still loads, and the same in-app password screen is used in both dev and production.
148
+ When password protection is enabled, the backend requires authentication for API routes and `/ws`. The SPA shell still loads, `/health` remains public for restart detection, and the same in-app password screen is used in both dev and production.
149
149
 
150
150
  ### Public share link
151
151
 
@@ -627,7 +627,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
627
627
 
628
628
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
629
629
 
630
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},TG="DialogDescriptionWarning",AG=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${SO(TG).contentName}}.`;return _.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},NG=cO,MG=hO,wO=fO,CO=pO,LG=gO,DG=bO,IG=yO;const cf="data-focus-fallback-ignore",kO="data-allow-focus-retain",tv="kanna:restore-chat-input-focus",Fw="data-chat-input",nv="data-chat-selection-zone";function Il(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function EO(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:Il(e,kO):!1}function PG(e){const t=e;return t!=null&&t.matches?EO(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:Il(e,kO):!1}function MA(e){return!!e.querySelector(`[${cf}][data-state='open']`)}function OG(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function jG(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${Fw}]`)).filter(o=>!o.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 LA(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||Il(t,Fw)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:o,hasActiveSelection:l}=e,u=s??i;return!o||!u||!o.contains(u)||Il(u,cf)||Il(t,cf)||l&&(Il(i,nv)||Il(u,nv))||EO(t)?"none":t&&t===u?"restore":PG(t)?"none":"restore"}const od=NG,zG=MG,RO=_.forwardRef(({className:e,...t},n)=>m.jsx(wO,{ref:n,className:xe("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}));RO.displayName=wO.displayName;const BG={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},uc=_.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(zG,{children:[m.jsx(RO,{}),m.jsxs(CO,{ref:i,[cf]:"",onCloseAutoFocus:s=>{var o;s.preventDefault(),window.dispatchEvent(new Event(tv)),(o=r.onCloseAutoFocus)==null||o.call(r,s)},className:xe("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",BG[n],e),...r,children:[t,m.jsxs(IG,{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(tl,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));uc.displayName=CO.displayName;function FG({className:e,...t}){return m.jsx("div",{className:xe("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function ad({className:e,...t}){return m.jsx(LG,{className:xe("text-lg font-medium leading-none tracking-tight",e),...t})}function c0({className:e,...t}){return m.jsx(DG,{className:xe("text-sm text-muted-foreground",e),...t})}function ld({className:e,...t}){return m.jsx("div",{className:xe("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function cd({className:e,...t}){return m.jsx("div",{className:xe("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function HG({className:e,...t}){return m.jsx("button",{className:xe("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 Wr=_.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:xe("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}));Wr.displayName="Input";const TO=_.createContext(null);function $G({children:e}){const[t,n]=_.useState(null),[r,i]=_.useState(""),s=_.useRef(null);_.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var b,y;(b=s.current)==null||b.focus(),(y=s.current)==null||y.select()},0))},[t]);const o=_.useCallback(()=>{n(null),i("")},[]),l=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),o())},[o,t]),u=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),o())},[o,t,r]),d=_.useCallback(b=>new Promise(y=>{n({kind:"confirm",options:b,resolve:y})}),[]),f=_.useCallback(b=>new Promise(y=>{n({kind:"prompt",options:b,resolve:y})}),[]),h=_.useCallback(b=>new Promise(y=>{n({kind:"alert",options:b,resolve:y})}),[]),g=_.useMemo(()=>({confirm:d,prompt:f,alert:h}),[h,d,f]);return m.jsxs(TO.Provider,{value:g,children:[e,m.jsx(od,{open:t!==null,onOpenChange:b=>{b||!t||l()},children:m.jsx(uc,{size:"sm",onKeyDown:b=>{b.key!=="Enter"||b.shiftKey||!t||t.kind!=="confirm"||(b.preventDefault(),u())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(ld,{className:"space-y-4",children:[m.jsx(ad,{children:t.options.title}),t.options.description?m.jsx(c0,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(Wr,{ref:s,type:"text",value:r,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),u())},placeholder:t.options.placeholder}):null]}),m.jsxs(cd,{children:[m.jsx(st,{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(st,{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 Hw(){const e=_.useContext(TO);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const $w=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("bg-card text-card-foreground",e),...t}));$w.displayName="Card";const Uw=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("flex flex-col space-y-1.5 p-2",e),...t}));Uw.displayName="CardHeader";const AO=_.forwardRef(({className:e,...t},n)=>m.jsx("h3",{ref:n,className:xe("text-2xl font-semibold leading-none tracking-tight",e),...t}));AO.displayName="CardTitle";const NO=_.forwardRef(({className:e,...t},n)=>m.jsx("p",{ref:n,className:xe("text-sm text-muted-foreground",e),...t}));NO.displayName="CardDescription";const Vw=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("p-6 pt-0",e),...t}));Vw.displayName="CardContent";const UG=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("flex items-center p-6 pt-0",e),...t}));UG.displayName="CardFooter";const VG=["top","right","bottom","left"],Ya=Math.min,Ci=Math.max,rv=Math.round,Lm=Math.floor,eo=e=>({x:e,y:e}),WG={left:"right",right:"left",bottom:"top",top:"bottom"};function gS(e,t,n){return Ci(e,Ya(t,n))}function Ho(e,t){return typeof e=="function"?e(t):e}function $o(e){return e.split("-")[0]}function ud(e){return e.split("-")[1]}function Ww(e){return e==="x"?"y":"x"}function Gw(e){return e==="y"?"height":"width"}function Ys(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function qw(e){return Ww(Ys(e))}function GG(e,t,n){n===void 0&&(n=!1);const r=ud(e),i=qw(e),s=Gw(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=iv(o)),[o,iv(o)]}function qG(e){const t=iv(e);return[vS(e),t,vS(t)]}function vS(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const DA=["left","right"],IA=["right","left"],KG=["top","bottom"],YG=["bottom","top"];function XG(e,t,n){switch(e){case"top":case"bottom":return n?t?IA:DA:t?DA:IA;case"left":case"right":return t?KG:YG;default:return[]}}function QG(e,t,n,r){const i=ud(e);let s=XG($o(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(vS)))),s}function iv(e){const t=$o(e);return WG[t]+e.slice(t.length)}function ZG(e){return{top:0,right:0,bottom:0,left:0,...e}}function MO(e){return typeof e!="number"?ZG(e):{top:e,right:e,bottom:e,left:e}}function sv(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 PA(e,t,n){let{reference:r,floating:i}=e;const s=Ys(t),o=qw(t),l=Gw(o),u=$o(t),d=s==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,g=r[l]/2-i[l]/2;let b;switch(u){case"top":b={x:f,y:r.y-i.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:h};break;case"left":b={x:r.x-i.width,y:h};break;default:b={x:r.x,y:r.y}}switch(ud(t)){case"start":b[o]-=g*(n&&d?-1:1);break;case"end":b[o]+=g*(n&&d?-1:1);break}return b}async function JG(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:g=!1,padding:b=0}=Ho(t,e),y=MO(b),w=l[g?h==="floating"?"reference":"floating":h],C=sv(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),R=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(E))?await(s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},N=sv(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:R,offsetParent:E,strategy:u}):R);return{top:(C.top-N.top+y.top)/T.y,bottom:(N.bottom-C.bottom+y.bottom)/T.y,left:(C.left-N.left+y.left)/T.x,right:(N.right-C.right+y.right)/T.x}}const eq=50,tq=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:JG},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=PA(d,r,u),g=r,b=0;const y={};for(let x=0;x<s.length;x++){const w=s[x];if(!w)continue;const{name:C,fn:R}=w,{x:E,y:T,data:N,reset:A}=await R({x:f,y:h,initialPlacement:r,placement:g,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});f=E??f,h=T??h,y[C]={...y[C],...N},A&&b<eq&&(b++,typeof A=="object"&&(A.placement&&(g=A.placement),A.rects&&(d=A.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):A.rects),{x:f,y:h}=PA(d,g,u)),x=-1)}return{x:f,y:h,placement:g,strategy:i,middlewareData:y}},nq=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=Ho(e,t)||{};if(d==null)return{};const h=MO(f),g={x:n,y:r},b=qw(i),y=Gw(b),x=await o.getDimensions(d),w=b==="y",C=w?"top":"left",R=w?"bottom":"right",E=w?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[b]-g[b]-s.floating[y],N=g[b]-s.reference[b],A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let L=A?A[E]:0;(!L||!await(o.isElement==null?void 0:o.isElement(A)))&&(L=l.floating[E]||s.floating[y]);const O=T/2-N/2,G=L/2-x[y]/2-1,P=Ya(h[C],G),j=Ya(h[R],G),B=P,H=L-x[y]-j,$=L/2-x[y]/2+O,V=gS(B,$,H),z=!u.arrow&&ud(i)!=null&&$!==V&&s.reference[y]/2-($<B?P:j)-x[y]/2<0,q=z?$<B?$-B:$-H:0;return{[b]:g[b]+q,data:{[b]:V,centerOffset:$-V-q,...z&&{alignmentOffset:q}},reset:z}}}),rq=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...w}=Ho(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=$o(i),R=Ys(l),E=$o(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),N=g||(E||!x?[iv(l)]:qG(l)),A=y!=="none";!g&&A&&N.push(...QG(l,x,y,T));const L=[l,...N],O=await u.detectOverflow(t,w),G=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&G.push(O[C]),h){const $=GG(i,o,T);G.push(O[$[0]],O[$[1]])}if(P=[...P,{placement:i,overflows:G}],!G.every($=>$<=0)){var j,B;const $=(((j=s.flip)==null?void 0:j.index)||0)+1,V=L[$];if(V&&(!(h==="alignment"?R!==Ys(V):!1)||P.every(F=>Ys(F.placement)===R?F.overflows[0]>0:!0)))return{data:{index:$,overflows:P},reset:{placement:V}};let z=(B=P.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:B.placement;if(!z)switch(b){case"bestFit":{var H;const q=(H=P.filter(F=>{if(A){const Y=Ys(F.placement);return Y===R||Y==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Y=>Y>0).reduce((Y,I)=>Y+I,0)]).sort((F,Y)=>F[1]-Y[1])[0])==null?void 0:H[0];q&&(z=q);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function OA(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function jA(e){return VG.some(t=>e[t]>=0)}const iq=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Ho(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=OA(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:jA(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=OA(o,n.floating);return{data:{escapedOffsets:l,escaped:jA(l)}}}default:return{}}}}},LO=new Set(["left","top"]);async function sq(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=$o(n),l=ud(n),u=Ys(n)==="y",d=LO.has(o)?-1:1,f=s&&u?-1:1,h=Ho(t,e);let{mainAxis:g,crossAxis:b,alignmentAxis:y}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof y=="number"&&(b=l==="end"?y*-1:y),u?{x:b*f,y:g*d}:{x:g*d,y:b*f}}const oq=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=t,u=await sq(t,e);return o===((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:o}}}}},aq=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:o=!0,crossAxis:l=!1,limiter:u={fn:C=>{let{x:R,y:E}=C;return{x:R,y:E}}},...d}=Ho(e,t),f={x:n,y:r},h=await s.detectOverflow(t,d),g=Ys($o(i)),b=Ww(g);let y=f[b],x=f[g];if(o){const C=b==="y"?"top":"left",R=b==="y"?"bottom":"right",E=y+h[C],T=y-h[R];y=gS(E,y,T)}if(l){const C=g==="y"?"top":"left",R=g==="y"?"bottom":"right",E=x+h[C],T=x-h[R];x=gS(E,x,T)}const w=u.fn({...t,[b]:y,[g]:x});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[b]:o,[g]:l}}}}}},lq=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=Ho(e,t),f={x:n,y:r},h=Ys(i),g=Ww(h);let b=f[g],y=f[h];const x=Ho(l,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(u){const E=g==="y"?"height":"width",T=s.reference[g]-s.floating[E]+w.mainAxis,N=s.reference[g]+s.reference[E]-w.mainAxis;b<T?b=T:b>N&&(b=N)}if(d){var C,R;const E=g==="y"?"width":"height",T=LO.has($o(i)),N=s.reference[h]-s.floating[E]+(T&&((C=o.offset)==null?void 0:C[h])||0)+(T?0:w.crossAxis),A=s.reference[h]+s.reference[E]+(T?0:((R=o.offset)==null?void 0:R[h])||0)-(T?w.crossAxis:0);y<N?y=N:y>A&&(y=A)}return{[g]:b,[h]:y}}}},cq=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:l}=t,{apply:u=()=>{},...d}=Ho(e,t),f=await o.detectOverflow(t,d),h=$o(i),g=ud(i),b=Ys(i)==="y",{width:y,height:x}=s.floating;let w,C;h==="top"||h==="bottom"?(w=h,C=g===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(C=h,w=g==="end"?"top":"bottom");const R=x-f.top-f.bottom,E=y-f.left-f.right,T=Ya(x-f[w],R),N=Ya(y-f[C],E),A=!t.middlewareData.shift;let L=T,O=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=E),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=R),A&&!g){const P=Ci(f.left,0),j=Ci(f.right,0),B=Ci(f.top,0),H=Ci(f.bottom,0);b?O=y-2*(P!==0||j!==0?P+j:Ci(f.left,f.right)):L=x-2*(B!==0||H!==0?B+H:Ci(f.top,f.bottom))}await u({...t,availableWidth:O,availableHeight:L});const G=await o.getDimensions(l.floating);return y!==G.width||x!==G.height?{reset:{rects:!0}}:{}}}};function u0(){return typeof window<"u"}function dd(e){return DO(e)?(e.nodeName||"").toLowerCase():"#document"}function Ei(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function io(e){var t;return(t=(DO(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function DO(e){return u0()?e instanceof Node||e instanceof Ei(e).Node:!1}function Rs(e){return u0()?e instanceof Element||e instanceof Ei(e).Element:!1}function Ko(e){return u0()?e instanceof HTMLElement||e instanceof Ei(e).HTMLElement:!1}function zA(e){return!u0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ei(e).ShadowRoot}function Vf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ts(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function uq(e){return/^(table|td|th)$/.test(dd(e))}function d0(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const dq=/transform|translate|scale|rotate|perspective|filter/,hq=/paint|layout|strict|content/,El=e=>!!e&&e!=="none";let Ny;function Kw(e){const t=Rs(e)?Ts(e):e;return El(t.transform)||El(t.translate)||El(t.scale)||El(t.rotate)||El(t.perspective)||!Yw()&&(El(t.backdropFilter)||El(t.filter))||dq.test(t.willChange||"")||hq.test(t.contain||"")}function fq(e){let t=Xa(e);for(;Ko(t)&&!Hu(t);){if(Kw(t))return t;if(d0(t))return null;t=Xa(t)}return null}function Yw(){return Ny==null&&(Ny=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ny}function Hu(e){return/^(html|body|#document)$/.test(dd(e))}function Ts(e){return Ei(e).getComputedStyle(e)}function h0(e){return Rs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Xa(e){if(dd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||zA(e)&&e.host||io(e);return zA(t)?t.host:t}function IO(e){const t=Xa(e);return Hu(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ko(t)&&Vf(t)?t:IO(t)}function uf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=IO(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=Ei(i);if(s){const l=bS(o);return t.concat(o,o.visualViewport||[],Vf(i)?i:[],l&&n?uf(l):[])}else return t.concat(i,uf(i,[],n))}function bS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function PO(e){const t=Ts(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Ko(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=rv(n)!==s||rv(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function Xw(e){return Rs(e)?e:e.contextElement}function Nu(e){const t=Xw(e);if(!Ko(t))return eo(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=PO(t);let o=(s?rv(n.width):n.width)/r,l=(s?rv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const pq=eo(0);function OO(e){const t=Ei(e);return!Yw()||!t.visualViewport?pq:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function mq(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ei(e)?!1:t}function Ql(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=Xw(e);let o=eo(1);t&&(r?Rs(r)&&(o=Nu(r)):o=Nu(e));const l=mq(s,n,r)?OO(s):eo(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(s){const g=Ei(s),b=r&&Rs(r)?Ei(r):r;let y=g,x=bS(y);for(;x&&r&&b!==y;){const w=Nu(x),C=x.getBoundingClientRect(),R=Ts(x),E=C.left+(x.clientLeft+parseFloat(R.paddingLeft))*w.x,T=C.top+(x.clientTop+parseFloat(R.paddingTop))*w.y;u*=w.x,d*=w.y,f*=w.x,h*=w.y,u+=E,d+=T,y=Ei(x),x=bS(y)}}return sv({width:f,height:h,x:u,y:d})}function f0(e,t){const n=h0(e).scrollLeft;return t?t.left+n:Ql(io(e)).left+n}function jO(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-f0(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function gq(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=io(r),l=t?d0(t.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=eo(1);const f=eo(0),h=Ko(r);if((h||!h&&!s)&&((dd(r)!=="body"||Vf(o))&&(u=h0(r)),h)){const b=Ql(r);d=Nu(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const g=o&&!h&&!s?jO(o,u):eo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-u.scrollTop*d.y+f.y+g.y}}function vq(e){return Array.from(e.getClientRects())}function bq(e){const t=io(e),n=h0(e),r=e.ownerDocument.body,i=Ci(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ci(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+f0(e);const l=-n.scrollTop;return Ts(r).direction==="rtl"&&(o+=Ci(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const BA=25;function _q(e,t){const n=Ei(e),r=io(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const f=Yw();(!f||f&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=f0(r);if(d<=0){const f=r.ownerDocument,h=f.body,g=getComputedStyle(h),b=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(r.clientWidth-h.clientWidth-b);y<=BA&&(s-=y)}else d<=BA&&(s+=d);return{width:s,height:o,x:l,y:u}}function yq(e,t){const n=Ql(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Ko(e)?Nu(e):eo(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:o,height:l,x:u,y:d}}function FA(e,t,n){let r;if(t==="viewport")r=_q(e,n);else if(t==="document")r=bq(io(e));else if(Rs(t))r=yq(t,n);else{const i=OO(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return sv(r)}function zO(e,t){const n=Xa(e);return n===t||!Rs(n)||Hu(n)?!1:Ts(n).position==="fixed"||zO(n,t)}function xq(e,t){const n=t.get(e);if(n)return n;let r=uf(e,[],!1).filter(l=>Rs(l)&&dd(l)!=="body"),i=null;const s=Ts(e).position==="fixed";let o=s?Xa(e):e;for(;Rs(o)&&!Hu(o);){const l=Ts(o),u=Kw(o);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Vf(o)&&!u&&zO(e,o))?r=r.filter(f=>f!==o):i=l,o=Xa(o)}return t.set(e,r),r}function Sq(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?d0(t)?[]:xq(t,this._c):[].concat(n),r],l=FA(t,o[0],i);let u=l.top,d=l.right,f=l.bottom,h=l.left;for(let g=1;g<o.length;g++){const b=FA(t,o[g],i);u=Ci(b.top,u),d=Ya(b.right,d),f=Ya(b.bottom,f),h=Ci(b.left,h)}return{width:d-h,height:f-u,x:h,y:u}}function wq(e){const{width:t,height:n}=PO(e);return{width:t,height:n}}function Cq(e,t,n){const r=Ko(t),i=io(t),s=n==="fixed",o=Ql(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=eo(0);function d(){u.x=f0(i)}if(r||!r&&!s)if((dd(t)!=="body"||Vf(i))&&(l=h0(t)),r){const b=Ql(t,!0,s,t);u.x=b.x+t.clientLeft,u.y=b.y+t.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?jO(i,l):eo(0),h=o.left+l.scrollLeft-u.x-f.x,g=o.top+l.scrollTop-u.y-f.y;return{x:h,y:g,width:o.width,height:o.height}}function My(e){return Ts(e).position==="static"}function HA(e,t){if(!Ko(e)||Ts(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return io(e)===n&&(n=n.ownerDocument.body),n}function BO(e,t){const n=Ei(e);if(d0(e))return n;if(!Ko(e)){let i=Xa(e);for(;i&&!Hu(i);){if(Rs(i)&&!My(i))return i;i=Xa(i)}return n}let r=HA(e,t);for(;r&&uq(r)&&My(r);)r=HA(r,t);return r&&Hu(r)&&My(r)&&!Kw(r)?n:r||fq(e)||n}const kq=async function(e){const t=this.getOffsetParent||BO,n=this.getDimensions,r=await n(e.floating);return{reference:Cq(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eq(e){return Ts(e).direction==="rtl"}const Rq={convertOffsetParentRelativeRectToViewportRelativeRect:gq,getDocumentElement:io,getClippingRect:Sq,getOffsetParent:BO,getElementRects:kq,getClientRects:vq,getDimensions:wq,getScale:Nu,isElement:Rs,isRTL:Eq};function FO(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Tq(e,t){let n=null,r;const i=io(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:f,top:h,width:g,height:b}=d;if(l||t(),!g||!b)return;const y=Lm(h),x=Lm(i.clientWidth-(f+g)),w=Lm(i.clientHeight-(h+b)),C=Lm(f),E={rootMargin:-y+"px "+-x+"px "+-w+"px "+-C+"px",threshold:Ci(0,Ya(1,u))||1};let T=!0;function N(A){const L=A[0].intersectionRatio;if(L!==u){if(!T)return o();L?o(!1,L):r=setTimeout(()=>{o(!1,1e-7)},1e3)}L===1&&!FO(d,e.getBoundingClientRect())&&o(),T=!1}try{n=new IntersectionObserver(N,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,E)}n.observe(e)}return o(!0),s}function Aq(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=Xw(e),f=i||s?[...d?uf(d):[],...t?uf(t):[]]:[];f.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const h=d&&l?Tq(d,n):null;let g=-1,b=null;o&&(b=new ResizeObserver(C=>{let[R]=C;R&&R.target===d&&b&&t&&(b.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var E;(E=b)==null||E.observe(t)})),n()}),d&&!u&&b.observe(d),t&&b.observe(t));let y,x=u?Ql(e):null;u&&w();function w(){const C=Ql(e);x&&!FO(x,C)&&n(),x=C,y=requestAnimationFrame(w)}return n(),()=>{var C;f.forEach(R=>{i&&R.removeEventListener("scroll",n),s&&R.removeEventListener("resize",n)}),h==null||h(),(C=b)==null||C.disconnect(),b=null,u&&cancelAnimationFrame(y)}}const Nq=oq,Mq=aq,Lq=rq,Dq=cq,Iq=iq,$A=nq,Pq=lq,Oq=(e,t,n)=>{const r=new Map,i={platform:Rq,...n},s={...i.platform,_c:r};return tq(e,t,{...i,platform:s})};var jq=typeof document<"u",zq=function(){},Rg=jq?_.useLayoutEffect:zq;function ov(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(!ov(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)&&!ov(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function HO(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function UA(e,t){const n=HO(e);return Math.round(t*n)/n}function Ly(e){const t=_.useRef(e);return Rg(()=>{t.current=e}),t}function Bq(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,h]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,b]=_.useState(r);ov(g,r)||b(r);const[y,x]=_.useState(null),[w,C]=_.useState(null),R=_.useCallback(F=>{F!==A.current&&(A.current=F,x(F))},[]),E=_.useCallback(F=>{F!==L.current&&(L.current=F,C(F))},[]),T=s||y,N=o||w,A=_.useRef(null),L=_.useRef(null),O=_.useRef(f),G=u!=null,P=Ly(u),j=Ly(i),B=Ly(d),H=_.useCallback(()=>{if(!A.current||!L.current)return;const F={placement:t,strategy:n,middleware:g};j.current&&(F.platform=j.current),Oq(A.current,L.current,F).then(Y=>{const I={...Y,isPositioned:B.current!==!1};$.current&&!ov(O.current,I)&&(O.current=I,is.flushSync(()=>{h(I)}))})},[g,t,n,j,B]);Rg(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[d]);const $=_.useRef(!1);Rg(()=>($.current=!0,()=>{$.current=!1}),[]),Rg(()=>{if(T&&(A.current=T),N&&(L.current=N),T&&N){if(P.current)return P.current(T,N,H);H()}},[T,N,H,P,G]);const V=_.useMemo(()=>({reference:A,floating:L,setReference:R,setFloating:E}),[R,E]),z=_.useMemo(()=>({reference:T,floating:N}),[T,N]),q=_.useMemo(()=>{const F={position:n,left:0,top:0};if(!z.floating)return F;const Y=UA(z.floating,f.x),I=UA(z.floating,f.y);return l?{...F,transform:"translate("+Y+"px, "+I+"px)",...HO(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:I}},[n,l,z.floating,f.x,f.y]);return _.useMemo(()=>({...f,update:H,refs:V,elements:z,floatingStyles:q}),[f,H,V,z,q])}const Fq=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?$A({element:r.current,padding:i}).fn(n):{}:r?$A({element:r,padding:i}).fn(n):{}}}},Hq=(e,t)=>{const n=Nq(e);return{name:n.name,fn:n.fn,options:[e,t]}},$q=(e,t)=>{const n=Mq(e);return{name:n.name,fn:n.fn,options:[e,t]}},Uq=(e,t)=>({fn:Pq(e).fn,options:[e,t]}),Vq=(e,t)=>{const n=Lq(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wq=(e,t)=>{const n=Dq(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gq=(e,t)=>{const n=Iq(e);return{name:n.name,fn:n.fn,options:[e,t]}},qq=(e,t)=>{const n=Fq(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Kq="Arrow",$O=_.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(Ut.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"})})});$O.displayName=Kq;var Yq=$O;function Xq(e){const[t,n]=_.useState(void 0);return Or(()=>{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 o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Qw="Popper",[UO,rl]=qo(Qw),[Qq,VO]=UO(Qw),WO=e=>{const{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return m.jsx(Qq,{scope:t,anchor:r,onAnchorChange:i,children:n})};WO.displayName=Qw;var GO="PopperAnchor",qO=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=VO(GO,n),o=_.useRef(null),l=an(t,o),u=_.useRef(null);return _.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||o.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(Ut.div,{...i,ref:l})});qO.displayName=GO;var Zw="PopperContent",[Zq,Jq]=UO(Zw),KO=_.forwardRef((e,t)=>{var se,pe,re,me,Ee,we;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:b="optimized",onPlaced:y,...x}=e,w=VO(Zw,n),[C,R]=_.useState(null),E=an(t,Ae=>R(Ae)),[T,N]=_.useState(null),A=Xq(T),L=(A==null?void 0:A.width)??0,O=(A==null?void 0:A.height)??0,G=r+(s!=="center"?"-"+s:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},j=Array.isArray(d)?d:[d],B=j.length>0,H={padding:P,boundary:j.filter(tK),altBoundary:B},{refs:$,floatingStyles:V,placement:z,isPositioned:q,middlewareData:F}=Bq({strategy:"fixed",placement:G,whileElementsMounted:(...Ae)=>Aq(...Ae,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[Hq({mainAxis:i+O,alignmentAxis:o}),u&&$q({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Uq():void 0,...H}),u&&Vq({...H}),Wq({...H,apply:({elements:Ae,rects:ze,availableWidth:Ue,availableHeight:tt})=>{const{width:kt,height:Qt}=ze.reference,Pe=Ae.floating.style;Pe.setProperty("--radix-popper-available-width",`${Ue}px`),Pe.setProperty("--radix-popper-available-height",`${tt}px`),Pe.setProperty("--radix-popper-anchor-width",`${kt}px`),Pe.setProperty("--radix-popper-anchor-height",`${Qt}px`)}}),T&&qq({element:T,padding:l}),nK({arrowWidth:L,arrowHeight:O}),g&&Gq({strategy:"referenceHidden",...H})]}),[Y,I]=QO(z),U=Es(y);Or(()=>{q&&(U==null||U())},[q,U]);const X=(se=F.arrow)==null?void 0:se.x,D=(pe=F.arrow)==null?void 0:pe.y,te=((re=F.arrow)==null?void 0:re.centerOffset)!==0,[Q,ie]=_.useState();return Or(()=>{C&&ie(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:q?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[(me=F.transformOrigin)==null?void 0:me.x,(Ee=F.transformOrigin)==null?void 0:Ee.y].join(" "),...((we=F.hide)==null?void 0:we.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(Zq,{scope:n,placedSide:Y,onArrowChange:N,arrowX:X,arrowY:D,shouldHideArrow:te,children:m.jsx(Ut.div,{"data-side":Y,"data-align":I,...x,ref:E,style:{...x.style,animation:q?void 0:"none"}})})})});KO.displayName=Zw;var YO="PopperArrow",eK={top:"bottom",right:"left",bottom:"top",left:"right"},XO=_.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=Jq(YO,r),o=eK[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]: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(Yq,{...i,ref:n,style:{...i.style,display:"block"}})})});XO.displayName=YO;function tK(e){return e!==null}var nK=e=>({name:"transformOrigin",options:e,fn(t){var w,C,R;const{placement:n,rects:r,middlewareData:i}=t,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,f]=QO(n),h={start:"0%",center:"50%",end:"100%"}[f],g=(((C=i.arrow)==null?void 0:C.x)??0)+l/2,b=(((R=i.arrow)==null?void 0:R.y)??0)+u/2;let y="",x="";return d==="bottom"?(y=o?h:`${g}px`,x=`${-u}px`):d==="top"?(y=o?h:`${g}px`,x=`${r.floating.height+u}px`):d==="right"?(y=`${-u}px`,x=o?h:`${b}px`):d==="left"&&(y=`${r.floating.width+u}px`,x=o?h:`${b}px`),{data:{x:y,y:x}}}});function QO(e){const[t,n="center"]=e.split("-");return[t,n]}var p0=WO,Wf=qO,m0=KO,g0=XO,ZO=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"}),rK="VisuallyHidden",JO=_.forwardRef((e,t)=>m.jsx(Ut.span,{...e,ref:t,style:{...ZO,...e.style}}));JO.displayName=rK;var iK=JO,[v0]=qo("Tooltip",[rl]),b0=rl(),e5="TooltipProvider",sK=700,_S="tooltip.open",[oK,Jw]=v0(e5),t5=e=>{const{__scopeTooltip:t,delayDuration:n=sK,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=_.useRef(!0),l=_.useRef(!1),u=_.useRef(0);return _.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(oK,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(u.current),o.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:_.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};t5.displayName=e5;var df="Tooltip",[aK,Gf]=v0(df),n5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,u=Jw(df,e.__scopeTooltip),d=b0(t),[f,h]=_.useState(null),g=zo(),b=_.useRef(0),y=o??u.disableHoverableContent,x=l??u.delayDuration,w=_.useRef(!1),[C,R]=Fu({prop:r,defaultProp:i??!1,onChange:L=>{L?(u.onOpen(),document.dispatchEvent(new CustomEvent(_S))):u.onClose(),s==null||s(L)},caller:df}),E=_.useMemo(()=>C?w.current?"delayed-open":"instant-open":"closed",[C]),T=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,R(!0)},[R]),N=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,R(!1)},[R]),A=_.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,R(!0),b.current=0},x)},[x,R]);return _.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),m.jsx(p0,{...d,children:m.jsx(aK,{scope:t,contentId:g,open:C,stateAttribute:E,trigger:f,onTriggerChange:h,onTriggerEnter:_.useCallback(()=>{u.isOpenDelayedRef.current?A():T()},[u.isOpenDelayedRef,A,T]),onTriggerLeave:_.useCallback(()=>{y?N():(window.clearTimeout(b.current),b.current=0)},[N,y]),onOpen:T,onClose:N,disableHoverableContent:y,children:n})})};n5.displayName=df;var yS="TooltipTrigger",r5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Gf(yS,n),s=Jw(yS,n),o=b0(n),l=_.useRef(null),u=an(t,l,i.onTriggerChange),d=_.useRef(!1),f=_.useRef(!1),h=_.useCallback(()=>d.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),m.jsx(Wf,{asChild:!0,...o,children:m.jsx(Ut.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:He(e.onPointerMove,g=>{g.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:He(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:He(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:He(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:He(e.onBlur,i.onClose),onClick:He(e.onClick,i.onClose)})})});r5.displayName=yS;var eC="TooltipPortal",[lK,cK]=v0(eC,{forceMount:void 0}),i5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Gf(eC,t);return m.jsx(lK,{scope:t,forceMount:n,children:m.jsx(hs,{present:n||s.open,children:m.jsx(sd,{asChild:!0,container:i,children:r})})})};i5.displayName=eC;var $u="TooltipContent",s5=_.forwardRef((e,t)=>{const n=cK($u,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Gf($u,e.__scopeTooltip);return m.jsx(hs,{present:r||o.open,children:o.disableHoverableContent?m.jsx(o5,{side:i,...s,ref:t}):m.jsx(uK,{side:i,...s,ref:t})})}),uK=_.forwardRef((e,t)=>{const n=Gf($u,e.__scopeTooltip),r=Jw($u,e.__scopeTooltip),i=_.useRef(null),s=an(t,i),[o,l]=_.useState(null),{trigger:u,onClose:d}=n,f=i.current,{onPointerInTransitChange:h}=r,g=_.useCallback(()=>{l(null),h(!1)},[h]),b=_.useCallback((y,x)=>{const w=y.currentTarget,C={x:y.clientX,y:y.clientY},R=mK(C,w.getBoundingClientRect()),E=gK(C,R),T=vK(x.getBoundingClientRect()),N=_K([...E,...T]);l(N),h(!0)},[h]);return _.useEffect(()=>()=>g(),[g]),_.useEffect(()=>{if(u&&f){const y=w=>b(w,f),x=w=>b(w,u);return u.addEventListener("pointerleave",y),f.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",y),f.removeEventListener("pointerleave",x)}}},[u,f,b,g]),_.useEffect(()=>{if(o){const y=x=>{const w=x.target,C={x:x.clientX,y:x.clientY},R=(u==null?void 0:u.contains(w))||(f==null?void 0:f.contains(w)),E=!bK(C,o);R?g():E&&(g(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,f,o,d,g]),m.jsx(o5,{...e,ref:s})}),[dK,hK]=v0(df,{isInside:!1}),fK=dW("TooltipContent"),o5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,u=Gf($u,n),d=b0(n),{onClose:f}=u;return _.useEffect(()=>(document.addEventListener(_S,f),()=>document.removeEventListener(_S,f)),[f]),_.useEffect(()=>{if(u.trigger){const h=g=>{const b=g.target;b!=null&&b.contains(u.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,f]),m.jsx(id,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:m.jsxs(m0,{"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(fK,{children:r}),m.jsx(dK,{scope:n,isInside:!0,children:m.jsx(iK,{id:u.contentId,role:"tooltip",children:i||r})})]})})});s5.displayName=$u;var a5="TooltipArrow",pK=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=b0(n);return hK(a5,n).isInside?null:m.jsx(g0,{...i,...r,ref:t})});pK.displayName=a5;function mK(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 gK(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 vK(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 bK(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],u=t[o],d=l.x,f=l.y,h=u.x,g=u.y;f>r!=g>r&&n<(h-d)*(r-f)/(g-f)+d&&(i=!i)}return i}function _K(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),yK(t)}function yK(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],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.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],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.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 xK=t5,l5=n5,c5=r5,u5=i5,tC=s5;function d5({className:e,...t}){return m.jsx("kbd",{className:xe("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 SK({className:e,...t}){return m.jsx("span",{className:xe("inline-flex items-center gap-0.5",e),...t})}const wK="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",CK=xK,Qa=l5,Za=c5,Uo=_.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(u5,{children:m.jsx(tC,{ref:r,sideOffset:t,className:xe("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})}));Uo.displayName=tC.displayName;const Ph=l5,Oh=c5;function h5(e){return e.toUpperCase()}function kK(e){const t=e.split("+");return m.jsx(SK,{children:t.map((n,r)=>m.jsx(d5,{children:h5(n)},`${n}-${r}`))})}const Su=_.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const o=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(u5,{children:m.jsx(tC,{ref:s,sideOffset:t,className:xe(wK,e),...i,children:o?kK(o):m.jsx("span",{children:typeof n=="string"?h5(n):n})})})});Su.displayName="HotkeyTooltipContent";const EK="0.33.6",RK={version:EK},Un="Kanna",VA="kanna",TK=".kanna",AK=".kanna-dev",NK="KANNA_RUNTIME_PROFILE",nC=`kanna/${RK.version}`,MK="[kanna]",LK=`~/${Un}`;function _0(){var t;return(t=globalThis.process)==null?void 0:t.env}function DK(e=_0()){var t;return((t=e==null?void 0:e[NK])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function IK(e=_0()){return DK(e)==="dev"?AK:TK}function PK(e=_0()){return`~/${IK(e)}`}function OK(e=_0()){return`${PK(e)}/keybindings.json`}function Dm(e){return e?`${VA} ${e}`:VA}const WA=e=>{let t;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const g=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(b=>b(t,g))}},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},jK=(e=>e?WA(e):WA),zK=e=>e;function BK(e,t=zK){const n=gn.useSyncExternalStore(e.subscribe,gn.useCallback(()=>t(e.getState()),[e,t]),gn.useCallback(()=>t(e.getInitialState()),[e,t]));return gn.useDebugValue(n),n}const FK=e=>{const t=jK(e),n=r=>BK(t,r);return Object.assign(n,t),n},dc=(e=>FK);function HK(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const o=u=>u===null?null:JSON.parse(u,void 0),l=(s=n.getItem(i))!=null?s:null;return l instanceof Promise?l.then(o):o(l)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const xS=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return xS(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return xS(r)(n)}}}},$K=(e,t)=>(n,r,i)=>{let s={storage:HK(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,C)=>({...C,...w}),...t},o=!1,l=0;const u=new Set,d=new Set;let f=s.storage;if(!f)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...w)},r,i);const h=()=>{const w=s.partialize({...r()});return f.setItem(s.name,{state:w,version:s.version})},g=i.setState;i.setState=(w,C)=>(g(w,C),h());const b=e((...w)=>(n(...w),h()),r,i);i.getInitialState=()=>b;let y;const x=()=>{var w,C;if(!f)return;const R=++l;o=!1,u.forEach(T=>{var N;return T((N=r())!=null?N:b)});const E=((C=s.onRehydrateStorage)==null?void 0:C.call(s,(w=r())!=null?w:b))||void 0;return xS(f.getItem.bind(f))(s.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==s.version){if(s.migrate){const N=s.migrate(T.state,T.version);return N instanceof Promise?N.then(A=>[!0,A]):[!0,N]}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 N;if(R!==l)return;const[A,L]=T;if(y=s.merge(L,(N=r())!=null?N:b),n(y,!0),A)return h()}).then(()=>{R===l&&(E==null||E(y,void 0),y=r(),o=!0,d.forEach(T=>T(y)))}).catch(T=>{R===l&&(E==null||E(void 0,T))})};return i.persist={setOptions:w=>{s={...s,...w},w.storage&&(f=w.storage)},clearStorage:()=>{f==null||f.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>x(),hasHydrated:()=>o,onHydrate:w=>(u.add(w),()=>{u.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},s.skipHydration||x(),y||b},hc=$K,f5="always",p5="funk",UK=[{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 GA(e){switch(e){case"never":case"unfocused":case"always":return e;default:return f5}}function qA(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 p5}}const wu=dc()(hc(e=>({chatSoundPreference:f5,chatSoundId:p5,setChatSoundPreference:t=>e({chatSoundPreference:GA(t)}),setChatSoundId:t=>e({chatSoundId:qA(t)})}),{name:"chat-sound-preferences",version:2,migrate:e=>{const t=e;return{chatSoundPreference:GA(t==null?void 0:t.chatSoundPreference),chatSoundId:qA(t==null?void 0:t.chatSoundId)}}})),VK={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 WK(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function GK(e){const t=new Audio(VK[e]);return t.preload="auto",t.play()}async function SS(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{GK(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function qK(e,t=document){return e==="never"?!1:e==="always"?!0:WK(t)}function KK(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 KA(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 YK(e,t){if(!e)return 0;const n=KA(e),r=KA(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}const hd=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>m.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:xe("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});function wS(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const XK=[/^(?:\/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 QK(e){const t=e.trim();for(const n of XK){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function m5(e){return e.split("/").pop()||e}const ZK=1440*6e4;function JK(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=ZK,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function eY(e){return e.lastMessageAt??e._creationTime}const tY=new Set(["starting","running"]);function nY({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onForkChat:o,onDeleteChat:l}){const u=JK(eY(e),n),d=i&&r?r:u,f=i&&!!r,h=nW(e.chatId);return m.jsxs("div",{"data-chat-id":h,className:xe("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===h?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>s(e.chatId),children:[tY.has(e.status)?m.jsx(kn,{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(hd,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),m.jsxs("div",{className:xe("relative h-7 mr-[2px] shrink-0",e.canFork?"w-12":"w-6"),children:[d?f?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(d5,{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:d}):null,m.jsxs("div",{className:xe("absolute inset-0 flex items-center justify-end gap-0 opacity-100",d?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),children:[e.canFork?m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:g=>{g.stopPropagation(),o(e.chatId)},title:"Fork chat",children:m.jsx(KU,{className:"size-3.5"})}):null,m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:g=>{g.stopPropagation(),l(e.chatId)},title:"Delete chat",children:m.jsx(m$,{className:"size-3.5"})})]})]})]},e._id)}const rY=_.memo(nY);function iY(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const y0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fd(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function rC(e){return"nodeType"in e}function ci(e){var t,n;return e?fd(e)?e:rC(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function iC(e){const{Document:t}=ci(e);return e instanceof t}function qf(e){return fd(e)?!1:e instanceof ci(e).HTMLElement}function g5(e){return e instanceof ci(e).SVGElement}function pd(e){return e?fd(e)?e.document:rC(e)?iC(e)?e:qf(e)||g5(e)?e.ownerDocument:document:document:document}const no=y0?_.useLayoutEffect:_.useEffect;function sC(e){const t=_.useRef(e);return no(()=>{t.current=e}),_.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 sY(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function hf(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return no(()=>{n.current!==e&&(n.current=e)},t),n}function Kf(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function av(e){const t=sC(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function CS(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let Dy={};function Yf(e,t){return _.useMemo(()=>{if(t)return t;const n=Dy[e]==null?0:Dy[e]+1;return Dy[e]=n,e+"-"+n},[e,t])}function v5(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,o)=>{const l=Object.entries(o);for(const[u,d]of l){const f=s[u];f!=null&&(s[u]=f+e*d)}return s},{...t})}}const Mu=v5(1),lv=v5(-1);function oY(e){return"clientX"in e&&"clientY"in e}function oC(e){if(!e)return!1;const{KeyboardEvent:t}=ci(e.target);return t&&e instanceof t}function aY(e){if(!e)return!1;const{TouchEvent:t}=ci(e.target);return t&&e instanceof t}function kS(e){if(aY(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 oY(e)?{x:e.clientX,y:e.clientY}:null}const ff=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[ff.Translate.toString(e),ff.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),YA="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function lY(e){return e.matches(YA)?e:e.querySelector(YA)}const cY={display:"none"};function uY(e){let{id:t,value:n}=e;return gn.createElement("div",{id:t,style:cY},n)}function dY(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 gn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function hY(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const b5=_.createContext(null);function fY(e){const t=_.useContext(b5);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function pY(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[e]),t]}const mY={draggable:`
630
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},TG="DialogDescriptionWarning",AG=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${SO(TG).contentName}}.`;return _.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},NG=cO,MG=hO,wO=fO,CO=pO,LG=gO,DG=bO,IG=yO;const cf="data-focus-fallback-ignore",kO="data-allow-focus-retain",tv="kanna:restore-chat-input-focus",Fw="data-chat-input",nv="data-chat-selection-zone";function Il(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function EO(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:Il(e,kO):!1}function PG(e){const t=e;return t!=null&&t.matches?EO(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:Il(e,kO):!1}function MA(e){return!!e.querySelector(`[${cf}][data-state='open']`)}function OG(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function jG(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${Fw}]`)).filter(o=>!o.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 LA(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||Il(t,Fw)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:o,hasActiveSelection:l}=e,u=s??i;return!o||!u||!o.contains(u)||Il(u,cf)||Il(t,cf)||l&&(Il(i,nv)||Il(u,nv))||EO(t)?"none":t&&t===u?"restore":PG(t)?"none":"restore"}const od=NG,zG=MG,RO=_.forwardRef(({className:e,...t},n)=>m.jsx(wO,{ref:n,className:xe("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}));RO.displayName=wO.displayName;const BG={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},uc=_.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(zG,{children:[m.jsx(RO,{}),m.jsxs(CO,{ref:i,[cf]:"",onCloseAutoFocus:s=>{var o;s.preventDefault(),window.dispatchEvent(new Event(tv)),(o=r.onCloseAutoFocus)==null||o.call(r,s)},className:xe("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",BG[n],e),...r,children:[t,m.jsxs(IG,{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(tl,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));uc.displayName=CO.displayName;function FG({className:e,...t}){return m.jsx("div",{className:xe("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function ad({className:e,...t}){return m.jsx(LG,{className:xe("text-lg font-medium leading-none tracking-tight",e),...t})}function c0({className:e,...t}){return m.jsx(DG,{className:xe("text-sm text-muted-foreground",e),...t})}function ld({className:e,...t}){return m.jsx("div",{className:xe("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function cd({className:e,...t}){return m.jsx("div",{className:xe("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function HG({className:e,...t}){return m.jsx("button",{className:xe("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 Wr=_.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:xe("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}));Wr.displayName="Input";const TO=_.createContext(null);function $G({children:e}){const[t,n]=_.useState(null),[r,i]=_.useState(""),s=_.useRef(null);_.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var b,y;(b=s.current)==null||b.focus(),(y=s.current)==null||y.select()},0))},[t]);const o=_.useCallback(()=>{n(null),i("")},[]),l=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),o())},[o,t]),u=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),o())},[o,t,r]),d=_.useCallback(b=>new Promise(y=>{n({kind:"confirm",options:b,resolve:y})}),[]),f=_.useCallback(b=>new Promise(y=>{n({kind:"prompt",options:b,resolve:y})}),[]),h=_.useCallback(b=>new Promise(y=>{n({kind:"alert",options:b,resolve:y})}),[]),g=_.useMemo(()=>({confirm:d,prompt:f,alert:h}),[h,d,f]);return m.jsxs(TO.Provider,{value:g,children:[e,m.jsx(od,{open:t!==null,onOpenChange:b=>{b||!t||l()},children:m.jsx(uc,{size:"sm",onKeyDown:b=>{b.key!=="Enter"||b.shiftKey||!t||t.kind!=="confirm"||(b.preventDefault(),u())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(ld,{className:"space-y-4",children:[m.jsx(ad,{children:t.options.title}),t.options.description?m.jsx(c0,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(Wr,{ref:s,type:"text",value:r,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),u())},placeholder:t.options.placeholder}):null]}),m.jsxs(cd,{children:[m.jsx(st,{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(st,{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 Hw(){const e=_.useContext(TO);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const $w=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("bg-card text-card-foreground",e),...t}));$w.displayName="Card";const Uw=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("flex flex-col space-y-1.5 p-2",e),...t}));Uw.displayName="CardHeader";const AO=_.forwardRef(({className:e,...t},n)=>m.jsx("h3",{ref:n,className:xe("text-2xl font-semibold leading-none tracking-tight",e),...t}));AO.displayName="CardTitle";const NO=_.forwardRef(({className:e,...t},n)=>m.jsx("p",{ref:n,className:xe("text-sm text-muted-foreground",e),...t}));NO.displayName="CardDescription";const Vw=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("p-6 pt-0",e),...t}));Vw.displayName="CardContent";const UG=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:xe("flex items-center p-6 pt-0",e),...t}));UG.displayName="CardFooter";const VG=["top","right","bottom","left"],Ya=Math.min,Ci=Math.max,rv=Math.round,Lm=Math.floor,eo=e=>({x:e,y:e}),WG={left:"right",right:"left",bottom:"top",top:"bottom"};function gS(e,t,n){return Ci(e,Ya(t,n))}function Ho(e,t){return typeof e=="function"?e(t):e}function $o(e){return e.split("-")[0]}function ud(e){return e.split("-")[1]}function Ww(e){return e==="x"?"y":"x"}function Gw(e){return e==="y"?"height":"width"}function Ys(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function qw(e){return Ww(Ys(e))}function GG(e,t,n){n===void 0&&(n=!1);const r=ud(e),i=qw(e),s=Gw(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=iv(o)),[o,iv(o)]}function qG(e){const t=iv(e);return[vS(e),t,vS(t)]}function vS(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const DA=["left","right"],IA=["right","left"],KG=["top","bottom"],YG=["bottom","top"];function XG(e,t,n){switch(e){case"top":case"bottom":return n?t?IA:DA:t?DA:IA;case"left":case"right":return t?KG:YG;default:return[]}}function QG(e,t,n,r){const i=ud(e);let s=XG($o(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(vS)))),s}function iv(e){const t=$o(e);return WG[t]+e.slice(t.length)}function ZG(e){return{top:0,right:0,bottom:0,left:0,...e}}function MO(e){return typeof e!="number"?ZG(e):{top:e,right:e,bottom:e,left:e}}function sv(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 PA(e,t,n){let{reference:r,floating:i}=e;const s=Ys(t),o=qw(t),l=Gw(o),u=$o(t),d=s==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,g=r[l]/2-i[l]/2;let b;switch(u){case"top":b={x:f,y:r.y-i.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:h};break;case"left":b={x:r.x-i.width,y:h};break;default:b={x:r.x,y:r.y}}switch(ud(t)){case"start":b[o]-=g*(n&&d?-1:1);break;case"end":b[o]+=g*(n&&d?-1:1);break}return b}async function JG(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:g=!1,padding:b=0}=Ho(t,e),y=MO(b),w=l[g?h==="floating"?"reference":"floating":h],C=sv(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),R=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(E))?await(s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},N=sv(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:R,offsetParent:E,strategy:u}):R);return{top:(C.top-N.top+y.top)/T.y,bottom:(N.bottom-C.bottom+y.bottom)/T.y,left:(C.left-N.left+y.left)/T.x,right:(N.right-C.right+y.right)/T.x}}const eq=50,tq=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:JG},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=PA(d,r,u),g=r,b=0;const y={};for(let x=0;x<s.length;x++){const w=s[x];if(!w)continue;const{name:C,fn:R}=w,{x:E,y:T,data:N,reset:A}=await R({x:f,y:h,initialPlacement:r,placement:g,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});f=E??f,h=T??h,y[C]={...y[C],...N},A&&b<eq&&(b++,typeof A=="object"&&(A.placement&&(g=A.placement),A.rects&&(d=A.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):A.rects),{x:f,y:h}=PA(d,g,u)),x=-1)}return{x:f,y:h,placement:g,strategy:i,middlewareData:y}},nq=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=Ho(e,t)||{};if(d==null)return{};const h=MO(f),g={x:n,y:r},b=qw(i),y=Gw(b),x=await o.getDimensions(d),w=b==="y",C=w?"top":"left",R=w?"bottom":"right",E=w?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[b]-g[b]-s.floating[y],N=g[b]-s.reference[b],A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let L=A?A[E]:0;(!L||!await(o.isElement==null?void 0:o.isElement(A)))&&(L=l.floating[E]||s.floating[y]);const O=T/2-N/2,G=L/2-x[y]/2-1,P=Ya(h[C],G),j=Ya(h[R],G),B=P,H=L-x[y]-j,$=L/2-x[y]/2+O,V=gS(B,$,H),z=!u.arrow&&ud(i)!=null&&$!==V&&s.reference[y]/2-($<B?P:j)-x[y]/2<0,q=z?$<B?$-B:$-H:0;return{[b]:g[b]+q,data:{[b]:V,centerOffset:$-V-q,...z&&{alignmentOffset:q}},reset:z}}}),rq=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...w}=Ho(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=$o(i),R=Ys(l),E=$o(l)===l,T=await(u.isRTL==null?void 0:u.isRTL(d.floating)),N=g||(E||!x?[iv(l)]:qG(l)),A=y!=="none";!g&&A&&N.push(...QG(l,x,y,T));const L=[l,...N],O=await u.detectOverflow(t,w),G=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&G.push(O[C]),h){const $=GG(i,o,T);G.push(O[$[0]],O[$[1]])}if(P=[...P,{placement:i,overflows:G}],!G.every($=>$<=0)){var j,B;const $=(((j=s.flip)==null?void 0:j.index)||0)+1,V=L[$];if(V&&(!(h==="alignment"?R!==Ys(V):!1)||P.every(F=>Ys(F.placement)===R?F.overflows[0]>0:!0)))return{data:{index:$,overflows:P},reset:{placement:V}};let z=(B=P.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:B.placement;if(!z)switch(b){case"bestFit":{var H;const q=(H=P.filter(F=>{if(A){const Y=Ys(F.placement);return Y===R||Y==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Y=>Y>0).reduce((Y,I)=>Y+I,0)]).sort((F,Y)=>F[1]-Y[1])[0])==null?void 0:H[0];q&&(z=q);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function OA(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function jA(e){return VG.some(t=>e[t]>=0)}const iq=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Ho(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=OA(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:jA(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=OA(o,n.floating);return{data:{escapedOffsets:l,escaped:jA(l)}}}default:return{}}}}},LO=new Set(["left","top"]);async function sq(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=$o(n),l=ud(n),u=Ys(n)==="y",d=LO.has(o)?-1:1,f=s&&u?-1:1,h=Ho(t,e);let{mainAxis:g,crossAxis:b,alignmentAxis:y}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof y=="number"&&(b=l==="end"?y*-1:y),u?{x:b*f,y:g*d}:{x:g*d,y:b*f}}const oq=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=t,u=await sq(t,e);return o===((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:o}}}}},aq=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:o=!0,crossAxis:l=!1,limiter:u={fn:C=>{let{x:R,y:E}=C;return{x:R,y:E}}},...d}=Ho(e,t),f={x:n,y:r},h=await s.detectOverflow(t,d),g=Ys($o(i)),b=Ww(g);let y=f[b],x=f[g];if(o){const C=b==="y"?"top":"left",R=b==="y"?"bottom":"right",E=y+h[C],T=y-h[R];y=gS(E,y,T)}if(l){const C=g==="y"?"top":"left",R=g==="y"?"bottom":"right",E=x+h[C],T=x-h[R];x=gS(E,x,T)}const w=u.fn({...t,[b]:y,[g]:x});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[b]:o,[g]:l}}}}}},lq=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=Ho(e,t),f={x:n,y:r},h=Ys(i),g=Ww(h);let b=f[g],y=f[h];const x=Ho(l,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(u){const E=g==="y"?"height":"width",T=s.reference[g]-s.floating[E]+w.mainAxis,N=s.reference[g]+s.reference[E]-w.mainAxis;b<T?b=T:b>N&&(b=N)}if(d){var C,R;const E=g==="y"?"width":"height",T=LO.has($o(i)),N=s.reference[h]-s.floating[E]+(T&&((C=o.offset)==null?void 0:C[h])||0)+(T?0:w.crossAxis),A=s.reference[h]+s.reference[E]+(T?0:((R=o.offset)==null?void 0:R[h])||0)-(T?w.crossAxis:0);y<N?y=N:y>A&&(y=A)}return{[g]:b,[h]:y}}}},cq=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:l}=t,{apply:u=()=>{},...d}=Ho(e,t),f=await o.detectOverflow(t,d),h=$o(i),g=ud(i),b=Ys(i)==="y",{width:y,height:x}=s.floating;let w,C;h==="top"||h==="bottom"?(w=h,C=g===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(C=h,w=g==="end"?"top":"bottom");const R=x-f.top-f.bottom,E=y-f.left-f.right,T=Ya(x-f[w],R),N=Ya(y-f[C],E),A=!t.middlewareData.shift;let L=T,O=N;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=E),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=R),A&&!g){const P=Ci(f.left,0),j=Ci(f.right,0),B=Ci(f.top,0),H=Ci(f.bottom,0);b?O=y-2*(P!==0||j!==0?P+j:Ci(f.left,f.right)):L=x-2*(B!==0||H!==0?B+H:Ci(f.top,f.bottom))}await u({...t,availableWidth:O,availableHeight:L});const G=await o.getDimensions(l.floating);return y!==G.width||x!==G.height?{reset:{rects:!0}}:{}}}};function u0(){return typeof window<"u"}function dd(e){return DO(e)?(e.nodeName||"").toLowerCase():"#document"}function Ei(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function io(e){var t;return(t=(DO(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function DO(e){return u0()?e instanceof Node||e instanceof Ei(e).Node:!1}function Rs(e){return u0()?e instanceof Element||e instanceof Ei(e).Element:!1}function Ko(e){return u0()?e instanceof HTMLElement||e instanceof Ei(e).HTMLElement:!1}function zA(e){return!u0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ei(e).ShadowRoot}function Vf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ts(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function uq(e){return/^(table|td|th)$/.test(dd(e))}function d0(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const dq=/transform|translate|scale|rotate|perspective|filter/,hq=/paint|layout|strict|content/,El=e=>!!e&&e!=="none";let Ny;function Kw(e){const t=Rs(e)?Ts(e):e;return El(t.transform)||El(t.translate)||El(t.scale)||El(t.rotate)||El(t.perspective)||!Yw()&&(El(t.backdropFilter)||El(t.filter))||dq.test(t.willChange||"")||hq.test(t.contain||"")}function fq(e){let t=Xa(e);for(;Ko(t)&&!Hu(t);){if(Kw(t))return t;if(d0(t))return null;t=Xa(t)}return null}function Yw(){return Ny==null&&(Ny=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ny}function Hu(e){return/^(html|body|#document)$/.test(dd(e))}function Ts(e){return Ei(e).getComputedStyle(e)}function h0(e){return Rs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Xa(e){if(dd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||zA(e)&&e.host||io(e);return zA(t)?t.host:t}function IO(e){const t=Xa(e);return Hu(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ko(t)&&Vf(t)?t:IO(t)}function uf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=IO(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=Ei(i);if(s){const l=bS(o);return t.concat(o,o.visualViewport||[],Vf(i)?i:[],l&&n?uf(l):[])}else return t.concat(i,uf(i,[],n))}function bS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function PO(e){const t=Ts(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Ko(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=rv(n)!==s||rv(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function Xw(e){return Rs(e)?e:e.contextElement}function Nu(e){const t=Xw(e);if(!Ko(t))return eo(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=PO(t);let o=(s?rv(n.width):n.width)/r,l=(s?rv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const pq=eo(0);function OO(e){const t=Ei(e);return!Yw()||!t.visualViewport?pq:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function mq(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ei(e)?!1:t}function Ql(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=Xw(e);let o=eo(1);t&&(r?Rs(r)&&(o=Nu(r)):o=Nu(e));const l=mq(s,n,r)?OO(s):eo(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(s){const g=Ei(s),b=r&&Rs(r)?Ei(r):r;let y=g,x=bS(y);for(;x&&r&&b!==y;){const w=Nu(x),C=x.getBoundingClientRect(),R=Ts(x),E=C.left+(x.clientLeft+parseFloat(R.paddingLeft))*w.x,T=C.top+(x.clientTop+parseFloat(R.paddingTop))*w.y;u*=w.x,d*=w.y,f*=w.x,h*=w.y,u+=E,d+=T,y=Ei(x),x=bS(y)}}return sv({width:f,height:h,x:u,y:d})}function f0(e,t){const n=h0(e).scrollLeft;return t?t.left+n:Ql(io(e)).left+n}function jO(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-f0(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function gq(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=io(r),l=t?d0(t.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=eo(1);const f=eo(0),h=Ko(r);if((h||!h&&!s)&&((dd(r)!=="body"||Vf(o))&&(u=h0(r)),h)){const b=Ql(r);d=Nu(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const g=o&&!h&&!s?jO(o,u):eo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-u.scrollTop*d.y+f.y+g.y}}function vq(e){return Array.from(e.getClientRects())}function bq(e){const t=io(e),n=h0(e),r=e.ownerDocument.body,i=Ci(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ci(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+f0(e);const l=-n.scrollTop;return Ts(r).direction==="rtl"&&(o+=Ci(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const BA=25;function _q(e,t){const n=Ei(e),r=io(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const f=Yw();(!f||f&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=f0(r);if(d<=0){const f=r.ownerDocument,h=f.body,g=getComputedStyle(h),b=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(r.clientWidth-h.clientWidth-b);y<=BA&&(s-=y)}else d<=BA&&(s+=d);return{width:s,height:o,x:l,y:u}}function yq(e,t){const n=Ql(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Ko(e)?Nu(e):eo(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:o,height:l,x:u,y:d}}function FA(e,t,n){let r;if(t==="viewport")r=_q(e,n);else if(t==="document")r=bq(io(e));else if(Rs(t))r=yq(t,n);else{const i=OO(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return sv(r)}function zO(e,t){const n=Xa(e);return n===t||!Rs(n)||Hu(n)?!1:Ts(n).position==="fixed"||zO(n,t)}function xq(e,t){const n=t.get(e);if(n)return n;let r=uf(e,[],!1).filter(l=>Rs(l)&&dd(l)!=="body"),i=null;const s=Ts(e).position==="fixed";let o=s?Xa(e):e;for(;Rs(o)&&!Hu(o);){const l=Ts(o),u=Kw(o);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Vf(o)&&!u&&zO(e,o))?r=r.filter(f=>f!==o):i=l,o=Xa(o)}return t.set(e,r),r}function Sq(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?d0(t)?[]:xq(t,this._c):[].concat(n),r],l=FA(t,o[0],i);let u=l.top,d=l.right,f=l.bottom,h=l.left;for(let g=1;g<o.length;g++){const b=FA(t,o[g],i);u=Ci(b.top,u),d=Ya(b.right,d),f=Ya(b.bottom,f),h=Ci(b.left,h)}return{width:d-h,height:f-u,x:h,y:u}}function wq(e){const{width:t,height:n}=PO(e);return{width:t,height:n}}function Cq(e,t,n){const r=Ko(t),i=io(t),s=n==="fixed",o=Ql(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=eo(0);function d(){u.x=f0(i)}if(r||!r&&!s)if((dd(t)!=="body"||Vf(i))&&(l=h0(t)),r){const b=Ql(t,!0,s,t);u.x=b.x+t.clientLeft,u.y=b.y+t.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?jO(i,l):eo(0),h=o.left+l.scrollLeft-u.x-f.x,g=o.top+l.scrollTop-u.y-f.y;return{x:h,y:g,width:o.width,height:o.height}}function My(e){return Ts(e).position==="static"}function HA(e,t){if(!Ko(e)||Ts(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return io(e)===n&&(n=n.ownerDocument.body),n}function BO(e,t){const n=Ei(e);if(d0(e))return n;if(!Ko(e)){let i=Xa(e);for(;i&&!Hu(i);){if(Rs(i)&&!My(i))return i;i=Xa(i)}return n}let r=HA(e,t);for(;r&&uq(r)&&My(r);)r=HA(r,t);return r&&Hu(r)&&My(r)&&!Kw(r)?n:r||fq(e)||n}const kq=async function(e){const t=this.getOffsetParent||BO,n=this.getDimensions,r=await n(e.floating);return{reference:Cq(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eq(e){return Ts(e).direction==="rtl"}const Rq={convertOffsetParentRelativeRectToViewportRelativeRect:gq,getDocumentElement:io,getClippingRect:Sq,getOffsetParent:BO,getElementRects:kq,getClientRects:vq,getDimensions:wq,getScale:Nu,isElement:Rs,isRTL:Eq};function FO(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Tq(e,t){let n=null,r;const i=io(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:f,top:h,width:g,height:b}=d;if(l||t(),!g||!b)return;const y=Lm(h),x=Lm(i.clientWidth-(f+g)),w=Lm(i.clientHeight-(h+b)),C=Lm(f),E={rootMargin:-y+"px "+-x+"px "+-w+"px "+-C+"px",threshold:Ci(0,Ya(1,u))||1};let T=!0;function N(A){const L=A[0].intersectionRatio;if(L!==u){if(!T)return o();L?o(!1,L):r=setTimeout(()=>{o(!1,1e-7)},1e3)}L===1&&!FO(d,e.getBoundingClientRect())&&o(),T=!1}try{n=new IntersectionObserver(N,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(N,E)}n.observe(e)}return o(!0),s}function Aq(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=Xw(e),f=i||s?[...d?uf(d):[],...t?uf(t):[]]:[];f.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const h=d&&l?Tq(d,n):null;let g=-1,b=null;o&&(b=new ResizeObserver(C=>{let[R]=C;R&&R.target===d&&b&&t&&(b.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var E;(E=b)==null||E.observe(t)})),n()}),d&&!u&&b.observe(d),t&&b.observe(t));let y,x=u?Ql(e):null;u&&w();function w(){const C=Ql(e);x&&!FO(x,C)&&n(),x=C,y=requestAnimationFrame(w)}return n(),()=>{var C;f.forEach(R=>{i&&R.removeEventListener("scroll",n),s&&R.removeEventListener("resize",n)}),h==null||h(),(C=b)==null||C.disconnect(),b=null,u&&cancelAnimationFrame(y)}}const Nq=oq,Mq=aq,Lq=rq,Dq=cq,Iq=iq,$A=nq,Pq=lq,Oq=(e,t,n)=>{const r=new Map,i={platform:Rq,...n},s={...i.platform,_c:r};return tq(e,t,{...i,platform:s})};var jq=typeof document<"u",zq=function(){},Rg=jq?_.useLayoutEffect:zq;function ov(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(!ov(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)&&!ov(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function HO(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function UA(e,t){const n=HO(e);return Math.round(t*n)/n}function Ly(e){const t=_.useRef(e);return Rg(()=>{t.current=e}),t}function Bq(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,h]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,b]=_.useState(r);ov(g,r)||b(r);const[y,x]=_.useState(null),[w,C]=_.useState(null),R=_.useCallback(F=>{F!==A.current&&(A.current=F,x(F))},[]),E=_.useCallback(F=>{F!==L.current&&(L.current=F,C(F))},[]),T=s||y,N=o||w,A=_.useRef(null),L=_.useRef(null),O=_.useRef(f),G=u!=null,P=Ly(u),j=Ly(i),B=Ly(d),H=_.useCallback(()=>{if(!A.current||!L.current)return;const F={placement:t,strategy:n,middleware:g};j.current&&(F.platform=j.current),Oq(A.current,L.current,F).then(Y=>{const I={...Y,isPositioned:B.current!==!1};$.current&&!ov(O.current,I)&&(O.current=I,is.flushSync(()=>{h(I)}))})},[g,t,n,j,B]);Rg(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[d]);const $=_.useRef(!1);Rg(()=>($.current=!0,()=>{$.current=!1}),[]),Rg(()=>{if(T&&(A.current=T),N&&(L.current=N),T&&N){if(P.current)return P.current(T,N,H);H()}},[T,N,H,P,G]);const V=_.useMemo(()=>({reference:A,floating:L,setReference:R,setFloating:E}),[R,E]),z=_.useMemo(()=>({reference:T,floating:N}),[T,N]),q=_.useMemo(()=>{const F={position:n,left:0,top:0};if(!z.floating)return F;const Y=UA(z.floating,f.x),I=UA(z.floating,f.y);return l?{...F,transform:"translate("+Y+"px, "+I+"px)",...HO(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:I}},[n,l,z.floating,f.x,f.y]);return _.useMemo(()=>({...f,update:H,refs:V,elements:z,floatingStyles:q}),[f,H,V,z,q])}const Fq=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?$A({element:r.current,padding:i}).fn(n):{}:r?$A({element:r,padding:i}).fn(n):{}}}},Hq=(e,t)=>{const n=Nq(e);return{name:n.name,fn:n.fn,options:[e,t]}},$q=(e,t)=>{const n=Mq(e);return{name:n.name,fn:n.fn,options:[e,t]}},Uq=(e,t)=>({fn:Pq(e).fn,options:[e,t]}),Vq=(e,t)=>{const n=Lq(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wq=(e,t)=>{const n=Dq(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gq=(e,t)=>{const n=Iq(e);return{name:n.name,fn:n.fn,options:[e,t]}},qq=(e,t)=>{const n=Fq(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Kq="Arrow",$O=_.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(Ut.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"})})});$O.displayName=Kq;var Yq=$O;function Xq(e){const[t,n]=_.useState(void 0);return Or(()=>{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 o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Qw="Popper",[UO,rl]=qo(Qw),[Qq,VO]=UO(Qw),WO=e=>{const{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return m.jsx(Qq,{scope:t,anchor:r,onAnchorChange:i,children:n})};WO.displayName=Qw;var GO="PopperAnchor",qO=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=VO(GO,n),o=_.useRef(null),l=an(t,o),u=_.useRef(null);return _.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||o.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(Ut.div,{...i,ref:l})});qO.displayName=GO;var Zw="PopperContent",[Zq,Jq]=UO(Zw),KO=_.forwardRef((e,t)=>{var se,pe,re,me,Ee,we;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:b="optimized",onPlaced:y,...x}=e,w=VO(Zw,n),[C,R]=_.useState(null),E=an(t,Ae=>R(Ae)),[T,N]=_.useState(null),A=Xq(T),L=(A==null?void 0:A.width)??0,O=(A==null?void 0:A.height)??0,G=r+(s!=="center"?"-"+s:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},j=Array.isArray(d)?d:[d],B=j.length>0,H={padding:P,boundary:j.filter(tK),altBoundary:B},{refs:$,floatingStyles:V,placement:z,isPositioned:q,middlewareData:F}=Bq({strategy:"fixed",placement:G,whileElementsMounted:(...Ae)=>Aq(...Ae,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[Hq({mainAxis:i+O,alignmentAxis:o}),u&&$q({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Uq():void 0,...H}),u&&Vq({...H}),Wq({...H,apply:({elements:Ae,rects:ze,availableWidth:Ue,availableHeight:tt})=>{const{width:kt,height:Qt}=ze.reference,Pe=Ae.floating.style;Pe.setProperty("--radix-popper-available-width",`${Ue}px`),Pe.setProperty("--radix-popper-available-height",`${tt}px`),Pe.setProperty("--radix-popper-anchor-width",`${kt}px`),Pe.setProperty("--radix-popper-anchor-height",`${Qt}px`)}}),T&&qq({element:T,padding:l}),nK({arrowWidth:L,arrowHeight:O}),g&&Gq({strategy:"referenceHidden",...H})]}),[Y,I]=QO(z),U=Es(y);Or(()=>{q&&(U==null||U())},[q,U]);const X=(se=F.arrow)==null?void 0:se.x,D=(pe=F.arrow)==null?void 0:pe.y,te=((re=F.arrow)==null?void 0:re.centerOffset)!==0,[Q,ie]=_.useState();return Or(()=>{C&&ie(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:q?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[(me=F.transformOrigin)==null?void 0:me.x,(Ee=F.transformOrigin)==null?void 0:Ee.y].join(" "),...((we=F.hide)==null?void 0:we.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(Zq,{scope:n,placedSide:Y,onArrowChange:N,arrowX:X,arrowY:D,shouldHideArrow:te,children:m.jsx(Ut.div,{"data-side":Y,"data-align":I,...x,ref:E,style:{...x.style,animation:q?void 0:"none"}})})})});KO.displayName=Zw;var YO="PopperArrow",eK={top:"bottom",right:"left",bottom:"top",left:"right"},XO=_.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=Jq(YO,r),o=eK[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]: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(Yq,{...i,ref:n,style:{...i.style,display:"block"}})})});XO.displayName=YO;function tK(e){return e!==null}var nK=e=>({name:"transformOrigin",options:e,fn(t){var w,C,R;const{placement:n,rects:r,middlewareData:i}=t,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,f]=QO(n),h={start:"0%",center:"50%",end:"100%"}[f],g=(((C=i.arrow)==null?void 0:C.x)??0)+l/2,b=(((R=i.arrow)==null?void 0:R.y)??0)+u/2;let y="",x="";return d==="bottom"?(y=o?h:`${g}px`,x=`${-u}px`):d==="top"?(y=o?h:`${g}px`,x=`${r.floating.height+u}px`):d==="right"?(y=`${-u}px`,x=o?h:`${b}px`):d==="left"&&(y=`${r.floating.width+u}px`,x=o?h:`${b}px`),{data:{x:y,y:x}}}});function QO(e){const[t,n="center"]=e.split("-");return[t,n]}var p0=WO,Wf=qO,m0=KO,g0=XO,ZO=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"}),rK="VisuallyHidden",JO=_.forwardRef((e,t)=>m.jsx(Ut.span,{...e,ref:t,style:{...ZO,...e.style}}));JO.displayName=rK;var iK=JO,[v0]=qo("Tooltip",[rl]),b0=rl(),e5="TooltipProvider",sK=700,_S="tooltip.open",[oK,Jw]=v0(e5),t5=e=>{const{__scopeTooltip:t,delayDuration:n=sK,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=_.useRef(!0),l=_.useRef(!1),u=_.useRef(0);return _.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(oK,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(u.current),o.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:_.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};t5.displayName=e5;var df="Tooltip",[aK,Gf]=v0(df),n5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,u=Jw(df,e.__scopeTooltip),d=b0(t),[f,h]=_.useState(null),g=zo(),b=_.useRef(0),y=o??u.disableHoverableContent,x=l??u.delayDuration,w=_.useRef(!1),[C,R]=Fu({prop:r,defaultProp:i??!1,onChange:L=>{L?(u.onOpen(),document.dispatchEvent(new CustomEvent(_S))):u.onClose(),s==null||s(L)},caller:df}),E=_.useMemo(()=>C?w.current?"delayed-open":"instant-open":"closed",[C]),T=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,R(!0)},[R]),N=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,R(!1)},[R]),A=_.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,R(!0),b.current=0},x)},[x,R]);return _.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),m.jsx(p0,{...d,children:m.jsx(aK,{scope:t,contentId:g,open:C,stateAttribute:E,trigger:f,onTriggerChange:h,onTriggerEnter:_.useCallback(()=>{u.isOpenDelayedRef.current?A():T()},[u.isOpenDelayedRef,A,T]),onTriggerLeave:_.useCallback(()=>{y?N():(window.clearTimeout(b.current),b.current=0)},[N,y]),onOpen:T,onClose:N,disableHoverableContent:y,children:n})})};n5.displayName=df;var yS="TooltipTrigger",r5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Gf(yS,n),s=Jw(yS,n),o=b0(n),l=_.useRef(null),u=an(t,l,i.onTriggerChange),d=_.useRef(!1),f=_.useRef(!1),h=_.useCallback(()=>d.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),m.jsx(Wf,{asChild:!0,...o,children:m.jsx(Ut.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:He(e.onPointerMove,g=>{g.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:He(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:He(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:He(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:He(e.onBlur,i.onClose),onClick:He(e.onClick,i.onClose)})})});r5.displayName=yS;var eC="TooltipPortal",[lK,cK]=v0(eC,{forceMount:void 0}),i5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Gf(eC,t);return m.jsx(lK,{scope:t,forceMount:n,children:m.jsx(hs,{present:n||s.open,children:m.jsx(sd,{asChild:!0,container:i,children:r})})})};i5.displayName=eC;var $u="TooltipContent",s5=_.forwardRef((e,t)=>{const n=cK($u,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Gf($u,e.__scopeTooltip);return m.jsx(hs,{present:r||o.open,children:o.disableHoverableContent?m.jsx(o5,{side:i,...s,ref:t}):m.jsx(uK,{side:i,...s,ref:t})})}),uK=_.forwardRef((e,t)=>{const n=Gf($u,e.__scopeTooltip),r=Jw($u,e.__scopeTooltip),i=_.useRef(null),s=an(t,i),[o,l]=_.useState(null),{trigger:u,onClose:d}=n,f=i.current,{onPointerInTransitChange:h}=r,g=_.useCallback(()=>{l(null),h(!1)},[h]),b=_.useCallback((y,x)=>{const w=y.currentTarget,C={x:y.clientX,y:y.clientY},R=mK(C,w.getBoundingClientRect()),E=gK(C,R),T=vK(x.getBoundingClientRect()),N=_K([...E,...T]);l(N),h(!0)},[h]);return _.useEffect(()=>()=>g(),[g]),_.useEffect(()=>{if(u&&f){const y=w=>b(w,f),x=w=>b(w,u);return u.addEventListener("pointerleave",y),f.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",y),f.removeEventListener("pointerleave",x)}}},[u,f,b,g]),_.useEffect(()=>{if(o){const y=x=>{const w=x.target,C={x:x.clientX,y:x.clientY},R=(u==null?void 0:u.contains(w))||(f==null?void 0:f.contains(w)),E=!bK(C,o);R?g():E&&(g(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[u,f,o,d,g]),m.jsx(o5,{...e,ref:s})}),[dK,hK]=v0(df,{isInside:!1}),fK=dW("TooltipContent"),o5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,u=Gf($u,n),d=b0(n),{onClose:f}=u;return _.useEffect(()=>(document.addEventListener(_S,f),()=>document.removeEventListener(_S,f)),[f]),_.useEffect(()=>{if(u.trigger){const h=g=>{const b=g.target;b!=null&&b.contains(u.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,f]),m.jsx(id,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:m.jsxs(m0,{"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(fK,{children:r}),m.jsx(dK,{scope:n,isInside:!0,children:m.jsx(iK,{id:u.contentId,role:"tooltip",children:i||r})})]})})});s5.displayName=$u;var a5="TooltipArrow",pK=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=b0(n);return hK(a5,n).isInside?null:m.jsx(g0,{...i,...r,ref:t})});pK.displayName=a5;function mK(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 gK(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 vK(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 bK(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],u=t[o],d=l.x,f=l.y,h=u.x,g=u.y;f>r!=g>r&&n<(h-d)*(r-f)/(g-f)+d&&(i=!i)}return i}function _K(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),yK(t)}function yK(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],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.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],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.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 xK=t5,l5=n5,c5=r5,u5=i5,tC=s5;function d5({className:e,...t}){return m.jsx("kbd",{className:xe("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 SK({className:e,...t}){return m.jsx("span",{className:xe("inline-flex items-center gap-0.5",e),...t})}const wK="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",CK=xK,Qa=l5,Za=c5,Uo=_.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(u5,{children:m.jsx(tC,{ref:r,sideOffset:t,className:xe("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})}));Uo.displayName=tC.displayName;const Ph=l5,Oh=c5;function h5(e){return e.toUpperCase()}function kK(e){const t=e.split("+");return m.jsx(SK,{children:t.map((n,r)=>m.jsx(d5,{children:h5(n)},`${n}-${r}`))})}const Su=_.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const o=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(u5,{children:m.jsx(tC,{ref:s,sideOffset:t,className:xe(wK,e),...i,children:o?kK(o):m.jsx("span",{children:typeof n=="string"?h5(n):n})})})});Su.displayName="HotkeyTooltipContent";const EK="0.33.8",RK={version:EK},Un="Kanna",VA="kanna",TK=".kanna",AK=".kanna-dev",NK="KANNA_RUNTIME_PROFILE",nC=`kanna/${RK.version}`,MK="[kanna]",LK=`~/${Un}`;function _0(){var t;return(t=globalThis.process)==null?void 0:t.env}function DK(e=_0()){var t;return((t=e==null?void 0:e[NK])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function IK(e=_0()){return DK(e)==="dev"?AK:TK}function PK(e=_0()){return`~/${IK(e)}`}function OK(e=_0()){return`${PK(e)}/keybindings.json`}function Dm(e){return e?`${VA} ${e}`:VA}const WA=e=>{let t;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const g=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(b=>b(t,g))}},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},jK=(e=>e?WA(e):WA),zK=e=>e;function BK(e,t=zK){const n=gn.useSyncExternalStore(e.subscribe,gn.useCallback(()=>t(e.getState()),[e,t]),gn.useCallback(()=>t(e.getInitialState()),[e,t]));return gn.useDebugValue(n),n}const FK=e=>{const t=jK(e),n=r=>BK(t,r);return Object.assign(n,t),n},dc=(e=>FK);function HK(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const o=u=>u===null?null:JSON.parse(u,void 0),l=(s=n.getItem(i))!=null?s:null;return l instanceof Promise?l.then(o):o(l)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const xS=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return xS(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return xS(r)(n)}}}},$K=(e,t)=>(n,r,i)=>{let s={storage:HK(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,C)=>({...C,...w}),...t},o=!1,l=0;const u=new Set,d=new Set;let f=s.storage;if(!f)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...w)},r,i);const h=()=>{const w=s.partialize({...r()});return f.setItem(s.name,{state:w,version:s.version})},g=i.setState;i.setState=(w,C)=>(g(w,C),h());const b=e((...w)=>(n(...w),h()),r,i);i.getInitialState=()=>b;let y;const x=()=>{var w,C;if(!f)return;const R=++l;o=!1,u.forEach(T=>{var N;return T((N=r())!=null?N:b)});const E=((C=s.onRehydrateStorage)==null?void 0:C.call(s,(w=r())!=null?w:b))||void 0;return xS(f.getItem.bind(f))(s.name).then(T=>{if(T)if(typeof T.version=="number"&&T.version!==s.version){if(s.migrate){const N=s.migrate(T.state,T.version);return N instanceof Promise?N.then(A=>[!0,A]):[!0,N]}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 N;if(R!==l)return;const[A,L]=T;if(y=s.merge(L,(N=r())!=null?N:b),n(y,!0),A)return h()}).then(()=>{R===l&&(E==null||E(y,void 0),y=r(),o=!0,d.forEach(T=>T(y)))}).catch(T=>{R===l&&(E==null||E(void 0,T))})};return i.persist={setOptions:w=>{s={...s,...w},w.storage&&(f=w.storage)},clearStorage:()=>{f==null||f.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>x(),hasHydrated:()=>o,onHydrate:w=>(u.add(w),()=>{u.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},s.skipHydration||x(),y||b},hc=$K,f5="always",p5="funk",UK=[{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 GA(e){switch(e){case"never":case"unfocused":case"always":return e;default:return f5}}function qA(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 p5}}const wu=dc()(hc(e=>({chatSoundPreference:f5,chatSoundId:p5,setChatSoundPreference:t=>e({chatSoundPreference:GA(t)}),setChatSoundId:t=>e({chatSoundId:qA(t)})}),{name:"chat-sound-preferences",version:2,migrate:e=>{const t=e;return{chatSoundPreference:GA(t==null?void 0:t.chatSoundPreference),chatSoundId:qA(t==null?void 0:t.chatSoundId)}}})),VK={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 WK(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function GK(e){const t=new Audio(VK[e]);return t.preload="auto",t.play()}async function SS(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{GK(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function qK(e,t=document){return e==="never"?!1:e==="always"?!0:WK(t)}function KK(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 KA(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 YK(e,t){if(!e)return 0;const n=KA(e),r=KA(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}const hd=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...i})=>m.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:xe("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});function wS(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const XK=[/^(?:\/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 QK(e){const t=e.trim();for(const n of XK){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function m5(e){return e.split("/").pop()||e}const ZK=1440*6e4;function JK(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=ZK,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function eY(e){return e.lastMessageAt??e._creationTime}const tY=new Set(["starting","running"]);function nY({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onForkChat:o,onDeleteChat:l}){const u=JK(eY(e),n),d=i&&r?r:u,f=i&&!!r,h=nW(e.chatId);return m.jsxs("div",{"data-chat-id":h,className:xe("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===h?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>s(e.chatId),children:[tY.has(e.status)?m.jsx(kn,{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(hd,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),m.jsxs("div",{className:xe("relative h-7 mr-[2px] shrink-0",e.canFork?"w-12":"w-6"),children:[d?f?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(d5,{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:d}):null,m.jsxs("div",{className:xe("absolute inset-0 flex items-center justify-end gap-0 opacity-100",d?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),children:[e.canFork?m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:g=>{g.stopPropagation(),o(e.chatId)},title:"Fork chat",children:m.jsx(KU,{className:"size-3.5"})}):null,m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:g=>{g.stopPropagation(),l(e.chatId)},title:"Delete chat",children:m.jsx(m$,{className:"size-3.5"})})]})]})]},e._id)}const rY=_.memo(nY);function iY(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const y0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fd(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function rC(e){return"nodeType"in e}function ci(e){var t,n;return e?fd(e)?e:rC(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function iC(e){const{Document:t}=ci(e);return e instanceof t}function qf(e){return fd(e)?!1:e instanceof ci(e).HTMLElement}function g5(e){return e instanceof ci(e).SVGElement}function pd(e){return e?fd(e)?e.document:rC(e)?iC(e)?e:qf(e)||g5(e)?e.ownerDocument:document:document:document}const no=y0?_.useLayoutEffect:_.useEffect;function sC(e){const t=_.useRef(e);return no(()=>{t.current=e}),_.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 sY(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function hf(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return no(()=>{n.current!==e&&(n.current=e)},t),n}function Kf(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function av(e){const t=sC(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function CS(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let Dy={};function Yf(e,t){return _.useMemo(()=>{if(t)return t;const n=Dy[e]==null?0:Dy[e]+1;return Dy[e]=n,e+"-"+n},[e,t])}function v5(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,o)=>{const l=Object.entries(o);for(const[u,d]of l){const f=s[u];f!=null&&(s[u]=f+e*d)}return s},{...t})}}const Mu=v5(1),lv=v5(-1);function oY(e){return"clientX"in e&&"clientY"in e}function oC(e){if(!e)return!1;const{KeyboardEvent:t}=ci(e.target);return t&&e instanceof t}function aY(e){if(!e)return!1;const{TouchEvent:t}=ci(e.target);return t&&e instanceof t}function kS(e){if(aY(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 oY(e)?{x:e.clientX,y:e.clientY}:null}const ff=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[ff.Translate.toString(e),ff.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),YA="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function lY(e){return e.matches(YA)?e:e.querySelector(YA)}const cY={display:"none"};function uY(e){let{id:t,value:n}=e;return gn.createElement("div",{id:t,style:cY},n)}function dY(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 gn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function hY(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const b5=_.createContext(null);function fY(e){const t=_.useContext(b5);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function pY(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[e]),t]}const mY={draggable:`
631
631
  To pick up a draggable item, press the space bar.
632
632
  While dragging, use the arrow keys to move the item.
633
633
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -30,7 +30,7 @@
30
30
  })()
31
31
  </script>
32
32
  <title>Kanna</title>
33
- <script type="module" crossorigin src="/assets/index-V4zVK2BX.js"></script>
33
+ <script type="module" crossorigin src="/assets/index-BpMTihHB.js"></script>
34
34
  <link rel="stylesheet" crossorigin href="/assets/index-FQ1dOuTJ.css">
35
35
  </head>
36
36
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kanna-code",
3
3
  "type": "module",
4
- "version": "0.33.6",
4
+ "version": "0.33.8",
5
5
  "description": "A beautiful web UI for Claude Code",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -13,8 +13,11 @@ afterEach(async () => {
13
13
 
14
14
  async function startPasswordServer(options: { trustProxy?: boolean; port?: number } = {}) {
15
15
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-auth-test-"))
16
+ const dataDir = await mkdtemp(path.join(tmpdir(), "kanna-auth-data-"))
16
17
  tempDirs.push(projectDir)
18
+ tempDirs.push(dataDir)
17
19
  const server = await startKannaServer({
20
+ dataDir,
18
21
  port: options.port ?? 4320,
19
22
  strictPort: true,
20
23
  password: "secret",
@@ -37,6 +40,7 @@ describe("password auth", () => {
37
40
  try {
38
41
  const response = await fetch(`http://localhost:${server.port}/chat/demo`, { headers: { Accept: "text/html" } })
39
42
  expect(response.status).toBe(200)
43
+ expect(response.headers.get("cache-control")).toBe("no-store")
40
44
  expect(response.headers.get("content-type")).toContain("text/html")
41
45
  expect(await response.text()).toContain('id="root"')
42
46
  } finally {
@@ -44,11 +48,22 @@ describe("password auth", () => {
44
48
  }
45
49
  })
46
50
 
47
- test("blocks unauthenticated api requests", async () => {
51
+ test("serves health checks without authentication", async () => {
48
52
  const { server } = await startPasswordServer()
49
53
 
50
54
  try {
51
55
  const response = await fetch(`http://localhost:${server.port}/health`, { redirect: "manual" })
56
+ expect(response.status).toBe(200)
57
+ } finally {
58
+ await server.stop()
59
+ }
60
+ })
61
+
62
+ test("blocks unauthenticated api requests", async () => {
63
+ const { server } = await startPasswordServer()
64
+
65
+ try {
66
+ const response = await fetch(`http://localhost:${server.port}/api/projects/project-1/uploads`, { redirect: "manual" })
52
67
  expect(response.status).toBe(401)
53
68
  } finally {
54
69
  await server.stop()
@@ -306,7 +321,7 @@ describe("password auth", () => {
306
321
  Cookie: cookie,
307
322
  },
308
323
  })
309
- expect(healthResponse.status).toBe(401)
324
+ expect(healthResponse.status).toBe(200)
310
325
  } finally {
311
326
  await server.stop()
312
327
  }
@@ -58,6 +58,7 @@ export async function persistUploadedFiles(args: {
58
58
  export interface StartKannaServerOptions {
59
59
  port?: number
60
60
  host?: string
61
+ dataDir?: string
61
62
  password?: string | null
62
63
  strictPort?: boolean
63
64
  /**
@@ -80,7 +81,7 @@ export async function startKannaServer(options: StartKannaServerOptions = {}) {
80
81
  const hostname = options.host ?? "127.0.0.1"
81
82
  const strictPort = options.strictPort ?? false
82
83
  const auth = options.password ? createAuthManager(options.password, { trustProxy: options.trustProxy ?? false }) : null
83
- const store = new EventStore()
84
+ const store = new EventStore(options.dataDir)
84
85
  const diffStore = new DiffStore(store.dataDir)
85
86
  const machineDisplayName = getMachineDisplayName()
86
87
  await store.initialize()
@@ -190,7 +191,7 @@ export async function startKannaServer(options: StartKannaServerOptions = {}) {
190
191
  if (!auth.isAuthenticated(req)) {
191
192
  return new Response("Unauthorized", { status: 401 })
192
193
  }
193
- } else if ((url.pathname === "/health" || url.pathname.startsWith("/api/")) && !auth.isAuthenticated(req)) {
194
+ } else if (url.pathname.startsWith("/api/") && !auth.isAuthenticated(req)) {
194
195
  return Response.json({ error: "Unauthorized" }, { status: 401 })
195
196
  }
196
197
  }
@@ -452,7 +453,9 @@ async function serveStatic(distDir: string, pathname: string) {
452
453
 
453
454
  const file = Bun.file(filePath)
454
455
  if (await file.exists()) {
455
- return new Response(file)
456
+ return new Response(file, {
457
+ headers: getStaticHeaders(requestedPath),
458
+ })
456
459
  }
457
460
 
458
461
  const indexFile = Bun.file(indexPath)
@@ -460,6 +463,7 @@ async function serveStatic(distDir: string, pathname: string) {
460
463
  return new Response(indexFile, {
461
464
  headers: {
462
465
  "Content-Type": "text/html; charset=utf-8",
466
+ "Cache-Control": "no-store",
463
467
  },
464
468
  })
465
469
  }
@@ -469,3 +473,13 @@ async function serveStatic(distDir: string, pathname: string) {
469
473
  { status: 503 }
470
474
  )
471
475
  }
476
+
477
+ function getStaticHeaders(requestedPath: string) {
478
+ if (requestedPath.endsWith(".html")) {
479
+ return {
480
+ "Cache-Control": "no-store",
481
+ }
482
+ }
483
+
484
+ return undefined
485
+ }
@@ -15,6 +15,16 @@ afterEach(async () => {
15
15
  await Promise.all(tempDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true })))
16
16
  })
17
17
 
18
+ async function startIsolatedServer(options: { port: number; strictPort?: boolean }) {
19
+ const dataDir = await mkdtemp(path.join(tmpdir(), "kanna-server-data-"))
20
+ tempDirs.push(dataDir)
21
+ return startKannaServer({
22
+ dataDir,
23
+ port: options.port,
24
+ strictPort: options.strictPort ?? true,
25
+ })
26
+ }
27
+
18
28
  describe("uploads", () => {
19
29
  test("stores uploads in .kanna/uploads and keeps duplicate filenames", async () => {
20
30
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-upload-test-"))
@@ -103,7 +113,7 @@ describe("uploads", () => {
103
113
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-project-"))
104
114
  tempDirs.push(projectDir)
105
115
 
106
- const server = await startKannaServer({ port: 4310, strictPort: true })
116
+ const server = await startIsolatedServer({ port: 4310 })
107
117
 
108
118
  try {
109
119
  const project = await server.store.openProject(projectDir, "Project")
@@ -128,7 +138,7 @@ describe("uploads", () => {
128
138
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-project-typescript-"))
129
139
  tempDirs.push(projectDir)
130
140
 
131
- const server = await startKannaServer({ port: 4314, strictPort: true })
141
+ const server = await startIsolatedServer({ port: 4314 })
132
142
 
133
143
  try {
134
144
  const project = await server.store.openProject(projectDir, "Project")
@@ -153,7 +163,7 @@ describe("uploads", () => {
153
163
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-project-content-method-"))
154
164
  tempDirs.push(projectDir)
155
165
 
156
- const server = await startKannaServer({ port: 4312, strictPort: true })
166
+ const server = await startIsolatedServer({ port: 4312 })
157
167
 
158
168
  try {
159
169
  const project = await server.store.openProject(projectDir, "Project")
@@ -177,7 +187,7 @@ describe("uploads", () => {
177
187
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-project-oversize-"))
178
188
  tempDirs.push(projectDir)
179
189
 
180
- const server = await startKannaServer({ port: 4313, strictPort: true })
190
+ const server = await startIsolatedServer({ port: 4313 })
181
191
 
182
192
  try {
183
193
  const project = await server.store.openProject(projectDir, "Project")
@@ -251,7 +261,7 @@ describe("uploads", () => {
251
261
  const projectDir = await mkdtemp(path.join(tmpdir(), "kanna-project-delete-"))
252
262
  tempDirs.push(projectDir)
253
263
 
254
- const server = await startKannaServer({ port: 4311, strictPort: true })
264
+ const server = await startIsolatedServer({ port: 4311 })
255
265
 
256
266
  try {
257
267
  const project = await server.store.openProject(projectDir, "Project")