kanna-code 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -411,7 +411,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
411
411
  *
412
412
  * This source code is licensed under the ISC license.
413
413
  * See the LICENSE file in the root directory of this source tree.
414
- */const F6=[["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"}]],Ud=Re("zap",F6),Vc="data-focus-fallback-ignore",LE="data-allow-focus-retain",$d="kanna:restore-chat-input-focus",fy="data-chat-input",kv="data-chat-selection-zone";function nl(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function zE(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:nl(e,LE):!1}function U6(e){const t=e;return t!=null&&t.matches?zE(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:nl(e,LE):!1}function pw(e){return!!e.querySelector(`[${Vc}][data-state='open']`)}function $6(e){return nl(e,fy)}function mw(e){return nl(e,kv)}function W6(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function q6(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${fy}]`)).filter(l=>!l.disabled);if(n.length===0)return!1;const r=n.indexOf(e),s=r>=0?(r+1)%n.length:0,a=n[s];return a?(a.focus({preventScroll:!0}),!0):!1}function V6(e){const{activeElement:t,fallback:n,hasActiveOverlay:r,canCancel:s,defaultPrevented:a}=e;return!(a||!n||n.disabled||r||t===n||$6(t)||s)}function K6(e){const{activeElement:t,pointerStartTarget:n,pointerEndTarget:r,root:s,fallback:a,hasActiveOverlay:l,hasActiveSelection:u}=e,d=r??n;return!s||!a||a.disabled||!d||!s.contains(d)||nl(d,Vc)||l||t===a||nl(t,Vc)||u&&(mw(n)||mw(d))||zE(t)?!1:t&&t===d?!0:!U6(t)}const jE=XL,G6=ZL,BE=x.forwardRef(({className:e,...t},n)=>v.jsx(EE,{ref:n,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),...t}));BE.displayName=EE.displayName;const Y6={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},py=x.forwardRef(({className:e,children:t,size:n="md",...r},s)=>v.jsxs(G6,{children:[v.jsx(BE,{}),v.jsxs(RE,{ref:s,[Vc]:"",onCloseAutoFocus:a=>{var l;a.preventDefault(),window.dispatchEvent(new Event($d)),(l=r.onCloseAutoFocus)==null||l.call(r,a)},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",Y6[n],e),...r,children:[t,v.jsxs(ez,{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:[v.jsx(fu,{className:"h-4 w-4"}),v.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));py.displayName=RE.displayName;function PE({className:e,...t}){return v.jsx(QL,{className:ye("text-lg font-medium leading-none tracking-tight",e),...t})}function X6({className:e,...t}){return v.jsx(JL,{className:ye("text-sm text-muted-foreground",e),...t})}function IE({className:e,...t}){return v.jsx("div",{className:ye("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function HE({className:e,...t}){return v.jsx("div",{className:ye("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}const FE=x.createContext(null);function Z6({children:e}){const[t,n]=x.useState(null),[r,s]=x.useState(""),a=x.useRef(null);x.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(s(t.options.initialValue??""),setTimeout(()=>{var p,m;(p=a.current)==null||p.focus(),(m=a.current)==null||m.select()},0))},[t]);const l=x.useCallback(()=>{n(null),s("")},[]),u=x.useCallback(p=>new Promise(m=>{n({kind:"confirm",options:p,resolve:m})}),[]),d=x.useCallback(p=>new Promise(m=>{n({kind:"prompt",options:p,resolve:m})}),[]),h=x.useMemo(()=>({confirm:u,prompt:d}),[u,d]);return v.jsxs(FE.Provider,{value:h,children:[e,v.jsx(jE,{open:t!==null,onOpenChange:p=>{p||!t||(t.kind==="confirm"?t.resolve(!1):t.resolve(null),l())},children:v.jsx(py,{size:"sm",children:t?v.jsxs(v.Fragment,{children:[v.jsxs(IE,{className:"space-y-4",children:[v.jsx(PE,{children:t.options.title}),t.options.description?v.jsx(X6,{children:t.options.description}):null,t.kind==="prompt"?v.jsx("input",{ref:a,type:"text",value:r,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),t.resolve(r.trim()||null),l())},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:t.options.placeholder}):null]}),v.jsxs(HE,{children:[v.jsx(et,{variant:"ghost",size:"sm",onClick:()=>{t.kind==="confirm"?t.resolve(!1):t.resolve(null),l()},children:t.options.cancelLabel??"Cancel"}),v.jsx(et,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:()=>{t.kind==="confirm"?t.resolve(!0):t.resolve(r.trim()||null),l()},disabled:t.kind==="prompt"&&!r.trim(),children:t.options.confirmLabel??"Confirm"})]})]}):null})})]})}function Q6(){const e=x.useContext(FE);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const J6=["top","right","bottom","left"],Gs=Math.min,gr=Math.max,Wd=Math.round,Jh=Math.floor,yi=e=>({x:e,y:e}),ej={left:"right",right:"left",bottom:"top",top:"bottom"};function Ev(e,t,n){return gr(e,Gs(t,n))}function ns(e,t){return typeof e=="function"?e(t):e}function rs(e){return e.split("-")[0]}function dl(e){return e.split("-")[1]}function my(e){return e==="x"?"y":"x"}function gy(e){return e==="y"?"height":"width"}function mi(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function vy(e){return my(mi(e))}function tj(e,t,n){n===void 0&&(n=!1);const r=dl(e),s=vy(e),a=gy(s);let l=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=qd(l)),[l,qd(l)]}function nj(e){const t=qd(e);return[Rv(e),t,Rv(t)]}function Rv(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const gw=["left","right"],vw=["right","left"],rj=["top","bottom"],ij=["bottom","top"];function sj(e,t,n){switch(e){case"top":case"bottom":return n?t?vw:gw:t?gw:vw;case"left":case"right":return t?rj:ij;default:return[]}}function oj(e,t,n,r){const s=dl(e);let a=sj(rs(e),n==="start",r);return s&&(a=a.map(l=>l+"-"+s),t&&(a=a.concat(a.map(Rv)))),a}function qd(e){const t=rs(e);return ej[t]+e.slice(t.length)}function aj(e){return{top:0,right:0,bottom:0,left:0,...e}}function UE(e){return typeof e!="number"?aj(e):{top:e,right:e,bottom:e,left:e}}function Vd(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function _w(e,t,n){let{reference:r,floating:s}=e;const a=mi(t),l=vy(t),u=gy(l),d=rs(t),h=a==="y",p=r.x+r.width/2-s.width/2,m=r.y+r.height/2-s.height/2,_=r[u]/2-s[u]/2;let b;switch(d){case"top":b={x:p,y:r.y-s.height};break;case"bottom":b={x:p,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-s.width,y:m};break;default:b={x:r.x,y:r.y}}switch(dl(t)){case"start":b[l]-=_*(n&&h?-1:1);break;case"end":b[l]+=_*(n&&h?-1:1);break}return b}async function lj(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:l,elements:u,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:p="viewport",elementContext:m="floating",altBoundary:_=!1,padding:b=0}=ns(t,e),S=UE(b),C=u[_?m==="floating"?"reference":"floating":m],k=Vd(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(C)))==null||n?C:C.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(u.floating)),boundary:h,rootBoundary:p,strategy:d})),T=m==="floating"?{x:r,y:s,width:l.floating.width,height:l.floating.height}:l.reference,R=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u.floating)),D=await(a.isElement==null?void 0:a.isElement(R))?await(a.getScale==null?void 0:a.getScale(R))||{x:1,y:1}:{x:1,y:1},z=Vd(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:T,offsetParent:R,strategy:d}):T);return{top:(k.top-z.top+S.top)/D.y,bottom:(z.bottom-k.bottom+S.bottom)/D.y,left:(k.left-z.left+S.left)/D.x,right:(z.right-k.right+S.right)/D.x}}const cj=50,uj=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:l}=n,u=l.detectOverflow?l:{...l,detectOverflow:lj},d=await(l.isRTL==null?void 0:l.isRTL(t));let h=await l.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:m}=_w(h,r,d),_=r,b=0;const S={};for(let w=0;w<a.length;w++){const C=a[w];if(!C)continue;const{name:k,fn:T}=C,{x:R,y:D,data:z,reset:L}=await T({x:p,y:m,initialPlacement:r,placement:_,strategy:s,middlewareData:S,rects:h,platform:u,elements:{reference:e,floating:t}});p=R??p,m=D??m,S[k]={...S[k],...z},L&&b<cj&&(b++,typeof L=="object"&&(L.placement&&(_=L.placement),L.rects&&(h=L.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:s}):L.rects),{x:p,y:m}=_w(h,_,d)),w=-1)}return{x:p,y:m,placement:_,strategy:s,middlewareData:S}},hj=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:l,elements:u,middlewareData:d}=t,{element:h,padding:p=0}=ns(e,t)||{};if(h==null)return{};const m=UE(p),_={x:n,y:r},b=vy(s),S=gy(b),w=await l.getDimensions(h),C=b==="y",k=C?"top":"left",T=C?"bottom":"right",R=C?"clientHeight":"clientWidth",D=a.reference[S]+a.reference[b]-_[b]-a.floating[S],z=_[b]-a.reference[b],L=await(l.getOffsetParent==null?void 0:l.getOffsetParent(h));let j=L?L[R]:0;(!j||!await(l.isElement==null?void 0:l.isElement(L)))&&(j=u.floating[R]||a.floating[S]);const I=D/2-z/2,Z=j/2-w[S]/2-1,P=Gs(m[k],Z),W=Gs(m[T],Z),H=P,F=j-w[S]-W,V=j/2-w[S]/2+I,U=Ev(H,V,F),O=!d.arrow&&dl(s)!=null&&V!==U&&a.reference[S]/2-(V<H?P:W)-w[S]/2<0,K=O?V<H?V-H:V-F:0;return{[b]:_[b]+K,data:{[b]:U,centerOffset:V-U-K,...O&&{alignmentOffset:K}},reset:O}}}),dj=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:l,initialPlacement:u,platform:d,elements:h}=t,{mainAxis:p=!0,crossAxis:m=!0,fallbackPlacements:_,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:w=!0,...C}=ns(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const k=rs(s),T=mi(u),R=rs(u)===u,D=await(d.isRTL==null?void 0:d.isRTL(h.floating)),z=_||(R||!w?[qd(u)]:nj(u)),L=S!=="none";!_&&L&&z.push(...oj(u,w,S,D));const j=[u,...z],I=await d.detectOverflow(t,C),Z=[];let P=((r=a.flip)==null?void 0:r.overflows)||[];if(p&&Z.push(I[k]),m){const V=tj(s,l,D);Z.push(I[V[0]],I[V[1]])}if(P=[...P,{placement:s,overflows:Z}],!Z.every(V=>V<=0)){var W,H;const V=(((W=a.flip)==null?void 0:W.index)||0)+1,U=j[V];if(U&&(!(m==="alignment"?T!==mi(U):!1)||P.every($=>mi($.placement)===T?$.overflows[0]>0:!0)))return{data:{index:V,overflows:P},reset:{placement:U}};let O=(H=P.filter(K=>K.overflows[0]<=0).sort((K,$)=>K.overflows[1]-$.overflows[1])[0])==null?void 0:H.placement;if(!O)switch(b){case"bestFit":{var F;const K=(F=P.filter($=>{if(L){const J=mi($.placement);return J===T||J==="y"}return!0}).map($=>[$.placement,$.overflows.filter(J=>J>0).reduce((J,A)=>J+A,0)]).sort(($,J)=>$[1]-J[1])[0])==null?void 0:F[0];K&&(O=K);break}case"initialPlacement":O=u;break}if(s!==O)return{reset:{placement:O}}}return{}}}};function yw(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bw(e){return J6.some(t=>e[t]>=0)}const fj=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...a}=ns(e,t);switch(s){case"referenceHidden":{const l=await r.detectOverflow(t,{...a,elementContext:"reference"}),u=yw(l,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:bw(u)}}}case"escaped":{const l=await r.detectOverflow(t,{...a,altBoundary:!0}),u=yw(l,n.floating);return{data:{escapedOffsets:u,escaped:bw(u)}}}default:return{}}}}},$E=new Set(["left","top"]);async function pj(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),l=rs(n),u=dl(n),d=mi(n)==="y",h=$E.has(l)?-1:1,p=a&&d?-1:1,m=ns(t,e);let{mainAxis:_,crossAxis:b,alignmentAxis:S}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return u&&typeof S=="number"&&(b=u==="end"?S*-1:S),d?{x:b*p,y:_*h}:{x:_*h,y:b*p}}const mj=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:l,middlewareData:u}=t,d=await pj(t,e);return l===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:s+d.x,y:a+d.y,data:{...d,placement:l}}}}},gj=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:a}=t,{mainAxis:l=!0,crossAxis:u=!1,limiter:d={fn:k=>{let{x:T,y:R}=k;return{x:T,y:R}}},...h}=ns(e,t),p={x:n,y:r},m=await a.detectOverflow(t,h),_=mi(rs(s)),b=my(_);let S=p[b],w=p[_];if(l){const k=b==="y"?"top":"left",T=b==="y"?"bottom":"right",R=S+m[k],D=S-m[T];S=Ev(R,S,D)}if(u){const k=_==="y"?"top":"left",T=_==="y"?"bottom":"right",R=w+m[k],D=w-m[T];w=Ev(R,w,D)}const C=d.fn({...t,[b]:S,[_]:w});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[b]:l,[_]:u}}}}}},vj=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:l}=t,{offset:u=0,mainAxis:d=!0,crossAxis:h=!0}=ns(e,t),p={x:n,y:r},m=mi(s),_=my(m);let b=p[_],S=p[m];const w=ns(u,t),C=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const R=_==="y"?"height":"width",D=a.reference[_]-a.floating[R]+C.mainAxis,z=a.reference[_]+a.reference[R]-C.mainAxis;b<D?b=D:b>z&&(b=z)}if(h){var k,T;const R=_==="y"?"width":"height",D=$E.has(rs(s)),z=a.reference[m]-a.floating[R]+(D&&((k=l.offset)==null?void 0:k[m])||0)+(D?0:C.crossAxis),L=a.reference[m]+a.reference[R]+(D?0:((T=l.offset)==null?void 0:T[m])||0)-(D?C.crossAxis:0);S<z?S=z:S>L&&(S=L)}return{[_]:b,[m]:S}}}},_j=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:l,elements:u}=t,{apply:d=()=>{},...h}=ns(e,t),p=await l.detectOverflow(t,h),m=rs(s),_=dl(s),b=mi(s)==="y",{width:S,height:w}=a.floating;let C,k;m==="top"||m==="bottom"?(C=m,k=_===(await(l.isRTL==null?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(k=m,C=_==="end"?"top":"bottom");const T=w-p.top-p.bottom,R=S-p.left-p.right,D=Gs(w-p[C],T),z=Gs(S-p[k],R),L=!t.middlewareData.shift;let j=D,I=z;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(j=T),L&&!_){const P=gr(p.left,0),W=gr(p.right,0),H=gr(p.top,0),F=gr(p.bottom,0);b?I=S-2*(P!==0||W!==0?P+W:gr(p.left,p.right)):j=w-2*(H!==0||F!==0?H+F:gr(p.top,p.bottom))}await d({...t,availableWidth:I,availableHeight:j});const Z=await l.getDimensions(u.floating);return S!==Z.width||w!==Z.height?{reset:{rects:!0}}:{}}}};function Cf(){return typeof window<"u"}function fl(e){return WE(e)?(e.nodeName||"").toLowerCase():"#document"}function vr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ei(e){var t;return(t=(WE(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function WE(e){return Cf()?e instanceof Node||e instanceof vr(e).Node:!1}function Qr(e){return Cf()?e instanceof Element||e instanceof vr(e).Element:!1}function ss(e){return Cf()?e instanceof HTMLElement||e instanceof vr(e).HTMLElement:!1}function xw(e){return!Cf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vr(e).ShadowRoot}function pu(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Jr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function yj(e){return/^(table|td|th)$/.test(fl(e))}function kf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const bj=/transform|translate|scale|rotate|perspective|filter/,xj=/paint|layout|strict|content/,wo=e=>!!e&&e!=="none";let Eg;function _y(e){const t=Qr(e)?Jr(e):e;return wo(t.transform)||wo(t.translate)||wo(t.scale)||wo(t.rotate)||wo(t.perspective)||!yy()&&(wo(t.backdropFilter)||wo(t.filter))||bj.test(t.willChange||"")||xj.test(t.contain||"")}function Sj(e){let t=Ys(e);for(;ss(t)&&!rl(t);){if(_y(t))return t;if(kf(t))return null;t=Ys(t)}return null}function yy(){return Eg==null&&(Eg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Eg}function rl(e){return/^(html|body|#document)$/.test(fl(e))}function Jr(e){return vr(e).getComputedStyle(e)}function Ef(e){return Qr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ys(e){if(fl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xw(e)&&e.host||Ei(e);return xw(t)?t.host:t}function qE(e){const t=Ys(e);return rl(t)?e.ownerDocument?e.ownerDocument.body:e.body:ss(t)&&pu(t)?t:qE(t)}function Kc(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=qE(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),l=vr(s);if(a){const u=Mv(l);return t.concat(l,l.visualViewport||[],pu(s)?s:[],u&&n?Kc(u):[])}else return t.concat(s,Kc(s,[],n))}function Mv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function VE(e){const t=Jr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ss(e),a=s?e.offsetWidth:n,l=s?e.offsetHeight:r,u=Wd(n)!==a||Wd(r)!==l;return u&&(n=a,r=l),{width:n,height:r,$:u}}function by(e){return Qr(e)?e:e.contextElement}function Ya(e){const t=by(e);if(!ss(t))return yi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=VE(t);let l=(a?Wd(n.width):n.width)/r,u=(a?Wd(n.height):n.height)/s;return(!l||!Number.isFinite(l))&&(l=1),(!u||!Number.isFinite(u))&&(u=1),{x:l,y:u}}const wj=yi(0);function KE(e){const t=vr(e);return!yy()||!t.visualViewport?wj:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Cj(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vr(e)?!1:t}function jo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=by(e);let l=yi(1);t&&(r?Qr(r)&&(l=Ya(r)):l=Ya(e));const u=Cj(a,n,r)?KE(a):yi(0);let d=(s.left+u.x)/l.x,h=(s.top+u.y)/l.y,p=s.width/l.x,m=s.height/l.y;if(a){const _=vr(a),b=r&&Qr(r)?vr(r):r;let S=_,w=Mv(S);for(;w&&r&&b!==S;){const C=Ya(w),k=w.getBoundingClientRect(),T=Jr(w),R=k.left+(w.clientLeft+parseFloat(T.paddingLeft))*C.x,D=k.top+(w.clientTop+parseFloat(T.paddingTop))*C.y;d*=C.x,h*=C.y,p*=C.x,m*=C.y,d+=R,h+=D,S=vr(w),w=Mv(S)}}return Vd({width:p,height:m,x:d,y:h})}function Rf(e,t){const n=Ef(e).scrollLeft;return t?t.left+n:jo(Ei(e)).left+n}function GE(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Rf(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function kj(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",l=Ei(r),u=t?kf(t.floating):!1;if(r===l||u&&a)return n;let d={scrollLeft:0,scrollTop:0},h=yi(1);const p=yi(0),m=ss(r);if((m||!m&&!a)&&((fl(r)!=="body"||pu(l))&&(d=Ef(r)),m)){const b=jo(r);h=Ya(r),p.x=b.x+r.clientLeft,p.y=b.y+r.clientTop}const _=l&&!m&&!a?GE(l,d):yi(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-d.scrollLeft*h.x+p.x+_.x,y:n.y*h.y-d.scrollTop*h.y+p.y+_.y}}function Ej(e){return Array.from(e.getClientRects())}function Rj(e){const t=Ei(e),n=Ef(e),r=e.ownerDocument.body,s=gr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=gr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+Rf(e);const u=-n.scrollTop;return Jr(r).direction==="rtl"&&(l+=gr(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:l,y:u}}const Sw=25;function Mj(e,t){const n=vr(e),r=Ei(e),s=n.visualViewport;let a=r.clientWidth,l=r.clientHeight,u=0,d=0;if(s){a=s.width,l=s.height;const p=yy();(!p||p&&t==="fixed")&&(u=s.offsetLeft,d=s.offsetTop)}const h=Rf(r);if(h<=0){const p=r.ownerDocument,m=p.body,_=getComputedStyle(m),b=p.compatMode==="CSS1Compat"&&parseFloat(_.marginLeft)+parseFloat(_.marginRight)||0,S=Math.abs(r.clientWidth-m.clientWidth-b);S<=Sw&&(a-=S)}else h<=Sw&&(a+=h);return{width:a,height:l,x:u,y:d}}function Tj(e,t){const n=jo(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=ss(e)?Ya(e):yi(1),l=e.clientWidth*a.x,u=e.clientHeight*a.y,d=s*a.x,h=r*a.y;return{width:l,height:u,x:d,y:h}}function ww(e,t,n){let r;if(t==="viewport")r=Mj(e,n);else if(t==="document")r=Rj(Ei(e));else if(Qr(t))r=Tj(t,n);else{const s=KE(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Vd(r)}function YE(e,t){const n=Ys(e);return n===t||!Qr(n)||rl(n)?!1:Jr(n).position==="fixed"||YE(n,t)}function Aj(e,t){const n=t.get(e);if(n)return n;let r=Kc(e,[],!1).filter(u=>Qr(u)&&fl(u)!=="body"),s=null;const a=Jr(e).position==="fixed";let l=a?Ys(e):e;for(;Qr(l)&&!rl(l);){const u=Jr(l),d=_y(l);!d&&u.position==="fixed"&&(s=null),(a?!d&&!s:!d&&u.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||pu(l)&&!d&&YE(e,l))?r=r.filter(p=>p!==l):s=u,l=Ys(l)}return t.set(e,r),r}function Dj(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const l=[...n==="clippingAncestors"?kf(t)?[]:Aj(t,this._c):[].concat(n),r],u=ww(t,l[0],s);let d=u.top,h=u.right,p=u.bottom,m=u.left;for(let _=1;_<l.length;_++){const b=ww(t,l[_],s);d=gr(b.top,d),h=Gs(b.right,h),p=Gs(b.bottom,p),m=gr(b.left,m)}return{width:h-m,height:p-d,x:m,y:d}}function Nj(e){const{width:t,height:n}=VE(e);return{width:t,height:n}}function Oj(e,t,n){const r=ss(t),s=Ei(t),a=n==="fixed",l=jo(e,!0,a,t);let u={scrollLeft:0,scrollTop:0};const d=yi(0);function h(){d.x=Rf(s)}if(r||!r&&!a)if((fl(t)!=="body"||pu(s))&&(u=Ef(t)),r){const b=jo(t,!0,a,t);d.x=b.x+t.clientLeft,d.y=b.y+t.clientTop}else s&&h();a&&!r&&s&&h();const p=s&&!r&&!a?GE(s,u):yi(0),m=l.left+u.scrollLeft-d.x-p.x,_=l.top+u.scrollTop-d.y-p.y;return{x:m,y:_,width:l.width,height:l.height}}function Rg(e){return Jr(e).position==="static"}function Cw(e,t){if(!ss(e)||Jr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ei(e)===n&&(n=n.ownerDocument.body),n}function XE(e,t){const n=vr(e);if(kf(e))return n;if(!ss(e)){let s=Ys(e);for(;s&&!rl(s);){if(Qr(s)&&!Rg(s))return s;s=Ys(s)}return n}let r=Cw(e,t);for(;r&&yj(r)&&Rg(r);)r=Cw(r,t);return r&&rl(r)&&Rg(r)&&!_y(r)?n:r||Sj(e)||n}const Lj=async function(e){const t=this.getOffsetParent||XE,n=this.getDimensions,r=await n(e.floating);return{reference:Oj(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zj(e){return Jr(e).direction==="rtl"}const jj={convertOffsetParentRelativeRectToViewportRelativeRect:kj,getDocumentElement:Ei,getClippingRect:Dj,getOffsetParent:XE,getElementRects:Lj,getClientRects:Ej,getDimensions:Nj,getScale:Ya,isElement:Qr,isRTL:zj};function ZE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bj(e,t){let n=null,r;const s=Ei(e);function a(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),a();const h=e.getBoundingClientRect(),{left:p,top:m,width:_,height:b}=h;if(u||t(),!_||!b)return;const S=Jh(m),w=Jh(s.clientWidth-(p+_)),C=Jh(s.clientHeight-(m+b)),k=Jh(p),R={rootMargin:-S+"px "+-w+"px "+-C+"px "+-k+"px",threshold:gr(0,Gs(1,d))||1};let D=!0;function z(L){const j=L[0].intersectionRatio;if(j!==d){if(!D)return l();j?l(!1,j):r=setTimeout(()=>{l(!1,1e-7)},1e3)}j===1&&!ZE(h,e.getBoundingClientRect())&&l(),D=!1}try{n=new IntersectionObserver(z,{...R,root:s.ownerDocument})}catch{n=new IntersectionObserver(z,R)}n.observe(e)}return l(!0),a}function Pj(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,h=by(e),p=s||a?[...h?Kc(h):[],...t?Kc(t):[]]:[];p.forEach(k=>{s&&k.addEventListener("scroll",n,{passive:!0}),a&&k.addEventListener("resize",n)});const m=h&&u?Bj(h,n):null;let _=-1,b=null;l&&(b=new ResizeObserver(k=>{let[T]=k;T&&T.target===h&&b&&t&&(b.unobserve(t),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(t)})),n()}),h&&!d&&b.observe(h),t&&b.observe(t));let S,w=d?jo(e):null;d&&C();function C(){const k=jo(e);w&&!ZE(w,k)&&n(),w=k,S=requestAnimationFrame(C)}return n(),()=>{var k;p.forEach(T=>{s&&T.removeEventListener("scroll",n),a&&T.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,d&&cancelAnimationFrame(S)}}const Ij=mj,Hj=gj,Fj=dj,Uj=_j,$j=fj,kw=hj,Wj=vj,qj=(e,t,n)=>{const r=new Map,s={platform:jj,...n},a={...s.platform,_c:r};return uj(e,t,{...s,platform:a})};var Vj=typeof document<"u",Kj=function(){},Ed=Vj?x.useLayoutEffect:Kj;function Kd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Kd(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!Kd(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function QE(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ew(e,t){const n=QE(e);return Math.round(t*n)/n}function Mg(e){const t=x.useRef(e);return Ed(()=>{t.current=e}),t}function Gj(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:l}={},transform:u=!0,whileElementsMounted:d,open:h}=e,[p,m]=x.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[_,b]=x.useState(r);Kd(_,r)||b(r);const[S,w]=x.useState(null),[C,k]=x.useState(null),T=x.useCallback($=>{$!==L.current&&(L.current=$,w($))},[]),R=x.useCallback($=>{$!==j.current&&(j.current=$,k($))},[]),D=a||S,z=l||C,L=x.useRef(null),j=x.useRef(null),I=x.useRef(p),Z=d!=null,P=Mg(d),W=Mg(s),H=Mg(h),F=x.useCallback(()=>{if(!L.current||!j.current)return;const $={placement:t,strategy:n,middleware:_};W.current&&($.platform=W.current),qj(L.current,j.current,$).then(J=>{const A={...J,isPositioned:H.current!==!1};V.current&&!Kd(I.current,A)&&(I.current=A,$s.flushSync(()=>{m(A)}))})},[_,t,n,W,H]);Ed(()=>{h===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,m($=>({...$,isPositioned:!1})))},[h]);const V=x.useRef(!1);Ed(()=>(V.current=!0,()=>{V.current=!1}),[]),Ed(()=>{if(D&&(L.current=D),z&&(j.current=z),D&&z){if(P.current)return P.current(D,z,F);F()}},[D,z,F,P,Z]);const U=x.useMemo(()=>({reference:L,floating:j,setReference:T,setFloating:R}),[T,R]),O=x.useMemo(()=>({reference:D,floating:z}),[D,z]),K=x.useMemo(()=>{const $={position:n,left:0,top:0};if(!O.floating)return $;const J=Ew(O.floating,p.x),A=Ew(O.floating,p.y);return u?{...$,transform:"translate("+J+"px, "+A+"px)",...QE(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:J,top:A}},[n,u,O.floating,p.x,p.y]);return x.useMemo(()=>({...p,update:F,refs:U,elements:O,floatingStyles:K}),[p,F,U,O,K])}const Yj=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?kw({element:r.current,padding:s}).fn(n):{}:r?kw({element:r,padding:s}).fn(n):{}}}},Xj=(e,t)=>{const n=Ij(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zj=(e,t)=>{const n=Hj(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qj=(e,t)=>({fn:Wj(e).fn,options:[e,t]}),Jj=(e,t)=>{const n=Fj(e);return{name:n.name,fn:n.fn,options:[e,t]}},eB=(e,t)=>{const n=Uj(e);return{name:n.name,fn:n.fn,options:[e,t]}},tB=(e,t)=>{const n=$j(e);return{name:n.name,fn:n.fn,options:[e,t]}},nB=(e,t)=>{const n=Yj(e);return{name:n.name,fn:n.fn,options:[e,t]}};var rB="Arrow",JE=x.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return v.jsx(wt.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:v.jsx("polygon",{points:"0,0 30,0 15,10"})})});JE.displayName=rB;var iB=JE;function sB(e){const[t,n]=x.useState(void 0);return Ks(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let l,u;if("borderBoxSize"in a){const d=a.borderBoxSize,h=Array.isArray(d)?d[0]:d;l=h.inlineSize,u=h.blockSize}else l=e.offsetWidth,u=e.offsetHeight;n({width:l,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var xy="Popper",[eR,pl]=Qs(xy),[oB,tR]=eR(xy),nR=e=>{const{__scopePopper:t,children:n}=e,[r,s]=x.useState(null);return v.jsx(oB,{scope:t,anchor:r,onAnchorChange:s,children:n})};nR.displayName=xy;var rR="PopperAnchor",iR=x.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=tR(rR,n),l=x.useRef(null),u=Pt(t,l),d=x.useRef(null);return x.useEffect(()=>{const h=d.current;d.current=(r==null?void 0:r.current)||l.current,h!==d.current&&a.onAnchorChange(d.current)}),r?null:v.jsx(wt.div,{...s,ref:u})});iR.displayName=rR;var Sy="PopperContent",[aB,lB]=eR(Sy),sR=x.forwardRef((e,t)=>{var me,Ce,pe,ke,Je,qe;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:p=0,sticky:m="partial",hideWhenDetached:_=!1,updatePositionStrategy:b="optimized",onPlaced:S,...w}=e,C=tR(Sy,n),[k,T]=x.useState(null),R=Pt(t,Me=>T(Me)),[D,z]=x.useState(null),L=sB(D),j=(L==null?void 0:L.width)??0,I=(L==null?void 0:L.height)??0,Z=r+(a!=="center"?"-"+a:""),P=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},W=Array.isArray(h)?h:[h],H=W.length>0,F={padding:P,boundary:W.filter(uB),altBoundary:H},{refs:V,floatingStyles:U,placement:O,isPositioned:K,middlewareData:$}=Gj({strategy:"fixed",placement:Z,whileElementsMounted:(...Me)=>Pj(...Me,{animationFrame:b==="always"}),elements:{reference:C.anchor},middleware:[Xj({mainAxis:s+I,alignmentAxis:l}),d&&Zj({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Qj():void 0,...F}),d&&Jj({...F}),eB({...F,apply:({elements:Me,rects:Ve,availableWidth:Nt,availableHeight:It})=>{const{width:ir,height:Fn}=Ve.reference,Ht=Me.floating.style;Ht.setProperty("--radix-popper-available-width",`${Nt}px`),Ht.setProperty("--radix-popper-available-height",`${It}px`),Ht.setProperty("--radix-popper-anchor-width",`${ir}px`),Ht.setProperty("--radix-popper-anchor-height",`${Fn}px`)}}),D&&nB({element:D,padding:u}),hB({arrowWidth:j,arrowHeight:I}),_&&tB({strategy:"referenceHidden",...F})]}),[J,A]=lR(O),B=Si(S);Ks(()=>{K&&(B==null||B())},[K,B]);const Y=(me=$.arrow)==null?void 0:me.x,M=(Ce=$.arrow)==null?void 0:Ce.y,X=((pe=$.arrow)==null?void 0:pe.centerOffset)!==0,[se,re]=x.useState();return Ks(()=>{k&&re(window.getComputedStyle(k).zIndex)},[k]),v.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:K?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[(ke=$.transformOrigin)==null?void 0:ke.x,(Je=$.transformOrigin)==null?void 0:Je.y].join(" "),...((qe=$.hide)==null?void 0:qe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:v.jsx(aB,{scope:n,placedSide:J,onArrowChange:z,arrowX:Y,arrowY:M,shouldHideArrow:X,children:v.jsx(wt.div,{"data-side":J,"data-align":A,...w,ref:R,style:{...w.style,animation:K?void 0:"none"}})})})});sR.displayName=Sy;var oR="PopperArrow",cB={top:"bottom",right:"left",bottom:"top",left:"right"},aR=x.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=lB(oR,r),l=cB[a.placedSide];return v.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:v.jsx(iB,{...s,ref:n,style:{...s.style,display:"block"}})})});aR.displayName=oR;function uB(e){return e!==null}var hB=e=>({name:"transformOrigin",options:e,fn(t){var C,k,T;const{placement:n,rects:r,middlewareData:s}=t,l=((C=s.arrow)==null?void 0:C.centerOffset)!==0,u=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[h,p]=lR(n),m={start:"0%",center:"50%",end:"100%"}[p],_=(((k=s.arrow)==null?void 0:k.x)??0)+u/2,b=(((T=s.arrow)==null?void 0:T.y)??0)+d/2;let S="",w="";return h==="bottom"?(S=l?m:`${_}px`,w=`${-d}px`):h==="top"?(S=l?m:`${_}px`,w=`${r.floating.height+d}px`):h==="right"?(S=`${-d}px`,w=l?m:`${b}px`):h==="left"&&(S=`${r.floating.width+d}px`,w=l?m:`${b}px`),{data:{x:S,y:w}}}});function lR(e){const[t,n="center"]=e.split("-");return[t,n]}var wy=nR,Mf=iR,Cy=sR,ky=aR,dB=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"}),fB="VisuallyHidden",cR=x.forwardRef((e,t)=>v.jsx(wt.span,{...e,ref:t,style:{...dB,...e.style}}));cR.displayName=fB;var pB=cR,[Tf]=Qs("Tooltip",[pl]),Af=pl(),uR="TooltipProvider",mB=700,Tv="tooltip.open",[gB,Ey]=Tf(uR),hR=e=>{const{__scopeTooltip:t,delayDuration:n=mB,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:a}=e,l=x.useRef(!0),u=x.useRef(!1),d=x.useRef(0);return x.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),v.jsx(gB,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:x.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:x.useCallback(h=>{u.current=h},[]),disableHoverableContent:s,children:a})};hR.displayName=uR;var Gc="Tooltip",[vB,mu]=Tf(Gc),dR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:s,onOpenChange:a,disableHoverableContent:l,delayDuration:u}=e,d=Ey(Gc,e.__scopeTooltip),h=Af(t),[p,m]=x.useState(null),_=Ka(),b=x.useRef(0),S=l??d.disableHoverableContent,w=u??d.delayDuration,C=x.useRef(!1),[k,T]=_f({prop:r,defaultProp:s??!1,onChange:j=>{j?(d.onOpen(),document.dispatchEvent(new CustomEvent(Tv))):d.onClose(),a==null||a(j)},caller:Gc}),R=x.useMemo(()=>k?C.current?"delayed-open":"instant-open":"closed",[k]),D=x.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C.current=!1,T(!0)},[T]),z=x.useCallback(()=>{window.clearTimeout(b.current),b.current=0,T(!1)},[T]),L=x.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{C.current=!0,T(!0),b.current=0},w)},[w,T]);return x.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),v.jsx(wy,{...h,children:v.jsx(vB,{scope:t,contentId:_,open:k,stateAttribute:R,trigger:p,onTriggerChange:m,onTriggerEnter:x.useCallback(()=>{d.isOpenDelayedRef.current?L():D()},[d.isOpenDelayedRef,L,D]),onTriggerLeave:x.useCallback(()=>{S?z():(window.clearTimeout(b.current),b.current=0)},[z,S]),onOpen:D,onClose:z,disableHoverableContent:S,children:n})})};dR.displayName=Gc;var Av="TooltipTrigger",fR=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=mu(Av,n),a=Ey(Av,n),l=Af(n),u=x.useRef(null),d=Pt(t,u,s.onTriggerChange),h=x.useRef(!1),p=x.useRef(!1),m=x.useCallback(()=>h.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),v.jsx(Mf,{asChild:!0,...l,children:v.jsx(wt.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:d,onPointerMove:Ne(e.onPointerMove,_=>{_.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ne(e.onPointerLeave,()=>{s.onTriggerLeave(),p.current=!1}),onPointerDown:Ne(e.onPointerDown,()=>{s.open&&s.onClose(),h.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Ne(e.onFocus,()=>{h.current||s.onOpen()}),onBlur:Ne(e.onBlur,s.onClose),onClick:Ne(e.onClick,s.onClose)})})});fR.displayName=Av;var Ry="TooltipPortal",[_B,yB]=Tf(Ry,{forceMount:void 0}),pR=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:s}=e,a=mu(Ry,t);return v.jsx(_B,{scope:t,forceMount:n,children:v.jsx(Ur,{present:n||a.open,children:v.jsx(du,{asChild:!0,container:s,children:r})})})};pR.displayName=Ry;var il="TooltipContent",mR=x.forwardRef((e,t)=>{const n=yB(il,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...a}=e,l=mu(il,e.__scopeTooltip);return v.jsx(Ur,{present:r||l.open,children:l.disableHoverableContent?v.jsx(gR,{side:s,...a,ref:t}):v.jsx(bB,{side:s,...a,ref:t})})}),bB=x.forwardRef((e,t)=>{const n=mu(il,e.__scopeTooltip),r=Ey(il,e.__scopeTooltip),s=x.useRef(null),a=Pt(t,s),[l,u]=x.useState(null),{trigger:d,onClose:h}=n,p=s.current,{onPointerInTransitChange:m}=r,_=x.useCallback(()=>{u(null),m(!1)},[m]),b=x.useCallback((S,w)=>{const C=S.currentTarget,k={x:S.clientX,y:S.clientY},T=kB(k,C.getBoundingClientRect()),R=EB(k,T),D=RB(w.getBoundingClientRect()),z=TB([...R,...D]);u(z),m(!0)},[m]);return x.useEffect(()=>()=>_(),[_]),x.useEffect(()=>{if(d&&p){const S=C=>b(C,p),w=C=>b(C,d);return d.addEventListener("pointerleave",S),p.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",S),p.removeEventListener("pointerleave",w)}}},[d,p,b,_]),x.useEffect(()=>{if(l){const S=w=>{const C=w.target,k={x:w.clientX,y:w.clientY},T=(d==null?void 0:d.contains(C))||(p==null?void 0:p.contains(C)),R=!MB(k,l);T?_():R&&(_(),h())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[d,p,l,h,_]),v.jsx(gR,{...e,ref:a})}),[xB,SB]=Tf(Gc,{isInside:!1}),wB=DO("TooltipContent"),gR=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:l,...u}=e,d=mu(il,n),h=Af(n),{onClose:p}=d;return x.useEffect(()=>(document.addEventListener(Tv,p),()=>document.removeEventListener(Tv,p)),[p]),x.useEffect(()=>{if(d.trigger){const m=_=>{const b=_.target;b!=null&&b.contains(d.trigger)&&p()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[d.trigger,p]),v.jsx(hu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:m=>m.preventDefault(),onDismiss:p,children:v.jsxs(Cy,{"data-state":d.stateAttribute,...h,...u,ref:t,style:{...u.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:[v.jsx(wB,{children:r}),v.jsx(xB,{scope:n,isInside:!0,children:v.jsx(pB,{id:d.contentId,role:"tooltip",children:s||r})})]})})});mR.displayName=il;var vR="TooltipArrow",CB=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Af(n);return SB(vR,n).isInside?null:v.jsx(ky,{...s,...r,ref:t})});CB.displayName=vR;function kB(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,s,a)){case a:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function EB(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function RB(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function MB(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const u=t[a],d=t[l],h=u.x,p=u.y,m=d.x,_=d.y;p>r!=_>r&&n<(m-h)*(r-p)/(_-p)+h&&(s=!s)}return s}function TB(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),AB(t)}function AB(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const a=t[t.length-1],l=t[t.length-2];if((a.x-l.x)*(s.y-l.y)>=(a.y-l.y)*(s.x-l.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const a=n[n.length-1],l=n[n.length-2];if((a.x-l.x)*(s.y-l.y)>=(a.y-l.y)*(s.x-l.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var DB=hR,NB=dR,OB=fR,LB=pR,_R=mR;const zB=DB,Yc=NB,Xc=OB,sl=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>v.jsx(LB,{children:v.jsx(_R,{ref:r,sideOffset:t,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),...n})}));sl.displayName=_R.displayName;const jB="0.7.0",BB={version:jB},zn="Kanna",Rw="kanna",yR=`kanna/${BB.version}`,PB="[kanna]",IB=`~/${zn}`;function ed(e){return e?`${Rw} ${e}`:Rw}const Df=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...s})=>v.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:ye("mx-auto max-w-md text-foreground/50",r?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],t),...s,children:e});function Dv(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const HB=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function FB(e){const t=e.trim();for(const n of HB){const r=t.match(n);if(!r)continue;const s=(r[2]??r[1]??"").trim();if(s)return s}return t}function bR(e){return e.split("/").pop()||e}function UB(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,s=60*r,a=24*s,l=7*a;return n<r?"now":n<s?`${Math.floor(n/r)}m`:n<a?`${Math.floor(n/s)}h`:n<l?`${Math.floor(n/a)}d`:`${Math.floor(n/l)}w`}const $B=new Set(["starting","running"]);function WB({chat:e,activeChatId:t,nowMs:n,onSelectChat:r,onDeleteChat:s}){const a=UB(e.lastMessageAt,n);return v.jsxs("div",{"data-chat-id":YS(e.chatId),className:ye("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===YS(e.chatId)?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>r(e.chatId),children:[$B.has(e.status)?v.jsx(Js,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?v.jsx("div",{className:"relative ",children:v.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[v.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),v.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,v.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?v.jsx(Df,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),v.jsxs("div",{className:"relative h-7 w-7 mr-[2px] shrink-0",children:[a?v.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50 transition-opacity group-hover:opacity-0",children:a}):null,v.jsx(et,{variant:"ghost",size:"icon",className:ye("absolute inset-0 h-7 w-7 opacity-100 cursor-pointer rounded-sm hover:!bg-transparent !border-0",a?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),onClick:l=>{l.stopPropagation(),s(e.chatId)},title:"Delete chat",children:v.jsx(az,{className:"size-3.5"})})]})]},e._id)}function qB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const Nf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ml(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function My(e){return"nodeType"in e}function nr(e){var t,n;return e?ml(e)?e:My(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Ty(e){const{Document:t}=nr(e);return e instanceof t}function gu(e){return ml(e)?!1:e instanceof nr(e).HTMLElement}function xR(e){return e instanceof nr(e).SVGElement}function gl(e){return e?ml(e)?e.document:My(e)?Ty(e)?e:gu(e)||xR(e)?e.ownerDocument:document:document:document}const wi=Nf?x.useLayoutEffect:x.useEffect;function Ay(e){const t=x.useRef(e);return wi(()=>{t.current=e}),x.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function VB(){const e=x.useRef(null),t=x.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=x.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Zc(e,t){t===void 0&&(t=[e]);const n=x.useRef(e);return wi(()=>{n.current!==e&&(n.current=e)},t),n}function vu(e,t){const n=x.useRef();return x.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Gd(e){const t=Ay(e),n=x.useRef(null),r=x.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Nv(e){const t=x.useRef();return x.useEffect(()=>{t.current=e},[e]),t.current}let Tg={};function _u(e,t){return x.useMemo(()=>{if(t)return t;const n=Tg[e]==null?0:Tg[e]+1;return Tg[e]=n,e+"-"+n},[e,t])}function SR(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((a,l)=>{const u=Object.entries(l);for(const[d,h]of u){const p=a[d];p!=null&&(a[d]=p+e*h)}return a},{...t})}}const Xa=SR(1),Yd=SR(-1);function KB(e){return"clientX"in e&&"clientY"in e}function Dy(e){if(!e)return!1;const{KeyboardEvent:t}=nr(e.target);return t&&e instanceof t}function GB(e){if(!e)return!1;const{TouchEvent:t}=nr(e.target);return t&&e instanceof t}function Ov(e){if(GB(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return KB(e)?{x:e.clientX,y:e.clientY}:null}const Qc=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Qc.Translate.toString(e),Qc.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Mw="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function YB(e){return e.matches(Mw)?e:e.querySelector(Mw)}const XB={display:"none"};function ZB(e){let{id:t,value:n}=e;return vt.createElement("div",{id:t,style:XB},n)}function QB(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={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 vt.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function JB(){const[e,t]=x.useState("");return{announce:x.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const wR=x.createContext(null);function eP(e){const t=x.useContext(wR);x.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function tP(){const[e]=x.useState(()=>new Set),t=x.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[x.useCallback(r=>{let{type:s,event:a}=r;e.forEach(l=>{var u;return(u=l[s])==null?void 0:u.call(l,a)})},[e]),t]}const nP={draggable:`
414
+ */const F6=[["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"}]],Ud=Re("zap",F6),Vc="data-focus-fallback-ignore",LE="data-allow-focus-retain",$d="kanna:restore-chat-input-focus",fy="data-chat-input",kv="data-chat-selection-zone";function nl(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function zE(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:nl(e,LE):!1}function U6(e){const t=e;return t!=null&&t.matches?zE(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:nl(e,LE):!1}function pw(e){return!!e.querySelector(`[${Vc}][data-state='open']`)}function $6(e){return nl(e,fy)}function mw(e){return nl(e,kv)}function W6(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function q6(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${fy}]`)).filter(l=>!l.disabled);if(n.length===0)return!1;const r=n.indexOf(e),s=r>=0?(r+1)%n.length:0,a=n[s];return a?(a.focus({preventScroll:!0}),!0):!1}function V6(e){const{activeElement:t,fallback:n,hasActiveOverlay:r,canCancel:s,defaultPrevented:a}=e;return!(a||!n||n.disabled||r||t===n||$6(t)||s)}function K6(e){const{activeElement:t,pointerStartTarget:n,pointerEndTarget:r,root:s,fallback:a,hasActiveOverlay:l,hasActiveSelection:u}=e,d=r??n;return!s||!a||a.disabled||!d||!s.contains(d)||nl(d,Vc)||l||t===a||nl(t,Vc)||u&&(mw(n)||mw(d))||zE(t)?!1:t&&t===d?!0:!U6(t)}const jE=XL,G6=ZL,BE=x.forwardRef(({className:e,...t},n)=>v.jsx(EE,{ref:n,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),...t}));BE.displayName=EE.displayName;const Y6={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},py=x.forwardRef(({className:e,children:t,size:n="md",...r},s)=>v.jsxs(G6,{children:[v.jsx(BE,{}),v.jsxs(RE,{ref:s,[Vc]:"",onCloseAutoFocus:a=>{var l;a.preventDefault(),window.dispatchEvent(new Event($d)),(l=r.onCloseAutoFocus)==null||l.call(r,a)},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",Y6[n],e),...r,children:[t,v.jsxs(ez,{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:[v.jsx(fu,{className:"h-4 w-4"}),v.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));py.displayName=RE.displayName;function PE({className:e,...t}){return v.jsx(QL,{className:ye("text-lg font-medium leading-none tracking-tight",e),...t})}function X6({className:e,...t}){return v.jsx(JL,{className:ye("text-sm text-muted-foreground",e),...t})}function IE({className:e,...t}){return v.jsx("div",{className:ye("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function HE({className:e,...t}){return v.jsx("div",{className:ye("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}const FE=x.createContext(null);function Z6({children:e}){const[t,n]=x.useState(null),[r,s]=x.useState(""),a=x.useRef(null);x.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(s(t.options.initialValue??""),setTimeout(()=>{var p,m;(p=a.current)==null||p.focus(),(m=a.current)==null||m.select()},0))},[t]);const l=x.useCallback(()=>{n(null),s("")},[]),u=x.useCallback(p=>new Promise(m=>{n({kind:"confirm",options:p,resolve:m})}),[]),d=x.useCallback(p=>new Promise(m=>{n({kind:"prompt",options:p,resolve:m})}),[]),h=x.useMemo(()=>({confirm:u,prompt:d}),[u,d]);return v.jsxs(FE.Provider,{value:h,children:[e,v.jsx(jE,{open:t!==null,onOpenChange:p=>{p||!t||(t.kind==="confirm"?t.resolve(!1):t.resolve(null),l())},children:v.jsx(py,{size:"sm",children:t?v.jsxs(v.Fragment,{children:[v.jsxs(IE,{className:"space-y-4",children:[v.jsx(PE,{children:t.options.title}),t.options.description?v.jsx(X6,{children:t.options.description}):null,t.kind==="prompt"?v.jsx("input",{ref:a,type:"text",value:r,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),t.resolve(r.trim()||null),l())},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:t.options.placeholder}):null]}),v.jsxs(HE,{children:[v.jsx(et,{variant:"ghost",size:"sm",onClick:()=>{t.kind==="confirm"?t.resolve(!1):t.resolve(null),l()},children:t.options.cancelLabel??"Cancel"}),v.jsx(et,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:()=>{t.kind==="confirm"?t.resolve(!0):t.resolve(r.trim()||null),l()},disabled:t.kind==="prompt"&&!r.trim(),children:t.options.confirmLabel??"Confirm"})]})]}):null})})]})}function Q6(){const e=x.useContext(FE);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const J6=["top","right","bottom","left"],Gs=Math.min,gr=Math.max,Wd=Math.round,Jh=Math.floor,yi=e=>({x:e,y:e}),ej={left:"right",right:"left",bottom:"top",top:"bottom"};function Ev(e,t,n){return gr(e,Gs(t,n))}function ns(e,t){return typeof e=="function"?e(t):e}function rs(e){return e.split("-")[0]}function dl(e){return e.split("-")[1]}function my(e){return e==="x"?"y":"x"}function gy(e){return e==="y"?"height":"width"}function mi(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function vy(e){return my(mi(e))}function tj(e,t,n){n===void 0&&(n=!1);const r=dl(e),s=vy(e),a=gy(s);let l=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=qd(l)),[l,qd(l)]}function nj(e){const t=qd(e);return[Rv(e),t,Rv(t)]}function Rv(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const gw=["left","right"],vw=["right","left"],rj=["top","bottom"],ij=["bottom","top"];function sj(e,t,n){switch(e){case"top":case"bottom":return n?t?vw:gw:t?gw:vw;case"left":case"right":return t?rj:ij;default:return[]}}function oj(e,t,n,r){const s=dl(e);let a=sj(rs(e),n==="start",r);return s&&(a=a.map(l=>l+"-"+s),t&&(a=a.concat(a.map(Rv)))),a}function qd(e){const t=rs(e);return ej[t]+e.slice(t.length)}function aj(e){return{top:0,right:0,bottom:0,left:0,...e}}function UE(e){return typeof e!="number"?aj(e):{top:e,right:e,bottom:e,left:e}}function Vd(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function _w(e,t,n){let{reference:r,floating:s}=e;const a=mi(t),l=vy(t),u=gy(l),d=rs(t),h=a==="y",p=r.x+r.width/2-s.width/2,m=r.y+r.height/2-s.height/2,_=r[u]/2-s[u]/2;let b;switch(d){case"top":b={x:p,y:r.y-s.height};break;case"bottom":b={x:p,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-s.width,y:m};break;default:b={x:r.x,y:r.y}}switch(dl(t)){case"start":b[l]-=_*(n&&h?-1:1);break;case"end":b[l]+=_*(n&&h?-1:1);break}return b}async function lj(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:l,elements:u,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:p="viewport",elementContext:m="floating",altBoundary:_=!1,padding:b=0}=ns(t,e),S=UE(b),C=u[_?m==="floating"?"reference":"floating":m],k=Vd(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(C)))==null||n?C:C.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(u.floating)),boundary:h,rootBoundary:p,strategy:d})),T=m==="floating"?{x:r,y:s,width:l.floating.width,height:l.floating.height}:l.reference,R=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u.floating)),D=await(a.isElement==null?void 0:a.isElement(R))?await(a.getScale==null?void 0:a.getScale(R))||{x:1,y:1}:{x:1,y:1},z=Vd(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:T,offsetParent:R,strategy:d}):T);return{top:(k.top-z.top+S.top)/D.y,bottom:(z.bottom-k.bottom+S.bottom)/D.y,left:(k.left-z.left+S.left)/D.x,right:(z.right-k.right+S.right)/D.x}}const cj=50,uj=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:l}=n,u=l.detectOverflow?l:{...l,detectOverflow:lj},d=await(l.isRTL==null?void 0:l.isRTL(t));let h=await l.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:m}=_w(h,r,d),_=r,b=0;const S={};for(let w=0;w<a.length;w++){const C=a[w];if(!C)continue;const{name:k,fn:T}=C,{x:R,y:D,data:z,reset:L}=await T({x:p,y:m,initialPlacement:r,placement:_,strategy:s,middlewareData:S,rects:h,platform:u,elements:{reference:e,floating:t}});p=R??p,m=D??m,S[k]={...S[k],...z},L&&b<cj&&(b++,typeof L=="object"&&(L.placement&&(_=L.placement),L.rects&&(h=L.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:s}):L.rects),{x:p,y:m}=_w(h,_,d)),w=-1)}return{x:p,y:m,placement:_,strategy:s,middlewareData:S}},hj=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:l,elements:u,middlewareData:d}=t,{element:h,padding:p=0}=ns(e,t)||{};if(h==null)return{};const m=UE(p),_={x:n,y:r},b=vy(s),S=gy(b),w=await l.getDimensions(h),C=b==="y",k=C?"top":"left",T=C?"bottom":"right",R=C?"clientHeight":"clientWidth",D=a.reference[S]+a.reference[b]-_[b]-a.floating[S],z=_[b]-a.reference[b],L=await(l.getOffsetParent==null?void 0:l.getOffsetParent(h));let j=L?L[R]:0;(!j||!await(l.isElement==null?void 0:l.isElement(L)))&&(j=u.floating[R]||a.floating[S]);const I=D/2-z/2,Z=j/2-w[S]/2-1,P=Gs(m[k],Z),W=Gs(m[T],Z),H=P,F=j-w[S]-W,V=j/2-w[S]/2+I,U=Ev(H,V,F),O=!d.arrow&&dl(s)!=null&&V!==U&&a.reference[S]/2-(V<H?P:W)-w[S]/2<0,K=O?V<H?V-H:V-F:0;return{[b]:_[b]+K,data:{[b]:U,centerOffset:V-U-K,...O&&{alignmentOffset:K}},reset:O}}}),dj=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:l,initialPlacement:u,platform:d,elements:h}=t,{mainAxis:p=!0,crossAxis:m=!0,fallbackPlacements:_,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:w=!0,...C}=ns(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const k=rs(s),T=mi(u),R=rs(u)===u,D=await(d.isRTL==null?void 0:d.isRTL(h.floating)),z=_||(R||!w?[qd(u)]:nj(u)),L=S!=="none";!_&&L&&z.push(...oj(u,w,S,D));const j=[u,...z],I=await d.detectOverflow(t,C),Z=[];let P=((r=a.flip)==null?void 0:r.overflows)||[];if(p&&Z.push(I[k]),m){const V=tj(s,l,D);Z.push(I[V[0]],I[V[1]])}if(P=[...P,{placement:s,overflows:Z}],!Z.every(V=>V<=0)){var W,H;const V=(((W=a.flip)==null?void 0:W.index)||0)+1,U=j[V];if(U&&(!(m==="alignment"?T!==mi(U):!1)||P.every($=>mi($.placement)===T?$.overflows[0]>0:!0)))return{data:{index:V,overflows:P},reset:{placement:U}};let O=(H=P.filter(K=>K.overflows[0]<=0).sort((K,$)=>K.overflows[1]-$.overflows[1])[0])==null?void 0:H.placement;if(!O)switch(b){case"bestFit":{var F;const K=(F=P.filter($=>{if(L){const J=mi($.placement);return J===T||J==="y"}return!0}).map($=>[$.placement,$.overflows.filter(J=>J>0).reduce((J,A)=>J+A,0)]).sort(($,J)=>$[1]-J[1])[0])==null?void 0:F[0];K&&(O=K);break}case"initialPlacement":O=u;break}if(s!==O)return{reset:{placement:O}}}return{}}}};function yw(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bw(e){return J6.some(t=>e[t]>=0)}const fj=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...a}=ns(e,t);switch(s){case"referenceHidden":{const l=await r.detectOverflow(t,{...a,elementContext:"reference"}),u=yw(l,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:bw(u)}}}case"escaped":{const l=await r.detectOverflow(t,{...a,altBoundary:!0}),u=yw(l,n.floating);return{data:{escapedOffsets:u,escaped:bw(u)}}}default:return{}}}}},$E=new Set(["left","top"]);async function pj(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),l=rs(n),u=dl(n),d=mi(n)==="y",h=$E.has(l)?-1:1,p=a&&d?-1:1,m=ns(t,e);let{mainAxis:_,crossAxis:b,alignmentAxis:S}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return u&&typeof S=="number"&&(b=u==="end"?S*-1:S),d?{x:b*p,y:_*h}:{x:_*h,y:b*p}}const mj=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:l,middlewareData:u}=t,d=await pj(t,e);return l===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:s+d.x,y:a+d.y,data:{...d,placement:l}}}}},gj=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:a}=t,{mainAxis:l=!0,crossAxis:u=!1,limiter:d={fn:k=>{let{x:T,y:R}=k;return{x:T,y:R}}},...h}=ns(e,t),p={x:n,y:r},m=await a.detectOverflow(t,h),_=mi(rs(s)),b=my(_);let S=p[b],w=p[_];if(l){const k=b==="y"?"top":"left",T=b==="y"?"bottom":"right",R=S+m[k],D=S-m[T];S=Ev(R,S,D)}if(u){const k=_==="y"?"top":"left",T=_==="y"?"bottom":"right",R=w+m[k],D=w-m[T];w=Ev(R,w,D)}const C=d.fn({...t,[b]:S,[_]:w});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[b]:l,[_]:u}}}}}},vj=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:l}=t,{offset:u=0,mainAxis:d=!0,crossAxis:h=!0}=ns(e,t),p={x:n,y:r},m=mi(s),_=my(m);let b=p[_],S=p[m];const w=ns(u,t),C=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const R=_==="y"?"height":"width",D=a.reference[_]-a.floating[R]+C.mainAxis,z=a.reference[_]+a.reference[R]-C.mainAxis;b<D?b=D:b>z&&(b=z)}if(h){var k,T;const R=_==="y"?"width":"height",D=$E.has(rs(s)),z=a.reference[m]-a.floating[R]+(D&&((k=l.offset)==null?void 0:k[m])||0)+(D?0:C.crossAxis),L=a.reference[m]+a.reference[R]+(D?0:((T=l.offset)==null?void 0:T[m])||0)-(D?C.crossAxis:0);S<z?S=z:S>L&&(S=L)}return{[_]:b,[m]:S}}}},_j=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:l,elements:u}=t,{apply:d=()=>{},...h}=ns(e,t),p=await l.detectOverflow(t,h),m=rs(s),_=dl(s),b=mi(s)==="y",{width:S,height:w}=a.floating;let C,k;m==="top"||m==="bottom"?(C=m,k=_===(await(l.isRTL==null?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(k=m,C=_==="end"?"top":"bottom");const T=w-p.top-p.bottom,R=S-p.left-p.right,D=Gs(w-p[C],T),z=Gs(S-p[k],R),L=!t.middlewareData.shift;let j=D,I=z;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(j=T),L&&!_){const P=gr(p.left,0),W=gr(p.right,0),H=gr(p.top,0),F=gr(p.bottom,0);b?I=S-2*(P!==0||W!==0?P+W:gr(p.left,p.right)):j=w-2*(H!==0||F!==0?H+F:gr(p.top,p.bottom))}await d({...t,availableWidth:I,availableHeight:j});const Z=await l.getDimensions(u.floating);return S!==Z.width||w!==Z.height?{reset:{rects:!0}}:{}}}};function Cf(){return typeof window<"u"}function fl(e){return WE(e)?(e.nodeName||"").toLowerCase():"#document"}function vr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ei(e){var t;return(t=(WE(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function WE(e){return Cf()?e instanceof Node||e instanceof vr(e).Node:!1}function Qr(e){return Cf()?e instanceof Element||e instanceof vr(e).Element:!1}function ss(e){return Cf()?e instanceof HTMLElement||e instanceof vr(e).HTMLElement:!1}function xw(e){return!Cf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vr(e).ShadowRoot}function pu(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Jr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function yj(e){return/^(table|td|th)$/.test(fl(e))}function kf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const bj=/transform|translate|scale|rotate|perspective|filter/,xj=/paint|layout|strict|content/,wo=e=>!!e&&e!=="none";let Eg;function _y(e){const t=Qr(e)?Jr(e):e;return wo(t.transform)||wo(t.translate)||wo(t.scale)||wo(t.rotate)||wo(t.perspective)||!yy()&&(wo(t.backdropFilter)||wo(t.filter))||bj.test(t.willChange||"")||xj.test(t.contain||"")}function Sj(e){let t=Ys(e);for(;ss(t)&&!rl(t);){if(_y(t))return t;if(kf(t))return null;t=Ys(t)}return null}function yy(){return Eg==null&&(Eg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Eg}function rl(e){return/^(html|body|#document)$/.test(fl(e))}function Jr(e){return vr(e).getComputedStyle(e)}function Ef(e){return Qr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ys(e){if(fl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xw(e)&&e.host||Ei(e);return xw(t)?t.host:t}function qE(e){const t=Ys(e);return rl(t)?e.ownerDocument?e.ownerDocument.body:e.body:ss(t)&&pu(t)?t:qE(t)}function Kc(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=qE(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),l=vr(s);if(a){const u=Mv(l);return t.concat(l,l.visualViewport||[],pu(s)?s:[],u&&n?Kc(u):[])}else return t.concat(s,Kc(s,[],n))}function Mv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function VE(e){const t=Jr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ss(e),a=s?e.offsetWidth:n,l=s?e.offsetHeight:r,u=Wd(n)!==a||Wd(r)!==l;return u&&(n=a,r=l),{width:n,height:r,$:u}}function by(e){return Qr(e)?e:e.contextElement}function Ya(e){const t=by(e);if(!ss(t))return yi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=VE(t);let l=(a?Wd(n.width):n.width)/r,u=(a?Wd(n.height):n.height)/s;return(!l||!Number.isFinite(l))&&(l=1),(!u||!Number.isFinite(u))&&(u=1),{x:l,y:u}}const wj=yi(0);function KE(e){const t=vr(e);return!yy()||!t.visualViewport?wj:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Cj(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vr(e)?!1:t}function jo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=by(e);let l=yi(1);t&&(r?Qr(r)&&(l=Ya(r)):l=Ya(e));const u=Cj(a,n,r)?KE(a):yi(0);let d=(s.left+u.x)/l.x,h=(s.top+u.y)/l.y,p=s.width/l.x,m=s.height/l.y;if(a){const _=vr(a),b=r&&Qr(r)?vr(r):r;let S=_,w=Mv(S);for(;w&&r&&b!==S;){const C=Ya(w),k=w.getBoundingClientRect(),T=Jr(w),R=k.left+(w.clientLeft+parseFloat(T.paddingLeft))*C.x,D=k.top+(w.clientTop+parseFloat(T.paddingTop))*C.y;d*=C.x,h*=C.y,p*=C.x,m*=C.y,d+=R,h+=D,S=vr(w),w=Mv(S)}}return Vd({width:p,height:m,x:d,y:h})}function Rf(e,t){const n=Ef(e).scrollLeft;return t?t.left+n:jo(Ei(e)).left+n}function GE(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Rf(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function kj(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",l=Ei(r),u=t?kf(t.floating):!1;if(r===l||u&&a)return n;let d={scrollLeft:0,scrollTop:0},h=yi(1);const p=yi(0),m=ss(r);if((m||!m&&!a)&&((fl(r)!=="body"||pu(l))&&(d=Ef(r)),m)){const b=jo(r);h=Ya(r),p.x=b.x+r.clientLeft,p.y=b.y+r.clientTop}const _=l&&!m&&!a?GE(l,d):yi(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-d.scrollLeft*h.x+p.x+_.x,y:n.y*h.y-d.scrollTop*h.y+p.y+_.y}}function Ej(e){return Array.from(e.getClientRects())}function Rj(e){const t=Ei(e),n=Ef(e),r=e.ownerDocument.body,s=gr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=gr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let l=-n.scrollLeft+Rf(e);const u=-n.scrollTop;return Jr(r).direction==="rtl"&&(l+=gr(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:l,y:u}}const Sw=25;function Mj(e,t){const n=vr(e),r=Ei(e),s=n.visualViewport;let a=r.clientWidth,l=r.clientHeight,u=0,d=0;if(s){a=s.width,l=s.height;const p=yy();(!p||p&&t==="fixed")&&(u=s.offsetLeft,d=s.offsetTop)}const h=Rf(r);if(h<=0){const p=r.ownerDocument,m=p.body,_=getComputedStyle(m),b=p.compatMode==="CSS1Compat"&&parseFloat(_.marginLeft)+parseFloat(_.marginRight)||0,S=Math.abs(r.clientWidth-m.clientWidth-b);S<=Sw&&(a-=S)}else h<=Sw&&(a+=h);return{width:a,height:l,x:u,y:d}}function Tj(e,t){const n=jo(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=ss(e)?Ya(e):yi(1),l=e.clientWidth*a.x,u=e.clientHeight*a.y,d=s*a.x,h=r*a.y;return{width:l,height:u,x:d,y:h}}function ww(e,t,n){let r;if(t==="viewport")r=Mj(e,n);else if(t==="document")r=Rj(Ei(e));else if(Qr(t))r=Tj(t,n);else{const s=KE(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Vd(r)}function YE(e,t){const n=Ys(e);return n===t||!Qr(n)||rl(n)?!1:Jr(n).position==="fixed"||YE(n,t)}function Aj(e,t){const n=t.get(e);if(n)return n;let r=Kc(e,[],!1).filter(u=>Qr(u)&&fl(u)!=="body"),s=null;const a=Jr(e).position==="fixed";let l=a?Ys(e):e;for(;Qr(l)&&!rl(l);){const u=Jr(l),d=_y(l);!d&&u.position==="fixed"&&(s=null),(a?!d&&!s:!d&&u.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||pu(l)&&!d&&YE(e,l))?r=r.filter(p=>p!==l):s=u,l=Ys(l)}return t.set(e,r),r}function Dj(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const l=[...n==="clippingAncestors"?kf(t)?[]:Aj(t,this._c):[].concat(n),r],u=ww(t,l[0],s);let d=u.top,h=u.right,p=u.bottom,m=u.left;for(let _=1;_<l.length;_++){const b=ww(t,l[_],s);d=gr(b.top,d),h=Gs(b.right,h),p=Gs(b.bottom,p),m=gr(b.left,m)}return{width:h-m,height:p-d,x:m,y:d}}function Nj(e){const{width:t,height:n}=VE(e);return{width:t,height:n}}function Oj(e,t,n){const r=ss(t),s=Ei(t),a=n==="fixed",l=jo(e,!0,a,t);let u={scrollLeft:0,scrollTop:0};const d=yi(0);function h(){d.x=Rf(s)}if(r||!r&&!a)if((fl(t)!=="body"||pu(s))&&(u=Ef(t)),r){const b=jo(t,!0,a,t);d.x=b.x+t.clientLeft,d.y=b.y+t.clientTop}else s&&h();a&&!r&&s&&h();const p=s&&!r&&!a?GE(s,u):yi(0),m=l.left+u.scrollLeft-d.x-p.x,_=l.top+u.scrollTop-d.y-p.y;return{x:m,y:_,width:l.width,height:l.height}}function Rg(e){return Jr(e).position==="static"}function Cw(e,t){if(!ss(e)||Jr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ei(e)===n&&(n=n.ownerDocument.body),n}function XE(e,t){const n=vr(e);if(kf(e))return n;if(!ss(e)){let s=Ys(e);for(;s&&!rl(s);){if(Qr(s)&&!Rg(s))return s;s=Ys(s)}return n}let r=Cw(e,t);for(;r&&yj(r)&&Rg(r);)r=Cw(r,t);return r&&rl(r)&&Rg(r)&&!_y(r)?n:r||Sj(e)||n}const Lj=async function(e){const t=this.getOffsetParent||XE,n=this.getDimensions,r=await n(e.floating);return{reference:Oj(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zj(e){return Jr(e).direction==="rtl"}const jj={convertOffsetParentRelativeRectToViewportRelativeRect:kj,getDocumentElement:Ei,getClippingRect:Dj,getOffsetParent:XE,getElementRects:Lj,getClientRects:Ej,getDimensions:Nj,getScale:Ya,isElement:Qr,isRTL:zj};function ZE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bj(e,t){let n=null,r;const s=Ei(e);function a(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function l(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),a();const h=e.getBoundingClientRect(),{left:p,top:m,width:_,height:b}=h;if(u||t(),!_||!b)return;const S=Jh(m),w=Jh(s.clientWidth-(p+_)),C=Jh(s.clientHeight-(m+b)),k=Jh(p),R={rootMargin:-S+"px "+-w+"px "+-C+"px "+-k+"px",threshold:gr(0,Gs(1,d))||1};let D=!0;function z(L){const j=L[0].intersectionRatio;if(j!==d){if(!D)return l();j?l(!1,j):r=setTimeout(()=>{l(!1,1e-7)},1e3)}j===1&&!ZE(h,e.getBoundingClientRect())&&l(),D=!1}try{n=new IntersectionObserver(z,{...R,root:s.ownerDocument})}catch{n=new IntersectionObserver(z,R)}n.observe(e)}return l(!0),a}function Pj(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,h=by(e),p=s||a?[...h?Kc(h):[],...t?Kc(t):[]]:[];p.forEach(k=>{s&&k.addEventListener("scroll",n,{passive:!0}),a&&k.addEventListener("resize",n)});const m=h&&u?Bj(h,n):null;let _=-1,b=null;l&&(b=new ResizeObserver(k=>{let[T]=k;T&&T.target===h&&b&&t&&(b.unobserve(t),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(t)})),n()}),h&&!d&&b.observe(h),t&&b.observe(t));let S,w=d?jo(e):null;d&&C();function C(){const k=jo(e);w&&!ZE(w,k)&&n(),w=k,S=requestAnimationFrame(C)}return n(),()=>{var k;p.forEach(T=>{s&&T.removeEventListener("scroll",n),a&&T.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,d&&cancelAnimationFrame(S)}}const Ij=mj,Hj=gj,Fj=dj,Uj=_j,$j=fj,kw=hj,Wj=vj,qj=(e,t,n)=>{const r=new Map,s={platform:jj,...n},a={...s.platform,_c:r};return uj(e,t,{...s,platform:a})};var Vj=typeof document<"u",Kj=function(){},Ed=Vj?x.useLayoutEffect:Kj;function Kd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Kd(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!Kd(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function QE(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ew(e,t){const n=QE(e);return Math.round(t*n)/n}function Mg(e){const t=x.useRef(e);return Ed(()=>{t.current=e}),t}function Gj(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:l}={},transform:u=!0,whileElementsMounted:d,open:h}=e,[p,m]=x.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[_,b]=x.useState(r);Kd(_,r)||b(r);const[S,w]=x.useState(null),[C,k]=x.useState(null),T=x.useCallback($=>{$!==L.current&&(L.current=$,w($))},[]),R=x.useCallback($=>{$!==j.current&&(j.current=$,k($))},[]),D=a||S,z=l||C,L=x.useRef(null),j=x.useRef(null),I=x.useRef(p),Z=d!=null,P=Mg(d),W=Mg(s),H=Mg(h),F=x.useCallback(()=>{if(!L.current||!j.current)return;const $={placement:t,strategy:n,middleware:_};W.current&&($.platform=W.current),qj(L.current,j.current,$).then(J=>{const A={...J,isPositioned:H.current!==!1};V.current&&!Kd(I.current,A)&&(I.current=A,$s.flushSync(()=>{m(A)}))})},[_,t,n,W,H]);Ed(()=>{h===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,m($=>({...$,isPositioned:!1})))},[h]);const V=x.useRef(!1);Ed(()=>(V.current=!0,()=>{V.current=!1}),[]),Ed(()=>{if(D&&(L.current=D),z&&(j.current=z),D&&z){if(P.current)return P.current(D,z,F);F()}},[D,z,F,P,Z]);const U=x.useMemo(()=>({reference:L,floating:j,setReference:T,setFloating:R}),[T,R]),O=x.useMemo(()=>({reference:D,floating:z}),[D,z]),K=x.useMemo(()=>{const $={position:n,left:0,top:0};if(!O.floating)return $;const J=Ew(O.floating,p.x),A=Ew(O.floating,p.y);return u?{...$,transform:"translate("+J+"px, "+A+"px)",...QE(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:J,top:A}},[n,u,O.floating,p.x,p.y]);return x.useMemo(()=>({...p,update:F,refs:U,elements:O,floatingStyles:K}),[p,F,U,O,K])}const Yj=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?kw({element:r.current,padding:s}).fn(n):{}:r?kw({element:r,padding:s}).fn(n):{}}}},Xj=(e,t)=>{const n=Ij(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zj=(e,t)=>{const n=Hj(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qj=(e,t)=>({fn:Wj(e).fn,options:[e,t]}),Jj=(e,t)=>{const n=Fj(e);return{name:n.name,fn:n.fn,options:[e,t]}},eB=(e,t)=>{const n=Uj(e);return{name:n.name,fn:n.fn,options:[e,t]}},tB=(e,t)=>{const n=$j(e);return{name:n.name,fn:n.fn,options:[e,t]}},nB=(e,t)=>{const n=Yj(e);return{name:n.name,fn:n.fn,options:[e,t]}};var rB="Arrow",JE=x.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return v.jsx(wt.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:v.jsx("polygon",{points:"0,0 30,0 15,10"})})});JE.displayName=rB;var iB=JE;function sB(e){const[t,n]=x.useState(void 0);return Ks(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let l,u;if("borderBoxSize"in a){const d=a.borderBoxSize,h=Array.isArray(d)?d[0]:d;l=h.inlineSize,u=h.blockSize}else l=e.offsetWidth,u=e.offsetHeight;n({width:l,height:u})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var xy="Popper",[eR,pl]=Qs(xy),[oB,tR]=eR(xy),nR=e=>{const{__scopePopper:t,children:n}=e,[r,s]=x.useState(null);return v.jsx(oB,{scope:t,anchor:r,onAnchorChange:s,children:n})};nR.displayName=xy;var rR="PopperAnchor",iR=x.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=tR(rR,n),l=x.useRef(null),u=Pt(t,l),d=x.useRef(null);return x.useEffect(()=>{const h=d.current;d.current=(r==null?void 0:r.current)||l.current,h!==d.current&&a.onAnchorChange(d.current)}),r?null:v.jsx(wt.div,{...s,ref:u})});iR.displayName=rR;var Sy="PopperContent",[aB,lB]=eR(Sy),sR=x.forwardRef((e,t)=>{var me,Ce,pe,ke,Je,qe;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:p=0,sticky:m="partial",hideWhenDetached:_=!1,updatePositionStrategy:b="optimized",onPlaced:S,...w}=e,C=tR(Sy,n),[k,T]=x.useState(null),R=Pt(t,Me=>T(Me)),[D,z]=x.useState(null),L=sB(D),j=(L==null?void 0:L.width)??0,I=(L==null?void 0:L.height)??0,Z=r+(a!=="center"?"-"+a:""),P=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},W=Array.isArray(h)?h:[h],H=W.length>0,F={padding:P,boundary:W.filter(uB),altBoundary:H},{refs:V,floatingStyles:U,placement:O,isPositioned:K,middlewareData:$}=Gj({strategy:"fixed",placement:Z,whileElementsMounted:(...Me)=>Pj(...Me,{animationFrame:b==="always"}),elements:{reference:C.anchor},middleware:[Xj({mainAxis:s+I,alignmentAxis:l}),d&&Zj({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Qj():void 0,...F}),d&&Jj({...F}),eB({...F,apply:({elements:Me,rects:Ve,availableWidth:Nt,availableHeight:It})=>{const{width:ir,height:Fn}=Ve.reference,Ht=Me.floating.style;Ht.setProperty("--radix-popper-available-width",`${Nt}px`),Ht.setProperty("--radix-popper-available-height",`${It}px`),Ht.setProperty("--radix-popper-anchor-width",`${ir}px`),Ht.setProperty("--radix-popper-anchor-height",`${Fn}px`)}}),D&&nB({element:D,padding:u}),hB({arrowWidth:j,arrowHeight:I}),_&&tB({strategy:"referenceHidden",...F})]}),[J,A]=lR(O),B=Si(S);Ks(()=>{K&&(B==null||B())},[K,B]);const Y=(me=$.arrow)==null?void 0:me.x,M=(Ce=$.arrow)==null?void 0:Ce.y,X=((pe=$.arrow)==null?void 0:pe.centerOffset)!==0,[se,re]=x.useState();return Ks(()=>{k&&re(window.getComputedStyle(k).zIndex)},[k]),v.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:K?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[(ke=$.transformOrigin)==null?void 0:ke.x,(Je=$.transformOrigin)==null?void 0:Je.y].join(" "),...((qe=$.hide)==null?void 0:qe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:v.jsx(aB,{scope:n,placedSide:J,onArrowChange:z,arrowX:Y,arrowY:M,shouldHideArrow:X,children:v.jsx(wt.div,{"data-side":J,"data-align":A,...w,ref:R,style:{...w.style,animation:K?void 0:"none"}})})})});sR.displayName=Sy;var oR="PopperArrow",cB={top:"bottom",right:"left",bottom:"top",left:"right"},aR=x.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=lB(oR,r),l=cB[a.placedSide];return v.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:v.jsx(iB,{...s,ref:n,style:{...s.style,display:"block"}})})});aR.displayName=oR;function uB(e){return e!==null}var hB=e=>({name:"transformOrigin",options:e,fn(t){var C,k,T;const{placement:n,rects:r,middlewareData:s}=t,l=((C=s.arrow)==null?void 0:C.centerOffset)!==0,u=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[h,p]=lR(n),m={start:"0%",center:"50%",end:"100%"}[p],_=(((k=s.arrow)==null?void 0:k.x)??0)+u/2,b=(((T=s.arrow)==null?void 0:T.y)??0)+d/2;let S="",w="";return h==="bottom"?(S=l?m:`${_}px`,w=`${-d}px`):h==="top"?(S=l?m:`${_}px`,w=`${r.floating.height+d}px`):h==="right"?(S=`${-d}px`,w=l?m:`${b}px`):h==="left"&&(S=`${r.floating.width+d}px`,w=l?m:`${b}px`),{data:{x:S,y:w}}}});function lR(e){const[t,n="center"]=e.split("-");return[t,n]}var wy=nR,Mf=iR,Cy=sR,ky=aR,dB=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"}),fB="VisuallyHidden",cR=x.forwardRef((e,t)=>v.jsx(wt.span,{...e,ref:t,style:{...dB,...e.style}}));cR.displayName=fB;var pB=cR,[Tf]=Qs("Tooltip",[pl]),Af=pl(),uR="TooltipProvider",mB=700,Tv="tooltip.open",[gB,Ey]=Tf(uR),hR=e=>{const{__scopeTooltip:t,delayDuration:n=mB,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:a}=e,l=x.useRef(!0),u=x.useRef(!1),d=x.useRef(0);return x.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),v.jsx(gB,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:x.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:x.useCallback(h=>{u.current=h},[]),disableHoverableContent:s,children:a})};hR.displayName=uR;var Gc="Tooltip",[vB,mu]=Tf(Gc),dR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:s,onOpenChange:a,disableHoverableContent:l,delayDuration:u}=e,d=Ey(Gc,e.__scopeTooltip),h=Af(t),[p,m]=x.useState(null),_=Ka(),b=x.useRef(0),S=l??d.disableHoverableContent,w=u??d.delayDuration,C=x.useRef(!1),[k,T]=_f({prop:r,defaultProp:s??!1,onChange:j=>{j?(d.onOpen(),document.dispatchEvent(new CustomEvent(Tv))):d.onClose(),a==null||a(j)},caller:Gc}),R=x.useMemo(()=>k?C.current?"delayed-open":"instant-open":"closed",[k]),D=x.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C.current=!1,T(!0)},[T]),z=x.useCallback(()=>{window.clearTimeout(b.current),b.current=0,T(!1)},[T]),L=x.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{C.current=!0,T(!0),b.current=0},w)},[w,T]);return x.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),v.jsx(wy,{...h,children:v.jsx(vB,{scope:t,contentId:_,open:k,stateAttribute:R,trigger:p,onTriggerChange:m,onTriggerEnter:x.useCallback(()=>{d.isOpenDelayedRef.current?L():D()},[d.isOpenDelayedRef,L,D]),onTriggerLeave:x.useCallback(()=>{S?z():(window.clearTimeout(b.current),b.current=0)},[z,S]),onOpen:D,onClose:z,disableHoverableContent:S,children:n})})};dR.displayName=Gc;var Av="TooltipTrigger",fR=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=mu(Av,n),a=Ey(Av,n),l=Af(n),u=x.useRef(null),d=Pt(t,u,s.onTriggerChange),h=x.useRef(!1),p=x.useRef(!1),m=x.useCallback(()=>h.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),v.jsx(Mf,{asChild:!0,...l,children:v.jsx(wt.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:d,onPointerMove:Ne(e.onPointerMove,_=>{_.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ne(e.onPointerLeave,()=>{s.onTriggerLeave(),p.current=!1}),onPointerDown:Ne(e.onPointerDown,()=>{s.open&&s.onClose(),h.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Ne(e.onFocus,()=>{h.current||s.onOpen()}),onBlur:Ne(e.onBlur,s.onClose),onClick:Ne(e.onClick,s.onClose)})})});fR.displayName=Av;var Ry="TooltipPortal",[_B,yB]=Tf(Ry,{forceMount:void 0}),pR=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:s}=e,a=mu(Ry,t);return v.jsx(_B,{scope:t,forceMount:n,children:v.jsx(Ur,{present:n||a.open,children:v.jsx(du,{asChild:!0,container:s,children:r})})})};pR.displayName=Ry;var il="TooltipContent",mR=x.forwardRef((e,t)=>{const n=yB(il,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...a}=e,l=mu(il,e.__scopeTooltip);return v.jsx(Ur,{present:r||l.open,children:l.disableHoverableContent?v.jsx(gR,{side:s,...a,ref:t}):v.jsx(bB,{side:s,...a,ref:t})})}),bB=x.forwardRef((e,t)=>{const n=mu(il,e.__scopeTooltip),r=Ey(il,e.__scopeTooltip),s=x.useRef(null),a=Pt(t,s),[l,u]=x.useState(null),{trigger:d,onClose:h}=n,p=s.current,{onPointerInTransitChange:m}=r,_=x.useCallback(()=>{u(null),m(!1)},[m]),b=x.useCallback((S,w)=>{const C=S.currentTarget,k={x:S.clientX,y:S.clientY},T=kB(k,C.getBoundingClientRect()),R=EB(k,T),D=RB(w.getBoundingClientRect()),z=TB([...R,...D]);u(z),m(!0)},[m]);return x.useEffect(()=>()=>_(),[_]),x.useEffect(()=>{if(d&&p){const S=C=>b(C,p),w=C=>b(C,d);return d.addEventListener("pointerleave",S),p.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",S),p.removeEventListener("pointerleave",w)}}},[d,p,b,_]),x.useEffect(()=>{if(l){const S=w=>{const C=w.target,k={x:w.clientX,y:w.clientY},T=(d==null?void 0:d.contains(C))||(p==null?void 0:p.contains(C)),R=!MB(k,l);T?_():R&&(_(),h())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[d,p,l,h,_]),v.jsx(gR,{...e,ref:a})}),[xB,SB]=Tf(Gc,{isInside:!1}),wB=DO("TooltipContent"),gR=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:l,...u}=e,d=mu(il,n),h=Af(n),{onClose:p}=d;return x.useEffect(()=>(document.addEventListener(Tv,p),()=>document.removeEventListener(Tv,p)),[p]),x.useEffect(()=>{if(d.trigger){const m=_=>{const b=_.target;b!=null&&b.contains(d.trigger)&&p()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[d.trigger,p]),v.jsx(hu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:m=>m.preventDefault(),onDismiss:p,children:v.jsxs(Cy,{"data-state":d.stateAttribute,...h,...u,ref:t,style:{...u.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:[v.jsx(wB,{children:r}),v.jsx(xB,{scope:n,isInside:!0,children:v.jsx(pB,{id:d.contentId,role:"tooltip",children:s||r})})]})})});mR.displayName=il;var vR="TooltipArrow",CB=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Af(n);return SB(vR,n).isInside?null:v.jsx(ky,{...s,...r,ref:t})});CB.displayName=vR;function kB(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,s,a)){case a:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function EB(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function RB(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function MB(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const u=t[a],d=t[l],h=u.x,p=u.y,m=d.x,_=d.y;p>r!=_>r&&n<(m-h)*(r-p)/(_-p)+h&&(s=!s)}return s}function TB(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),AB(t)}function AB(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const a=t[t.length-1],l=t[t.length-2];if((a.x-l.x)*(s.y-l.y)>=(a.y-l.y)*(s.x-l.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const a=n[n.length-1],l=n[n.length-2];if((a.x-l.x)*(s.y-l.y)>=(a.y-l.y)*(s.x-l.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var DB=hR,NB=dR,OB=fR,LB=pR,_R=mR;const zB=DB,Yc=NB,Xc=OB,sl=x.forwardRef(({className:e,sideOffset:t=4,...n},r)=>v.jsx(LB,{children:v.jsx(_R,{ref:r,sideOffset:t,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),...n})}));sl.displayName=_R.displayName;const jB="0.7.1",BB={version:jB},zn="Kanna",Rw="kanna",yR=`kanna/${BB.version}`,PB="[kanna]",IB=`~/${zn}`;function ed(e){return e?`${Rw} ${e}`:Rw}const Df=({children:e,className:t,shimmerWidth:n=100,animate:r=!0,...s})=>v.jsx("span",{style:{"--shiny-width":`${Math.min(n,100)}px`},className:ye("mx-auto max-w-md text-foreground/50",r?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],t),...s,children:e});function Dv(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const HB=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function FB(e){const t=e.trim();for(const n of HB){const r=t.match(n);if(!r)continue;const s=(r[2]??r[1]??"").trim();if(s)return s}return t}function bR(e){return e.split("/").pop()||e}function UB(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,s=60*r,a=24*s,l=7*a;return n<r?"now":n<s?`${Math.floor(n/r)}m`:n<a?`${Math.floor(n/s)}h`:n<l?`${Math.floor(n/a)}d`:`${Math.floor(n/l)}w`}const $B=new Set(["starting","running"]);function WB({chat:e,activeChatId:t,nowMs:n,onSelectChat:r,onDeleteChat:s}){const a=UB(e.lastMessageAt,n);return v.jsxs("div",{"data-chat-id":YS(e.chatId),className:ye("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===YS(e.chatId)?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>r(e.chatId),children:[$B.has(e.status)?v.jsx(Js,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?v.jsx("div",{className:"relative ",children:v.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[v.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),v.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,v.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?v.jsx(Df,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),v.jsxs("div",{className:"relative h-7 w-7 mr-[2px] shrink-0",children:[a?v.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] text-muted-foreground opacity-50 transition-opacity group-hover:opacity-0",children:a}):null,v.jsx(et,{variant:"ghost",size:"icon",className:ye("absolute inset-0 h-7 w-7 opacity-100 cursor-pointer rounded-sm hover:!bg-transparent !border-0",a?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),onClick:l=>{l.stopPropagation(),s(e.chatId)},title:"Delete chat",children:v.jsx(az,{className:"size-3.5"})})]})]},e._id)}function qB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return x.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const Nf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ml(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function My(e){return"nodeType"in e}function nr(e){var t,n;return e?ml(e)?e:My(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Ty(e){const{Document:t}=nr(e);return e instanceof t}function gu(e){return ml(e)?!1:e instanceof nr(e).HTMLElement}function xR(e){return e instanceof nr(e).SVGElement}function gl(e){return e?ml(e)?e.document:My(e)?Ty(e)?e:gu(e)||xR(e)?e.ownerDocument:document:document:document}const wi=Nf?x.useLayoutEffect:x.useEffect;function Ay(e){const t=x.useRef(e);return wi(()=>{t.current=e}),x.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function VB(){const e=x.useRef(null),t=x.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=x.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Zc(e,t){t===void 0&&(t=[e]);const n=x.useRef(e);return wi(()=>{n.current!==e&&(n.current=e)},t),n}function vu(e,t){const n=x.useRef();return x.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Gd(e){const t=Ay(e),n=x.useRef(null),r=x.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Nv(e){const t=x.useRef();return x.useEffect(()=>{t.current=e},[e]),t.current}let Tg={};function _u(e,t){return x.useMemo(()=>{if(t)return t;const n=Tg[e]==null?0:Tg[e]+1;return Tg[e]=n,e+"-"+n},[e,t])}function SR(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((a,l)=>{const u=Object.entries(l);for(const[d,h]of u){const p=a[d];p!=null&&(a[d]=p+e*h)}return a},{...t})}}const Xa=SR(1),Yd=SR(-1);function KB(e){return"clientX"in e&&"clientY"in e}function Dy(e){if(!e)return!1;const{KeyboardEvent:t}=nr(e.target);return t&&e instanceof t}function GB(e){if(!e)return!1;const{TouchEvent:t}=nr(e.target);return t&&e instanceof t}function Ov(e){if(GB(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return KB(e)?{x:e.clientX,y:e.clientY}:null}const Qc=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Qc.Translate.toString(e),Qc.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Mw="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function YB(e){return e.matches(Mw)?e:e.querySelector(Mw)}const XB={display:"none"};function ZB(e){let{id:t,value:n}=e;return vt.createElement("div",{id:t,style:XB},n)}function QB(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={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 vt.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function JB(){const[e,t]=x.useState("");return{announce:x.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const wR=x.createContext(null);function eP(e){const t=x.useContext(wR);x.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function tP(){const[e]=x.useState(()=>new Set),t=x.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[x.useCallback(r=>{let{type:s,event:a}=r;e.forEach(l=>{var u;return(u=l[s])==null?void 0:u.call(l,a)})},[e]),t]}const nP={draggable:`
415
415
  To pick up a draggable item, press the space bar.
416
416
  While dragging, use the arrow keys to move the item.
417
417
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -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-BnsoKj0W.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-BVFjL2m3.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BQedIo87.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.7.0",
4
+ "version": "0.7.1",
5
5
  "description": "A beautiful web UI for Claude Code",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -22,6 +22,7 @@
22
22
  "bin": {
23
23
  "kanna": "./bin/kanna"
24
24
  },
25
+ "packageManager": "bun@1.3.5",
25
26
  "files": [
26
27
  "bin/",
27
28
  "src/server/",