kanna-code 0.2.0 → 0.3.0

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.
@@ -371,7 +371,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${n.do
371
371
  *
372
372
  * This source code is licensed under the ISC license.
373
373
  * See the LICENSE file in the root directory of this source tree.
374
- */const Gj=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Bu=Ee("zap",Gj),aw=yR,Yj=xR,ow=w.forwardRef(({className:e,...n},l)=>x.jsx(K1,{ref:l,className:ye("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),...n}));ow.displayName=K1.displayName;const $j={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},_p=w.forwardRef(({className:e,children:n,size:l="md",...i},o)=>x.jsxs(Yj,{children:[x.jsx(ow,{}),x.jsxs(Z1,{ref:o,className:ye("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",$j[l],e),...i,children:[n,x.jsxs(wR,{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:[x.jsx(Po,{className:"h-4 w-4"}),x.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_p.displayName=Z1.displayName;function sw({className:e,...n}){return x.jsx(vR,{className:ye("text-lg font-medium leading-none tracking-tight",e),...n})}function Xj({className:e,...n}){return x.jsx(bR,{className:ye("text-sm text-muted-foreground",e),...n})}function uw({className:e,...n}){return x.jsx("div",{className:ye("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...n})}function cw({className:e,...n}){return x.jsx("div",{className:ye("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...n})}const fw=w.createContext(null);function Qj({children:e}){const[n,l]=w.useState(null),[i,o]=w.useState(""),s=w.useRef(null);w.useEffect(()=>{(n==null?void 0:n.kind)==="prompt"&&(o(n.options.initialValue??""),setTimeout(()=>{var y,g;(y=s.current)==null||y.focus(),(g=s.current)==null||g.select()},0))},[n]);const c=w.useCallback(()=>{l(null),o("")},[]),f=w.useCallback(y=>new Promise(g=>{l({kind:"confirm",options:y,resolve:g})}),[]),d=w.useCallback(y=>new Promise(g=>{l({kind:"prompt",options:y,resolve:g})}),[]),h=w.useMemo(()=>({confirm:f,prompt:d}),[f,d]);return x.jsxs(fw.Provider,{value:h,children:[e,x.jsx(aw,{open:n!==null,onOpenChange:y=>{y||!n||(n.kind==="confirm"?n.resolve(!1):n.resolve(null),c())},children:x.jsx(_p,{size:"sm",children:n?x.jsxs(x.Fragment,{children:[x.jsxs(uw,{className:"space-y-4",children:[x.jsx(sw,{children:n.options.title}),n.options.description?x.jsx(Xj,{children:n.options.description}):null,n.kind==="prompt"?x.jsx("input",{ref:s,type:"text",value:i,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),n.resolve(i.trim()||null),c())},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:n.options.placeholder}):null]}),x.jsxs(cw,{children:[x.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{n.kind==="confirm"?n.resolve(!1):n.resolve(null),c()},children:n.options.cancelLabel??"Cancel"}),x.jsx(Fe,{variant:n.kind==="confirm"?n.options.confirmVariant??"default":"secondary",size:"sm",onClick:()=>{n.kind==="confirm"?n.resolve(!0):n.resolve(i.trim()||null),c()},disabled:n.kind==="prompt"&&!i.trim(),children:n.options.confirmLabel??"Confirm"})]})]}):null})})]})}function Kj(){const e=w.useContext(fw);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const Zj=["top","right","bottom","left"],Al=Math.min,Sn=Math.max,Uu=Math.round,gu=Math.floor,pr=e=>({x:e,y:e}),Jj={left:"right",right:"left",bottom:"top",top:"bottom"};function qh(e,n,l){return Sn(e,Al(n,l))}function Fr(e,n){return typeof e=="function"?e(n):e}function Vr(e){return e.split("-")[0]}function da(e){return e.split("-")[1]}function zp(e){return e==="x"?"y":"x"}function Lp(e){return e==="y"?"height":"width"}function dr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function Bp(e){return zp(dr(e))}function Wj(e,n,l){l===void 0&&(l=!1);const i=da(e),o=Bp(e),s=Lp(o);let c=o==="x"?i===(l?"end":"start")?"right":"left":i==="start"?"bottom":"top";return n.reference[s]>n.floating[s]&&(c=Hu(c)),[c,Hu(c)]}function e4(e){const n=Hu(e);return[Fh(e),n,Fh(n)]}function Fh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ib=["left","right"],ab=["right","left"],t4=["top","bottom"],n4=["bottom","top"];function r4(e,n,l){switch(e){case"top":case"bottom":return l?n?ab:ib:n?ib:ab;case"left":case"right":return n?t4:n4;default:return[]}}function l4(e,n,l,i){const o=da(e);let s=r4(Vr(e),l==="start",i);return o&&(s=s.map(c=>c+"-"+o),n&&(s=s.concat(s.map(Fh)))),s}function Hu(e){const n=Vr(e);return Jj[n]+e.slice(n.length)}function i4(e){return{top:0,right:0,bottom:0,left:0,...e}}function dw(e){return typeof e!="number"?i4(e):{top:e,right:e,bottom:e,left:e}}function Pu(e){const{x:n,y:l,width:i,height:o}=e;return{width:i,height:o,top:l,left:n,right:n+i,bottom:l+o,x:n,y:l}}function ob(e,n,l){let{reference:i,floating:o}=e;const s=dr(n),c=Bp(n),f=Lp(c),d=Vr(n),h=s==="y",y=i.x+i.width/2-o.width/2,g=i.y+i.height/2-o.height/2,v=i[f]/2-o[f]/2;let b;switch(d){case"top":b={x:y,y:i.y-o.height};break;case"bottom":b={x:y,y:i.y+i.height};break;case"right":b={x:i.x+i.width,y:g};break;case"left":b={x:i.x-o.width,y:g};break;default:b={x:i.x,y:i.y}}switch(da(n)){case"start":b[c]-=v*(l&&h?-1:1);break;case"end":b[c]+=v*(l&&h?-1:1);break}return b}async function a4(e,n){var l;n===void 0&&(n={});const{x:i,y:o,platform:s,rects:c,elements:f,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:y="viewport",elementContext:g="floating",altBoundary:v=!1,padding:b=0}=Fr(n,e),k=dw(b),E=f[v?g==="floating"?"reference":"floating":g],N=Pu(await s.getClippingRect({element:(l=await(s.isElement==null?void 0:s.isElement(E)))==null||l?E:E.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(f.floating)),boundary:h,rootBoundary:y,strategy:d})),M=g==="floating"?{x:i,y:o,width:c.floating.width,height:c.floating.height}:c.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f.floating)),D=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},I=Pu(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:M,offsetParent:j,strategy:d}):M);return{top:(N.top-I.top+k.top)/D.y,bottom:(I.bottom-N.bottom+k.bottom)/D.y,left:(N.left-I.left+k.left)/D.x,right:(I.right-N.right+k.right)/D.x}}const o4=50,s4=async(e,n,l)=>{const{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:c}=l,f=c.detectOverflow?c:{...c,detectOverflow:a4},d=await(c.isRTL==null?void 0:c.isRTL(n));let h=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:y,y:g}=ob(h,i,d),v=i,b=0;const k={};for(let C=0;C<s.length;C++){const E=s[C];if(!E)continue;const{name:N,fn:M}=E,{x:j,y:D,data:I,reset:O}=await M({x:y,y:g,initialPlacement:i,placement:v,strategy:o,middlewareData:k,rects:h,platform:f,elements:{reference:e,floating:n}});y=j??y,g=D??g,k[N]={...k[N],...I},O&&b<o4&&(b++,typeof O=="object"&&(O.placement&&(v=O.placement),O.rects&&(h=O.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):O.rects),{x:y,y:g}=ob(h,v,d)),C=-1)}return{x:y,y:g,placement:v,strategy:o,middlewareData:k}},u4=e=>({name:"arrow",options:e,async fn(n){const{x:l,y:i,placement:o,rects:s,platform:c,elements:f,middlewareData:d}=n,{element:h,padding:y=0}=Fr(e,n)||{};if(h==null)return{};const g=dw(y),v={x:l,y:i},b=Bp(o),k=Lp(b),C=await c.getDimensions(h),E=b==="y",N=E?"top":"left",M=E?"bottom":"right",j=E?"clientHeight":"clientWidth",D=s.reference[k]+s.reference[b]-v[b]-s.floating[k],I=v[b]-s.reference[b],O=await(c.getOffsetParent==null?void 0:c.getOffsetParent(h));let P=O?O[j]:0;(!P||!await(c.isElement==null?void 0:c.isElement(O)))&&(P=f.floating[j]||s.floating[k]);const q=D/2-I/2,re=P/2-C[k]/2-1,H=Al(g[N],re),J=Al(g[M],re),ne=H,W=P-C[k]-J,Z=P/2-C[k]/2+q,Q=qh(ne,Z,W),B=!d.arrow&&da(o)!=null&&Z!==Q&&s.reference[k]/2-(Z<ne?H:J)-C[k]/2<0,Y=B?Z<ne?Z-ne:Z-W:0;return{[b]:v[b]+Y,data:{[b]:Q,centerOffset:Z-Q-Y,...B&&{alignmentOffset:Y}},reset:B}}}),c4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var l,i;const{placement:o,middlewareData:s,rects:c,initialPlacement:f,platform:d,elements:h}=n,{mainAxis:y=!0,crossAxis:g=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:C=!0,...E}=Fr(e,n);if((l=s.arrow)!=null&&l.alignmentOffset)return{};const N=Vr(o),M=dr(f),j=Vr(f)===f,D=await(d.isRTL==null?void 0:d.isRTL(h.floating)),I=v||(j||!C?[Hu(f)]:e4(f)),O=k!=="none";!v&&O&&I.push(...l4(f,C,k,D));const P=[f,...I],q=await d.detectOverflow(n,E),re=[];let H=((i=s.flip)==null?void 0:i.overflows)||[];if(y&&re.push(q[N]),g){const Z=Wj(o,c,D);re.push(q[Z[0]],q[Z[1]])}if(H=[...H,{placement:o,overflows:re}],!re.every(Z=>Z<=0)){var J,ne;const Z=(((J=s.flip)==null?void 0:J.index)||0)+1,Q=P[Z];if(Q&&(!(g==="alignment"?M!==dr(Q):!1)||H.every(le=>dr(le.placement)===M?le.overflows[0]>0:!0)))return{data:{index:Z,overflows:H},reset:{placement:Q}};let B=(ne=H.filter(Y=>Y.overflows[0]<=0).sort((Y,le)=>Y.overflows[1]-le.overflows[1])[0])==null?void 0:ne.placement;if(!B)switch(b){case"bestFit":{var W;const Y=(W=H.filter(le=>{if(O){const de=dr(le.placement);return de===M||de==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(de=>de>0).reduce((de,R)=>de+R,0)]).sort((le,de)=>le[1]-de[1])[0])==null?void 0:W[0];Y&&(B=Y);break}case"initialPlacement":B=f;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function sb(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function ub(e){return Zj.some(n=>e[n]>=0)}const f4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:l,platform:i}=n,{strategy:o="referenceHidden",...s}=Fr(e,n);switch(o){case"referenceHidden":{const c=await i.detectOverflow(n,{...s,elementContext:"reference"}),f=sb(c,l.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:ub(f)}}}case"escaped":{const c=await i.detectOverflow(n,{...s,altBoundary:!0}),f=sb(c,l.floating);return{data:{escapedOffsets:f,escaped:ub(f)}}}default:return{}}}}},hw=new Set(["left","top"]);async function d4(e,n){const{placement:l,platform:i,elements:o}=e,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),c=Vr(l),f=da(l),d=dr(l)==="y",h=hw.has(c)?-1:1,y=s&&d?-1:1,g=Fr(n,e);let{mainAxis:v,crossAxis:b,alignmentAxis:k}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return f&&typeof k=="number"&&(b=f==="end"?k*-1:k),d?{x:b*y,y:v*h}:{x:v*h,y:b*y}}const h4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var l,i;const{x:o,y:s,placement:c,middlewareData:f}=n,d=await d4(n,e);return c===((l=f.offset)==null?void 0:l.placement)&&(i=f.arrow)!=null&&i.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:c}}}}},p4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:l,y:i,placement:o,platform:s}=n,{mainAxis:c=!0,crossAxis:f=!1,limiter:d={fn:N=>{let{x:M,y:j}=N;return{x:M,y:j}}},...h}=Fr(e,n),y={x:l,y:i},g=await s.detectOverflow(n,h),v=dr(Vr(o)),b=zp(v);let k=y[b],C=y[v];if(c){const N=b==="y"?"top":"left",M=b==="y"?"bottom":"right",j=k+g[N],D=k-g[M];k=qh(j,k,D)}if(f){const N=v==="y"?"top":"left",M=v==="y"?"bottom":"right",j=C+g[N],D=C-g[M];C=qh(j,C,D)}const E=d.fn({...n,[b]:k,[v]:C});return{...E,data:{x:E.x-l,y:E.y-i,enabled:{[b]:c,[v]:f}}}}}},m4=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:l,y:i,placement:o,rects:s,middlewareData:c}=n,{offset:f=0,mainAxis:d=!0,crossAxis:h=!0}=Fr(e,n),y={x:l,y:i},g=dr(o),v=zp(g);let b=y[v],k=y[g];const C=Fr(f,n),E=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(d){const j=v==="y"?"height":"width",D=s.reference[v]-s.floating[j]+E.mainAxis,I=s.reference[v]+s.reference[j]-E.mainAxis;b<D?b=D:b>I&&(b=I)}if(h){var N,M;const j=v==="y"?"width":"height",D=hw.has(Vr(o)),I=s.reference[g]-s.floating[j]+(D&&((N=c.offset)==null?void 0:N[g])||0)+(D?0:E.crossAxis),O=s.reference[g]+s.reference[j]+(D?0:((M=c.offset)==null?void 0:M[g])||0)-(D?E.crossAxis:0);k<I?k=I:k>O&&(k=O)}return{[v]:b,[g]:k}}}},g4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var l,i;const{placement:o,rects:s,platform:c,elements:f}=n,{apply:d=()=>{},...h}=Fr(e,n),y=await c.detectOverflow(n,h),g=Vr(o),v=da(o),b=dr(o)==="y",{width:k,height:C}=s.floating;let E,N;g==="top"||g==="bottom"?(E=g,N=v===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(N=g,E=v==="end"?"top":"bottom");const M=C-y.top-y.bottom,j=k-y.left-y.right,D=Al(C-y[E],M),I=Al(k-y[N],j),O=!n.middlewareData.shift;let P=D,q=I;if((l=n.middlewareData.shift)!=null&&l.enabled.x&&(q=j),(i=n.middlewareData.shift)!=null&&i.enabled.y&&(P=M),O&&!v){const H=Sn(y.left,0),J=Sn(y.right,0),ne=Sn(y.top,0),W=Sn(y.bottom,0);b?q=k-2*(H!==0||J!==0?H+J:Sn(y.left,y.right)):P=C-2*(ne!==0||W!==0?ne+W:Sn(y.top,y.bottom))}await d({...n,availableWidth:q,availableHeight:P});const re=await c.getDimensions(f.floating);return k!==re.width||C!==re.height?{reset:{rects:!0}}:{}}}};function uc(){return typeof window<"u"}function ha(e){return pw(e)?(e.nodeName||"").toLowerCase():"#document"}function Cn(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function xr(e){var n;return(n=(pw(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function pw(e){return uc()?e instanceof Node||e instanceof Cn(e).Node:!1}function Wn(e){return uc()?e instanceof Element||e instanceof Cn(e).Element:!1}function Gr(e){return uc()?e instanceof HTMLElement||e instanceof Cn(e).HTMLElement:!1}function cb(e){return!uc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Cn(e).ShadowRoot}function Io(e){const{overflow:n,overflowX:l,overflowY:i,display:o}=er(e);return/auto|scroll|overlay|hidden|clip/.test(n+i+l)&&o!=="inline"&&o!=="contents"}function y4(e){return/^(table|td|th)$/.test(ha(e))}function cc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const x4=/transform|translate|scale|rotate|perspective|filter/,v4=/paint|layout|strict|content/,Wl=e=>!!e&&e!=="none";let oh;function Up(e){const n=Wn(e)?er(e):e;return Wl(n.transform)||Wl(n.translate)||Wl(n.scale)||Wl(n.rotate)||Wl(n.perspective)||!Hp()&&(Wl(n.backdropFilter)||Wl(n.filter))||x4.test(n.willChange||"")||v4.test(n.contain||"")}function b4(e){let n=Tl(e);for(;Gr(n)&&!aa(n);){if(Up(n))return n;if(cc(n))return null;n=Tl(n)}return null}function Hp(){return oh==null&&(oh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),oh}function aa(e){return/^(html|body|#document)$/.test(ha(e))}function er(e){return Cn(e).getComputedStyle(e)}function fc(e){return Wn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tl(e){if(ha(e)==="html")return e;const n=e.assignedSlot||e.parentNode||cb(e)&&e.host||xr(e);return cb(n)?n.host:n}function mw(e){const n=Tl(e);return aa(n)?e.ownerDocument?e.ownerDocument.body:e.body:Gr(n)&&Io(n)?n:mw(n)}function Ro(e,n,l){var i;n===void 0&&(n=[]),l===void 0&&(l=!0);const o=mw(e),s=o===((i=e.ownerDocument)==null?void 0:i.body),c=Cn(o);if(s){const f=Vh(c);return n.concat(c,c.visualViewport||[],Io(o)?o:[],f&&l?Ro(f):[])}else return n.concat(o,Ro(o,[],l))}function Vh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gw(e){const n=er(e);let l=parseFloat(n.width)||0,i=parseFloat(n.height)||0;const o=Gr(e),s=o?e.offsetWidth:l,c=o?e.offsetHeight:i,f=Uu(l)!==s||Uu(i)!==c;return f&&(l=s,i=c),{width:l,height:i,$:f}}function Pp(e){return Wn(e)?e:e.contextElement}function na(e){const n=Pp(e);if(!Gr(n))return pr(1);const l=n.getBoundingClientRect(),{width:i,height:o,$:s}=gw(n);let c=(s?Uu(l.width):l.width)/i,f=(s?Uu(l.height):l.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const w4=pr(0);function yw(e){const n=Cn(e);return!Hp()||!n.visualViewport?w4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function S4(e,n,l){return n===void 0&&(n=!1),!l||n&&l!==Cn(e)?!1:n}function li(e,n,l,i){n===void 0&&(n=!1),l===void 0&&(l=!1);const o=e.getBoundingClientRect(),s=Pp(e);let c=pr(1);n&&(i?Wn(i)&&(c=na(i)):c=na(e));const f=S4(s,l,i)?yw(s):pr(0);let d=(o.left+f.x)/c.x,h=(o.top+f.y)/c.y,y=o.width/c.x,g=o.height/c.y;if(s){const v=Cn(s),b=i&&Wn(i)?Cn(i):i;let k=v,C=Vh(k);for(;C&&i&&b!==k;){const E=na(C),N=C.getBoundingClientRect(),M=er(C),j=N.left+(C.clientLeft+parseFloat(M.paddingLeft))*E.x,D=N.top+(C.clientTop+parseFloat(M.paddingTop))*E.y;d*=E.x,h*=E.y,y*=E.x,g*=E.y,d+=j,h+=D,k=Cn(C),C=Vh(k)}}return Pu({width:y,height:g,x:d,y:h})}function dc(e,n){const l=fc(e).scrollLeft;return n?n.left+l:li(xr(e)).left+l}function xw(e,n){const l=e.getBoundingClientRect(),i=l.left+n.scrollLeft-dc(e,l),o=l.top+n.scrollTop;return{x:i,y:o}}function C4(e){let{elements:n,rect:l,offsetParent:i,strategy:o}=e;const s=o==="fixed",c=xr(i),f=n?cc(n.floating):!1;if(i===c||f&&s)return l;let d={scrollLeft:0,scrollTop:0},h=pr(1);const y=pr(0),g=Gr(i);if((g||!g&&!s)&&((ha(i)!=="body"||Io(c))&&(d=fc(i)),g)){const b=li(i);h=na(i),y.x=b.x+i.clientLeft,y.y=b.y+i.clientTop}const v=c&&!g&&!s?xw(c,d):pr(0);return{width:l.width*h.x,height:l.height*h.y,x:l.x*h.x-d.scrollLeft*h.x+y.x+v.x,y:l.y*h.y-d.scrollTop*h.y+y.y+v.y}}function k4(e){return Array.from(e.getClientRects())}function E4(e){const n=xr(e),l=fc(e),i=e.ownerDocument.body,o=Sn(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),s=Sn(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let c=-l.scrollLeft+dc(e);const f=-l.scrollTop;return er(i).direction==="rtl"&&(c+=Sn(n.clientWidth,i.clientWidth)-o),{width:o,height:s,x:c,y:f}}const fb=25;function N4(e,n){const l=Cn(e),i=xr(e),o=l.visualViewport;let s=i.clientWidth,c=i.clientHeight,f=0,d=0;if(o){s=o.width,c=o.height;const y=Hp();(!y||y&&n==="fixed")&&(f=o.offsetLeft,d=o.offsetTop)}const h=dc(i);if(h<=0){const y=i.ownerDocument,g=y.body,v=getComputedStyle(g),b=y.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,k=Math.abs(i.clientWidth-g.clientWidth-b);k<=fb&&(s-=k)}else h<=fb&&(s+=h);return{width:s,height:c,x:f,y:d}}function A4(e,n){const l=li(e,!0,n==="fixed"),i=l.top+e.clientTop,o=l.left+e.clientLeft,s=Gr(e)?na(e):pr(1),c=e.clientWidth*s.x,f=e.clientHeight*s.y,d=o*s.x,h=i*s.y;return{width:c,height:f,x:d,y:h}}function db(e,n,l){let i;if(n==="viewport")i=N4(e,l);else if(n==="document")i=E4(xr(e));else if(Wn(n))i=A4(n,l);else{const o=yw(e);i={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return Pu(i)}function vw(e,n){const l=Tl(e);return l===n||!Wn(l)||aa(l)?!1:er(l).position==="fixed"||vw(l,n)}function T4(e,n){const l=n.get(e);if(l)return l;let i=Ro(e,[],!1).filter(f=>Wn(f)&&ha(f)!=="body"),o=null;const s=er(e).position==="fixed";let c=s?Tl(e):e;for(;Wn(c)&&!aa(c);){const f=er(c),d=Up(c);!d&&f.position==="fixed"&&(o=null),(s?!d&&!o:!d&&f.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Io(c)&&!d&&vw(e,c))?i=i.filter(y=>y!==c):o=f,c=Tl(c)}return n.set(e,i),i}function R4(e){let{element:n,boundary:l,rootBoundary:i,strategy:o}=e;const c=[...l==="clippingAncestors"?cc(n)?[]:T4(n,this._c):[].concat(l),i],f=db(n,c[0],o);let d=f.top,h=f.right,y=f.bottom,g=f.left;for(let v=1;v<c.length;v++){const b=db(n,c[v],o);d=Sn(b.top,d),h=Al(b.right,h),y=Al(b.bottom,y),g=Sn(b.left,g)}return{width:h-g,height:y-d,x:g,y:d}}function j4(e){const{width:n,height:l}=gw(e);return{width:n,height:l}}function M4(e,n,l){const i=Gr(n),o=xr(n),s=l==="fixed",c=li(e,!0,s,n);let f={scrollLeft:0,scrollTop:0};const d=pr(0);function h(){d.x=dc(o)}if(i||!i&&!s)if((ha(n)!=="body"||Io(o))&&(f=fc(n)),i){const b=li(n,!0,s,n);d.x=b.x+n.clientLeft,d.y=b.y+n.clientTop}else o&&h();s&&!i&&o&&h();const y=o&&!i&&!s?xw(o,f):pr(0),g=c.left+f.scrollLeft-d.x-y.x,v=c.top+f.scrollTop-d.y-y.y;return{x:g,y:v,width:c.width,height:c.height}}function sh(e){return er(e).position==="static"}function hb(e,n){if(!Gr(e)||er(e).position==="fixed")return null;if(n)return n(e);let l=e.offsetParent;return xr(e)===l&&(l=l.ownerDocument.body),l}function bw(e,n){const l=Cn(e);if(cc(e))return l;if(!Gr(e)){let o=Tl(e);for(;o&&!aa(o);){if(Wn(o)&&!sh(o))return o;o=Tl(o)}return l}let i=hb(e,n);for(;i&&y4(i)&&sh(i);)i=hb(i,n);return i&&aa(i)&&sh(i)&&!Up(i)?l:i||b4(e)||l}const O4=async function(e){const n=this.getOffsetParent||bw,l=this.getDimensions,i=await l(e.floating);return{reference:M4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function D4(e){return er(e).direction==="rtl"}const _4={convertOffsetParentRelativeRectToViewportRelativeRect:C4,getDocumentElement:xr,getClippingRect:R4,getOffsetParent:bw,getElementRects:O4,getClientRects:k4,getDimensions:j4,getScale:na,isElement:Wn,isRTL:D4};function ww(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function z4(e,n){let l=null,i;const o=xr(e);function s(){var f;clearTimeout(i),(f=l)==null||f.disconnect(),l=null}function c(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),s();const h=e.getBoundingClientRect(),{left:y,top:g,width:v,height:b}=h;if(f||n(),!v||!b)return;const k=gu(g),C=gu(o.clientWidth-(y+v)),E=gu(o.clientHeight-(g+b)),N=gu(y),j={rootMargin:-k+"px "+-C+"px "+-E+"px "+-N+"px",threshold:Sn(0,Al(1,d))||1};let D=!0;function I(O){const P=O[0].intersectionRatio;if(P!==d){if(!D)return c();P?c(!1,P):i=setTimeout(()=>{c(!1,1e-7)},1e3)}P===1&&!ww(h,e.getBoundingClientRect())&&c(),D=!1}try{l=new IntersectionObserver(I,{...j,root:o.ownerDocument})}catch{l=new IntersectionObserver(I,j)}l.observe(e)}return c(!0),s}function L4(e,n,l,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,h=Pp(e),y=o||s?[...h?Ro(h):[],...n?Ro(n):[]]:[];y.forEach(N=>{o&&N.addEventListener("scroll",l,{passive:!0}),s&&N.addEventListener("resize",l)});const g=h&&f?z4(h,l):null;let v=-1,b=null;c&&(b=new ResizeObserver(N=>{let[M]=N;M&&M.target===h&&b&&n&&(b.unobserve(n),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var j;(j=b)==null||j.observe(n)})),l()}),h&&!d&&b.observe(h),n&&b.observe(n));let k,C=d?li(e):null;d&&E();function E(){const N=li(e);C&&!ww(C,N)&&l(),C=N,k=requestAnimationFrame(E)}return l(),()=>{var N;y.forEach(M=>{o&&M.removeEventListener("scroll",l),s&&M.removeEventListener("resize",l)}),g==null||g(),(N=b)==null||N.disconnect(),b=null,d&&cancelAnimationFrame(k)}}const B4=h4,U4=p4,H4=c4,P4=g4,I4=f4,pb=u4,q4=m4,F4=(e,n,l)=>{const i=new Map,o={platform:_4,...l},s={...o.platform,_c:i};return s4(e,n,{...o,platform:s})};var V4=typeof document<"u",G4=function(){},ju=V4?w.useLayoutEffect:G4;function Iu(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let l,i,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(l=e.length,l!==n.length)return!1;for(i=l;i--!==0;)if(!Iu(e[i],n[i]))return!1;return!0}if(o=Object.keys(e),l=o.length,l!==Object.keys(n).length)return!1;for(i=l;i--!==0;)if(!{}.hasOwnProperty.call(n,o[i]))return!1;for(i=l;i--!==0;){const s=o[i];if(!(s==="_owner"&&e.$$typeof)&&!Iu(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}function Sw(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mb(e,n){const l=Sw(e);return Math.round(n*l)/l}function uh(e){const n=w.useRef(e);return ju(()=>{n.current=e}),n}function Y4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:l="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:c}={},transform:f=!0,whileElementsMounted:d,open:h}=e,[y,g]=w.useState({x:0,y:0,strategy:l,placement:n,middlewareData:{},isPositioned:!1}),[v,b]=w.useState(i);Iu(v,i)||b(i);const[k,C]=w.useState(null),[E,N]=w.useState(null),M=w.useCallback(le=>{le!==O.current&&(O.current=le,C(le))},[]),j=w.useCallback(le=>{le!==P.current&&(P.current=le,N(le))},[]),D=s||k,I=c||E,O=w.useRef(null),P=w.useRef(null),q=w.useRef(y),re=d!=null,H=uh(d),J=uh(o),ne=uh(h),W=w.useCallback(()=>{if(!O.current||!P.current)return;const le={placement:n,strategy:l,middleware:v};J.current&&(le.platform=J.current),F4(O.current,P.current,le).then(de=>{const R={...de,isPositioned:ne.current!==!1};Z.current&&!Iu(q.current,R)&&(q.current=R,kl.flushSync(()=>{g(R)}))})},[v,n,l,J,ne]);ju(()=>{h===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,g(le=>({...le,isPositioned:!1})))},[h]);const Z=w.useRef(!1);ju(()=>(Z.current=!0,()=>{Z.current=!1}),[]),ju(()=>{if(D&&(O.current=D),I&&(P.current=I),D&&I){if(H.current)return H.current(D,I,W);W()}},[D,I,W,H,re]);const Q=w.useMemo(()=>({reference:O,floating:P,setReference:M,setFloating:j}),[M,j]),B=w.useMemo(()=>({reference:D,floating:I}),[D,I]),Y=w.useMemo(()=>{const le={position:l,left:0,top:0};if(!B.floating)return le;const de=mb(B.floating,y.x),R=mb(B.floating,y.y);return f?{...le,transform:"translate("+de+"px, "+R+"px)",...Sw(B.floating)>=1.5&&{willChange:"transform"}}:{position:l,left:de,top:R}},[l,f,B.floating,y.x,y.y]);return w.useMemo(()=>({...y,update:W,refs:Q,elements:B,floatingStyles:Y}),[y,W,Q,B,Y])}const $4=e=>{function n(l){return{}.hasOwnProperty.call(l,"current")}return{name:"arrow",options:e,fn(l){const{element:i,padding:o}=typeof e=="function"?e(l):e;return i&&n(i)?i.current!=null?pb({element:i.current,padding:o}).fn(l):{}:i?pb({element:i,padding:o}).fn(l):{}}}},X4=(e,n)=>{const l=B4(e);return{name:l.name,fn:l.fn,options:[e,n]}},Q4=(e,n)=>{const l=U4(e);return{name:l.name,fn:l.fn,options:[e,n]}},K4=(e,n)=>({fn:q4(e).fn,options:[e,n]}),Z4=(e,n)=>{const l=H4(e);return{name:l.name,fn:l.fn,options:[e,n]}},J4=(e,n)=>{const l=P4(e);return{name:l.name,fn:l.fn,options:[e,n]}},W4=(e,n)=>{const l=I4(e);return{name:l.name,fn:l.fn,options:[e,n]}},e3=(e,n)=>{const l=$4(e);return{name:l.name,fn:l.fn,options:[e,n]}};var t3="Arrow",Cw=w.forwardRef((e,n)=>{const{children:l,width:i=10,height:o=5,...s}=e;return x.jsx(Yt.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?l:x.jsx("polygon",{points:"0,0 30,0 15,10"})})});Cw.displayName=t3;var n3=Cw;function r3(e){const[n,l]=w.useState(void 0);return El(()=>{if(e){l({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let c,f;if("borderBoxSize"in s){const d=s.borderBoxSize,h=Array.isArray(d)?d[0]:d;c=h.inlineSize,f=h.blockSize}else c=e.offsetWidth,f=e.offsetHeight;l({width:c,height:f})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else l(void 0)},[e]),n}var Ip="Popper",[kw,hc]=rc(Ip),[l3,Ew]=kw(Ip),Nw=e=>{const{__scopePopper:n,children:l}=e,[i,o]=w.useState(null);return x.jsx(l3,{scope:n,anchor:i,onAnchorChange:o,children:l})};Nw.displayName=Ip;var Aw="PopperAnchor",Tw=w.forwardRef((e,n)=>{const{__scopePopper:l,virtualRef:i,...o}=e,s=Ew(Aw,l),c=w.useRef(null),f=En(n,c),d=w.useRef(null);return w.useEffect(()=>{const h=d.current;d.current=(i==null?void 0:i.current)||c.current,h!==d.current&&s.onAnchorChange(d.current)}),i?null:x.jsx(Yt.div,{...o,ref:f})});Tw.displayName=Aw;var qp="PopperContent",[i3,a3]=kw(qp),Rw=w.forwardRef((e,n)=>{var we,Ae,xe,Ne,rt,tt;const{__scopePopper:l,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:c=0,arrowPadding:f=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:y=0,sticky:g="partial",hideWhenDetached:v=!1,updatePositionStrategy:b="optimized",onPlaced:k,...C}=e,E=Ew(qp,l),[N,M]=w.useState(null),j=En(n,at=>M(at)),[D,I]=w.useState(null),O=r3(D),P=(O==null?void 0:O.width)??0,q=(O==null?void 0:O.height)??0,re=i+(s!=="center"?"-"+s:""),H=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},J=Array.isArray(h)?h:[h],ne=J.length>0,W={padding:H,boundary:J.filter(s3),altBoundary:ne},{refs:Z,floatingStyles:Q,placement:B,isPositioned:Y,middlewareData:le}=Y4({strategy:"fixed",placement:re,whileElementsMounted:(...at)=>L4(...at,{animationFrame:b==="always"}),elements:{reference:E.anchor},middleware:[X4({mainAxis:o+q,alignmentAxis:c}),d&&Q4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?K4():void 0,...W}),d&&Z4({...W}),J4({...W,apply:({elements:at,rects:Ye,availableWidth:Dt,availableHeight:_t})=>{const{width:Fn,height:Vn}=Ye.reference,zt=at.floating.style;zt.setProperty("--radix-popper-available-width",`${Dt}px`),zt.setProperty("--radix-popper-available-height",`${_t}px`),zt.setProperty("--radix-popper-anchor-width",`${Fn}px`),zt.setProperty("--radix-popper-anchor-height",`${Vn}px`)}}),D&&e3({element:D,padding:f}),u3({arrowWidth:P,arrowHeight:q}),v&&W4({strategy:"referenceHidden",...W})]}),[de,R]=Ow(B),z=ia(k);El(()=>{Y&&(z==null||z())},[Y,z]);const L=(we=le.arrow)==null?void 0:we.x,T=(Ae=le.arrow)==null?void 0:Ae.y,se=((xe=le.arrow)==null?void 0:xe.centerOffset)!==0,[ce,ue]=w.useState();return El(()=>{N&&ue(window.getComputedStyle(N).zIndex)},[N]),x.jsx("div",{ref:Z.setFloating,"data-radix-popper-content-wrapper":"",style:{...Q,transform:Y?Q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[(Ne=le.transformOrigin)==null?void 0:Ne.x,(rt=le.transformOrigin)==null?void 0:rt.y].join(" "),...((tt=le.hide)==null?void 0:tt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:x.jsx(i3,{scope:l,placedSide:de,onArrowChange:I,arrowX:L,arrowY:T,shouldHideArrow:se,children:x.jsx(Yt.div,{"data-side":de,"data-align":R,...C,ref:j,style:{...C.style,animation:Y?void 0:"none"}})})})});Rw.displayName=qp;var jw="PopperArrow",o3={top:"bottom",right:"left",bottom:"top",left:"right"},Mw=w.forwardRef(function(n,l){const{__scopePopper:i,...o}=n,s=a3(jw,i),c=o3[s.placedSide];return x.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[c]: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:x.jsx(n3,{...o,ref:l,style:{...o.style,display:"block"}})})});Mw.displayName=jw;function s3(e){return e!==null}var u3=e=>({name:"transformOrigin",options:e,fn(n){var E,N,M;const{placement:l,rects:i,middlewareData:o}=n,c=((E=o.arrow)==null?void 0:E.centerOffset)!==0,f=c?0:e.arrowWidth,d=c?0:e.arrowHeight,[h,y]=Ow(l),g={start:"0%",center:"50%",end:"100%"}[y],v=(((N=o.arrow)==null?void 0:N.x)??0)+f/2,b=(((M=o.arrow)==null?void 0:M.y)??0)+d/2;let k="",C="";return h==="bottom"?(k=c?g:`${v}px`,C=`${-d}px`):h==="top"?(k=c?g:`${v}px`,C=`${i.floating.height+d}px`):h==="right"?(k=`${-d}px`,C=c?g:`${b}px`):h==="left"&&(k=`${i.floating.width+d}px`,C=c?g:`${b}px`),{data:{x:k,y:C}}}});function Ow(e){const[n,l="center"]=e.split("-");return[n,l]}var Dw=Nw,Fp=Tw,_w=Rw,zw=Mw,c3=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"}),f3="VisuallyHidden",Lw=w.forwardRef((e,n)=>x.jsx(Yt.span,{...e,ref:n,style:{...c3,...e.style}}));Lw.displayName=f3;var d3=Lw,[pc]=rc("Tooltip",[hc]),mc=hc(),Bw="TooltipProvider",h3=700,Gh="tooltip.open",[p3,Vp]=pc(Bw),Uw=e=>{const{__scopeTooltip:n,delayDuration:l=h3,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=e,c=w.useRef(!0),f=w.useRef(!1),d=w.useRef(0);return w.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),x.jsx(p3,{scope:n,isOpenDelayedRef:c,delayDuration:l,onOpen:w.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:w.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,i)},[i]),isPointerInTransitRef:f,onPointerInTransitChange:w.useCallback(h=>{f.current=h},[]),disableHoverableContent:o,children:s})};Uw.displayName=Bw;var jo="Tooltip",[m3,qo]=pc(jo),Hw=e=>{const{__scopeTooltip:n,children:l,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:c,delayDuration:f}=e,d=Vp(jo,e.__scopeTooltip),h=mc(n),[y,g]=w.useState(null),v=vo(),b=w.useRef(0),k=c??d.disableHoverableContent,C=f??d.delayDuration,E=w.useRef(!1),[N,M]=Cp({prop:i,defaultProp:o??!1,onChange:P=>{P?(d.onOpen(),document.dispatchEvent(new CustomEvent(Gh))):d.onClose(),s==null||s(P)},caller:jo}),j=w.useMemo(()=>N?E.current?"delayed-open":"instant-open":"closed",[N]),D=w.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E.current=!1,M(!0)},[M]),I=w.useCallback(()=>{window.clearTimeout(b.current),b.current=0,M(!1)},[M]),O=w.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{E.current=!0,M(!0),b.current=0},C)},[C,M]);return w.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),x.jsx(Dw,{...h,children:x.jsx(m3,{scope:n,contentId:v,open:N,stateAttribute:j,trigger:y,onTriggerChange:g,onTriggerEnter:w.useCallback(()=>{d.isOpenDelayedRef.current?O():D()},[d.isOpenDelayedRef,O,D]),onTriggerLeave:w.useCallback(()=>{k?I():(window.clearTimeout(b.current),b.current=0)},[I,k]),onOpen:D,onClose:I,disableHoverableContent:k,children:l})})};Hw.displayName=jo;var Yh="TooltipTrigger",Pw=w.forwardRef((e,n)=>{const{__scopeTooltip:l,...i}=e,o=qo(Yh,l),s=Vp(Yh,l),c=mc(l),f=w.useRef(null),d=En(n,f,o.onTriggerChange),h=w.useRef(!1),y=w.useRef(!1),g=w.useCallback(()=>h.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),x.jsx(Fp,{asChild:!0,...c,children:x.jsx(Yt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:d,onPointerMove:At(e.onPointerMove,v=>{v.pointerType!=="touch"&&!y.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),y.current=!0)}),onPointerLeave:At(e.onPointerLeave,()=>{o.onTriggerLeave(),y.current=!1}),onPointerDown:At(e.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:At(e.onFocus,()=>{h.current||o.onOpen()}),onBlur:At(e.onBlur,o.onClose),onClick:At(e.onClick,o.onClose)})})});Pw.displayName=Yh;var Gp="TooltipPortal",[g3,y3]=pc(Gp,{forceMount:void 0}),Iw=e=>{const{__scopeTooltip:n,forceMount:l,children:i,container:o}=e,s=qo(Gp,n);return x.jsx(g3,{scope:n,forceMount:l,children:x.jsx(Ml,{present:l||s.open,children:x.jsx(ic,{asChild:!0,container:o,children:i})})})};Iw.displayName=Gp;var oa="TooltipContent",qw=w.forwardRef((e,n)=>{const l=y3(oa,e.__scopeTooltip),{forceMount:i=l.forceMount,side:o="top",...s}=e,c=qo(oa,e.__scopeTooltip);return x.jsx(Ml,{present:i||c.open,children:c.disableHoverableContent?x.jsx(Fw,{side:o,...s,ref:n}):x.jsx(x3,{side:o,...s,ref:n})})}),x3=w.forwardRef((e,n)=>{const l=qo(oa,e.__scopeTooltip),i=Vp(oa,e.__scopeTooltip),o=w.useRef(null),s=En(n,o),[c,f]=w.useState(null),{trigger:d,onClose:h}=l,y=o.current,{onPointerInTransitChange:g}=i,v=w.useCallback(()=>{f(null),g(!1)},[g]),b=w.useCallback((k,C)=>{const E=k.currentTarget,N={x:k.clientX,y:k.clientY},M=C3(N,E.getBoundingClientRect()),j=k3(N,M),D=E3(C.getBoundingClientRect()),I=A3([...j,...D]);f(I),g(!0)},[g]);return w.useEffect(()=>()=>v(),[v]),w.useEffect(()=>{if(d&&y){const k=E=>b(E,y),C=E=>b(E,d);return d.addEventListener("pointerleave",k),y.addEventListener("pointerleave",C),()=>{d.removeEventListener("pointerleave",k),y.removeEventListener("pointerleave",C)}}},[d,y,b,v]),w.useEffect(()=>{if(c){const k=C=>{const E=C.target,N={x:C.clientX,y:C.clientY},M=(d==null?void 0:d.contains(E))||(y==null?void 0:y.contains(E)),j=!N3(N,c);M?v():j&&(v(),h())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[d,y,c,h,v]),x.jsx(Fw,{...e,ref:s})}),[v3,b3]=pc(jo,{isInside:!1}),w3=ZA("TooltipContent"),Fw=w.forwardRef((e,n)=>{const{__scopeTooltip:l,children:i,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:c,...f}=e,d=qo(oa,l),h=mc(l),{onClose:y}=d;return w.useEffect(()=>(document.addEventListener(Gh,y),()=>document.removeEventListener(Gh,y)),[y]),w.useEffect(()=>{if(d.trigger){const g=v=>{const b=v.target;b!=null&&b.contains(d.trigger)&&y()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,y]),x.jsx(lc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:y,children:x.jsxs(_w,{"data-state":d.stateAttribute,...h,...f,ref:n,style:{...f.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:[x.jsx(w3,{children:i}),x.jsx(v3,{scope:l,isInside:!0,children:x.jsx(d3,{id:d.contentId,role:"tooltip",children:o||i})})]})})});qw.displayName=oa;var Vw="TooltipArrow",S3=w.forwardRef((e,n)=>{const{__scopeTooltip:l,...i}=e,o=mc(l);return b3(Vw,l).isInside?null:x.jsx(zw,{...o,...i,ref:n})});S3.displayName=Vw;function C3(e,n){const l=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),o=Math.abs(n.right-e.x),s=Math.abs(n.left-e.x);switch(Math.min(l,i,o,s)){case s:return"left";case o:return"right";case l:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function k3(e,n,l=5){const i=[];switch(n){case"top":i.push({x:e.x-l,y:e.y+l},{x:e.x+l,y:e.y+l});break;case"bottom":i.push({x:e.x-l,y:e.y-l},{x:e.x+l,y:e.y-l});break;case"left":i.push({x:e.x+l,y:e.y-l},{x:e.x+l,y:e.y+l});break;case"right":i.push({x:e.x-l,y:e.y-l},{x:e.x-l,y:e.y+l});break}return i}function E3(e){const{top:n,right:l,bottom:i,left:o}=e;return[{x:o,y:n},{x:l,y:n},{x:l,y:i},{x:o,y:i}]}function N3(e,n){const{x:l,y:i}=e;let o=!1;for(let s=0,c=n.length-1;s<n.length;c=s++){const f=n[s],d=n[c],h=f.x,y=f.y,g=d.x,v=d.y;y>i!=v>i&&l<(g-h)*(i-y)/(v-y)+h&&(o=!o)}return o}function A3(e){const n=e.slice();return n.sort((l,i)=>l.x<i.x?-1:l.x>i.x?1:l.y<i.y?-1:l.y>i.y?1:0),T3(n)}function T3(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(;n.length>=2;){const s=n[n.length-1],c=n[n.length-2];if((s.x-c.x)*(o.y-c.y)>=(s.y-c.y)*(o.x-c.x))n.pop();else break}n.push(o)}n.pop();const l=[];for(let i=e.length-1;i>=0;i--){const o=e[i];for(;l.length>=2;){const s=l[l.length-1],c=l[l.length-2];if((s.x-c.x)*(o.y-c.y)>=(s.y-c.y)*(o.x-c.x))l.pop();else break}l.push(o)}return l.pop(),n.length===1&&l.length===1&&n[0].x===l[0].x&&n[0].y===l[0].y?n:n.concat(l)}var R3=Uw,j3=Hw,M3=Pw,O3=Iw,Gw=qw;const D3=R3,qu=j3,Fu=M3,Mo=w.forwardRef(({className:e,sideOffset:n=4,...l},i)=>x.jsx(O3,{children:x.jsx(Gw,{ref:i,sideOffset:n,className:ye("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),...l})}));Mo.displayName=Gw.displayName;const _3="0.2.0",z3={version:_3},Qt="Kanna",gb="kanna",L3=`kanna/${z3.version}`,B3="[kanna]",U3=`~/${Qt}`;function yu(e){return e?`${gb} ${e}`:gb}const H3={sm:"text-sm px-2.5 py-1",md:"text-sm px-3 py-1.5"};function P3({value:e,onValueChange:n,options:l,size:i="md",className:o,optionClassName:s}){return x.jsx("div",{className:ye("inline-flex items-center rounded-full border border-border p-0.5 ",o),children:l.map(c=>{const f=c.value===e,d=c.icon,h=d?w.isValidElement(d)?d:(()=>{const g=d;return x.jsx(g,{className:i==="sm"?"h-3.5 w-3.5":"h-4 w-4"})})():null,y=x.jsxs("button",{type:"button",onClick:()=>n(c.value),disabled:c.disabled,"aria-pressed":f,className:ye("rounded-full border transition-colors",d?"grid grid-cols-[auto_auto] items-center gap-2":"inline-flex items-center gap-1.5",H3[i],f?"bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 ":"border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",c.disabled&&"opacity-50 pointer-events-none",s),children:[h,x.jsx("span",{children:c.label})]},c.value);return c.tooltip?x.jsxs(qu,{children:[x.jsx(Fu,{asChild:!0,children:y}),x.jsx(Mo,{children:c.tooltip})]},c.value):y})})}function I3(e){return e.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Yw({open:e,onOpenChange:n,onConfirm:l}){const[i,o]=w.useState("new"),[s,c]=w.useState(""),[f,d]=w.useState(""),h=w.useRef(null),y=w.useRef(null);w.useEffect(()=>{e&&(o("new"),c(""),d(""),setTimeout(()=>{var E;return(E=h.current)==null?void 0:E.focus()},0))},[e]),w.useEffect(()=>{e&&setTimeout(()=>{var E,N;i==="new"?(E=h.current)==null||E.focus():(N=y.current)==null||N.focus()},0)},[i,e]);const g=I3(s),v=g?`${U3}/${g}`:"",b=f.trim(),k=i==="new"?!!g:!!b,C=()=>{if(k){if(i==="new")l({mode:"new",localPath:v,title:s.trim()});else{const E=b.split("/").pop()||b;l({mode:"existing",localPath:b,title:E})}n(!1)}};return x.jsx(aw,{open:e,onOpenChange:n,children:x.jsxs(_p,{size:"sm",children:[x.jsxs(uw,{className:"space-y-4",children:[x.jsx(sw,{children:"Add Project"}),x.jsx(P3,{value:i,onValueChange:o,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full",optionClassName:"flex-1 justify-center"}),i==="new"?x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:h,type:"text",value:s,onChange:E=>c(E.target.value),onKeyDown:E=>{E.key==="Enter"&&C(),E.key==="Escape"&&n(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"Project name"}),v&&x.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:v})]}):x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:y,type:"text",value:f,onChange:E=>d(E.target.value),onKeyDown:E=>{E.key==="Enter"&&C(),E.key==="Escape"&&n(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"~/Projects/my-app"}),x.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),x.jsxs(cw,{children:[x.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>n(!1),children:"Cancel"}),x.jsx(Fe,{variant:"secondary",size:"sm",onClick:C,disabled:!k,children:"Create"})]})]})})}const gc=({children:e,className:n,shimmerWidth:l=100,animate:i=!0,...o})=>x.jsx("span",{style:{"--shiny-width":`${Math.min(l,100)}px`},className:ye("mx-auto max-w-md text-foreground/50",i?["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"],n),...o,children:e}),q3=new Set(["starting","running"]);function F3({chat:e,activeChatId:n,onSelectChat:l,onDeleteChat:i}){return x.jsxs("div",{"data-chat-id":Pv(e.chatId),className:ye("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-md cursor-pointer border-border/0 hover:border-border hover:bg-muted active:bg-muted border transition-colors",n===Pv(e.chatId)?"bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>l(e.chatId),children:[q3.has(e.status)?x.jsx(oi,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?x.jsx("div",{className:"relative ",children:x.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[x.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),x.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,x.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?x.jsx(gc,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),x.jsx(Fe,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-100 md:opacity-0 md:group-hover:opacity-100 cursor-pointer rounded-sm hover:!bg-transparent",onClick:o=>{o.stopPropagation(),i(e.chatId)},title:"Delete chat",children:x.jsx(Po,{className:"size-3.5"})})]},e._id)}function V3(){for(var e=arguments.length,n=new Array(e),l=0;l<e;l++)n[l]=arguments[l];return w.useMemo(()=>i=>{n.forEach(o=>o(i))},n)}const yc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pa(e){const n=Object.prototype.toString.call(e);return n==="[object Window]"||n==="[object global]"}function Yp(e){return"nodeType"in e}function cn(e){var n,l;return e?pa(e)?e:Yp(e)&&(n=(l=e.ownerDocument)==null?void 0:l.defaultView)!=null?n:window:window}function $p(e){const{Document:n}=cn(e);return e instanceof n}function Fo(e){return pa(e)?!1:e instanceof cn(e).HTMLElement}function $w(e){return e instanceof cn(e).SVGElement}function ma(e){return e?pa(e)?e.document:Yp(e)?$p(e)?e:Fo(e)||$w(e)?e.ownerDocument:document:document:document}const gr=yc?w.useLayoutEffect:w.useEffect;function Xp(e){const n=w.useRef(e);return gr(()=>{n.current=e}),w.useCallback(function(){for(var l=arguments.length,i=new Array(l),o=0;o<l;o++)i[o]=arguments[o];return n.current==null?void 0:n.current(...i)},[])}function G3(){const e=w.useRef(null),n=w.useCallback((i,o)=>{e.current=setInterval(i,o)},[]),l=w.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[n,l]}function Oo(e,n){n===void 0&&(n=[e]);const l=w.useRef(e);return gr(()=>{l.current!==e&&(l.current=e)},n),l}function Vo(e,n){const l=w.useRef();return w.useMemo(()=>{const i=e(l.current);return l.current=i,i},[...n])}function Vu(e){const n=Xp(e),l=w.useRef(null),i=w.useCallback(o=>{o!==l.current&&(n==null||n(o,l.current)),l.current=o},[]);return[l,i]}function $h(e){const n=w.useRef();return w.useEffect(()=>{n.current=e},[e]),n.current}let ch={};function Go(e,n){return w.useMemo(()=>{if(n)return n;const l=ch[e]==null?0:ch[e]+1;return ch[e]=l,e+"-"+l},[e,n])}function Xw(e){return function(n){for(var l=arguments.length,i=new Array(l>1?l-1:0),o=1;o<l;o++)i[o-1]=arguments[o];return i.reduce((s,c)=>{const f=Object.entries(c);for(const[d,h]of f){const y=s[d];y!=null&&(s[d]=y+e*h)}return s},{...n})}}const ra=Xw(1),Gu=Xw(-1);function Y3(e){return"clientX"in e&&"clientY"in e}function Qp(e){if(!e)return!1;const{KeyboardEvent:n}=cn(e.target);return n&&e instanceof n}function $3(e){if(!e)return!1;const{TouchEvent:n}=cn(e.target);return n&&e instanceof n}function Xh(e){if($3(e)){if(e.touches&&e.touches.length){const{clientX:n,clientY:l}=e.touches[0];return{x:n,y:l}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:n,clientY:l}=e.changedTouches[0];return{x:n,y:l}}}return Y3(e)?{x:e.clientX,y:e.clientY}:null}const Do=Object.freeze({Translate:{toString(e){if(!e)return;const{x:n,y:l}=e;return"translate3d("+(n?Math.round(n):0)+"px, "+(l?Math.round(l):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:n,scaleY:l}=e;return"scaleX("+n+") scaleY("+l+")"}},Transform:{toString(e){if(e)return[Do.Translate.toString(e),Do.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:n,duration:l,easing:i}=e;return n+" "+l+"ms "+i}}}),yb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function X3(e){return e.matches(yb)?e:e.querySelector(yb)}const Q3={display:"none"};function K3(e){let{id:n,value:l}=e;return Nt.createElement("div",{id:n,style:Q3},l)}function Z3(e){let{id:n,announcement:l,ariaLiveType:i="assertive"}=e;const o={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 Nt.createElement("div",{id:n,style:o,role:"status","aria-live":i,"aria-atomic":!0},l)}function J3(){const[e,n]=w.useState("");return{announce:w.useCallback(i=>{i!=null&&n(i)},[]),announcement:e}}const Qw=w.createContext(null);function W3(e){const n=w.useContext(Qw);w.useEffect(()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(e)},[e,n])}function e5(){const[e]=w.useState(()=>new Set),n=w.useCallback(i=>(e.add(i),()=>e.delete(i)),[e]);return[w.useCallback(i=>{let{type:o,event:s}=i;e.forEach(c=>{var f;return(f=c[o])==null?void 0:f.call(c,s)})},[e]),n]}const t5={draggable:`
374
+ */const Gj=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Bu=Ee("zap",Gj),aw=yR,Yj=xR,ow=w.forwardRef(({className:e,...n},l)=>x.jsx(K1,{ref:l,className:ye("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),...n}));ow.displayName=K1.displayName;const $j={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},_p=w.forwardRef(({className:e,children:n,size:l="md",...i},o)=>x.jsxs(Yj,{children:[x.jsx(ow,{}),x.jsxs(Z1,{ref:o,className:ye("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",$j[l],e),...i,children:[n,x.jsxs(wR,{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:[x.jsx(Po,{className:"h-4 w-4"}),x.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_p.displayName=Z1.displayName;function sw({className:e,...n}){return x.jsx(vR,{className:ye("text-lg font-medium leading-none tracking-tight",e),...n})}function Xj({className:e,...n}){return x.jsx(bR,{className:ye("text-sm text-muted-foreground",e),...n})}function uw({className:e,...n}){return x.jsx("div",{className:ye("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...n})}function cw({className:e,...n}){return x.jsx("div",{className:ye("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...n})}const fw=w.createContext(null);function Qj({children:e}){const[n,l]=w.useState(null),[i,o]=w.useState(""),s=w.useRef(null);w.useEffect(()=>{(n==null?void 0:n.kind)==="prompt"&&(o(n.options.initialValue??""),setTimeout(()=>{var y,g;(y=s.current)==null||y.focus(),(g=s.current)==null||g.select()},0))},[n]);const c=w.useCallback(()=>{l(null),o("")},[]),f=w.useCallback(y=>new Promise(g=>{l({kind:"confirm",options:y,resolve:g})}),[]),d=w.useCallback(y=>new Promise(g=>{l({kind:"prompt",options:y,resolve:g})}),[]),h=w.useMemo(()=>({confirm:f,prompt:d}),[f,d]);return x.jsxs(fw.Provider,{value:h,children:[e,x.jsx(aw,{open:n!==null,onOpenChange:y=>{y||!n||(n.kind==="confirm"?n.resolve(!1):n.resolve(null),c())},children:x.jsx(_p,{size:"sm",children:n?x.jsxs(x.Fragment,{children:[x.jsxs(uw,{className:"space-y-4",children:[x.jsx(sw,{children:n.options.title}),n.options.description?x.jsx(Xj,{children:n.options.description}):null,n.kind==="prompt"?x.jsx("input",{ref:s,type:"text",value:i,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),n.resolve(i.trim()||null),c())},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:n.options.placeholder}):null]}),x.jsxs(cw,{children:[x.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{n.kind==="confirm"?n.resolve(!1):n.resolve(null),c()},children:n.options.cancelLabel??"Cancel"}),x.jsx(Fe,{variant:n.kind==="confirm"?n.options.confirmVariant??"default":"secondary",size:"sm",onClick:()=>{n.kind==="confirm"?n.resolve(!0):n.resolve(i.trim()||null),c()},disabled:n.kind==="prompt"&&!i.trim(),children:n.options.confirmLabel??"Confirm"})]})]}):null})})]})}function Kj(){const e=w.useContext(fw);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const Zj=["top","right","bottom","left"],Al=Math.min,Sn=Math.max,Uu=Math.round,gu=Math.floor,pr=e=>({x:e,y:e}),Jj={left:"right",right:"left",bottom:"top",top:"bottom"};function qh(e,n,l){return Sn(e,Al(n,l))}function Fr(e,n){return typeof e=="function"?e(n):e}function Vr(e){return e.split("-")[0]}function da(e){return e.split("-")[1]}function zp(e){return e==="x"?"y":"x"}function Lp(e){return e==="y"?"height":"width"}function dr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function Bp(e){return zp(dr(e))}function Wj(e,n,l){l===void 0&&(l=!1);const i=da(e),o=Bp(e),s=Lp(o);let c=o==="x"?i===(l?"end":"start")?"right":"left":i==="start"?"bottom":"top";return n.reference[s]>n.floating[s]&&(c=Hu(c)),[c,Hu(c)]}function e4(e){const n=Hu(e);return[Fh(e),n,Fh(n)]}function Fh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ib=["left","right"],ab=["right","left"],t4=["top","bottom"],n4=["bottom","top"];function r4(e,n,l){switch(e){case"top":case"bottom":return l?n?ab:ib:n?ib:ab;case"left":case"right":return n?t4:n4;default:return[]}}function l4(e,n,l,i){const o=da(e);let s=r4(Vr(e),l==="start",i);return o&&(s=s.map(c=>c+"-"+o),n&&(s=s.concat(s.map(Fh)))),s}function Hu(e){const n=Vr(e);return Jj[n]+e.slice(n.length)}function i4(e){return{top:0,right:0,bottom:0,left:0,...e}}function dw(e){return typeof e!="number"?i4(e):{top:e,right:e,bottom:e,left:e}}function Pu(e){const{x:n,y:l,width:i,height:o}=e;return{width:i,height:o,top:l,left:n,right:n+i,bottom:l+o,x:n,y:l}}function ob(e,n,l){let{reference:i,floating:o}=e;const s=dr(n),c=Bp(n),f=Lp(c),d=Vr(n),h=s==="y",y=i.x+i.width/2-o.width/2,g=i.y+i.height/2-o.height/2,v=i[f]/2-o[f]/2;let b;switch(d){case"top":b={x:y,y:i.y-o.height};break;case"bottom":b={x:y,y:i.y+i.height};break;case"right":b={x:i.x+i.width,y:g};break;case"left":b={x:i.x-o.width,y:g};break;default:b={x:i.x,y:i.y}}switch(da(n)){case"start":b[c]-=v*(l&&h?-1:1);break;case"end":b[c]+=v*(l&&h?-1:1);break}return b}async function a4(e,n){var l;n===void 0&&(n={});const{x:i,y:o,platform:s,rects:c,elements:f,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:y="viewport",elementContext:g="floating",altBoundary:v=!1,padding:b=0}=Fr(n,e),k=dw(b),E=f[v?g==="floating"?"reference":"floating":g],N=Pu(await s.getClippingRect({element:(l=await(s.isElement==null?void 0:s.isElement(E)))==null||l?E:E.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(f.floating)),boundary:h,rootBoundary:y,strategy:d})),M=g==="floating"?{x:i,y:o,width:c.floating.width,height:c.floating.height}:c.reference,j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f.floating)),D=await(s.isElement==null?void 0:s.isElement(j))?await(s.getScale==null?void 0:s.getScale(j))||{x:1,y:1}:{x:1,y:1},I=Pu(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:M,offsetParent:j,strategy:d}):M);return{top:(N.top-I.top+k.top)/D.y,bottom:(I.bottom-N.bottom+k.bottom)/D.y,left:(N.left-I.left+k.left)/D.x,right:(I.right-N.right+k.right)/D.x}}const o4=50,s4=async(e,n,l)=>{const{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:c}=l,f=c.detectOverflow?c:{...c,detectOverflow:a4},d=await(c.isRTL==null?void 0:c.isRTL(n));let h=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:y,y:g}=ob(h,i,d),v=i,b=0;const k={};for(let C=0;C<s.length;C++){const E=s[C];if(!E)continue;const{name:N,fn:M}=E,{x:j,y:D,data:I,reset:O}=await M({x:y,y:g,initialPlacement:i,placement:v,strategy:o,middlewareData:k,rects:h,platform:f,elements:{reference:e,floating:n}});y=j??y,g=D??g,k[N]={...k[N],...I},O&&b<o4&&(b++,typeof O=="object"&&(O.placement&&(v=O.placement),O.rects&&(h=O.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):O.rects),{x:y,y:g}=ob(h,v,d)),C=-1)}return{x:y,y:g,placement:v,strategy:o,middlewareData:k}},u4=e=>({name:"arrow",options:e,async fn(n){const{x:l,y:i,placement:o,rects:s,platform:c,elements:f,middlewareData:d}=n,{element:h,padding:y=0}=Fr(e,n)||{};if(h==null)return{};const g=dw(y),v={x:l,y:i},b=Bp(o),k=Lp(b),C=await c.getDimensions(h),E=b==="y",N=E?"top":"left",M=E?"bottom":"right",j=E?"clientHeight":"clientWidth",D=s.reference[k]+s.reference[b]-v[b]-s.floating[k],I=v[b]-s.reference[b],O=await(c.getOffsetParent==null?void 0:c.getOffsetParent(h));let P=O?O[j]:0;(!P||!await(c.isElement==null?void 0:c.isElement(O)))&&(P=f.floating[j]||s.floating[k]);const q=D/2-I/2,re=P/2-C[k]/2-1,H=Al(g[N],re),J=Al(g[M],re),ne=H,W=P-C[k]-J,Z=P/2-C[k]/2+q,Q=qh(ne,Z,W),B=!d.arrow&&da(o)!=null&&Z!==Q&&s.reference[k]/2-(Z<ne?H:J)-C[k]/2<0,Y=B?Z<ne?Z-ne:Z-W:0;return{[b]:v[b]+Y,data:{[b]:Q,centerOffset:Z-Q-Y,...B&&{alignmentOffset:Y}},reset:B}}}),c4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var l,i;const{placement:o,middlewareData:s,rects:c,initialPlacement:f,platform:d,elements:h}=n,{mainAxis:y=!0,crossAxis:g=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:C=!0,...E}=Fr(e,n);if((l=s.arrow)!=null&&l.alignmentOffset)return{};const N=Vr(o),M=dr(f),j=Vr(f)===f,D=await(d.isRTL==null?void 0:d.isRTL(h.floating)),I=v||(j||!C?[Hu(f)]:e4(f)),O=k!=="none";!v&&O&&I.push(...l4(f,C,k,D));const P=[f,...I],q=await d.detectOverflow(n,E),re=[];let H=((i=s.flip)==null?void 0:i.overflows)||[];if(y&&re.push(q[N]),g){const Z=Wj(o,c,D);re.push(q[Z[0]],q[Z[1]])}if(H=[...H,{placement:o,overflows:re}],!re.every(Z=>Z<=0)){var J,ne;const Z=(((J=s.flip)==null?void 0:J.index)||0)+1,Q=P[Z];if(Q&&(!(g==="alignment"?M!==dr(Q):!1)||H.every(le=>dr(le.placement)===M?le.overflows[0]>0:!0)))return{data:{index:Z,overflows:H},reset:{placement:Q}};let B=(ne=H.filter(Y=>Y.overflows[0]<=0).sort((Y,le)=>Y.overflows[1]-le.overflows[1])[0])==null?void 0:ne.placement;if(!B)switch(b){case"bestFit":{var W;const Y=(W=H.filter(le=>{if(O){const de=dr(le.placement);return de===M||de==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(de=>de>0).reduce((de,R)=>de+R,0)]).sort((le,de)=>le[1]-de[1])[0])==null?void 0:W[0];Y&&(B=Y);break}case"initialPlacement":B=f;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function sb(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function ub(e){return Zj.some(n=>e[n]>=0)}const f4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:l,platform:i}=n,{strategy:o="referenceHidden",...s}=Fr(e,n);switch(o){case"referenceHidden":{const c=await i.detectOverflow(n,{...s,elementContext:"reference"}),f=sb(c,l.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:ub(f)}}}case"escaped":{const c=await i.detectOverflow(n,{...s,altBoundary:!0}),f=sb(c,l.floating);return{data:{escapedOffsets:f,escaped:ub(f)}}}default:return{}}}}},hw=new Set(["left","top"]);async function d4(e,n){const{placement:l,platform:i,elements:o}=e,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),c=Vr(l),f=da(l),d=dr(l)==="y",h=hw.has(c)?-1:1,y=s&&d?-1:1,g=Fr(n,e);let{mainAxis:v,crossAxis:b,alignmentAxis:k}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return f&&typeof k=="number"&&(b=f==="end"?k*-1:k),d?{x:b*y,y:v*h}:{x:v*h,y:b*y}}const h4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var l,i;const{x:o,y:s,placement:c,middlewareData:f}=n,d=await d4(n,e);return c===((l=f.offset)==null?void 0:l.placement)&&(i=f.arrow)!=null&&i.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:c}}}}},p4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:l,y:i,placement:o,platform:s}=n,{mainAxis:c=!0,crossAxis:f=!1,limiter:d={fn:N=>{let{x:M,y:j}=N;return{x:M,y:j}}},...h}=Fr(e,n),y={x:l,y:i},g=await s.detectOverflow(n,h),v=dr(Vr(o)),b=zp(v);let k=y[b],C=y[v];if(c){const N=b==="y"?"top":"left",M=b==="y"?"bottom":"right",j=k+g[N],D=k-g[M];k=qh(j,k,D)}if(f){const N=v==="y"?"top":"left",M=v==="y"?"bottom":"right",j=C+g[N],D=C-g[M];C=qh(j,C,D)}const E=d.fn({...n,[b]:k,[v]:C});return{...E,data:{x:E.x-l,y:E.y-i,enabled:{[b]:c,[v]:f}}}}}},m4=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:l,y:i,placement:o,rects:s,middlewareData:c}=n,{offset:f=0,mainAxis:d=!0,crossAxis:h=!0}=Fr(e,n),y={x:l,y:i},g=dr(o),v=zp(g);let b=y[v],k=y[g];const C=Fr(f,n),E=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(d){const j=v==="y"?"height":"width",D=s.reference[v]-s.floating[j]+E.mainAxis,I=s.reference[v]+s.reference[j]-E.mainAxis;b<D?b=D:b>I&&(b=I)}if(h){var N,M;const j=v==="y"?"width":"height",D=hw.has(Vr(o)),I=s.reference[g]-s.floating[j]+(D&&((N=c.offset)==null?void 0:N[g])||0)+(D?0:E.crossAxis),O=s.reference[g]+s.reference[j]+(D?0:((M=c.offset)==null?void 0:M[g])||0)-(D?E.crossAxis:0);k<I?k=I:k>O&&(k=O)}return{[v]:b,[g]:k}}}},g4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var l,i;const{placement:o,rects:s,platform:c,elements:f}=n,{apply:d=()=>{},...h}=Fr(e,n),y=await c.detectOverflow(n,h),g=Vr(o),v=da(o),b=dr(o)==="y",{width:k,height:C}=s.floating;let E,N;g==="top"||g==="bottom"?(E=g,N=v===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(N=g,E=v==="end"?"top":"bottom");const M=C-y.top-y.bottom,j=k-y.left-y.right,D=Al(C-y[E],M),I=Al(k-y[N],j),O=!n.middlewareData.shift;let P=D,q=I;if((l=n.middlewareData.shift)!=null&&l.enabled.x&&(q=j),(i=n.middlewareData.shift)!=null&&i.enabled.y&&(P=M),O&&!v){const H=Sn(y.left,0),J=Sn(y.right,0),ne=Sn(y.top,0),W=Sn(y.bottom,0);b?q=k-2*(H!==0||J!==0?H+J:Sn(y.left,y.right)):P=C-2*(ne!==0||W!==0?ne+W:Sn(y.top,y.bottom))}await d({...n,availableWidth:q,availableHeight:P});const re=await c.getDimensions(f.floating);return k!==re.width||C!==re.height?{reset:{rects:!0}}:{}}}};function uc(){return typeof window<"u"}function ha(e){return pw(e)?(e.nodeName||"").toLowerCase():"#document"}function Cn(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function xr(e){var n;return(n=(pw(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function pw(e){return uc()?e instanceof Node||e instanceof Cn(e).Node:!1}function Wn(e){return uc()?e instanceof Element||e instanceof Cn(e).Element:!1}function Gr(e){return uc()?e instanceof HTMLElement||e instanceof Cn(e).HTMLElement:!1}function cb(e){return!uc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Cn(e).ShadowRoot}function Io(e){const{overflow:n,overflowX:l,overflowY:i,display:o}=er(e);return/auto|scroll|overlay|hidden|clip/.test(n+i+l)&&o!=="inline"&&o!=="contents"}function y4(e){return/^(table|td|th)$/.test(ha(e))}function cc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const x4=/transform|translate|scale|rotate|perspective|filter/,v4=/paint|layout|strict|content/,Wl=e=>!!e&&e!=="none";let oh;function Up(e){const n=Wn(e)?er(e):e;return Wl(n.transform)||Wl(n.translate)||Wl(n.scale)||Wl(n.rotate)||Wl(n.perspective)||!Hp()&&(Wl(n.backdropFilter)||Wl(n.filter))||x4.test(n.willChange||"")||v4.test(n.contain||"")}function b4(e){let n=Tl(e);for(;Gr(n)&&!aa(n);){if(Up(n))return n;if(cc(n))return null;n=Tl(n)}return null}function Hp(){return oh==null&&(oh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),oh}function aa(e){return/^(html|body|#document)$/.test(ha(e))}function er(e){return Cn(e).getComputedStyle(e)}function fc(e){return Wn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tl(e){if(ha(e)==="html")return e;const n=e.assignedSlot||e.parentNode||cb(e)&&e.host||xr(e);return cb(n)?n.host:n}function mw(e){const n=Tl(e);return aa(n)?e.ownerDocument?e.ownerDocument.body:e.body:Gr(n)&&Io(n)?n:mw(n)}function Ro(e,n,l){var i;n===void 0&&(n=[]),l===void 0&&(l=!0);const o=mw(e),s=o===((i=e.ownerDocument)==null?void 0:i.body),c=Cn(o);if(s){const f=Vh(c);return n.concat(c,c.visualViewport||[],Io(o)?o:[],f&&l?Ro(f):[])}else return n.concat(o,Ro(o,[],l))}function Vh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gw(e){const n=er(e);let l=parseFloat(n.width)||0,i=parseFloat(n.height)||0;const o=Gr(e),s=o?e.offsetWidth:l,c=o?e.offsetHeight:i,f=Uu(l)!==s||Uu(i)!==c;return f&&(l=s,i=c),{width:l,height:i,$:f}}function Pp(e){return Wn(e)?e:e.contextElement}function na(e){const n=Pp(e);if(!Gr(n))return pr(1);const l=n.getBoundingClientRect(),{width:i,height:o,$:s}=gw(n);let c=(s?Uu(l.width):l.width)/i,f=(s?Uu(l.height):l.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const w4=pr(0);function yw(e){const n=Cn(e);return!Hp()||!n.visualViewport?w4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function S4(e,n,l){return n===void 0&&(n=!1),!l||n&&l!==Cn(e)?!1:n}function li(e,n,l,i){n===void 0&&(n=!1),l===void 0&&(l=!1);const o=e.getBoundingClientRect(),s=Pp(e);let c=pr(1);n&&(i?Wn(i)&&(c=na(i)):c=na(e));const f=S4(s,l,i)?yw(s):pr(0);let d=(o.left+f.x)/c.x,h=(o.top+f.y)/c.y,y=o.width/c.x,g=o.height/c.y;if(s){const v=Cn(s),b=i&&Wn(i)?Cn(i):i;let k=v,C=Vh(k);for(;C&&i&&b!==k;){const E=na(C),N=C.getBoundingClientRect(),M=er(C),j=N.left+(C.clientLeft+parseFloat(M.paddingLeft))*E.x,D=N.top+(C.clientTop+parseFloat(M.paddingTop))*E.y;d*=E.x,h*=E.y,y*=E.x,g*=E.y,d+=j,h+=D,k=Cn(C),C=Vh(k)}}return Pu({width:y,height:g,x:d,y:h})}function dc(e,n){const l=fc(e).scrollLeft;return n?n.left+l:li(xr(e)).left+l}function xw(e,n){const l=e.getBoundingClientRect(),i=l.left+n.scrollLeft-dc(e,l),o=l.top+n.scrollTop;return{x:i,y:o}}function C4(e){let{elements:n,rect:l,offsetParent:i,strategy:o}=e;const s=o==="fixed",c=xr(i),f=n?cc(n.floating):!1;if(i===c||f&&s)return l;let d={scrollLeft:0,scrollTop:0},h=pr(1);const y=pr(0),g=Gr(i);if((g||!g&&!s)&&((ha(i)!=="body"||Io(c))&&(d=fc(i)),g)){const b=li(i);h=na(i),y.x=b.x+i.clientLeft,y.y=b.y+i.clientTop}const v=c&&!g&&!s?xw(c,d):pr(0);return{width:l.width*h.x,height:l.height*h.y,x:l.x*h.x-d.scrollLeft*h.x+y.x+v.x,y:l.y*h.y-d.scrollTop*h.y+y.y+v.y}}function k4(e){return Array.from(e.getClientRects())}function E4(e){const n=xr(e),l=fc(e),i=e.ownerDocument.body,o=Sn(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),s=Sn(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let c=-l.scrollLeft+dc(e);const f=-l.scrollTop;return er(i).direction==="rtl"&&(c+=Sn(n.clientWidth,i.clientWidth)-o),{width:o,height:s,x:c,y:f}}const fb=25;function N4(e,n){const l=Cn(e),i=xr(e),o=l.visualViewport;let s=i.clientWidth,c=i.clientHeight,f=0,d=0;if(o){s=o.width,c=o.height;const y=Hp();(!y||y&&n==="fixed")&&(f=o.offsetLeft,d=o.offsetTop)}const h=dc(i);if(h<=0){const y=i.ownerDocument,g=y.body,v=getComputedStyle(g),b=y.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,k=Math.abs(i.clientWidth-g.clientWidth-b);k<=fb&&(s-=k)}else h<=fb&&(s+=h);return{width:s,height:c,x:f,y:d}}function A4(e,n){const l=li(e,!0,n==="fixed"),i=l.top+e.clientTop,o=l.left+e.clientLeft,s=Gr(e)?na(e):pr(1),c=e.clientWidth*s.x,f=e.clientHeight*s.y,d=o*s.x,h=i*s.y;return{width:c,height:f,x:d,y:h}}function db(e,n,l){let i;if(n==="viewport")i=N4(e,l);else if(n==="document")i=E4(xr(e));else if(Wn(n))i=A4(n,l);else{const o=yw(e);i={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return Pu(i)}function vw(e,n){const l=Tl(e);return l===n||!Wn(l)||aa(l)?!1:er(l).position==="fixed"||vw(l,n)}function T4(e,n){const l=n.get(e);if(l)return l;let i=Ro(e,[],!1).filter(f=>Wn(f)&&ha(f)!=="body"),o=null;const s=er(e).position==="fixed";let c=s?Tl(e):e;for(;Wn(c)&&!aa(c);){const f=er(c),d=Up(c);!d&&f.position==="fixed"&&(o=null),(s?!d&&!o:!d&&f.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Io(c)&&!d&&vw(e,c))?i=i.filter(y=>y!==c):o=f,c=Tl(c)}return n.set(e,i),i}function R4(e){let{element:n,boundary:l,rootBoundary:i,strategy:o}=e;const c=[...l==="clippingAncestors"?cc(n)?[]:T4(n,this._c):[].concat(l),i],f=db(n,c[0],o);let d=f.top,h=f.right,y=f.bottom,g=f.left;for(let v=1;v<c.length;v++){const b=db(n,c[v],o);d=Sn(b.top,d),h=Al(b.right,h),y=Al(b.bottom,y),g=Sn(b.left,g)}return{width:h-g,height:y-d,x:g,y:d}}function j4(e){const{width:n,height:l}=gw(e);return{width:n,height:l}}function M4(e,n,l){const i=Gr(n),o=xr(n),s=l==="fixed",c=li(e,!0,s,n);let f={scrollLeft:0,scrollTop:0};const d=pr(0);function h(){d.x=dc(o)}if(i||!i&&!s)if((ha(n)!=="body"||Io(o))&&(f=fc(n)),i){const b=li(n,!0,s,n);d.x=b.x+n.clientLeft,d.y=b.y+n.clientTop}else o&&h();s&&!i&&o&&h();const y=o&&!i&&!s?xw(o,f):pr(0),g=c.left+f.scrollLeft-d.x-y.x,v=c.top+f.scrollTop-d.y-y.y;return{x:g,y:v,width:c.width,height:c.height}}function sh(e){return er(e).position==="static"}function hb(e,n){if(!Gr(e)||er(e).position==="fixed")return null;if(n)return n(e);let l=e.offsetParent;return xr(e)===l&&(l=l.ownerDocument.body),l}function bw(e,n){const l=Cn(e);if(cc(e))return l;if(!Gr(e)){let o=Tl(e);for(;o&&!aa(o);){if(Wn(o)&&!sh(o))return o;o=Tl(o)}return l}let i=hb(e,n);for(;i&&y4(i)&&sh(i);)i=hb(i,n);return i&&aa(i)&&sh(i)&&!Up(i)?l:i||b4(e)||l}const O4=async function(e){const n=this.getOffsetParent||bw,l=this.getDimensions,i=await l(e.floating);return{reference:M4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function D4(e){return er(e).direction==="rtl"}const _4={convertOffsetParentRelativeRectToViewportRelativeRect:C4,getDocumentElement:xr,getClippingRect:R4,getOffsetParent:bw,getElementRects:O4,getClientRects:k4,getDimensions:j4,getScale:na,isElement:Wn,isRTL:D4};function ww(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function z4(e,n){let l=null,i;const o=xr(e);function s(){var f;clearTimeout(i),(f=l)==null||f.disconnect(),l=null}function c(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),s();const h=e.getBoundingClientRect(),{left:y,top:g,width:v,height:b}=h;if(f||n(),!v||!b)return;const k=gu(g),C=gu(o.clientWidth-(y+v)),E=gu(o.clientHeight-(g+b)),N=gu(y),j={rootMargin:-k+"px "+-C+"px "+-E+"px "+-N+"px",threshold:Sn(0,Al(1,d))||1};let D=!0;function I(O){const P=O[0].intersectionRatio;if(P!==d){if(!D)return c();P?c(!1,P):i=setTimeout(()=>{c(!1,1e-7)},1e3)}P===1&&!ww(h,e.getBoundingClientRect())&&c(),D=!1}try{l=new IntersectionObserver(I,{...j,root:o.ownerDocument})}catch{l=new IntersectionObserver(I,j)}l.observe(e)}return c(!0),s}function L4(e,n,l,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,h=Pp(e),y=o||s?[...h?Ro(h):[],...n?Ro(n):[]]:[];y.forEach(N=>{o&&N.addEventListener("scroll",l,{passive:!0}),s&&N.addEventListener("resize",l)});const g=h&&f?z4(h,l):null;let v=-1,b=null;c&&(b=new ResizeObserver(N=>{let[M]=N;M&&M.target===h&&b&&n&&(b.unobserve(n),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var j;(j=b)==null||j.observe(n)})),l()}),h&&!d&&b.observe(h),n&&b.observe(n));let k,C=d?li(e):null;d&&E();function E(){const N=li(e);C&&!ww(C,N)&&l(),C=N,k=requestAnimationFrame(E)}return l(),()=>{var N;y.forEach(M=>{o&&M.removeEventListener("scroll",l),s&&M.removeEventListener("resize",l)}),g==null||g(),(N=b)==null||N.disconnect(),b=null,d&&cancelAnimationFrame(k)}}const B4=h4,U4=p4,H4=c4,P4=g4,I4=f4,pb=u4,q4=m4,F4=(e,n,l)=>{const i=new Map,o={platform:_4,...l},s={...o.platform,_c:i};return s4(e,n,{...o,platform:s})};var V4=typeof document<"u",G4=function(){},ju=V4?w.useLayoutEffect:G4;function Iu(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let l,i,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(l=e.length,l!==n.length)return!1;for(i=l;i--!==0;)if(!Iu(e[i],n[i]))return!1;return!0}if(o=Object.keys(e),l=o.length,l!==Object.keys(n).length)return!1;for(i=l;i--!==0;)if(!{}.hasOwnProperty.call(n,o[i]))return!1;for(i=l;i--!==0;){const s=o[i];if(!(s==="_owner"&&e.$$typeof)&&!Iu(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}function Sw(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mb(e,n){const l=Sw(e);return Math.round(n*l)/l}function uh(e){const n=w.useRef(e);return ju(()=>{n.current=e}),n}function Y4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:l="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:c}={},transform:f=!0,whileElementsMounted:d,open:h}=e,[y,g]=w.useState({x:0,y:0,strategy:l,placement:n,middlewareData:{},isPositioned:!1}),[v,b]=w.useState(i);Iu(v,i)||b(i);const[k,C]=w.useState(null),[E,N]=w.useState(null),M=w.useCallback(le=>{le!==O.current&&(O.current=le,C(le))},[]),j=w.useCallback(le=>{le!==P.current&&(P.current=le,N(le))},[]),D=s||k,I=c||E,O=w.useRef(null),P=w.useRef(null),q=w.useRef(y),re=d!=null,H=uh(d),J=uh(o),ne=uh(h),W=w.useCallback(()=>{if(!O.current||!P.current)return;const le={placement:n,strategy:l,middleware:v};J.current&&(le.platform=J.current),F4(O.current,P.current,le).then(de=>{const R={...de,isPositioned:ne.current!==!1};Z.current&&!Iu(q.current,R)&&(q.current=R,kl.flushSync(()=>{g(R)}))})},[v,n,l,J,ne]);ju(()=>{h===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,g(le=>({...le,isPositioned:!1})))},[h]);const Z=w.useRef(!1);ju(()=>(Z.current=!0,()=>{Z.current=!1}),[]),ju(()=>{if(D&&(O.current=D),I&&(P.current=I),D&&I){if(H.current)return H.current(D,I,W);W()}},[D,I,W,H,re]);const Q=w.useMemo(()=>({reference:O,floating:P,setReference:M,setFloating:j}),[M,j]),B=w.useMemo(()=>({reference:D,floating:I}),[D,I]),Y=w.useMemo(()=>{const le={position:l,left:0,top:0};if(!B.floating)return le;const de=mb(B.floating,y.x),R=mb(B.floating,y.y);return f?{...le,transform:"translate("+de+"px, "+R+"px)",...Sw(B.floating)>=1.5&&{willChange:"transform"}}:{position:l,left:de,top:R}},[l,f,B.floating,y.x,y.y]);return w.useMemo(()=>({...y,update:W,refs:Q,elements:B,floatingStyles:Y}),[y,W,Q,B,Y])}const $4=e=>{function n(l){return{}.hasOwnProperty.call(l,"current")}return{name:"arrow",options:e,fn(l){const{element:i,padding:o}=typeof e=="function"?e(l):e;return i&&n(i)?i.current!=null?pb({element:i.current,padding:o}).fn(l):{}:i?pb({element:i,padding:o}).fn(l):{}}}},X4=(e,n)=>{const l=B4(e);return{name:l.name,fn:l.fn,options:[e,n]}},Q4=(e,n)=>{const l=U4(e);return{name:l.name,fn:l.fn,options:[e,n]}},K4=(e,n)=>({fn:q4(e).fn,options:[e,n]}),Z4=(e,n)=>{const l=H4(e);return{name:l.name,fn:l.fn,options:[e,n]}},J4=(e,n)=>{const l=P4(e);return{name:l.name,fn:l.fn,options:[e,n]}},W4=(e,n)=>{const l=I4(e);return{name:l.name,fn:l.fn,options:[e,n]}},e3=(e,n)=>{const l=$4(e);return{name:l.name,fn:l.fn,options:[e,n]}};var t3="Arrow",Cw=w.forwardRef((e,n)=>{const{children:l,width:i=10,height:o=5,...s}=e;return x.jsx(Yt.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?l:x.jsx("polygon",{points:"0,0 30,0 15,10"})})});Cw.displayName=t3;var n3=Cw;function r3(e){const[n,l]=w.useState(void 0);return El(()=>{if(e){l({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let c,f;if("borderBoxSize"in s){const d=s.borderBoxSize,h=Array.isArray(d)?d[0]:d;c=h.inlineSize,f=h.blockSize}else c=e.offsetWidth,f=e.offsetHeight;l({width:c,height:f})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else l(void 0)},[e]),n}var Ip="Popper",[kw,hc]=rc(Ip),[l3,Ew]=kw(Ip),Nw=e=>{const{__scopePopper:n,children:l}=e,[i,o]=w.useState(null);return x.jsx(l3,{scope:n,anchor:i,onAnchorChange:o,children:l})};Nw.displayName=Ip;var Aw="PopperAnchor",Tw=w.forwardRef((e,n)=>{const{__scopePopper:l,virtualRef:i,...o}=e,s=Ew(Aw,l),c=w.useRef(null),f=En(n,c),d=w.useRef(null);return w.useEffect(()=>{const h=d.current;d.current=(i==null?void 0:i.current)||c.current,h!==d.current&&s.onAnchorChange(d.current)}),i?null:x.jsx(Yt.div,{...o,ref:f})});Tw.displayName=Aw;var qp="PopperContent",[i3,a3]=kw(qp),Rw=w.forwardRef((e,n)=>{var we,Ae,xe,Ne,rt,tt;const{__scopePopper:l,side:i="bottom",sideOffset:o=0,align:s="center",alignOffset:c=0,arrowPadding:f=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:y=0,sticky:g="partial",hideWhenDetached:v=!1,updatePositionStrategy:b="optimized",onPlaced:k,...C}=e,E=Ew(qp,l),[N,M]=w.useState(null),j=En(n,at=>M(at)),[D,I]=w.useState(null),O=r3(D),P=(O==null?void 0:O.width)??0,q=(O==null?void 0:O.height)??0,re=i+(s!=="center"?"-"+s:""),H=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},J=Array.isArray(h)?h:[h],ne=J.length>0,W={padding:H,boundary:J.filter(s3),altBoundary:ne},{refs:Z,floatingStyles:Q,placement:B,isPositioned:Y,middlewareData:le}=Y4({strategy:"fixed",placement:re,whileElementsMounted:(...at)=>L4(...at,{animationFrame:b==="always"}),elements:{reference:E.anchor},middleware:[X4({mainAxis:o+q,alignmentAxis:c}),d&&Q4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?K4():void 0,...W}),d&&Z4({...W}),J4({...W,apply:({elements:at,rects:Ye,availableWidth:Dt,availableHeight:_t})=>{const{width:Fn,height:Vn}=Ye.reference,zt=at.floating.style;zt.setProperty("--radix-popper-available-width",`${Dt}px`),zt.setProperty("--radix-popper-available-height",`${_t}px`),zt.setProperty("--radix-popper-anchor-width",`${Fn}px`),zt.setProperty("--radix-popper-anchor-height",`${Vn}px`)}}),D&&e3({element:D,padding:f}),u3({arrowWidth:P,arrowHeight:q}),v&&W4({strategy:"referenceHidden",...W})]}),[de,R]=Ow(B),z=ia(k);El(()=>{Y&&(z==null||z())},[Y,z]);const L=(we=le.arrow)==null?void 0:we.x,T=(Ae=le.arrow)==null?void 0:Ae.y,se=((xe=le.arrow)==null?void 0:xe.centerOffset)!==0,[ce,ue]=w.useState();return El(()=>{N&&ue(window.getComputedStyle(N).zIndex)},[N]),x.jsx("div",{ref:Z.setFloating,"data-radix-popper-content-wrapper":"",style:{...Q,transform:Y?Q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[(Ne=le.transformOrigin)==null?void 0:Ne.x,(rt=le.transformOrigin)==null?void 0:rt.y].join(" "),...((tt=le.hide)==null?void 0:tt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:x.jsx(i3,{scope:l,placedSide:de,onArrowChange:I,arrowX:L,arrowY:T,shouldHideArrow:se,children:x.jsx(Yt.div,{"data-side":de,"data-align":R,...C,ref:j,style:{...C.style,animation:Y?void 0:"none"}})})})});Rw.displayName=qp;var jw="PopperArrow",o3={top:"bottom",right:"left",bottom:"top",left:"right"},Mw=w.forwardRef(function(n,l){const{__scopePopper:i,...o}=n,s=a3(jw,i),c=o3[s.placedSide];return x.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[c]: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:x.jsx(n3,{...o,ref:l,style:{...o.style,display:"block"}})})});Mw.displayName=jw;function s3(e){return e!==null}var u3=e=>({name:"transformOrigin",options:e,fn(n){var E,N,M;const{placement:l,rects:i,middlewareData:o}=n,c=((E=o.arrow)==null?void 0:E.centerOffset)!==0,f=c?0:e.arrowWidth,d=c?0:e.arrowHeight,[h,y]=Ow(l),g={start:"0%",center:"50%",end:"100%"}[y],v=(((N=o.arrow)==null?void 0:N.x)??0)+f/2,b=(((M=o.arrow)==null?void 0:M.y)??0)+d/2;let k="",C="";return h==="bottom"?(k=c?g:`${v}px`,C=`${-d}px`):h==="top"?(k=c?g:`${v}px`,C=`${i.floating.height+d}px`):h==="right"?(k=`${-d}px`,C=c?g:`${b}px`):h==="left"&&(k=`${i.floating.width+d}px`,C=c?g:`${b}px`),{data:{x:k,y:C}}}});function Ow(e){const[n,l="center"]=e.split("-");return[n,l]}var Dw=Nw,Fp=Tw,_w=Rw,zw=Mw,c3=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"}),f3="VisuallyHidden",Lw=w.forwardRef((e,n)=>x.jsx(Yt.span,{...e,ref:n,style:{...c3,...e.style}}));Lw.displayName=f3;var d3=Lw,[pc]=rc("Tooltip",[hc]),mc=hc(),Bw="TooltipProvider",h3=700,Gh="tooltip.open",[p3,Vp]=pc(Bw),Uw=e=>{const{__scopeTooltip:n,delayDuration:l=h3,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=e,c=w.useRef(!0),f=w.useRef(!1),d=w.useRef(0);return w.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),x.jsx(p3,{scope:n,isOpenDelayedRef:c,delayDuration:l,onOpen:w.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:w.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,i)},[i]),isPointerInTransitRef:f,onPointerInTransitChange:w.useCallback(h=>{f.current=h},[]),disableHoverableContent:o,children:s})};Uw.displayName=Bw;var jo="Tooltip",[m3,qo]=pc(jo),Hw=e=>{const{__scopeTooltip:n,children:l,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:c,delayDuration:f}=e,d=Vp(jo,e.__scopeTooltip),h=mc(n),[y,g]=w.useState(null),v=vo(),b=w.useRef(0),k=c??d.disableHoverableContent,C=f??d.delayDuration,E=w.useRef(!1),[N,M]=Cp({prop:i,defaultProp:o??!1,onChange:P=>{P?(d.onOpen(),document.dispatchEvent(new CustomEvent(Gh))):d.onClose(),s==null||s(P)},caller:jo}),j=w.useMemo(()=>N?E.current?"delayed-open":"instant-open":"closed",[N]),D=w.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E.current=!1,M(!0)},[M]),I=w.useCallback(()=>{window.clearTimeout(b.current),b.current=0,M(!1)},[M]),O=w.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{E.current=!0,M(!0),b.current=0},C)},[C,M]);return w.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),x.jsx(Dw,{...h,children:x.jsx(m3,{scope:n,contentId:v,open:N,stateAttribute:j,trigger:y,onTriggerChange:g,onTriggerEnter:w.useCallback(()=>{d.isOpenDelayedRef.current?O():D()},[d.isOpenDelayedRef,O,D]),onTriggerLeave:w.useCallback(()=>{k?I():(window.clearTimeout(b.current),b.current=0)},[I,k]),onOpen:D,onClose:I,disableHoverableContent:k,children:l})})};Hw.displayName=jo;var Yh="TooltipTrigger",Pw=w.forwardRef((e,n)=>{const{__scopeTooltip:l,...i}=e,o=qo(Yh,l),s=Vp(Yh,l),c=mc(l),f=w.useRef(null),d=En(n,f,o.onTriggerChange),h=w.useRef(!1),y=w.useRef(!1),g=w.useCallback(()=>h.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),x.jsx(Fp,{asChild:!0,...c,children:x.jsx(Yt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:d,onPointerMove:At(e.onPointerMove,v=>{v.pointerType!=="touch"&&!y.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),y.current=!0)}),onPointerLeave:At(e.onPointerLeave,()=>{o.onTriggerLeave(),y.current=!1}),onPointerDown:At(e.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:At(e.onFocus,()=>{h.current||o.onOpen()}),onBlur:At(e.onBlur,o.onClose),onClick:At(e.onClick,o.onClose)})})});Pw.displayName=Yh;var Gp="TooltipPortal",[g3,y3]=pc(Gp,{forceMount:void 0}),Iw=e=>{const{__scopeTooltip:n,forceMount:l,children:i,container:o}=e,s=qo(Gp,n);return x.jsx(g3,{scope:n,forceMount:l,children:x.jsx(Ml,{present:l||s.open,children:x.jsx(ic,{asChild:!0,container:o,children:i})})})};Iw.displayName=Gp;var oa="TooltipContent",qw=w.forwardRef((e,n)=>{const l=y3(oa,e.__scopeTooltip),{forceMount:i=l.forceMount,side:o="top",...s}=e,c=qo(oa,e.__scopeTooltip);return x.jsx(Ml,{present:i||c.open,children:c.disableHoverableContent?x.jsx(Fw,{side:o,...s,ref:n}):x.jsx(x3,{side:o,...s,ref:n})})}),x3=w.forwardRef((e,n)=>{const l=qo(oa,e.__scopeTooltip),i=Vp(oa,e.__scopeTooltip),o=w.useRef(null),s=En(n,o),[c,f]=w.useState(null),{trigger:d,onClose:h}=l,y=o.current,{onPointerInTransitChange:g}=i,v=w.useCallback(()=>{f(null),g(!1)},[g]),b=w.useCallback((k,C)=>{const E=k.currentTarget,N={x:k.clientX,y:k.clientY},M=C3(N,E.getBoundingClientRect()),j=k3(N,M),D=E3(C.getBoundingClientRect()),I=A3([...j,...D]);f(I),g(!0)},[g]);return w.useEffect(()=>()=>v(),[v]),w.useEffect(()=>{if(d&&y){const k=E=>b(E,y),C=E=>b(E,d);return d.addEventListener("pointerleave",k),y.addEventListener("pointerleave",C),()=>{d.removeEventListener("pointerleave",k),y.removeEventListener("pointerleave",C)}}},[d,y,b,v]),w.useEffect(()=>{if(c){const k=C=>{const E=C.target,N={x:C.clientX,y:C.clientY},M=(d==null?void 0:d.contains(E))||(y==null?void 0:y.contains(E)),j=!N3(N,c);M?v():j&&(v(),h())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[d,y,c,h,v]),x.jsx(Fw,{...e,ref:s})}),[v3,b3]=pc(jo,{isInside:!1}),w3=ZA("TooltipContent"),Fw=w.forwardRef((e,n)=>{const{__scopeTooltip:l,children:i,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:c,...f}=e,d=qo(oa,l),h=mc(l),{onClose:y}=d;return w.useEffect(()=>(document.addEventListener(Gh,y),()=>document.removeEventListener(Gh,y)),[y]),w.useEffect(()=>{if(d.trigger){const g=v=>{const b=v.target;b!=null&&b.contains(d.trigger)&&y()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,y]),x.jsx(lc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:y,children:x.jsxs(_w,{"data-state":d.stateAttribute,...h,...f,ref:n,style:{...f.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:[x.jsx(w3,{children:i}),x.jsx(v3,{scope:l,isInside:!0,children:x.jsx(d3,{id:d.contentId,role:"tooltip",children:o||i})})]})})});qw.displayName=oa;var Vw="TooltipArrow",S3=w.forwardRef((e,n)=>{const{__scopeTooltip:l,...i}=e,o=mc(l);return b3(Vw,l).isInside?null:x.jsx(zw,{...o,...i,ref:n})});S3.displayName=Vw;function C3(e,n){const l=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),o=Math.abs(n.right-e.x),s=Math.abs(n.left-e.x);switch(Math.min(l,i,o,s)){case s:return"left";case o:return"right";case l:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function k3(e,n,l=5){const i=[];switch(n){case"top":i.push({x:e.x-l,y:e.y+l},{x:e.x+l,y:e.y+l});break;case"bottom":i.push({x:e.x-l,y:e.y-l},{x:e.x+l,y:e.y-l});break;case"left":i.push({x:e.x+l,y:e.y-l},{x:e.x+l,y:e.y+l});break;case"right":i.push({x:e.x-l,y:e.y-l},{x:e.x-l,y:e.y+l});break}return i}function E3(e){const{top:n,right:l,bottom:i,left:o}=e;return[{x:o,y:n},{x:l,y:n},{x:l,y:i},{x:o,y:i}]}function N3(e,n){const{x:l,y:i}=e;let o=!1;for(let s=0,c=n.length-1;s<n.length;c=s++){const f=n[s],d=n[c],h=f.x,y=f.y,g=d.x,v=d.y;y>i!=v>i&&l<(g-h)*(i-y)/(v-y)+h&&(o=!o)}return o}function A3(e){const n=e.slice();return n.sort((l,i)=>l.x<i.x?-1:l.x>i.x?1:l.y<i.y?-1:l.y>i.y?1:0),T3(n)}function T3(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(;n.length>=2;){const s=n[n.length-1],c=n[n.length-2];if((s.x-c.x)*(o.y-c.y)>=(s.y-c.y)*(o.x-c.x))n.pop();else break}n.push(o)}n.pop();const l=[];for(let i=e.length-1;i>=0;i--){const o=e[i];for(;l.length>=2;){const s=l[l.length-1],c=l[l.length-2];if((s.x-c.x)*(o.y-c.y)>=(s.y-c.y)*(o.x-c.x))l.pop();else break}l.push(o)}return l.pop(),n.length===1&&l.length===1&&n[0].x===l[0].x&&n[0].y===l[0].y?n:n.concat(l)}var R3=Uw,j3=Hw,M3=Pw,O3=Iw,Gw=qw;const D3=R3,qu=j3,Fu=M3,Mo=w.forwardRef(({className:e,sideOffset:n=4,...l},i)=>x.jsx(O3,{children:x.jsx(Gw,{ref:i,sideOffset:n,className:ye("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),...l})}));Mo.displayName=Gw.displayName;const _3="0.3.0",z3={version:_3},Qt="Kanna",gb="kanna",L3=`kanna/${z3.version}`,B3="[kanna]",U3=`~/${Qt}`;function yu(e){return e?`${gb} ${e}`:gb}const H3={sm:"text-sm px-2.5 py-1",md:"text-sm px-3 py-1.5"};function P3({value:e,onValueChange:n,options:l,size:i="md",className:o,optionClassName:s}){return x.jsx("div",{className:ye("inline-flex items-center rounded-full border border-border p-0.5 ",o),children:l.map(c=>{const f=c.value===e,d=c.icon,h=d?w.isValidElement(d)?d:(()=>{const g=d;return x.jsx(g,{className:i==="sm"?"h-3.5 w-3.5":"h-4 w-4"})})():null,y=x.jsxs("button",{type:"button",onClick:()=>n(c.value),disabled:c.disabled,"aria-pressed":f,className:ye("rounded-full border transition-colors",d?"grid grid-cols-[auto_auto] items-center gap-2":"inline-flex items-center gap-1.5",H3[i],f?"bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 ":"border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",c.disabled&&"opacity-50 pointer-events-none",s),children:[h,x.jsx("span",{children:c.label})]},c.value);return c.tooltip?x.jsxs(qu,{children:[x.jsx(Fu,{asChild:!0,children:y}),x.jsx(Mo,{children:c.tooltip})]},c.value):y})})}function I3(e){return e.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Yw({open:e,onOpenChange:n,onConfirm:l}){const[i,o]=w.useState("new"),[s,c]=w.useState(""),[f,d]=w.useState(""),h=w.useRef(null),y=w.useRef(null);w.useEffect(()=>{e&&(o("new"),c(""),d(""),setTimeout(()=>{var E;return(E=h.current)==null?void 0:E.focus()},0))},[e]),w.useEffect(()=>{e&&setTimeout(()=>{var E,N;i==="new"?(E=h.current)==null||E.focus():(N=y.current)==null||N.focus()},0)},[i,e]);const g=I3(s),v=g?`${U3}/${g}`:"",b=f.trim(),k=i==="new"?!!g:!!b,C=()=>{if(k){if(i==="new")l({mode:"new",localPath:v,title:s.trim()});else{const E=b.split("/").pop()||b;l({mode:"existing",localPath:b,title:E})}n(!1)}};return x.jsx(aw,{open:e,onOpenChange:n,children:x.jsxs(_p,{size:"sm",children:[x.jsxs(uw,{className:"space-y-4",children:[x.jsx(sw,{children:"Add Project"}),x.jsx(P3,{value:i,onValueChange:o,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full",optionClassName:"flex-1 justify-center"}),i==="new"?x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:h,type:"text",value:s,onChange:E=>c(E.target.value),onKeyDown:E=>{E.key==="Enter"&&C(),E.key==="Escape"&&n(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"Project name"}),v&&x.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:v})]}):x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:y,type:"text",value:f,onChange:E=>d(E.target.value),onKeyDown:E=>{E.key==="Enter"&&C(),E.key==="Escape"&&n(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"~/Projects/my-app"}),x.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),x.jsxs(cw,{children:[x.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>n(!1),children:"Cancel"}),x.jsx(Fe,{variant:"secondary",size:"sm",onClick:C,disabled:!k,children:"Create"})]})]})})}const gc=({children:e,className:n,shimmerWidth:l=100,animate:i=!0,...o})=>x.jsx("span",{style:{"--shiny-width":`${Math.min(l,100)}px`},className:ye("mx-auto max-w-md text-foreground/50",i?["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"],n),...o,children:e}),q3=new Set(["starting","running"]);function F3({chat:e,activeChatId:n,onSelectChat:l,onDeleteChat:i}){return x.jsxs("div",{"data-chat-id":Pv(e.chatId),className:ye("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-md cursor-pointer border-border/0 hover:border-border hover:bg-muted active:bg-muted border transition-colors",n===Pv(e.chatId)?"bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>l(e.chatId),children:[q3.has(e.status)?x.jsx(oi,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?x.jsx("div",{className:"relative ",children:x.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[x.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),x.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,x.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?x.jsx(gc,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),x.jsx(Fe,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-100 md:opacity-0 md:group-hover:opacity-100 cursor-pointer rounded-sm hover:!bg-transparent",onClick:o=>{o.stopPropagation(),i(e.chatId)},title:"Delete chat",children:x.jsx(Po,{className:"size-3.5"})})]},e._id)}function V3(){for(var e=arguments.length,n=new Array(e),l=0;l<e;l++)n[l]=arguments[l];return w.useMemo(()=>i=>{n.forEach(o=>o(i))},n)}const yc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pa(e){const n=Object.prototype.toString.call(e);return n==="[object Window]"||n==="[object global]"}function Yp(e){return"nodeType"in e}function cn(e){var n,l;return e?pa(e)?e:Yp(e)&&(n=(l=e.ownerDocument)==null?void 0:l.defaultView)!=null?n:window:window}function $p(e){const{Document:n}=cn(e);return e instanceof n}function Fo(e){return pa(e)?!1:e instanceof cn(e).HTMLElement}function $w(e){return e instanceof cn(e).SVGElement}function ma(e){return e?pa(e)?e.document:Yp(e)?$p(e)?e:Fo(e)||$w(e)?e.ownerDocument:document:document:document}const gr=yc?w.useLayoutEffect:w.useEffect;function Xp(e){const n=w.useRef(e);return gr(()=>{n.current=e}),w.useCallback(function(){for(var l=arguments.length,i=new Array(l),o=0;o<l;o++)i[o]=arguments[o];return n.current==null?void 0:n.current(...i)},[])}function G3(){const e=w.useRef(null),n=w.useCallback((i,o)=>{e.current=setInterval(i,o)},[]),l=w.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[n,l]}function Oo(e,n){n===void 0&&(n=[e]);const l=w.useRef(e);return gr(()=>{l.current!==e&&(l.current=e)},n),l}function Vo(e,n){const l=w.useRef();return w.useMemo(()=>{const i=e(l.current);return l.current=i,i},[...n])}function Vu(e){const n=Xp(e),l=w.useRef(null),i=w.useCallback(o=>{o!==l.current&&(n==null||n(o,l.current)),l.current=o},[]);return[l,i]}function $h(e){const n=w.useRef();return w.useEffect(()=>{n.current=e},[e]),n.current}let ch={};function Go(e,n){return w.useMemo(()=>{if(n)return n;const l=ch[e]==null?0:ch[e]+1;return ch[e]=l,e+"-"+l},[e,n])}function Xw(e){return function(n){for(var l=arguments.length,i=new Array(l>1?l-1:0),o=1;o<l;o++)i[o-1]=arguments[o];return i.reduce((s,c)=>{const f=Object.entries(c);for(const[d,h]of f){const y=s[d];y!=null&&(s[d]=y+e*h)}return s},{...n})}}const ra=Xw(1),Gu=Xw(-1);function Y3(e){return"clientX"in e&&"clientY"in e}function Qp(e){if(!e)return!1;const{KeyboardEvent:n}=cn(e.target);return n&&e instanceof n}function $3(e){if(!e)return!1;const{TouchEvent:n}=cn(e.target);return n&&e instanceof n}function Xh(e){if($3(e)){if(e.touches&&e.touches.length){const{clientX:n,clientY:l}=e.touches[0];return{x:n,y:l}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:n,clientY:l}=e.changedTouches[0];return{x:n,y:l}}}return Y3(e)?{x:e.clientX,y:e.clientY}:null}const Do=Object.freeze({Translate:{toString(e){if(!e)return;const{x:n,y:l}=e;return"translate3d("+(n?Math.round(n):0)+"px, "+(l?Math.round(l):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:n,scaleY:l}=e;return"scaleX("+n+") scaleY("+l+")"}},Transform:{toString(e){if(e)return[Do.Translate.toString(e),Do.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:n,duration:l,easing:i}=e;return n+" "+l+"ms "+i}}}),yb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function X3(e){return e.matches(yb)?e:e.querySelector(yb)}const Q3={display:"none"};function K3(e){let{id:n,value:l}=e;return Nt.createElement("div",{id:n,style:Q3},l)}function Z3(e){let{id:n,announcement:l,ariaLiveType:i="assertive"}=e;const o={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 Nt.createElement("div",{id:n,style:o,role:"status","aria-live":i,"aria-atomic":!0},l)}function J3(){const[e,n]=w.useState("");return{announce:w.useCallback(i=>{i!=null&&n(i)},[]),announcement:e}}const Qw=w.createContext(null);function W3(e){const n=w.useContext(Qw);w.useEffect(()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(e)},[e,n])}function e5(){const[e]=w.useState(()=>new Set),n=w.useCallback(i=>(e.add(i),()=>e.delete(i)),[e]);return[w.useCallback(i=>{let{type:o,event:s}=i;e.forEach(c=>{var f;return(f=c[o])==null?void 0:f.call(c,s)})},[e]),n]}const t5={draggable:`
375
375
  To pick up a draggable item, press the space bar.
376
376
  While dragging, use the arrow keys to move the item.
377
377
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -406,4 +406,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${n.do
406
406
  `))}function d(b,k,C,E){const N=C.enter("tableCell"),M=C.enter("phrasing"),j=C.containerPhrasing(b,{...E,before:s,after:s});return M(),N(),j}function h(b,k){return hL(b,{align:k,alignDelimiters:i,padding:l,stringLength:o})}function y(b,k,C){const E=b.children;let N=-1;const M=[],j=k.enter("table");for(;++N<E.length;)M[N]=g(E[N],k,C);return j(),M}function g(b,k,C){const E=b.children;let N=-1;const M=[],j=k.enter("tableRow");for(;++N<E.length;)M[N]=d(E[N],b,k,C);return j(),M}function v(b,k,C){let E=O2.inlineCode(b,k,C);return C.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function e8(){return{exit:{taskListCheckValueChecked:k0,taskListCheckValueUnchecked:k0,paragraph:n8}}}function t8(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:r8}}}function k0(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function n8(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const l=this.stack[this.stack.length-1];l.type;const i=l.children[0];if(i&&i.type==="text"){const o=n.children;let s=-1,c;for(;++s<o.length;){const f=o[s];if(f.type==="paragraph"){c=f;break}}c===l&&(i.value=i.value.slice(1),i.value.length===0?l.children.shift():l.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,l.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function r8(e,n,l,i){const o=e.children[0],s=typeof e.checked=="boolean"&&o&&o.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",f=l.createTracker(i);s&&f.move(c);let d=O2.listItem(e,n,l,{...i,...f.current()});return s&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(y){return y+c}}function l8(){return[L6(),rL(),oL(),$L(),e8()]}function i8(e){return{extensions:[B6(),lL(e),sL(),WL(e),t8()]}}const a8={tokenize:d8,partial:!0},D2={tokenize:h8,partial:!0},_2={tokenize:p8,partial:!0},z2={tokenize:m8,partial:!0},o8={tokenize:g8,partial:!0},L2={name:"wwwAutolink",tokenize:c8,previous:U2},B2={name:"protocolAutolink",tokenize:f8,previous:H2},Yr={name:"emailAutolink",tokenize:u8,previous:P2},vr={};function s8(){return{text:vr}}let ti=48;for(;ti<123;)vr[ti]=Yr,ti++,ti===58?ti=65:ti===91&&(ti=97);vr[43]=Yr;vr[45]=Yr;vr[46]=Yr;vr[95]=Yr;vr[72]=[Yr,B2];vr[104]=[Yr,B2];vr[87]=[Yr,L2];vr[119]=[Yr,L2];function u8(e,n,l){const i=this;let o,s;return c;function c(g){return!dp(g)||!P2.call(i,i.previous)||km(i.events)?l(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return dp(g)?(e.consume(g),f):g===64?(e.consume(g),d):l(g)}function d(g){return g===46?e.check(o8,y,h)(g):g===45||g===95||Gt(g)?(s=!0,e.consume(g),d):y(g)}function h(g){return e.consume(g),o=!0,d}function y(g){return s&&o&&Kt(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):l(g)}}function c8(e,n,l){const i=this;return o;function o(c){return c!==87&&c!==119||!U2.call(i,i.previous)||km(i.events)?l(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(a8,e.attempt(D2,e.attempt(_2,s),l),l)(c))}function s(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function f8(e,n,l){const i=this;let o="",s=!1;return c;function c(g){return(g===72||g===104)&&H2.call(i,i.previous)&&!km(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):l(g)}function f(g){if(Kt(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(g),d}return l(g)}function d(g){return g===47?(e.consume(g),s?h:(s=!0,d)):l(g)}function h(g){return g===null||Qu(g)||et(g)||ii(g)||kc(g)?l(g):e.attempt(D2,e.attempt(_2,y),l)(g)}function y(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function d8(e,n,l){let i=0;return o;function o(c){return(c===87||c===119)&&i<3?(i++,e.consume(c),o):c===46&&i===3?(e.consume(c),s):l(c)}function s(c){return c===null?l(c):n(c)}}function h8(e,n,l){let i,o,s;return c;function c(h){return h===46||h===95?e.check(z2,d,f)(h):h===null||et(h)||ii(h)||h!==45&&kc(h)?d(h):(s=!0,e.consume(h),c)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),c}function d(h){return o||i||!s?l(h):n(h)}}function p8(e,n){let l=0,i=0;return o;function o(c){return c===40?(l++,e.consume(c),o):c===41&&i<l?s(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(z2,n,s)(c):c===null||et(c)||ii(c)?n(c):(e.consume(c),o)}function s(c){return c===41&&i++,e.consume(c),o}}function m8(e,n,l){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),s):f===93?(e.consume(f),o):f===60||f===null||et(f)||ii(f)?n(f):l(f)}function o(f){return f===null||f===40||f===91||et(f)||ii(f)?n(f):i(f)}function s(f){return Kt(f)?c(f):l(f)}function c(f){return f===59?(e.consume(f),i):Kt(f)?(e.consume(f),c):l(f)}}function g8(e,n,l){return i;function i(s){return e.consume(s),o}function o(s){return Gt(s)?l(s):n(s)}}function U2(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||et(e)}function H2(e){return!Kt(e)}function P2(e){return!(e===47||dp(e))}function dp(e){return e===43||e===45||e===46||e===95||Gt(e)}function km(e){let n=e.length,l=!1;for(;n--;){const i=e[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){l=!0;break}if(i._gfmAutolinkLiteralWalkedInto){l=!1;break}}return e.length>0&&!l&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),l}const y8={tokenize:E8,partial:!0};function x8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:S8,continuation:{tokenize:C8},exit:k8}},text:{91:{name:"gfmFootnoteCall",tokenize:w8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:v8,resolveTo:b8}}}}function v8(e,n,l){const i=this;let o=i.events.length;const s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;o--;){const d=i.events[o][1];if(d.type==="labelImage"){c=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return f;function f(d){if(!c||!c._balanced)return l(d);const h=Jn(i.sliceSerialize({start:c.end,end:i.now()}));return h.codePointAt(0)!==94||!s.includes(h.slice(1))?l(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),n(d))}}function b8(e,n){let l=e.length;for(;l--;)if(e[l][1].type==="labelImage"&&e[l][0]==="enter"){e[l][1];break}e[l+1][1].type="data",e[l+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[l+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[l+3][1].end),end:Object.assign({},e[l+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},f=[e[l+1],e[l+2],["enter",i,n],e[l+3],e[l+4],["enter",o,n],["exit",o,n],["enter",s,n],["enter",c,n],["exit",c,n],["exit",s,n],e[e.length-2],e[e.length-1],["exit",i,n]];return e.splice(l,e.length-l+1,...f),e}function w8(e,n,l){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s=0,c;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),d}function d(g){return g!==94?l(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(s>999||g===93&&!c||g===null||g===91||et(g))return l(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(Jn(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):l(g)}return et(g)||(c=!0),s++,e.consume(g),g===92?y:h}function y(g){return g===91||g===92||g===93?(e.consume(g),s++,h):h(g)}}function S8(e,n,l){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let s,c=0,f;return d;function d(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",y):l(k)}function y(k){if(c>999||k===93&&!f||k===null||k===91||et(k))return l(k);if(k===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return s=Jn(i.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return et(k)||(f=!0),c++,e.consume(k),k===92?g:y}function g(k){return k===91||k===92||k===93?(e.consume(k),c++,y):y(k)}function v(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),o.includes(s)||o.push(s),Pe(e,b,"gfmFootnoteDefinitionWhitespace")):l(k)}function b(k){return n(k)}}function C8(e,n,l){return e.check(Xo,n,e.attempt(y8,n,l))}function k8(e){e.exit("gfmFootnoteDefinition")}function E8(e,n,l){const i=this;return Pe(e,o,"gfmFootnoteDefinitionIndent",5);function o(s){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(s):l(s)}}function N8(e){let l=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:s,resolveAll:o};return l==null&&(l=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(c,f){let d=-1;for(;++d<c.length;)if(c[d][0]==="enter"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._close){let h=d;for(;h--;)if(c[h][0]==="exit"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._open&&c[d][1].end.offset-c[d][1].start.offset===c[h][1].end.offset-c[h][1].start.offset){c[d][1].type="strikethroughSequence",c[h][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[d][1].end)},g={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[d][1].start)},v=[["enter",y,f],["enter",c[h][1],f],["exit",c[h][1],f],["enter",g,f]],b=f.parser.constructs.insideSpan.null;b&&kn(v,v.length,0,Ec(b,c.slice(h+1,d),f)),kn(v,v.length,0,[["exit",g,f],["enter",c[d][1],f],["exit",c[d][1],f],["exit",y,f]]),kn(c,h-1,d-h+3,v),d=h+v.length-2;break}}for(d=-1;++d<c.length;)c[d][1].type==="strikethroughSequenceTemporary"&&(c[d][1].type="data");return c}function s(c,f,d){const h=this.previous,y=this.events;let g=0;return v;function v(k){return h===126&&y[y.length-1][1].type!=="characterEscape"?d(k):(c.enter("strikethroughSequenceTemporary"),b(k))}function b(k){const C=ua(h);if(k===126)return g>1?d(k):(c.consume(k),g++,b);if(g<2&&!l)return d(k);const E=c.exit("strikethroughSequenceTemporary"),N=ua(k);return E._open=!N||N===2&&!!C,E._close=!C||C===2&&!!N,f(k)}}}class A8{constructor(){this.map=[]}add(n,l,i){T8(this,n,l,i)}consume(n){if(this.map.sort(function(s,c){return s[0]-c[0]}),this.map.length===0)return;let l=this.map.length;const i=[];for(;l>0;)l-=1,i.push(n.slice(this.map[l][0]+this.map[l][1]),this.map[l][2]),n.length=this.map[l][0];i.push(n.slice()),n.length=0;let o=i.pop();for(;o;){for(const s of o)n.push(s);o=i.pop()}this.map.length=0}}function T8(e,n,l,i){let o=0;if(!(l===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===n){e.map[o][1]+=l,e.map[o][2].push(...i);return}o+=1}e.map.push([n,l,i])}}function R8(e,n){let l=!1;const i=[];for(;n<e.length;){const o=e[n];if(l){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const s=i.length-1;i[s]=i[s]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(l=!0);n+=1}return i}function j8(){return{flow:{null:{name:"table",tokenize:M8,resolveAll:O8}}}}function M8(e,n,l){const i=this;let o=0,s=0,c;return f;function f(H){let J=i.events.length-1;for(;J>-1;){const Z=i.events[J][1].type;if(Z==="lineEnding"||Z==="linePrefix")J--;else break}const ne=J>-1?i.events[J][1].type:null,W=ne==="tableHead"||ne==="tableRow"?O:d;return W===O&&i.parser.lazy[i.now().line]?l(H):W(H)}function d(H){return e.enter("tableHead"),e.enter("tableRow"),h(H)}function h(H){return H===124||(c=!0,s+=1),y(H)}function y(H){return H===null?l(H):Ce(H)?s>1?(s=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):l(H):Le(H)?Pe(e,y,"whitespace")(H):(s+=1,c&&(c=!1,o+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),c=!0,y):(e.enter("data"),g(H)))}function g(H){return H===null||H===124||et(H)?(e.exit("data"),y(H)):(e.consume(H),H===92?v:g)}function v(H){return H===92||H===124?(e.consume(H),g):g(H)}function b(H){return i.interrupt=!1,i.parser.lazy[i.now().line]?l(H):(e.enter("tableDelimiterRow"),c=!1,Le(H)?Pe(e,k,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):k(H))}function k(H){return H===45||H===58?E(H):H===124?(c=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),C):I(H)}function C(H){return Le(H)?Pe(e,E,"whitespace")(H):E(H)}function E(H){return H===58?(s+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),N):H===45?(s+=1,N(H)):H===null||Ce(H)?D(H):I(H)}function N(H){return H===45?(e.enter("tableDelimiterFiller"),M(H)):I(H)}function M(H){return H===45?(e.consume(H),M):H===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(H))}function j(H){return Le(H)?Pe(e,D,"whitespace")(H):D(H)}function D(H){return H===124?k(H):H===null||Ce(H)?!c||o!==s?I(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(H)):I(H)}function I(H){return l(H)}function O(H){return e.enter("tableRow"),P(H)}function P(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),P):H===null||Ce(H)?(e.exit("tableRow"),n(H)):Le(H)?Pe(e,P,"whitespace")(H):(e.enter("data"),q(H))}function q(H){return H===null||H===124||et(H)?(e.exit("data"),P(H)):(e.consume(H),H===92?re:q)}function re(H){return H===92||H===124?(e.consume(H),q):q(H)}}function O8(e,n){let l=-1,i=!0,o=0,s=[0,0,0,0],c=[0,0,0,0],f=!1,d=0,h,y,g;const v=new A8;for(;++l<e.length;){const b=e[l],k=b[1];b[0]==="enter"?k.type==="tableHead"?(f=!1,d!==0&&(E0(v,n,d,h,y),y=void 0,d=0),h={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},v.add(l,0,[["enter",h,n]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(i=!0,g=void 0,s=[0,0,0,0],c=[0,l+1,0,0],f&&(f=!1,y={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},v.add(l,0,[["enter",y,n]])),o=k.type==="tableDelimiterRow"?2:y?3:1):o&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(s[1]!==0&&(c[0]=c[1],g=Cu(v,n,s,o,void 0,g),s=[0,0,0,0]),c[2]=l)):k.type==="tableCellDivider"&&(i?i=!1:(s[1]!==0&&(c[0]=c[1],g=Cu(v,n,s,o,void 0,g)),s=c,c=[s[1],l,0,0])):k.type==="tableHead"?(f=!0,d=l):k.type==="tableRow"||k.type==="tableDelimiterRow"?(d=l,s[1]!==0?(c[0]=c[1],g=Cu(v,n,s,o,l,g)):c[1]!==0&&(g=Cu(v,n,c,o,l,g)),o=0):o&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(c[3]=l)}for(d!==0&&E0(v,n,d,h,y),v.consume(n.events),l=-1;++l<n.events.length;){const b=n.events[l];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=R8(n.events,l))}return e}function Cu(e,n,l,i,o,s){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";l[0]!==0&&(s.end=Object.assign({},ea(n.events,l[0])),e.add(l[0],0,[["exit",s,n]]));const d=ea(n.events,l[1]);if(s={type:c,start:Object.assign({},d),end:Object.assign({},d)},e.add(l[1],0,[["enter",s,n]]),l[2]!==0){const h=ea(n.events,l[2]),y=ea(n.events,l[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},y)};if(e.add(l[2],0,[["enter",g,n]]),i!==2){const v=n.events[l[2]],b=n.events[l[3]];if(v[1].end=Object.assign({},b[1].end),v[1].type="chunkText",v[1].contentType="text",l[3]>l[2]+1){const k=l[2]+1,C=l[3]-l[2]-1;e.add(k,C,[])}}e.add(l[3]+1,0,[["exit",g,n]])}return o!==void 0&&(s.end=Object.assign({},ea(n.events,o)),e.add(o,0,[["exit",s,n]]),s=void 0),s}function E0(e,n,l,i,o){const s=[],c=ea(n.events,l);o&&(o.end=Object.assign({},c),s.push(["exit",o,n])),i.end=Object.assign({},c),s.push(["exit",i,n]),e.add(l+1,0,s)}function ea(e,n){const l=e[n],i=l[0]==="enter"?"start":"end";return l[1][i]}const D8={name:"tasklistCheck",tokenize:z8};function _8(){return{text:{91:D8}}}function z8(e,n,l){const i=this;return o;function o(d){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?l(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),s)}function s(d){return et(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),c):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),c):l(d)}function c(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):l(d)}function f(d){return Ce(d)?n(d):Le(d)?e.check({tokenize:L8},n,l)(d):l(d)}}function L8(e,n,l){return Pe(e,i,"whitespace");function i(o){return o===null?l(o):n(o)}}function B8(e){return ZS([s8(),x8(),N8(e),j8(),_8()])}const U8={};function jc(e){const n=this,l=e||U8,i=n.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),s=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(B8(l)),s.push(l8()),c.push(i8(l))}function H8({content:e}){return x.jsx("div",{className:"flex gap-2 justify-end",children:x.jsx("div",{className:"max-w-[85%] sm:max-w-[80%] rounded-[20px] py-1.5 px-3.5 bg-muted text-primary border border-border prose prose-sm prose-invert [&_p]:whitespace-pre-line",children:x.jsx(Rc,{remarkPlugins:[jc],components:Cc,children:e})})})}function P8({json:e}){return x.jsx("div",{className:"flex gap-3 justify-start",children:x.jsx("div",{className:"flex-1 max-w-[90%]",children:x.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted rounded-lg p-3 overflow-auto max-h-96",children:e})})})}function I2({title:e,count:n,children:l,badge:i}){const[o,s]=w.useState(!1);return n===0?null:x.jsxs("div",{className:"flex flex-col gap-1.5",children:[x.jsxs("button",{onClick:()=>s(!o),className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[x.jsx(Nl,{className:ye("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",o&&"rotate-90")}),x.jsx("span",{className:"text-muted-foreground font-medium",children:e}),x.jsx("span",{className:"text-muted-foreground/60",children:n}),i]}),o&&x.jsx("div",{className:"ml-5",children:l})]})}function Mh({title:e,items:n,icon:l,getIcon:i}){return n.length===0?null:x.jsx(I2,{title:e,count:n.length,children:x.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.map(o=>x.jsx(zS,{icon:i?i(o):l,children:o},o))})})}function I8(e){const n=e.match(/^mcp__([^_]+)__(.+)$/);return n?{server:n[1],tool:n[2]}:null}function q2({status:e}){const n=e==="connected"?"bg-emerald-500":e==="pending"?"bg-yellow-500":"bg-red-500";return x.jsx("span",{className:ye("inline-block h-2 w-2 rounded-full shrink-0",n)})}function q8(e){switch(e){case"connected":return"Connected";case"failed":return"Failed";case"needs-auth":return"Needs auth";case"pending":return"Connecting...";case"disabled":return"Disabled";default:return e}}function N0({server:e}){const[n,l]=w.useState(!1),i=e.status==="connected";return x.jsxs("div",{className:"flex flex-col gap-1.5",children:[x.jsxs("button",{onClick:()=>i&&e.tools.length>0&&l(!n),className:ye("flex items-center gap-1.5",i&&e.tools.length>0&&"cursor-pointer hover:opacity-60 transition-opacity"),children:[i&&e.tools.length>0&&x.jsx(Nl,{className:ye("h-3 w-3 text-muted-foreground transition-transform duration-200",n&&"rotate-90")}),x.jsx(q2,{status:e.status}),x.jsx("span",{className:"text-muted-foreground font-medium",children:Jh(e.name)}),i?x.jsxs("span",{className:"text-muted-foreground/50",children:[e.tools.length," tools"]}):x.jsx("span",{className:"text-muted-foreground/50",children:q8(e.status)})]}),!i&&e.error&&x.jsx("span",{className:"text-destructive ml-5",children:e.error}),n&&e.tools.length>0&&x.jsx("div",{className:"flex flex-wrap gap-1.5 ml-5",children:e.tools.map(o=>x.jsx(zS,{icon:_S(`mcp__${e.name}__${o}`),children:o},o))})]})}function F8({servers:e}){if(e.length===0)return null;const n=e.filter(o=>o.status==="connected"),l=e.filter(o=>o.status!=="connected"),i=l.length>0?x.jsxs("span",{className:"flex items-center gap-1 ml-1",children:[x.jsx(q2,{status:"failed"}),x.jsxs("span",{className:"text-muted-foreground/60",children:[l.length," disconnected"]})]}):null;return x.jsx(I2,{title:"MCP Servers",count:e.length,badge:i,children:x.jsxs("div",{className:"flex flex-col gap-2",children:[n.map(o=>x.jsx(N0,{server:o},o.name)),l.map(o=>x.jsx(N0,{server:o},o.name))]})})}function V8({rawJson:e}){const[n,l]=w.useState(!1);return x.jsxs("div",{className:"flex flex-col gap-1.5",children:[x.jsxs("button",{onClick:()=>l(!n),className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[x.jsx(Nl,{className:ye("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",n&&"rotate-90")}),x.jsx("span",{className:"text-muted-foreground font-medium",children:"Raw Message"})]}),n&&x.jsx("pre",{className:"ml-5 text-xs whitespace-pre-wrap break-all border border-border rounded-md p-3 overflow-x-auto max-h-96 overflow-y-auto",children:e})]})}function G8({message:e,rawJson:n}){const{coreTools:l,mcpServersWithTools:i}=w.useMemo(()=>{const o=new Map,s=[];for(const f of e.tools){const d=I8(f);if(d){const h=o.get(d.server)||[];h.push(d.tool),o.set(d.server,h)}else s.push(f)}const c=e.mcpServers.map(f=>({name:f.name,status:f.status,error:f.error,tools:o.get(f.name)||[]}));return{coreTools:s,mcpServersWithTools:c}},[e.tools,e.mcpServers]);return x.jsx(Dl,{children:x.jsxs(wc,{expandedContent:x.jsx(Sc,{className:"my-4 text-xs",children:x.jsxs("div",{className:"flex flex-col gap-3",children:[x.jsx(hO,{children:e.model}),x.jsx(Mh,{title:"Tools",items:l,getIcon:o=>tp[o]??DS}),x.jsx(Mh,{title:"Agents",items:e.agents,icon:Dp}),x.jsx(Mh,{title:"Commands",items:e.slashCommands,icon:Dj}),x.jsx(F8,{servers:i}),n&&x.jsx(V8,{rawJson:n})]})}),children:[x.jsx(LR,{className:"h-5 w-5 text-logo"}),x.jsx(Rl,{children:"Session Started"})]})})}function Y8({message:e}){return x.jsx(Dl,{className:"hidden",children:x.jsxs(wc,{expandedContent:x.jsx(Sc,{className:"my-4 text-xs",children:x.jsx("pre",{className:"font-mono whitespace-pre-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto",children:JSON.stringify(e.accountInfo,null,2)})}),children:[x.jsx("div",{className:"size-5 flex justify-center items-center ",children:x.jsx(Dp,{className:"h-4 w-4 text-muted-foreground"})}),x.jsx(Rl,{children:"Account"})]})})}function $8({message:e}){return x.jsx("div",{className:"text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-full space-y-4",children:x.jsx(Rc,{remarkPlugins:[jc],components:Cc,children:e.text})})}function X8({question:e,currentIndex:n,totalQuestions:l,onBack:i,children:o}){const s=i&&n>0;return x.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[x.jsxs("div",{className:"relative",children:[x.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border text-foreground flex flex-row items-center gap-2",children:[s?x.jsx("button",{onClick:i,className:" text-muted-foreground hover:opacity-60 transition-all flex items-center",children:x.jsx(YR,{className:"h-4 w-4 -ml-0.5",strokeWidth:3})}):l>1?x.jsxs("span",{className:"font-bold text-muted-foreground whitespace-nowrap",children:[n+1," of ",l]}):null,e]}),l>1&&x.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-border",children:x.jsx("div",{className:"h-full bg-muted-foreground/40 transition-all duration-300",style:{width:`${n/l*100}%`}})})]}),o]})}function A0({label:e,description:n}){return x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"text-foreground text-sm",children:e}),n&&x.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:n})]})}function F2({selected:e,multiSelect:n,onClick:l}){return x.jsx("button",{type:"button",onClick:l,className:ye("flex-shrink-0 w-5 h-5 border-1 flex items-center justify-center",n?"rounded":"rounded-full",e?"border-slate-500/0 bg-foreground":"border-muted-foreground/50 bg-background",l&&e&&"cursor-pointer"),children:e&&x.jsx(ri,{strokeWidth:3,className:"translate-y-[0.5px] h-3 w-3 text-white dark:text-background"})})}function Q8({option:e,selected:n,multiSelect:l,onClick:i,isLast:o}){const s="w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background",c=o?"":"border-b border-border";return i?x.jsx("button",{onClick:i,className:ye(s,c,"transition-all cursor-pointer"),children:x.jsxs("div",{className:"flex items-center justify-between gap-3",children:[x.jsx("div",{className:"flex-1 min-w-0",children:x.jsx(A0,{label:e.label,description:e.description})}),x.jsx(F2,{selected:n,multiSelect:l})]})}):x.jsx("div",{className:ye(s,c),children:x.jsx(A0,{label:e.label,description:e.description})})}function K8(e){return e==null?void 0:e.answers}function Kn(e){return e.id||e.question}function Z8({message:e,onSubmit:n,isLatest:l}){var ne;const i=e.input.questions,o=!!e.result,s=K8(e.result),[c,f]=w.useState(0),[d,h]=w.useState({}),[y,g]=w.useState({}),[v,b]=w.useState(o),k=(W,Z)=>{var le;const Q=(le=y[W])==null?void 0:le.trim(),B=d[W]||"",Y=Z||i.find(de=>Kn(de)===W);return Y!=null&&Y.multiSelect?[B,Q].filter(Boolean).join(", "):Q||B},C=W=>{const Z=d[Kn(W)]||"";return W.multiSelect?Z.split(", ").filter(Boolean):[Z]},E=(W,Z)=>{const Q=Kn(W);if(W.multiSelect){const B=d[Q]?d[Q].split(", ").filter(Boolean):[],Y=B.includes(Z)?B.filter(le=>le!==Z):[...B,Z];h({...d,[Q]:Y.join(", ")})}else h({...d,[Q]:Z}),g({...y,[Q]:""}),c<i.length-1&&setTimeout(()=>f(c+1),150)},N=(W,Z)=>{const Q=Kn(W);g({...y,[Q]:Z}),Z&&!W.multiSelect&&h({...d,[Q]:""})},M=W=>{const Z=Kn(W);W.multiSelect&&y[Z]&&g({...y,[Z]:""})},j=i.every(W=>k(Kn(W),W).length>0),D=i[c],I=c===i.length-1,O=D&&k(Kn(D),D).length>0,P=()=>{c<i.length-1&&f(c+1)},q=()=>{c>0&&f(c-1)},re=()=>{if(!j)return;const W={};for(const Z of i){const Q=Kn(Z);W[Q]=k(Q,Z)}h(W),b(!0),n(e.toolId,i,W)};if(v||o){const W=s||d;return x.jsx("div",{className:"w-full",children:x.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[x.jsxs("div",{className:"font-medium text-sm p-3 px-4 pr-5 bg-muted border-b border-border flex flex-row items-center justify-between",children:[x.jsxs("p",{children:["Question",i.length!==1?"s":""]}),x.jsx("p",{className:"",children:"Answers"})]}),i.map((Z,Q)=>{const B=W[Kn(Z)]||W[Z.question]||"",Y=Q===i.length-1;return x.jsxs("div",{className:ye("w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-center justify-between gap-3",!Y&&"border-b border-border"),children:[x.jsx("span",{className:"text-sm",children:Z.question}),B&&x.jsx("span",{className:"text-sm font-medium text-right",children:B}),!B&&x.jsx("span",{className:"text-sm font-medium text-right italic",children:"No Response"})]},Kn(Z))})]})})}if(!l)return x.jsx("div",{className:"w-full py-2",children:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(nw,{className:"h-4 w-4 text-muted-foreground"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:"Questions pending (newer question active)"})]})});if(!D)return null;const H=C(D),J=y[Kn(D)]||"";return x.jsxs("div",{className:"w-full space-y-3",children:[x.jsxs(X8,{question:D.question,currentIndex:c,totalQuestions:i.length,onBack:c>0?q:void 0,children:[(ne=D.options)==null?void 0:ne.map(W=>x.jsx(Q8,{option:W,selected:H.includes(W.label),multiSelect:D.multiSelect,onClick:()=>E(D,W.label)},W.label)),x.jsx("div",{className:"transition-all bg-background",children:x.jsxs("div",{className:"flex pr-5 items-center justify-between gap-3",children:[x.jsx("input",{type:"text",value:J,onChange:W=>N(D,W.target.value),placeholder:"Other...",className:"flex-1 px-3 !py-1 pl-4 min-h-[55px] min-w-0 text-sm bg-transparent outline-none text-foreground placeholder:text-muted-foreground"}),x.jsx(F2,{selected:!!J,multiSelect:D.multiSelect,onClick:D.multiSelect&&J?()=>M(D):void 0})]})})]}),x.jsxs("div",{className:"flex justify-end gap-2 mx-2",children:[!I&&O&&(D.multiSelect||!!J)&&x.jsx(Fe,{size:"sm",onClick:P,children:"Next"}),I&&x.jsx(Fe,{size:"sm",onClick:re,disabled:!j,className:ye(!j&&"opacity-50 cursor-not-allowed","rounded-full"),children:"Submit"})]})]})}function J8({message:e,onConfirm:n}){const l=!!e.result,[i,o]=w.useState(!1),[s,c]=w.useState(!1),[f,d]=w.useState(!1),[h,y]=w.useState(""),g=w.useRef(null),v=e.input;w.useEffect(()=>{f&&g.current&&g.current.focus()},[f]);const b=async()=>{v!=null&&v.plan&&(await navigator.clipboard.writeText(v.plan),c(!0),setTimeout(()=>c(!1),2e3))},k=l?e.result:null;return x.jsxs("div",{className:"flex flex-col gap-3",children:[x.jsxs("div",{className:"relative rounded-2xl border border-border overflow-hidden group/plan",children:[(v==null?void 0:v.plan)&&x.jsx(Fe,{variant:"ghost",size:"icon",className:ye("absolute top-2 right-2 z-10 h-8 w-8 rounded-md text-muted-foreground opacity-0 group-hover/plan:opacity-100 transition-opacity",!s&&"hover:text-foreground",s&&"hover:!bg-transparent hover:!border-transparent"),onClick:b,children:s?x.jsx(ri,{className:"h-4 w-4 text-green-400"}):x.jsx(sc,{className:"h-4 w-4"})}),x.jsxs("div",{className:ye("!pt-5 !pb-0 px-4 md:py-4.5 md:px-5.5 bg-muted dark:bg-card overflow-scroll no-pre-highlight transition-all",l&&!i?"max-h-[min(400px,40vh)] ":"",l?"hover:!pb-[32px]":""),children:[l&&x.jsxs(Fe,{variant:"ghost",className:"absolute z-10 bottom-2 pr-2.5 !pl-3.5 h-[34px] inline-flex gap-1 text-sm left-[50%] -translate-x-[50%] text-muted-foreground backdrop-blur-sm hover:text-foreground opacity-0 group-hover/plan:opacity-100 transition-all rounded-full border border-border",onClick:()=>o(!i),children:[i?"Show Less":"Show More",x.jsx(VR,{className:`size-3.5 transition-transform ${i?"rotate-180":""}`})]}),v!=null&&v.plan?x.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:[x.jsx(Rc,{remarkPlugins:[jc],components:pO,children:v.plan}),x.jsx("div",{className:"mt-5"})]}):x.jsx("p",{className:"text-sm text-muted-foreground",children:"No plan provided"})]})]}),l?x.jsx("div",{className:"flex justify-end mx-2",children:x.jsxs("span",{className:"pl-4 inline text-sm font-medium bg-background text-foreground/60 border border-border py-1.5 px-3 rounded-[20px] leading-relaxed max-w-[85%] sm:max-w-[80%]",children:[x.jsx("em",{children:k!=null&&k.clearContext?"Approved & Cleared Context":k!=null&&k.confirmed?"Approved":k!=null&&k.message?`Adjusted: "${k.message}"`:"Adjusted Plan"}),x.jsx(rj,{className:"inline h-4 w-4 ml-1.5 -mt-0.5"})]})}):x.jsxs("div",{className:"flex flex-col gap-3",children:[!f&&x.jsxs("div",{className:"flex flex-col md:flex-row items-stretch md:items-center justify-end gap-2 mx-2",children:[x.jsxs(Fe,{size:"sm",onClick:()=>n(e.toolId,!0,!0),className:"rounded-full bg-primary text-background pr-4 md:order-last",children:[x.jsx(HR,{className:"h-4 w-4 mr-1.5"}),"Approve & Clear"]}),x.jsxs("div",{className:"flex items-stretch md:items-center gap-2 md:contents",children:[x.jsxs(Fe,{size:"sm",variant:"outline",onClick:()=>d(!0),className:"rounded-full border-border flex-1 md:flex-initial md:order-first",children:[x.jsx(lw,{className:"h-4 w-4 mr-1.5"}),"Suggest Edits"]}),x.jsxs(Fe,{size:"sm",variant:"outline",onClick:()=>n(e.toolId,!0),className:"rounded-full border-border flex-1 md:flex-initial",children:[x.jsx(ri,{className:"h-4 w-4 mr-1.5"}),"Approve"]})]})]}),f&&x.jsxs("div",{className:"flex flex-col gap-2",children:[x.jsx("textarea",{ref:g,value:h,onChange:C=>y(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&h.trim()&&(C.preventDefault(),n(e.toolId,!1,void 0,h.trim())),C.key==="Escape"&&(d(!1),y(""))},placeholder:"Describe what you'd like to change...",rows:3,className:"w-full rounded-2xl border border-border bg-muted dark:bg-card px-4 py-3 text-sm text-foreground placeholder:text-muted-foreground resize-none outline-none"}),x.jsxs("div",{className:"flex items-center justify-end gap-2 mx-2",children:[x.jsx(Fe,{size:"sm",variant:"ghost",onClick:()=>{d(!1),y("")},className:"rounded-full text-muted-foreground",children:"Cancel"}),x.jsxs(Fe,{size:"sm",disabled:!h.trim(),onClick:()=>n(e.toolId,!1,void 0,h.trim()),className:"rounded-full bg-primary text-background disabled:opacity-50 disabled:pointer-events-none",children:[x.jsx(Mj,{className:"h-4 w-4 mr-1.5"}),"Adjust Plan"]})]})]})]})]})}const W8={completed:{Icon:ri,iconClass:"text-emerald-500",textClass:"text-muted-foreground"},in_progress:{Icon:oi,iconClass:"text-foreground animate-spin",textClass:"text-foreground font-medium"},pending:{Icon:ZR,iconClass:"text-muted-foreground",textClass:"text-muted-foreground"}};function e9({message:e}){const n=e.input.todos;return n.length?x.jsx("div",{className:"w-full",children:x.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[x.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2",children:[x.jsx(yj,{className:"h-4 w-4 text-muted-foreground"}),"Progress"]}),x.jsx("div",{children:n.map((l,i)=>{const o=i===n.length-1,{Icon:s,iconClass:c,textClass:f}=W8[l.status];return x.jsxs("div",{className:ye("flex items-center gap-3 px-4 py-2.5 bg-background",!o&&"border-b border-border"),children:[x.jsx(s,{className:ye("h-4 w-4 flex-shrink-0",c)}),x.jsx("span",{className:ye("text-sm",f),children:l.status==="in_progress"?l.activeForm:l.content})]},i)})})]})}):null}function Oh(e,n){if(!e)return"";if(n){const l=n.endsWith("/")?n:`${n}/`;if(e.startsWith(l))return e.slice(l.length);if(e===n)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function t9(e){const n=e.split(`
407
407
  `),l=/^\s*(\d+)→(.*)$/;return n.map(i=>{const o=i.match(l);return o?{lineNumber:parseInt(o[1],10),content:o[2]}:{lineNumber:null,content:i}})}function n9(e){return e.replace(/<[^>]+>/g,"")}function r9(e,n){const l=e.split(`
408
408
  `),i=n.split(`
409
- `),o=l9(l,i),s=i9(l,i,o);return a9(s)}function l9(e,n){const l=e.length,i=n.length,o=Array.from({length:l+1},()=>Array(i+1).fill(0));for(let s=1;s<=l;s++)for(let c=1;c<=i;c++)o[s][c]=e[s-1]===n[c-1]?o[s-1][c-1]+1:Math.max(o[s-1][c],o[s][c-1]);return o}function i9(e,n,l){const i=[];let o=e.length,s=n.length;for(;o>0||s>0;)o>0&&s>0&&e[o-1]===n[s-1]?(i.push({type:"context",text:e[o-1],oldIdx:o,newIdx:s}),o--,s--):s>0&&(o===0||l[o][s-1]>=l[o-1][s])?(i.push({type:"added",text:n[s-1],oldIdx:o,newIdx:s}),s--):(i.push({type:"removed",text:e[o-1],oldIdx:o,newIdx:s}),o--);return i.reverse()}function a9(e){return e.map(n=>{const l=n.type==="removed"?"-":n.type==="added"?"+":" ";return{type:n.type,content:`${l}${n.text}`}})}function Dh({content:e,isDiff:n=!1,oldString:l,newString:i}){const o=w.useMemo(()=>n&&l!==void 0&&i!==void 0?r9(l,i):[],[n,l,i]),s=w.useMemo(()=>n?[]:t9(e),[e,n]),c=w.useMemo(()=>s.some(f=>f.lineNumber!==null),[s]);return n&&o.length>0?x.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:x.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:x.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:x.jsx("tbody",{children:o.map((f,d)=>{const h=f.type==="removed"?"bg-red-500/10 dark:bg-red-500/15":f.type==="added"?"bg-green-500/10 dark:bg-green-500/15":"",y=f.type==="removed"?"text-red-700 dark:text-red-400":f.type==="added"?"text-green-700 dark:text-green-400":"text-foreground";return x.jsxs("tr",{className:h,children:[x.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${f.type==="removed"?"text-red-500/50":f.type==="added"?"text-green-500/50":"text-muted-foreground/50"}`,children:f.type==="removed"?"-":f.type==="added"?"+":" "}),x.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${y}`,children:f.content.slice(1)})]},d)})})})})}):x.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:x.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:x.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:x.jsx("tbody",{children:s.map((f,d)=>x.jsxs("tr",{children:[c&&x.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:f.lineNumber!==null?f.lineNumber:""}),x.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:n9(f.content)})]},d))})})})})}function V2({message:e,isLoading:n=!1,localPath:l}){var k;const i=e.result!==void 0,o=!i&&n,s=w.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill;if(e.toolKind==="glob")return`Search files ${e.input.pattern==="**/*"?"in all directories":`matching ${e.input.pattern}`}`;if(e.toolKind==="grep"){const C=e.input.pattern,E=e.input.outputMode;return E==="count"?`Count \`${C}\` occurrences`:E==="content"?`Find \`${C}\` in text`:`Find \`${C}\` in files`}return e.toolKind==="bash"?e.input.description||e.input.command||"Bash":e.toolKind==="web_search"?e.input.query||"Web Search":e.toolKind==="read_file"?`Read ${Oh(e.input.filePath,l)}`:e.toolKind==="write_file"?`Write ${Oh(e.input.filePath,l)}`:e.toolKind==="edit_file"?`Edit ${Oh(e.input.filePath,l)}`:e.toolKind==="mcp_generic"?`${Jh(e.input.tool)} from ${Jh(e.input.server)}`:e.toolKind==="subagent_task"&&e.input.subagentType||e.toolName},[e.input,e.toolName,l]),c=w.useMemo(()=>e.toolKind==="subagent_task",[e.toolKind]),f=w.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill},[e.input,e.toolKind]),d=e.toolKind==="bash",h=e.toolKind==="write_file",y=e.toolKind==="edit_file",g=e.toolKind==="read_file",v=w.useMemo(()=>{if(typeof e.result=="string")return e.result;if(!e.result)return"";if(typeof e.result=="object"&&e.result!==null&&"content"in e.result){const C=e.result.content;if(typeof C=="string")return C}return JSON.stringify(e.result,null,2)},[e.result]),b=w.useMemo(()=>{switch(e.toolKind){case"bash":return e.input.command;case"write_file":return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]);return x.jsx(Dl,{className:"w-full",children:x.jsxs(wc,{expandedContent:x.jsx(Sc,{className:"my-4 text-sm",children:x.jsxs("div",{className:"flex flex-col gap-2",children:[y?x.jsx(Dh,{content:"",isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):!g&&!h&&x.jsx(Lb,{label:d?x.jsxs("span",{className:"flex items-center gap-2 w-full",children:[x.jsx("span",{children:"Command"}),!!e.input.timeoutMs&&x.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeoutMs),"ms"]}),!!e.input.runInBackground&&x.jsx("span",{className:"text-muted-foreground",children:"background"})]}):h?"Contents":"Input",copyText:b,children:b}),i&&g&&!e.isError&&x.jsx(Dh,{content:v}),h&&!e.isError&&x.jsx(Dh,{content:e.input.content}),i&&!g&&!(h&&!e.isError)&&!(y&&!e.isError)&&x.jsx(Lb,{label:e.isError?"Error":"Result",copyText:v,children:v})]})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:(()=>{if(e.isError)return x.jsx(Po,{className:"size-4 text-destructive"});if(c)return x.jsx(Dp,{className:"size-4 text-muted-icon"});const C=_S(e.toolName);return x.jsx(C,{className:"size-4 text-muted-icon"})})()}),x.jsx(Rl,{className:"text-left transition-opacity duration-200 truncate",children:x.jsx(gc,{animate:o,shimmerWidth:Math.max(20,(((k=f||s)==null?void 0:k.length)??33)*3),children:f||s})})]})})}function o9({message:e}){const n=l=>{if(l<1e3)return`${l}ms`;const i=Math.floor(l/1e3),o=Math.floor(i/3600),s=Math.floor(i%3600/60),c=i%60;return o>0?`${o}h${s>0?` ${s}m`:""}`:s>0?`${s}m${c>0?` ${c}s`:""}`:`${c}s`};return x.jsxs(Dl,{className:`px-0.5 text-xs tracking-wide ${e.durationMs>6e4?"":"hidden"}`,children:[x.jsx("div",{className:"w-full h-[1px] bg-border"}),x.jsxs(Rl,{className:"whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0",children:["Worked for ",n(e.durationMs)]}),x.jsx("div",{className:"w-full h-[1px] bg-border"})]})}function s9({message:e}){return x.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground my-3",children:x.jsxs("div",{className:"inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full",children:[x.jsx(QR,{className:"h-4 w-4 ml-1.5"}),x.jsx("em",{children:"Interrupted"})]})})}function Wu({size:e=4}){return x.jsxs("svg",{className:"flex-1",viewBox:`0 0 100 ${e}`,preserveAspectRatio:"none",style:{height:`${e}px`},children:[x.jsx("pattern",{id:"zigzag",width:e,height:e,patternUnits:"userSpaceOnUse",children:x.jsx("path",{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:{stroke:"currentColor"}})}),x.jsx("rect",{width:"100%",height:e,fill:"url(#zigzag)",className:"text-muted-foreground/30"})]})}function u9(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(Wu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),x.jsx(Wu,{})]})}function c9(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(Wu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),x.jsx(Wu,{})]})}function f9({message:e}){return x.jsx(Dl,{children:x.jsxs(wc,{expandedContent:x.jsx(Sc,{className:"my-4 text-xs",children:x.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:x.jsx(Rc,{remarkPlugins:[jc],components:Cc,children:e.summary})})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(rw,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(Rl,{children:"Summarized"})]})})}const d9={compacting:"Compacting..."};function h9({message:e}){const n=d9[e.status]||e.status;return x.jsxs(Dl,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(rw,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(Rl,{className:"text-left transition-opacity duration-200 truncate",children:n})]})}const p9={read_file:{key:"read",singular:"read",plural:"reads"},edit_file:{key:"edit",singular:"edit",plural:"edits"},write_file:{key:"write",singular:"write",plural:"writes"},bash:{key:"bash",singular:"command",plural:"commands"},grep:{key:"grep",singular:"search",plural:"searches"},glob:{key:"glob",singular:"glob",plural:"globs"},subagent_task:{key:"task",singular:"agent",plural:"agents"},web_search:{key:"websearch",singular:"web search",plural:"web searches"},skill:{key:"skill",singular:"skill",plural:"skills"},todo_write:{key:"todo",singular:"todo update",plural:"todo updates"}},m9={key:"other",singular:"tool call",plural:"tool calls"};function g9(e){return p9[e]??m9}function y9(e){const n=new Map,l=[];for(const i of e){const o=i.toolKind,s=g9(o),c=n.get(s.key);c?c.count++:(n.set(s.key,{category:s,count:1}),l.push(s.key))}return l.map(i=>{const{category:o,count:s}=n.get(i);return`${s} ${s===1?o.singular:o.plural}`}).join(", ")}function x9({messages:e,isLoading:n,localPath:l}){const[i,o]=w.useState(!1),s=w.useMemo(()=>y9(e),[e]),f=e.some(d=>d.result===void 0)&&n;return x.jsx(Dl,{className:"w-full",children:x.jsxs("div",{className:"flex flex-col w-full",children:[x.jsx("button",{onClick:()=>o(!i),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!i&&!f?"hover:opacity-60 transition-opacity":""}`,children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Nl,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${i?"rotate-90":""}`})}),x.jsx(Rl,{className:"text-left",children:x.jsx(gc,{animate:f,children:s})})]})}),i&&x.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[e.map(d=>x.jsx(V2,{message:d,isLoading:n,localPath:l},d.id)),e.length>5&&x.jsx("button",{onClick:()=>o(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Nl,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),x.jsx(Rl,{className:"text-left",children:"Collapse"})]})})]})]})})}const v9=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite"]);function T0(e){if(e.kind!=="tool")return!1;const n=e.toolName;return!v9.has(n)}function b9(e){const n=[];let l=0;for(;l<e.length;){const i=e[l];if(T0(i)){const o=[i],s=l;for(l+=1;l<e.length&&T0(e[l]);)o.push(e[l]),l+=1;o.length>=2?n.push({type:"tool-group",messages:o,startIndex:s}):n.push({type:"single",message:i,index:s});continue}n.push({type:"single",message:i,index:l}),l+=1}return n}function w9({messages:e,isLoading:n,localPath:l,latestToolIds:i,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:s}){const c=w.useMemo(()=>b9(e),[e]);function f(d,h){if(d.kind==="user_prompt")return x.jsx(H8,{content:d.content},d.id);switch(d.kind){case"unknown":return x.jsx(P8,{json:d.json},d.id);case"system_init":return e.findIndex(g=>g.kind==="system_init")===h?x.jsx(G8,{message:d,rawJson:d.debugRaw},d.id):null;case"account_info":return e.findIndex(g=>g.kind==="account_info")===h?x.jsx(Y8,{message:d},d.id):null;case"assistant_text":return x.jsx($8,{message:d},d.id);case"tool":return d.toolKind==="ask_user_question"?x.jsx(Z8,{message:d,onSubmit:o,isLatest:d.id===i.AskUserQuestion},d.id):d.toolKind==="exit_plan_mode"?x.jsx(J8,{message:d,onConfirm:s,isLatest:d.id===i.ExitPlanMode},d.id):d.toolKind==="todo_write"?d.id!==i.TodoWrite?null:x.jsx(e9,{message:d},d.id):x.jsx(V2,{message:d,isLoading:n,localPath:l},d.id);case"result":{const y=e[h+1],g=e[h-1];return(y==null?void 0:y.kind)==="context_cleared"||(g==null?void 0:g.kind)==="context_cleared"?null:x.jsx(o9,{message:d},d.id)}case"interrupted":return x.jsx(s9,{message:d},d.id);case"compact_boundary":return x.jsx(u9,{},d.id);case"context_cleared":return x.jsx(c9,{},d.id);case"compact_summary":return x.jsx(f9,{message:d},d.id);case"status":return h===e.length-1?x.jsx(h9,{message:d},d.id):null}}return x.jsx(x.Fragment,{children:c.map(d=>{if(d.type==="tool-group")return x.jsx("div",{className:"group relative",children:x.jsx(x9,{messages:d.messages,isLoading:n,localPath:l})},`group-${d.startIndex}`);const h=f(d.message,d.index);return h?x.jsx("div",{id:`msg-${d.message.id}`,className:"group relative",children:h},d.message.id):null})})}function R0(){var n,l,i,o;const e=Q0();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsxs(jS,{className:"bg-background flex-1 flex flex-col overflow-hidden border-0 rounded-none relative",children:[x.jsxs(OS,{className:"flex-1 p-0 overflow-hidden relative",children:[x.jsx(fO,{sidebarCollapsed:e.sidebarCollapsed,onOpenSidebar:e.openSidebar,onExpandSidebar:e.expandSidebar,onNewChat:e.handleCompose,localPath:e.navbarLocalPath,onOpenExternal:s=>{e.handleOpenExternal(s)}}),x.jsx(LS,{ref:e.scrollRef,onScroll:e.updateScrollState,className:"h-full px-4 scroll-pt-[72px]",children:x.jsxs("div",{className:"animate-fade-in space-y-5 pt-[72px] max-w-[800px] mx-auto",style:{paddingBottom:e.transcriptPaddingBottom},children:[e.messages.length===0?x.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[40vh] text-muted-foreground gap-4",children:[x.jsx(bo,{strokeWidth:1.5,className:"size-8 text-muted-foreground"}),x.jsx("div",{className:"text-base font-normal text-muted-foreground text-center max-w-xs",children:"What are we making?"})]}):x.jsx(w9,{messages:e.messages,isLoading:e.isProcessing,localPath:(n=e.runtime)==null?void 0:n.localPath,latestToolIds:e.latestToolIds,onAskUserQuestionSubmit:e.handleAskUserQuestion,onExitPlanModeConfirm:e.handleExitPlanMode}),e.isProcessing?x.jsx(gO,{status:(l=e.runtime)==null?void 0:l.status}):null,e.commandError?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3",children:e.commandError}):null,x.jsx("div",{className:"flex-1 min-h-[10vh]","aria-hidden":"true"})]})}),x.jsx("div",{style:{bottom:e.transcriptPaddingBottom-36},className:ye("absolute left-1/2 -translate-x-1/2 z-10 transition-all",e.showScrollButton?"scale-100 duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]":"scale-60 duration-300 ease-out pointer-events-none blur-sm opacity-0"),children:x.jsx("button",{onClick:e.scrollToBottom,className:"flex items-center transition-colors gap-1.5 px-2 bg-white hover:bg-muted border border-border rounded-full aspect-square cursor-pointer text-sm text-primary hover:text-foreground dark:bg-slate-700 dark:hover:bg-slate-600 dark:text-slate-100 dark:border-slate-600",children:x.jsx(jR,{className:"h-5 w-5"})})})]}),x.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:x.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:e.inputRef,children:x.jsx(oO,{onSubmit:e.handleSend,onCancel:()=>{e.handleCancel()},disabled:!e.hasSelectedProject||((i=e.runtime)==null?void 0:i.status)==="waiting_for_user",canCancel:e.canCancel,chatId:e.activeChatId,activeProvider:((o=e.runtime)==null?void 0:o.provider)??null,availableProviders:e.availableProviders},e.activeChatId??"new-chat")})})]})})}function S9({text:e}){const[n,l]=w.useState(!1);async function i(){await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3)}return x.jsx(Fe,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void i(),children:n?x.jsx(ri,{className:"h-4 w-4 text-green-400"}):x.jsx(sc,{className:"h-4 w-4"})})}function j0({children:e}){return x.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[x.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[x.jsx(Nl,{className:"inline h-4 w-4 opacity-40"}),x.jsx("code",{children:e})]}),x.jsx(S9,{text:e})]})}function ku({children:e}){return x.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:e})}function _h({children:e}){return x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider mb-3",children:e})}function M0({narrow:e=!1,title:n,subtitle:l,icon:i=jp}){return x.jsxs("div",{className:ye("w-full",e?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[x.jsxs("div",{className:ye("flex items-center gap-3 mb-2",e&&"justify-center"),children:[x.jsx("div",{className:"p-2 pl-0 rounded-lg",children:x.jsx(i,{className:"h-6 w-6 text-muted-foreground"})}),x.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:n})]}),x.jsx("p",{className:ye("text-muted-foreground",e&&"mb-10 text-center"),children:l})]})}function zh({icon:e,title:n,subtitle:l,iconClassName:i}){return x.jsxs("div",{className:"flex flex-col items-center gap-0",children:[x.jsx("div",{className:"p-3 mb-2 rounded-xl bg-background border border-border",children:x.jsx(e,{className:i||"h-8 w-8 text-muted-foreground"})}),x.jsx("span",{className:"text-sm font-medium",children:n}),x.jsx("span",{className:"text-xs text-muted-foreground",children:l})]})}function O0(){return x.jsx(OR,{className:"h-4 w-4 text-muted-foreground"})}function D0({number:e,title:n,children:l}){return x.jsx("div",{className:"flex gap-4",children:x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[x.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[e,"."]}),x.jsx("h3",{className:"font-medium text-foreground mb-2",children:n})]}),x.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:l})]})})}function C9({localPath:e,loading:n,onClick:l}){return x.jsxs(qu,{children:[x.jsx(Fu,{asChild:!0,children:x.jsxs("button",{className:ye("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",n&&"opacity-50 cursor-not-allowed"),disabled:n,onClick:l,children:[x.jsx(ew,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),x.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:dS(e)}),n?x.jsx(oi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):x.jsx(Mp,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),x.jsx(Mo,{children:x.jsx("p",{children:e})})]})}function k9({connectionStatus:e,ready:n,snapshot:l,startingLocalPath:i,commandError:o,onOpenProject:s,onCreateProject:c}){const[f,d]=w.useState(!1),h=w.useMemo(()=>(l==null?void 0:l.projects)??[],[l==null?void 0:l.projects]),y=e==="connecting"||!n,g=e==="connected"&&n;return x.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[g?x.jsxs(x.Fragment,{children:[x.jsx(M0,{title:(l==null?void 0:l.machine.displayName)??"Local Projects",subtitle:`${Qt} is connected, choose a project below to get started.`}),x.jsxs("div",{className:"w-full px-6 mb-10",children:[x.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider",children:"Projects"}),x.jsxs(Fe,{variant:"default",size:"sm",onClick:()=>d(!0),children:[x.jsx(iw,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),h.length>0?x.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4 3xl:grid-cols-5 gap-2",children:h.map(v=>x.jsx(C9,{localPath:v.localPath,loading:i===v.localPath,onClick:()=>{s(v.localPath)}},v.localPath))}):x.jsx(ku,{children:x.jsx("p",{className:"text-sm text-muted-foreground",children:"No Claude projects discovered yet. Open one with Claude Code or create a new project here."})}),o?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:o}):null]})]}):x.jsxs(x.Fragment,{children:[x.jsx(M0,{narrow:!0,icon:nb,title:y?`Connecting ${Qt}`:`Connect ${Qt}`,subtitle:y?`${Qt} is starting up and loading your local projects.`:`Run ${Qt} directly on your machine with full access to your local files and Claude projects.`}),x.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[x.jsx(_h,{children:"Status"}),x.jsx("div",{className:"mb-8",children:x.jsx(ku,{children:x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(oi,{className:"h-4 w-4 text-muted-foreground animate-spin"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:y?`Connecting to your local ${Qt} server...`:x.jsxs(x.Fragment,{children:["Not connected. Run ",x.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:yu()})," from any terminal on this machine."]})})]})})}),y?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(_h,{children:"How it works"}),x.jsx(ku,{children:x.jsxs("div",{className:"flex items-center justify-around gap-6 py-4 px-2",children:[x.jsx(zh,{icon:Op,title:`${Qt} CLI`,subtitle:"On Your Machine"}),x.jsx(O0,{}),x.jsx(zh,{icon:jp,title:`${Qt} Server`,subtitle:"Local WebSocket"}),x.jsx(O0,{}),x.jsx(zh,{icon:nb,title:`${Qt} UI`,subtitle:"Project Chat"})]})})]}),y?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(_h,{children:"Setup"}),x.jsx(ku,{children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs(D0,{number:1,title:`Start ${Qt}`,children:[x.jsx("p",{children:"Run this command in your terminal:"}),x.jsx(j0,{children:yu()})]}),x.jsxs(D0,{number:2,title:"Open the local UI",children:[x.jsxs("p",{children:[Qt," serves the app locally and opens the Local Projects page in an app-style browser window."]}),x.jsx(j0,{children:"http://localhost:3210/local"})]}),x.jsxs("div",{className:"mt-8",children:[x.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-4",children:"Notes"}),x.jsxs("div",{className:"space-y-3 text-sm",children:[x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:yu("").trim()}),x.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:yu("--no-open")}),x.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),x.jsx(Yw,{open:f,onOpenChange:d,onConfirm:v=>{c(v)}}),x.jsx("div",{className:"py-4 text-center",children:x.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",L3.split("/")[1]]})})]})}function E9(){const e=Q0();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsx(k9,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}function Eu(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function N9(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function A9(e,n){const l=N9(n);switch(e.toolKind){case"ask_user_question":{const o=Eu(l),s=Eu(o==null?void 0:o.answers)??(o||{});return{answers:Object.fromEntries(Object.entries(s).map(([c,f])=>[c,String(f)]))}}case"exit_plan_mode":{const o=Eu(l);return{confirmed:typeof(o==null?void 0:o.confirmed)=="boolean"?o.confirmed:void 0,clearContext:typeof(o==null?void 0:o.clearContext)=="boolean"?o.clearContext:void 0,message:typeof(o==null?void 0:o.message)=="string"?o.message:void 0}}case"read_file":if(typeof l=="string")return l;const i=Eu(l);return{content:typeof(i==null?void 0:i.content)=="string"?i.content:JSON.stringify(l,null,2)};default:return l}}function G2(e){return new Date(e).toISOString()}function Zn(e){return{id:e._id,messageId:e.messageId,timestamp:G2(e.createdAt),hidden:e.hidden}}function T9(e){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:"tool",toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:e.tool.input,timestamp:G2(e.createdAt)}}function R9(e){if(e.debugRaw)try{return JSON.parse(e.debugRaw).tool_use_result}catch{return}}function j9(e){const n=new Map,l=[];for(const i of e)switch(i.kind){case"user_prompt":l.push({...Zn(i),kind:"user_prompt",content:i.content});break;case"system_init":l.push({...Zn(i),kind:"system_init",provider:i.provider,model:i.model,tools:i.tools,agents:i.agents,slashCommands:i.slashCommands,mcpServers:i.mcpServers,debugRaw:i.debugRaw});break;case"account_info":l.push({...Zn(i),kind:"account_info",accountInfo:i.accountInfo});break;case"assistant_text":l.push({...Zn(i),kind:"assistant_text",text:i.text});break;case"tool_call":{const o=T9(i);n.set(i.tool.toolId,{hydrated:o,normalized:i.tool}),l.push(o);break}case"tool_result":{const o=n.get(i.toolId);if(o){const s=o.normalized.toolKind==="ask_user_question"||o.normalized.toolKind==="exit_plan_mode"?R9(i)??i.content:i.content;o.hydrated.result=A9(o.normalized,s),o.hydrated.rawResult=s,o.hydrated.isError=i.isError}break}case"result":l.push({...Zn(i),kind:"result",success:!i.isError,cancelled:i.subtype==="cancelled",result:i.result,durationMs:i.durationMs,costUsd:i.costUsd});break;case"status":l.push({...Zn(i),kind:"status",status:i.status});break;case"compact_boundary":l.push({...Zn(i),kind:"compact_boundary"});break;case"compact_summary":l.push({...Zn(i),kind:"compact_summary",summary:i.summary});break;case"context_cleared":l.push({...Zn(i),kind:"context_cleared"});break;case"interrupted":l.push({...Zn(i),kind:"interrupted"});break;default:l.push({...Zn(i),kind:"unknown",json:JSON.stringify(i,null,2)});break}return l}const M9=["AskUserQuestion","ExitPlanMode","TodoWrite"],O9=new Set(["TodoWrite"]);function D9(e,n){for(let l=e.length-1;l>=0;l-=1){const i=e[l];if(i.kind!=="tool")continue;const o=i;if(o.toolName===n&&!o.result)return o.id}return null}function _9(e,n){for(let l=e.length-1;l>=0;l-=1){const i=e[l];if(i.kind!=="tool")continue;const o=i;if(o.toolName===n)return o.id}return null}function z9(e){const n={};for(const l of M9)n[l]=O9.has(l)?_9(e,l):D9(e,l);return n}function L9(e){return e==="starting"||e==="running"||e==="waiting_for_user"}function B9(e){return e==="starting"||e==="running"||e==="waiting_for_user"}class U9{constructor(n){Pr(this,"url");Pr(this,"ws",null);Pr(this,"reconnectTimer",null);Pr(this,"reconnectDelayMs",750);Pr(this,"subscriptions",new Map);Pr(this,"pending",new Map);Pr(this,"outboundQueue",[]);Pr(this,"statusListeners",new Set);this.url=n,this.connect()}dispose(){var n;this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(n=this.ws)==null||n.close(),this.ws=null;for(const l of this.pending.values())l.reject(new Error("Socket disposed"));this.pending.clear()}onStatus(n){return this.statusListeners.add(n),n(this.getStatus()),()=>{this.statusListeners.delete(n)}}subscribe(n,l){const i=crypto.randomUUID();return this.subscriptions.set(i,{topic:n,listener:l}),this.enqueue({v:1,type:"subscribe",id:i,topic:n}),()=>{this.subscriptions.delete(i),this.enqueue({v:1,type:"unsubscribe",id:i})}}command(n){const l=crypto.randomUUID(),i={v:1,type:"command",id:l,command:n};return new Promise((o,s)=>{this.pending.set(l,{resolve:o,reject:s}),this.enqueue(i)})}connect(){this.emitStatus("connecting"),this.ws=new WebSocket(this.url),this.ws.addEventListener("open",()=>{this.reconnectDelayMs=750,this.emitStatus("connected");for(const[n,l]of this.subscriptions.entries())this.sendNow({v:1,type:"subscribe",id:n,topic:l.topic});for(;this.outboundQueue.length>0;){const n=this.outboundQueue.shift();n&&this.sendNow(n)}}),this.ws.addEventListener("message",n=>{let l;try{l=JSON.parse(String(n.data))}catch{return}if(l.type==="snapshot"){const i=this.subscriptions.get(l.id);i==null||i.listener(l.snapshot.data);return}if(l.type==="ack"){const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.resolve(l.result);return}if(l.type==="error"){if(!l.id){console.error(B3,l.message);return}const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.reject(new Error(l.message))}}),this.ws.addEventListener("close",()=>{this.emitStatus("disconnected");for(const n of this.pending.values())n.reject(new Error("Disconnected"));this.pending.clear(),this.scheduleReconnect()})}scheduleReconnect(){this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect(),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,5e3)},this.reconnectDelayMs))}getStatus(){var n,l;return((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?"connected":((l=this.ws)==null?void 0:l.readyState)===WebSocket.CONNECTING?"connecting":"disconnected"}emitStatus(n){for(const l of this.statusListeners)l(n)}enqueue(n){var l;if(((l=this.ws)==null?void 0:l.readyState)===WebSocket.OPEN){this.sendNow(n);return}this.outboundQueue.push(n)}sendNow(n){var l;(l=this.ws)==null||l.send(JSON.stringify(n))}}function H9(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}function P9(){const e=w.useRef(null);return e.current||(e.current=new U9(H9())),w.useEffect(()=>{const n=e.current;return()=>{n==null||n.dispose()}},[]),e.current}function I9(e){var ft,Xr,te;const n=gp(),l=P9(),i=Kj(),[o,s]=w.useState({projectGroups:[]}),[c,f]=w.useState(null),[d,h]=w.useState(null),[y,g]=w.useState("connecting"),[v,b]=w.useState(!1),[k,C]=w.useState(!1),[E,N]=w.useState(!1),[M,j]=w.useState(null),[D,I]=w.useState(!1),[O,P]=w.useState(!1),[q,re]=w.useState(148),[H,J]=w.useState(!0),[ne,W]=w.useState(null),[Z,Q]=w.useState(null),[B,Y]=w.useState(null),le=w.useRef(null),de=w.useRef(null);w.useEffect(()=>l.onStatus(g),[l]),w.useEffect(()=>l.subscribe({type:"sidebar"},$=>{s($),b(!0),W(null)}),[l]),w.useEffect(()=>l.subscribe({type:"local-projects"},$=>{f($),C(!0),W(null)}),[l]),w.useEffect(()=>{if(!e){h(null),N(!0);return}return N(!1),l.subscribe({type:"chat",chatId:e},$=>{h($),N(!0),W(null)})},[e,l]),w.useEffect(()=>{if(M)return;const $=o.projectGroups[0];$&&j($.groupKey)},[M,o.projectGroups]),w.useEffect(()=>{if(!e||!v||!E)return;if(o.projectGroups.some(oe=>oe.chats.some(he=>he.chatId===e))){B===e&&Y(null);return}B!==e&&n("/")},[e,E,n,B,o.projectGroups,v]),w.useEffect(()=>{d&&(j(d.runtime.projectId),B===d.runtime.chatId&&Y(null))},[d,B]),w.useLayoutEffect(()=>{const $=de.current;if(!$)return;const oe=new ResizeObserver(()=>{re($.getBoundingClientRect().height)});return oe.observe($),re($.getBoundingClientRect().height),()=>oe.disconnect()},[]);const R=w.useMemo(()=>j9((d==null?void 0:d.messages)??[]),[d==null?void 0:d.messages]),z=w.useMemo(()=>z9(R),[R]),L=(d==null?void 0:d.runtime)??null,T=(d==null?void 0:d.availableProviders)??WM,se=B9(L==null?void 0:L.status),ce=L9(L==null?void 0:L.status),ue=q+48,we=!H&&R.length>0,Ae=((ft=c==null?void 0:c.projects[0])==null?void 0:ft.localPath)??null,xe=(L==null?void 0:L.localPath)??Ae??((Xr=o.projectGroups[0])==null?void 0:Xr.localPath),Ne=!!(M??(L==null?void 0:L.projectId)??((te=o.projectGroups[0])==null?void 0:te.groupKey)??Ae);w.useEffect(()=>{const $=le.current;if(!$)return;$.scrollHeight-$.scrollTop-$.clientHeight<120&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})},[e,R.length,L==null?void 0:L.status]);function rt(){const $=le.current;if(!$)return;const oe=$.scrollHeight-$.scrollTop-$.clientHeight;J(oe<24)}function tt(){const $=le.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})}async function at($){try{const oe=await l.command({type:"chat.create",projectId:$});j($),Y(oe.chatId),n(`/chat/${oe.chatId}`),I(!1)}catch(oe){W(oe instanceof Error?oe.message:String(oe))}}async function Ye($){try{Q($);const oe=await l.command({type:"project.open",localPath:$});j(oe.projectId);const he=await l.command({type:"chat.create",projectId:oe.projectId});Y(he.chatId),n(`/chat/${he.chatId}`),I(!1),W(null)}catch(oe){W(oe instanceof Error?oe.message:String(oe))}finally{Q(null)}}async function Dt($){try{Q($.localPath);const oe=await l.command($.mode==="new"?{type:"project.create",localPath:$.localPath,title:$.title}:{type:"project.open",localPath:$.localPath});j(oe.projectId);const he=await l.command({type:"chat.create",projectId:oe.projectId});Y(he.chatId),n(`/chat/${he.chatId}`),I(!1),W(null)}catch(oe){W(oe instanceof Error?oe.message:String(oe))}finally{Q(null)}}async function _t($,oe){var he;try{let be=M??((he=o.projectGroups[0])==null?void 0:he.groupKey)??null;if(!e&&!be&&Ae&&(be=(await l.command({type:"project.open",localPath:Ae})).projectId,j(be)),!e&&!be)throw new Error("Open a project first");const Oe=await l.command({type:"chat.send",chatId:e??void 0,projectId:e?void 0:be??void 0,provider:oe==null?void 0:oe.provider,content:$,model:oe==null?void 0:oe.model,modelOptions:oe==null?void 0:oe.modelOptions,planMode:oe==null?void 0:oe.planMode});!e&&Oe.chatId&&(Y(Oe.chatId),n(`/chat/${Oe.chatId}`)),W(null)}catch(be){throw W(be instanceof Error?be.message:String(be)),be}}async function Fn(){if(e)try{await l.command({type:"chat.cancel",chatId:e})}catch($){W($ instanceof Error?$.message:String($))}}async function Vn($){if(await i.confirm({title:"Delete Chat",description:`Delete "${$.title}"? This cannot be undone.`,confirmLabel:"Delete",confirmVariant:"destructive"}))try{await l.command({type:"chat.delete",chatId:$.chatId}),$.chatId===e&&n("/")}catch(he){W(he instanceof Error?he.message:String(he))}}async function zt($){const oe=o.projectGroups.find(Oe=>Oe.groupKey===$);if(!oe)return;const he=oe.localPath.split("/").filter(Boolean).pop()??oe.localPath;if(await i.confirm({title:"Remove",description:`Remove "${he}" from the sidebar? Existing chats will be removed from ${Qt}.`,confirmLabel:"Remove",confirmVariant:"destructive"}))try{await l.command({type:"project.remove",projectId:$}),(L==null?void 0:L.projectId)===$&&n("/projects"),W(null)}catch(Oe){W(Oe instanceof Error?Oe.message:String(Oe))}}async function Lt($){var he,be;const oe=(L==null?void 0:L.localPath)??((he=c==null?void 0:c.projects[0])==null?void 0:he.localPath)??((be=o.projectGroups[0])==null?void 0:be.localPath);if(oe)try{await l.command({type:"system.openExternal",action:$,localPath:oe})}catch(Oe){W(Oe instanceof Error?Oe.message:String(Oe))}}function Nn(){var he,be;const $=M??((he=o.projectGroups[0])==null?void 0:he.groupKey);if($){at($);return}const oe=(be=c==null?void 0:c.projects[0])==null?void 0:be.localPath;if(oe){Ye(oe);return}n("/projects")}async function lr($,oe,he){if(e)try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:$,result:{questions:oe,answers:he}})}catch(be){W(be instanceof Error?be.message:String(be))}}async function $r($,oe,he,be){if(e){oe&&RS.getState().setPlanMode(!1);try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:$,result:{confirmed:oe,...he?{clearContext:!0}:{},...be?{message:be}:{}}})}catch(Oe){W(Oe instanceof Error?Oe.message:String(Oe))}}}return{activeChatId:e,sidebarData:o,localProjects:c,chatSnapshot:d,connectionStatus:y,sidebarReady:v,localProjectsReady:k,commandError:ne,startingLocalPath:Z,sidebarOpen:D,sidebarCollapsed:O,scrollRef:le,inputRef:de,messages:R,latestToolIds:z,runtime:L,availableProviders:T,isProcessing:se,canCancel:ce,transcriptPaddingBottom:ue,showScrollButton:we,navbarLocalPath:xe,hasSelectedProject:Ne,openSidebar:()=>I(!0),closeSidebar:()=>I(!1),collapseSidebar:()=>P(!0),expandSidebar:()=>P(!1),updateScrollState:rt,scrollToBottom:tt,handleCreateChat:at,handleOpenLocalProject:Ye,handleCreateProject:Dt,handleSend:_t,handleCancel:Fn,handleDeleteChat:Vn,handleRemoveProject:zt,handleOpenExternal:Lt,handleCompose:Nn,handleAskUserQuestion:lr,handleExitPlanMode:$r}}function q9(){const e=yr(),n=tN(),l=I9(n.chatId??null),i=e.pathname==="/projects";return x.jsxs("div",{className:"flex h-[100dvh] min-h-[100dvh] overflow-hidden",children:[x.jsx(JM,{data:l.sidebarData,activeChatId:l.activeChatId,connectionStatus:l.connectionStatus,ready:l.sidebarReady,open:l.sidebarOpen,collapsed:l.sidebarCollapsed,showMobileOpenButton:i,onOpen:l.openSidebar,onClose:l.closeSidebar,onCollapse:l.collapseSidebar,onExpand:l.expandSidebar,onCreateChat:o=>{l.handleCreateChat(o)},onCreateProject:o=>{l.handleCreateProject(o)},onDeleteChat:o=>{l.handleDeleteChat(o)},onRemoveProject:o=>{l.handleRemoveProject(o)}}),x.jsx(mN,{context:l})]})}function F9(){return x.jsx(D3,{children:x.jsx(Qj,{children:x.jsx(yN,{children:x.jsxs(xo,{element:x.jsx(q9,{}),children:[x.jsx(xo,{path:"/",element:x.jsx(R0,{})}),x.jsx(xo,{path:"/projects",element:x.jsx(E9,{})}),x.jsx(xo,{path:"/chat/:chatId",element:x.jsx(R0,{})})]})})})})}const Y2="lever-theme",V9=w.createContext(void 0),G9=e=>e==="light"||e==="dark"||e==="system",$2=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",_0=e=>{if(typeof document>"u")return;const n=e==="system"?$2():e;document.documentElement.classList.toggle("dark",n==="dark")},Y9=()=>{if(typeof window>"u")return"system";const e=window.localStorage.getItem(Y2);return G9(e)?e:"system"};function $9({children:e}){const[n,l]=w.useState(Y9);w.useEffect(()=>{_0(n),typeof window<"u"&&window.localStorage.setItem(Y2,n)},[n]),w.useEffect(()=>{if(n!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>_0("system");return o.addEventListener?(o.addEventListener("change",s),()=>o.removeEventListener("change",s)):(o.addListener(s),()=>o.removeListener(s))},[n]);const i=w.useMemo(()=>{const o=n==="system"?$2():n;return{theme:n,resolvedTheme:o,setTheme:l}},[n]);return x.jsx(V9.Provider,{value:i,children:e})}const X2=document.getElementById("root");if(!X2)throw new Error("Missing #root");yE.createRoot(X2).render(x.jsx(w.StrictMode,{children:x.jsx(IN,{children:x.jsx($9,{children:x.jsx(F9,{})})})}));
409
+ `),o=l9(l,i),s=i9(l,i,o);return a9(s)}function l9(e,n){const l=e.length,i=n.length,o=Array.from({length:l+1},()=>Array(i+1).fill(0));for(let s=1;s<=l;s++)for(let c=1;c<=i;c++)o[s][c]=e[s-1]===n[c-1]?o[s-1][c-1]+1:Math.max(o[s-1][c],o[s][c-1]);return o}function i9(e,n,l){const i=[];let o=e.length,s=n.length;for(;o>0||s>0;)o>0&&s>0&&e[o-1]===n[s-1]?(i.push({type:"context",text:e[o-1],oldIdx:o,newIdx:s}),o--,s--):s>0&&(o===0||l[o][s-1]>=l[o-1][s])?(i.push({type:"added",text:n[s-1],oldIdx:o,newIdx:s}),s--):(i.push({type:"removed",text:e[o-1],oldIdx:o,newIdx:s}),o--);return i.reverse()}function a9(e){return e.map(n=>{const l=n.type==="removed"?"-":n.type==="added"?"+":" ";return{type:n.type,content:`${l}${n.text}`}})}function Dh({content:e,isDiff:n=!1,oldString:l,newString:i}){const o=w.useMemo(()=>n&&l!==void 0&&i!==void 0?r9(l,i):[],[n,l,i]),s=w.useMemo(()=>n?[]:t9(e),[e,n]),c=w.useMemo(()=>s.some(f=>f.lineNumber!==null),[s]);return n&&o.length>0?x.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:x.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:x.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:x.jsx("tbody",{children:o.map((f,d)=>{const h=f.type==="removed"?"bg-red-500/10 dark:bg-red-500/15":f.type==="added"?"bg-green-500/10 dark:bg-green-500/15":"",y=f.type==="removed"?"text-red-700 dark:text-red-400":f.type==="added"?"text-green-700 dark:text-green-400":"text-foreground";return x.jsxs("tr",{className:h,children:[x.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${f.type==="removed"?"text-red-500/50":f.type==="added"?"text-green-500/50":"text-muted-foreground/50"}`,children:f.type==="removed"?"-":f.type==="added"?"+":" "}),x.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${y}`,children:f.content.slice(1)})]},d)})})})})}):x.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:x.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:x.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:x.jsx("tbody",{children:s.map((f,d)=>x.jsxs("tr",{children:[c&&x.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:f.lineNumber!==null?f.lineNumber:""}),x.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:n9(f.content)})]},d))})})})})}function V2({message:e,isLoading:n=!1,localPath:l}){var k;const i=e.result!==void 0,o=!i&&n,s=w.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill;if(e.toolKind==="glob")return`Search files ${e.input.pattern==="**/*"?"in all directories":`matching ${e.input.pattern}`}`;if(e.toolKind==="grep"){const C=e.input.pattern,E=e.input.outputMode;return E==="count"?`Count \`${C}\` occurrences`:E==="content"?`Find \`${C}\` in text`:`Find \`${C}\` in files`}return e.toolKind==="bash"?e.input.description||e.input.command||"Bash":e.toolKind==="web_search"?e.input.query||"Web Search":e.toolKind==="read_file"?`Read ${Oh(e.input.filePath,l)}`:e.toolKind==="write_file"?`Write ${Oh(e.input.filePath,l)}`:e.toolKind==="edit_file"?`Edit ${Oh(e.input.filePath,l)}`:e.toolKind==="mcp_generic"?`${Jh(e.input.tool)} from ${Jh(e.input.server)}`:e.toolKind==="subagent_task"&&e.input.subagentType||e.toolName},[e.input,e.toolName,l]),c=w.useMemo(()=>e.toolKind==="subagent_task",[e.toolKind]),f=w.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill},[e.input,e.toolKind]),d=e.toolKind==="bash",h=e.toolKind==="write_file",y=e.toolKind==="edit_file",g=e.toolKind==="read_file",v=w.useMemo(()=>{if(typeof e.result=="string")return e.result;if(!e.result)return"";if(typeof e.result=="object"&&e.result!==null&&"content"in e.result){const C=e.result.content;if(typeof C=="string")return C}return JSON.stringify(e.result,null,2)},[e.result]),b=w.useMemo(()=>{switch(e.toolKind){case"bash":return e.input.command;case"write_file":return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]);return x.jsx(Dl,{className:"w-full",children:x.jsxs(wc,{expandedContent:x.jsx(Sc,{className:"my-4 text-sm",children:x.jsxs("div",{className:"flex flex-col gap-2",children:[y?x.jsx(Dh,{content:"",isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):!g&&!h&&x.jsx(Lb,{label:d?x.jsxs("span",{className:"flex items-center gap-2 w-full",children:[x.jsx("span",{children:"Command"}),!!e.input.timeoutMs&&x.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeoutMs),"ms"]}),!!e.input.runInBackground&&x.jsx("span",{className:"text-muted-foreground",children:"background"})]}):h?"Contents":"Input",copyText:b,children:b}),i&&g&&!e.isError&&x.jsx(Dh,{content:v}),h&&!e.isError&&x.jsx(Dh,{content:e.input.content}),i&&!g&&!(h&&!e.isError)&&!(y&&!e.isError)&&x.jsx(Lb,{label:e.isError?"Error":"Result",copyText:v,children:v})]})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:(()=>{if(e.isError)return x.jsx(Po,{className:"size-4 text-destructive"});if(c)return x.jsx(Dp,{className:"size-4 text-muted-icon"});const C=_S(e.toolName);return x.jsx(C,{className:"size-4 text-muted-icon"})})()}),x.jsx(Rl,{className:"text-left transition-opacity duration-200 truncate",children:x.jsx(gc,{animate:o,shimmerWidth:Math.max(20,(((k=f||s)==null?void 0:k.length)??33)*3),children:f||s})})]})})}function o9({message:e}){const n=l=>{if(l<1e3)return`${l}ms`;const i=Math.floor(l/1e3),o=Math.floor(i/3600),s=Math.floor(i%3600/60),c=i%60;return o>0?`${o}h${s>0?` ${s}m`:""}`:s>0?`${s}m${c>0?` ${c}s`:""}`:`${c}s`};return x.jsxs(Dl,{className:`px-0.5 text-xs tracking-wide ${e.durationMs>6e4?"":"hidden"}`,children:[x.jsx("div",{className:"w-full h-[1px] bg-border"}),x.jsxs(Rl,{className:"whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0",children:["Worked for ",n(e.durationMs)]}),x.jsx("div",{className:"w-full h-[1px] bg-border"})]})}function s9({message:e}){return x.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground my-3",children:x.jsxs("div",{className:"inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full",children:[x.jsx(QR,{className:"h-4 w-4 ml-1.5"}),x.jsx("em",{children:"Interrupted"})]})})}function Wu({size:e=4}){return x.jsxs("svg",{className:"flex-1",viewBox:`0 0 100 ${e}`,preserveAspectRatio:"none",style:{height:`${e}px`},children:[x.jsx("pattern",{id:"zigzag",width:e,height:e,patternUnits:"userSpaceOnUse",children:x.jsx("path",{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:{stroke:"currentColor"}})}),x.jsx("rect",{width:"100%",height:e,fill:"url(#zigzag)",className:"text-muted-foreground/30"})]})}function u9(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(Wu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),x.jsx(Wu,{})]})}function c9(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(Wu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),x.jsx(Wu,{})]})}function f9({message:e}){return x.jsx(Dl,{children:x.jsxs(wc,{expandedContent:x.jsx(Sc,{className:"my-4 text-xs",children:x.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:x.jsx(Rc,{remarkPlugins:[jc],components:Cc,children:e.summary})})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(rw,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(Rl,{children:"Summarized"})]})})}const d9={compacting:"Compacting..."};function h9({message:e}){const n=d9[e.status]||e.status;return x.jsxs(Dl,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(rw,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(Rl,{className:"text-left transition-opacity duration-200 truncate",children:n})]})}const p9={read_file:{key:"read",singular:"read",plural:"reads"},edit_file:{key:"edit",singular:"edit",plural:"edits"},write_file:{key:"write",singular:"write",plural:"writes"},bash:{key:"bash",singular:"command",plural:"commands"},grep:{key:"grep",singular:"search",plural:"searches"},glob:{key:"glob",singular:"glob",plural:"globs"},subagent_task:{key:"task",singular:"agent",plural:"agents"},web_search:{key:"websearch",singular:"web search",plural:"web searches"},skill:{key:"skill",singular:"skill",plural:"skills"},todo_write:{key:"todo",singular:"todo update",plural:"todo updates"}},m9={key:"other",singular:"tool call",plural:"tool calls"};function g9(e){return p9[e]??m9}function y9(e){const n=new Map,l=[];for(const i of e){const o=i.toolKind,s=g9(o),c=n.get(s.key);c?c.count++:(n.set(s.key,{category:s,count:1}),l.push(s.key))}return l.map(i=>{const{category:o,count:s}=n.get(i);return`${s} ${s===1?o.singular:o.plural}`}).join(", ")}function x9({messages:e,isLoading:n,localPath:l}){const[i,o]=w.useState(!1),s=w.useMemo(()=>y9(e),[e]),f=e.some(d=>d.result===void 0)&&n;return x.jsx(Dl,{className:"w-full",children:x.jsxs("div",{className:"flex flex-col w-full",children:[x.jsx("button",{onClick:()=>o(!i),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!i&&!f?"hover:opacity-60 transition-opacity":""}`,children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Nl,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${i?"rotate-90":""}`})}),x.jsx(Rl,{className:"text-left",children:x.jsx(gc,{animate:f,children:s})})]})}),i&&x.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[e.map(d=>x.jsx(V2,{message:d,isLoading:n,localPath:l},d.id)),e.length>5&&x.jsx("button",{onClick:()=>o(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Nl,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),x.jsx(Rl,{className:"text-left",children:"Collapse"})]})})]})]})})}const v9=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite"]);function T0(e){if(e.kind!=="tool")return!1;const n=e.toolName;return!v9.has(n)}function b9(e){const n=[];let l=0;for(;l<e.length;){const i=e[l];if(T0(i)){const o=[i],s=l;for(l+=1;l<e.length&&T0(e[l]);)o.push(e[l]),l+=1;o.length>=2?n.push({type:"tool-group",messages:o,startIndex:s}):n.push({type:"single",message:i,index:s});continue}n.push({type:"single",message:i,index:l}),l+=1}return n}function w9({messages:e,isLoading:n,localPath:l,latestToolIds:i,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:s}){const c=w.useMemo(()=>b9(e),[e]);function f(d,h){if(d.kind==="user_prompt")return x.jsx(H8,{content:d.content},d.id);switch(d.kind){case"unknown":return x.jsx(P8,{json:d.json},d.id);case"system_init":return e.findIndex(g=>g.kind==="system_init")===h?x.jsx(G8,{message:d,rawJson:d.debugRaw},d.id):null;case"account_info":return e.findIndex(g=>g.kind==="account_info")===h?x.jsx(Y8,{message:d},d.id):null;case"assistant_text":return x.jsx($8,{message:d},d.id);case"tool":return d.toolKind==="ask_user_question"?x.jsx(Z8,{message:d,onSubmit:o,isLatest:d.id===i.AskUserQuestion},d.id):d.toolKind==="exit_plan_mode"?x.jsx(J8,{message:d,onConfirm:s,isLatest:d.id===i.ExitPlanMode},d.id):d.toolKind==="todo_write"?d.id!==i.TodoWrite?null:x.jsx(e9,{message:d},d.id):x.jsx(V2,{message:d,isLoading:n,localPath:l},d.id);case"result":{const y=e[h+1],g=e[h-1];return(y==null?void 0:y.kind)==="context_cleared"||(g==null?void 0:g.kind)==="context_cleared"?null:x.jsx(o9,{message:d},d.id)}case"interrupted":return x.jsx(s9,{message:d},d.id);case"compact_boundary":return x.jsx(u9,{},d.id);case"context_cleared":return x.jsx(c9,{},d.id);case"compact_summary":return x.jsx(f9,{message:d},d.id);case"status":return h===e.length-1?x.jsx(h9,{message:d},d.id):null}}return x.jsx(x.Fragment,{children:c.map(d=>{if(d.type==="tool-group")return x.jsx("div",{className:"group relative",children:x.jsx(x9,{messages:d.messages,isLoading:n,localPath:l})},`group-${d.startIndex}`);const h=f(d.message,d.index);return h?x.jsx("div",{id:`msg-${d.message.id}`,className:"group relative",children:h},d.message.id):null})})}function R0(){var n,l,i,o;const e=Q0();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsxs(jS,{className:"bg-background flex-1 flex flex-col overflow-hidden border-0 rounded-none relative",children:[x.jsxs(OS,{className:"flex-1 p-0 overflow-hidden relative",children:[x.jsx(fO,{sidebarCollapsed:e.sidebarCollapsed,onOpenSidebar:e.openSidebar,onExpandSidebar:e.expandSidebar,onNewChat:e.handleCompose,localPath:e.navbarLocalPath,onOpenExternal:s=>{e.handleOpenExternal(s)}}),x.jsx(LS,{ref:e.scrollRef,onScroll:e.updateScrollState,className:"h-full px-4 scroll-pt-[72px]",children:x.jsxs("div",{className:"animate-fade-in space-y-5 pt-[72px] max-w-[800px] mx-auto",style:{paddingBottom:e.transcriptPaddingBottom},children:[e.messages.length===0?x.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[40vh] text-muted-foreground gap-4",children:[x.jsx(bo,{strokeWidth:1.5,className:"size-8 text-muted-foreground"}),x.jsx("div",{className:"text-base font-normal text-muted-foreground text-center max-w-xs",children:"What are we making?"})]}):x.jsx(w9,{messages:e.messages,isLoading:e.isProcessing,localPath:(n=e.runtime)==null?void 0:n.localPath,latestToolIds:e.latestToolIds,onAskUserQuestionSubmit:e.handleAskUserQuestion,onExitPlanModeConfirm:e.handleExitPlanMode}),e.isProcessing?x.jsx(gO,{status:(l=e.runtime)==null?void 0:l.status}):null,e.commandError?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3",children:e.commandError}):null,x.jsx("div",{className:"flex-1 min-h-[10vh]","aria-hidden":"true"})]})}),x.jsx("div",{style:{bottom:e.transcriptPaddingBottom-36},className:ye("absolute left-1/2 -translate-x-1/2 z-10 transition-all",e.showScrollButton?"scale-100 duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]":"scale-60 duration-300 ease-out pointer-events-none blur-sm opacity-0"),children:x.jsx("button",{onClick:e.scrollToBottom,className:"flex items-center transition-colors gap-1.5 px-2 bg-white hover:bg-muted border border-border rounded-full aspect-square cursor-pointer text-sm text-primary hover:text-foreground dark:bg-slate-700 dark:hover:bg-slate-600 dark:text-slate-100 dark:border-slate-600",children:x.jsx(jR,{className:"h-5 w-5"})})})]}),x.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:x.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:e.inputRef,children:x.jsx(oO,{onSubmit:e.handleSend,onCancel:()=>{e.handleCancel()},disabled:!e.hasSelectedProject||((i=e.runtime)==null?void 0:i.status)==="waiting_for_user",canCancel:e.canCancel,chatId:e.activeChatId,activeProvider:((o=e.runtime)==null?void 0:o.provider)??null,availableProviders:e.availableProviders},e.activeChatId??"new-chat")})})]})})}function S9({text:e}){const[n,l]=w.useState(!1);async function i(){await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3)}return x.jsx(Fe,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void i(),children:n?x.jsx(ri,{className:"h-4 w-4 text-green-400"}):x.jsx(sc,{className:"h-4 w-4"})})}function j0({children:e}){return x.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[x.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[x.jsx(Nl,{className:"inline h-4 w-4 opacity-40"}),x.jsx("code",{children:e})]}),x.jsx(S9,{text:e})]})}function ku({children:e}){return x.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:e})}function _h({children:e}){return x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider mb-3",children:e})}function M0({narrow:e=!1,title:n,subtitle:l,icon:i=jp}){return x.jsxs("div",{className:ye("w-full",e?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[x.jsxs("div",{className:ye("flex items-center gap-3 mb-2",e&&"justify-center"),children:[x.jsx("div",{className:"p-2 pl-0 rounded-lg",children:x.jsx(i,{className:"h-6 w-6 text-muted-foreground"})}),x.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:n})]}),x.jsx("p",{className:ye("text-muted-foreground",e&&"mb-10 text-center"),children:l})]})}function zh({icon:e,title:n,subtitle:l,iconClassName:i}){return x.jsxs("div",{className:"flex flex-col items-center gap-0",children:[x.jsx("div",{className:"p-3 mb-2 rounded-xl bg-background border border-border",children:x.jsx(e,{className:i||"h-8 w-8 text-muted-foreground"})}),x.jsx("span",{className:"text-sm font-medium",children:n}),x.jsx("span",{className:"text-xs text-muted-foreground",children:l})]})}function O0(){return x.jsx(OR,{className:"h-4 w-4 text-muted-foreground"})}function D0({number:e,title:n,children:l}){return x.jsx("div",{className:"flex gap-4",children:x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[x.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[e,"."]}),x.jsx("h3",{className:"font-medium text-foreground mb-2",children:n})]}),x.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:l})]})})}function C9({localPath:e,loading:n,onClick:l}){return x.jsxs(qu,{children:[x.jsx(Fu,{asChild:!0,children:x.jsxs("button",{className:ye("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",n&&"opacity-50 cursor-not-allowed"),disabled:n,onClick:l,children:[x.jsx(ew,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),x.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:dS(e)}),n?x.jsx(oi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):x.jsx(Mp,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),x.jsx(Mo,{children:x.jsx("p",{children:e})})]})}function k9({connectionStatus:e,ready:n,snapshot:l,startingLocalPath:i,commandError:o,onOpenProject:s,onCreateProject:c}){const[f,d]=w.useState(!1),h=w.useMemo(()=>(l==null?void 0:l.projects)??[],[l==null?void 0:l.projects]),y=e==="connecting"||!n,g=e==="connected"&&n;return x.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[g?x.jsxs(x.Fragment,{children:[x.jsx(M0,{title:(l==null?void 0:l.machine.displayName)??"Local Projects",subtitle:`${Qt} is connected, choose a project below to get started.`}),x.jsxs("div",{className:"w-full px-6 mb-10",children:[x.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider",children:"Projects"}),x.jsxs(Fe,{variant:"default",size:"sm",onClick:()=>d(!0),children:[x.jsx(iw,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),h.length>0?x.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4 3xl:grid-cols-5 gap-2",children:h.map(v=>x.jsx(C9,{localPath:v.localPath,loading:i===v.localPath,onClick:()=>{s(v.localPath)}},v.localPath))}):x.jsx(ku,{children:x.jsx("p",{className:"text-sm text-muted-foreground",children:"No local projects discovered yet. Open one with Claude or Codex, or create a new project here."})}),o?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:o}):null]})]}):x.jsxs(x.Fragment,{children:[x.jsx(M0,{narrow:!0,icon:nb,title:y?`Connecting ${Qt}`:`Connect ${Qt}`,subtitle:y?`${Qt} is starting up and loading your local projects.`:`Run ${Qt} directly on your machine with full access to your local files and agent project history.`}),x.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[x.jsx(_h,{children:"Status"}),x.jsx("div",{className:"mb-8",children:x.jsx(ku,{children:x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(oi,{className:"h-4 w-4 text-muted-foreground animate-spin"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:y?`Connecting to your local ${Qt} server...`:x.jsxs(x.Fragment,{children:["Not connected. Run ",x.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:yu()})," from any terminal on this machine."]})})]})})}),y?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(_h,{children:"How it works"}),x.jsx(ku,{children:x.jsxs("div",{className:"flex items-center justify-around gap-6 py-4 px-2",children:[x.jsx(zh,{icon:Op,title:`${Qt} CLI`,subtitle:"On Your Machine"}),x.jsx(O0,{}),x.jsx(zh,{icon:jp,title:`${Qt} Server`,subtitle:"Local WebSocket"}),x.jsx(O0,{}),x.jsx(zh,{icon:nb,title:`${Qt} UI`,subtitle:"Project Chat"})]})})]}),y?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(_h,{children:"Setup"}),x.jsx(ku,{children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs(D0,{number:1,title:`Start ${Qt}`,children:[x.jsx("p",{children:"Run this command in your terminal:"}),x.jsx(j0,{children:yu()})]}),x.jsxs(D0,{number:2,title:"Open the local UI",children:[x.jsxs("p",{children:[Qt," serves the app locally and opens the Local Projects page in an app-style browser window."]}),x.jsx(j0,{children:"http://localhost:3210/local"})]}),x.jsxs("div",{className:"mt-8",children:[x.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-4",children:"Notes"}),x.jsxs("div",{className:"space-y-3 text-sm",children:[x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:yu("").trim()}),x.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:yu("--no-open")}),x.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),x.jsx(Yw,{open:f,onOpenChange:d,onConfirm:v=>{c(v)}}),x.jsx("div",{className:"py-4 text-center",children:x.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",L3.split("/")[1]]})})]})}function E9(){const e=Q0();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsx(k9,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}function Eu(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function N9(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function A9(e,n){const l=N9(n);switch(e.toolKind){case"ask_user_question":{const o=Eu(l),s=Eu(o==null?void 0:o.answers)??(o||{});return{answers:Object.fromEntries(Object.entries(s).map(([c,f])=>[c,String(f)]))}}case"exit_plan_mode":{const o=Eu(l);return{confirmed:typeof(o==null?void 0:o.confirmed)=="boolean"?o.confirmed:void 0,clearContext:typeof(o==null?void 0:o.clearContext)=="boolean"?o.clearContext:void 0,message:typeof(o==null?void 0:o.message)=="string"?o.message:void 0}}case"read_file":if(typeof l=="string")return l;const i=Eu(l);return{content:typeof(i==null?void 0:i.content)=="string"?i.content:JSON.stringify(l,null,2)};default:return l}}function G2(e){return new Date(e).toISOString()}function Zn(e){return{id:e._id,messageId:e.messageId,timestamp:G2(e.createdAt),hidden:e.hidden}}function T9(e){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:"tool",toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:e.tool.input,timestamp:G2(e.createdAt)}}function R9(e){if(e.debugRaw)try{return JSON.parse(e.debugRaw).tool_use_result}catch{return}}function j9(e){const n=new Map,l=[];for(const i of e)switch(i.kind){case"user_prompt":l.push({...Zn(i),kind:"user_prompt",content:i.content});break;case"system_init":l.push({...Zn(i),kind:"system_init",provider:i.provider,model:i.model,tools:i.tools,agents:i.agents,slashCommands:i.slashCommands,mcpServers:i.mcpServers,debugRaw:i.debugRaw});break;case"account_info":l.push({...Zn(i),kind:"account_info",accountInfo:i.accountInfo});break;case"assistant_text":l.push({...Zn(i),kind:"assistant_text",text:i.text});break;case"tool_call":{const o=T9(i);n.set(i.tool.toolId,{hydrated:o,normalized:i.tool}),l.push(o);break}case"tool_result":{const o=n.get(i.toolId);if(o){const s=o.normalized.toolKind==="ask_user_question"||o.normalized.toolKind==="exit_plan_mode"?R9(i)??i.content:i.content;o.hydrated.result=A9(o.normalized,s),o.hydrated.rawResult=s,o.hydrated.isError=i.isError}break}case"result":l.push({...Zn(i),kind:"result",success:!i.isError,cancelled:i.subtype==="cancelled",result:i.result,durationMs:i.durationMs,costUsd:i.costUsd});break;case"status":l.push({...Zn(i),kind:"status",status:i.status});break;case"compact_boundary":l.push({...Zn(i),kind:"compact_boundary"});break;case"compact_summary":l.push({...Zn(i),kind:"compact_summary",summary:i.summary});break;case"context_cleared":l.push({...Zn(i),kind:"context_cleared"});break;case"interrupted":l.push({...Zn(i),kind:"interrupted"});break;default:l.push({...Zn(i),kind:"unknown",json:JSON.stringify(i,null,2)});break}return l}const M9=["AskUserQuestion","ExitPlanMode","TodoWrite"],O9=new Set(["TodoWrite"]);function D9(e,n){for(let l=e.length-1;l>=0;l-=1){const i=e[l];if(i.kind!=="tool")continue;const o=i;if(o.toolName===n&&!o.result)return o.id}return null}function _9(e,n){for(let l=e.length-1;l>=0;l-=1){const i=e[l];if(i.kind!=="tool")continue;const o=i;if(o.toolName===n)return o.id}return null}function z9(e){const n={};for(const l of M9)n[l]=O9.has(l)?_9(e,l):D9(e,l);return n}function L9(e){return e==="starting"||e==="running"||e==="waiting_for_user"}function B9(e){return e==="starting"||e==="running"||e==="waiting_for_user"}class U9{constructor(n){Pr(this,"url");Pr(this,"ws",null);Pr(this,"reconnectTimer",null);Pr(this,"reconnectDelayMs",750);Pr(this,"subscriptions",new Map);Pr(this,"pending",new Map);Pr(this,"outboundQueue",[]);Pr(this,"statusListeners",new Set);this.url=n,this.connect()}dispose(){var n;this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(n=this.ws)==null||n.close(),this.ws=null;for(const l of this.pending.values())l.reject(new Error("Socket disposed"));this.pending.clear()}onStatus(n){return this.statusListeners.add(n),n(this.getStatus()),()=>{this.statusListeners.delete(n)}}subscribe(n,l){const i=crypto.randomUUID();return this.subscriptions.set(i,{topic:n,listener:l}),this.enqueue({v:1,type:"subscribe",id:i,topic:n}),()=>{this.subscriptions.delete(i),this.enqueue({v:1,type:"unsubscribe",id:i})}}command(n){const l=crypto.randomUUID(),i={v:1,type:"command",id:l,command:n};return new Promise((o,s)=>{this.pending.set(l,{resolve:o,reject:s}),this.enqueue(i)})}connect(){this.emitStatus("connecting"),this.ws=new WebSocket(this.url),this.ws.addEventListener("open",()=>{this.reconnectDelayMs=750,this.emitStatus("connected");for(const[n,l]of this.subscriptions.entries())this.sendNow({v:1,type:"subscribe",id:n,topic:l.topic});for(;this.outboundQueue.length>0;){const n=this.outboundQueue.shift();n&&this.sendNow(n)}}),this.ws.addEventListener("message",n=>{let l;try{l=JSON.parse(String(n.data))}catch{return}if(l.type==="snapshot"){const i=this.subscriptions.get(l.id);i==null||i.listener(l.snapshot.data);return}if(l.type==="ack"){const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.resolve(l.result);return}if(l.type==="error"){if(!l.id){console.error(B3,l.message);return}const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.reject(new Error(l.message))}}),this.ws.addEventListener("close",()=>{this.emitStatus("disconnected");for(const n of this.pending.values())n.reject(new Error("Disconnected"));this.pending.clear(),this.scheduleReconnect()})}scheduleReconnect(){this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect(),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,5e3)},this.reconnectDelayMs))}getStatus(){var n,l;return((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?"connected":((l=this.ws)==null?void 0:l.readyState)===WebSocket.CONNECTING?"connecting":"disconnected"}emitStatus(n){for(const l of this.statusListeners)l(n)}enqueue(n){var l;if(((l=this.ws)==null?void 0:l.readyState)===WebSocket.OPEN){this.sendNow(n);return}this.outboundQueue.push(n)}sendNow(n){var l;(l=this.ws)==null||l.send(JSON.stringify(n))}}function H9(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}function P9(){const e=w.useRef(null);return e.current||(e.current=new U9(H9())),w.useEffect(()=>{const n=e.current;return()=>{n==null||n.dispose()}},[]),e.current}function I9(e){var ft,Xr,te;const n=gp(),l=P9(),i=Kj(),[o,s]=w.useState({projectGroups:[]}),[c,f]=w.useState(null),[d,h]=w.useState(null),[y,g]=w.useState("connecting"),[v,b]=w.useState(!1),[k,C]=w.useState(!1),[E,N]=w.useState(!1),[M,j]=w.useState(null),[D,I]=w.useState(!1),[O,P]=w.useState(!1),[q,re]=w.useState(148),[H,J]=w.useState(!0),[ne,W]=w.useState(null),[Z,Q]=w.useState(null),[B,Y]=w.useState(null),le=w.useRef(null),de=w.useRef(null);w.useEffect(()=>l.onStatus(g),[l]),w.useEffect(()=>l.subscribe({type:"sidebar"},$=>{s($),b(!0),W(null)}),[l]),w.useEffect(()=>l.subscribe({type:"local-projects"},$=>{f($),C(!0),W(null)}),[l]),w.useEffect(()=>{if(!e){h(null),N(!0);return}return N(!1),l.subscribe({type:"chat",chatId:e},$=>{h($),N(!0),W(null)})},[e,l]),w.useEffect(()=>{if(M)return;const $=o.projectGroups[0];$&&j($.groupKey)},[M,o.projectGroups]),w.useEffect(()=>{if(!e||!v||!E)return;if(o.projectGroups.some(oe=>oe.chats.some(he=>he.chatId===e))){B===e&&Y(null);return}B!==e&&n("/")},[e,E,n,B,o.projectGroups,v]),w.useEffect(()=>{d&&(j(d.runtime.projectId),B===d.runtime.chatId&&Y(null))},[d,B]),w.useLayoutEffect(()=>{const $=de.current;if(!$)return;const oe=new ResizeObserver(()=>{re($.getBoundingClientRect().height)});return oe.observe($),re($.getBoundingClientRect().height),()=>oe.disconnect()},[]);const R=w.useMemo(()=>j9((d==null?void 0:d.messages)??[]),[d==null?void 0:d.messages]),z=w.useMemo(()=>z9(R),[R]),L=(d==null?void 0:d.runtime)??null,T=(d==null?void 0:d.availableProviders)??WM,se=B9(L==null?void 0:L.status),ce=L9(L==null?void 0:L.status),ue=q+48,we=!H&&R.length>0,Ae=((ft=c==null?void 0:c.projects[0])==null?void 0:ft.localPath)??null,xe=(L==null?void 0:L.localPath)??Ae??((Xr=o.projectGroups[0])==null?void 0:Xr.localPath),Ne=!!(M??(L==null?void 0:L.projectId)??((te=o.projectGroups[0])==null?void 0:te.groupKey)??Ae);w.useEffect(()=>{const $=le.current;if(!$)return;$.scrollHeight-$.scrollTop-$.clientHeight<120&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})},[e,R.length,L==null?void 0:L.status]);function rt(){const $=le.current;if(!$)return;const oe=$.scrollHeight-$.scrollTop-$.clientHeight;J(oe<24)}function tt(){const $=le.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})}async function at($){try{const oe=await l.command({type:"chat.create",projectId:$});j($),Y(oe.chatId),n(`/chat/${oe.chatId}`),I(!1)}catch(oe){W(oe instanceof Error?oe.message:String(oe))}}async function Ye($){try{Q($);const oe=await l.command({type:"project.open",localPath:$});j(oe.projectId);const he=await l.command({type:"chat.create",projectId:oe.projectId});Y(he.chatId),n(`/chat/${he.chatId}`),I(!1),W(null)}catch(oe){W(oe instanceof Error?oe.message:String(oe))}finally{Q(null)}}async function Dt($){try{Q($.localPath);const oe=await l.command($.mode==="new"?{type:"project.create",localPath:$.localPath,title:$.title}:{type:"project.open",localPath:$.localPath});j(oe.projectId);const he=await l.command({type:"chat.create",projectId:oe.projectId});Y(he.chatId),n(`/chat/${he.chatId}`),I(!1),W(null)}catch(oe){W(oe instanceof Error?oe.message:String(oe))}finally{Q(null)}}async function _t($,oe){var he;try{let be=M??((he=o.projectGroups[0])==null?void 0:he.groupKey)??null;if(!e&&!be&&Ae&&(be=(await l.command({type:"project.open",localPath:Ae})).projectId,j(be)),!e&&!be)throw new Error("Open a project first");const Oe=await l.command({type:"chat.send",chatId:e??void 0,projectId:e?void 0:be??void 0,provider:oe==null?void 0:oe.provider,content:$,model:oe==null?void 0:oe.model,modelOptions:oe==null?void 0:oe.modelOptions,planMode:oe==null?void 0:oe.planMode});!e&&Oe.chatId&&(Y(Oe.chatId),n(`/chat/${Oe.chatId}`)),W(null)}catch(be){throw W(be instanceof Error?be.message:String(be)),be}}async function Fn(){if(e)try{await l.command({type:"chat.cancel",chatId:e})}catch($){W($ instanceof Error?$.message:String($))}}async function Vn($){if(await i.confirm({title:"Delete Chat",description:`Delete "${$.title}"? This cannot be undone.`,confirmLabel:"Delete",confirmVariant:"destructive"}))try{await l.command({type:"chat.delete",chatId:$.chatId}),$.chatId===e&&n("/")}catch(he){W(he instanceof Error?he.message:String(he))}}async function zt($){const oe=o.projectGroups.find(Oe=>Oe.groupKey===$);if(!oe)return;const he=oe.localPath.split("/").filter(Boolean).pop()??oe.localPath;if(await i.confirm({title:"Remove",description:`Remove "${he}" from the sidebar? Existing chats will be removed from ${Qt}.`,confirmLabel:"Remove",confirmVariant:"destructive"}))try{await l.command({type:"project.remove",projectId:$}),(L==null?void 0:L.projectId)===$&&n("/projects"),W(null)}catch(Oe){W(Oe instanceof Error?Oe.message:String(Oe))}}async function Lt($){var he,be;const oe=(L==null?void 0:L.localPath)??((he=c==null?void 0:c.projects[0])==null?void 0:he.localPath)??((be=o.projectGroups[0])==null?void 0:be.localPath);if(oe)try{await l.command({type:"system.openExternal",action:$,localPath:oe})}catch(Oe){W(Oe instanceof Error?Oe.message:String(Oe))}}function Nn(){var he,be;const $=M??((he=o.projectGroups[0])==null?void 0:he.groupKey);if($){at($);return}const oe=(be=c==null?void 0:c.projects[0])==null?void 0:be.localPath;if(oe){Ye(oe);return}n("/projects")}async function lr($,oe,he){if(e)try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:$,result:{questions:oe,answers:he}})}catch(be){W(be instanceof Error?be.message:String(be))}}async function $r($,oe,he,be){if(e){oe&&RS.getState().setPlanMode(!1);try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:$,result:{confirmed:oe,...he?{clearContext:!0}:{},...be?{message:be}:{}}})}catch(Oe){W(Oe instanceof Error?Oe.message:String(Oe))}}}return{activeChatId:e,sidebarData:o,localProjects:c,chatSnapshot:d,connectionStatus:y,sidebarReady:v,localProjectsReady:k,commandError:ne,startingLocalPath:Z,sidebarOpen:D,sidebarCollapsed:O,scrollRef:le,inputRef:de,messages:R,latestToolIds:z,runtime:L,availableProviders:T,isProcessing:se,canCancel:ce,transcriptPaddingBottom:ue,showScrollButton:we,navbarLocalPath:xe,hasSelectedProject:Ne,openSidebar:()=>I(!0),closeSidebar:()=>I(!1),collapseSidebar:()=>P(!0),expandSidebar:()=>P(!1),updateScrollState:rt,scrollToBottom:tt,handleCreateChat:at,handleOpenLocalProject:Ye,handleCreateProject:Dt,handleSend:_t,handleCancel:Fn,handleDeleteChat:Vn,handleRemoveProject:zt,handleOpenExternal:Lt,handleCompose:Nn,handleAskUserQuestion:lr,handleExitPlanMode:$r}}function q9(){const e=yr(),n=tN(),l=I9(n.chatId??null),i=e.pathname==="/projects";return x.jsxs("div",{className:"flex h-[100dvh] min-h-[100dvh] overflow-hidden",children:[x.jsx(JM,{data:l.sidebarData,activeChatId:l.activeChatId,connectionStatus:l.connectionStatus,ready:l.sidebarReady,open:l.sidebarOpen,collapsed:l.sidebarCollapsed,showMobileOpenButton:i,onOpen:l.openSidebar,onClose:l.closeSidebar,onCollapse:l.collapseSidebar,onExpand:l.expandSidebar,onCreateChat:o=>{l.handleCreateChat(o)},onCreateProject:o=>{l.handleCreateProject(o)},onDeleteChat:o=>{l.handleDeleteChat(o)},onRemoveProject:o=>{l.handleRemoveProject(o)}}),x.jsx(mN,{context:l})]})}function F9(){return x.jsx(D3,{children:x.jsx(Qj,{children:x.jsx(yN,{children:x.jsxs(xo,{element:x.jsx(q9,{}),children:[x.jsx(xo,{path:"/",element:x.jsx(R0,{})}),x.jsx(xo,{path:"/projects",element:x.jsx(E9,{})}),x.jsx(xo,{path:"/chat/:chatId",element:x.jsx(R0,{})})]})})})})}const Y2="lever-theme",V9=w.createContext(void 0),G9=e=>e==="light"||e==="dark"||e==="system",$2=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",_0=e=>{if(typeof document>"u")return;const n=e==="system"?$2():e;document.documentElement.classList.toggle("dark",n==="dark")},Y9=()=>{if(typeof window>"u")return"system";const e=window.localStorage.getItem(Y2);return G9(e)?e:"system"};function $9({children:e}){const[n,l]=w.useState(Y9);w.useEffect(()=>{_0(n),typeof window<"u"&&window.localStorage.setItem(Y2,n)},[n]),w.useEffect(()=>{if(n!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>_0("system");return o.addEventListener?(o.addEventListener("change",s),()=>o.removeEventListener("change",s)):(o.addListener(s),()=>o.removeListener(s))},[n]);const i=w.useMemo(()=>{const o=n==="system"?$2():n;return{theme:n,resolvedTheme:o,setTheme:l}},[n]);return x.jsx(V9.Provider,{value:i,children:e})}const X2=document.getElementById("root");if(!X2)throw new Error("Missing #root");yE.createRoot(X2).render(x.jsx(w.StrictMode,{children:x.jsx(IN,{children:x.jsx($9,{children:x.jsx(F9,{})})})}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/png" href="/favicon.png" />
7
7
  <title>Kanna</title>
8
- <script type="module" crossorigin src="/assets/index-C-sGbl7X.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-Byzgv_-q.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-gld9RxCU.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kanna-code",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "description": "A beautiful web UI for Claude Code",
6
6
  "license": "MIT",
7
7
  "keywords": [