kanna-code 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jake Mor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,28 @@
1
- # Kanna
1
+ <p align="center">
2
+ <img src="assets/icon.png" alt="Kanna" width="80" />
3
+ </p>
2
4
 
3
- A web-first chat UI for using Claude Code in style. Remote access coming soon.
5
+ <h1 align="center">Kanna</h1>
6
+
7
+ <p align="center">
8
+ <strong>A beautiful web UI for Claude Code.</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/kanna-code"><img src="https://img.shields.io/npm/v/kanna-code.svg?style=flat&colorA=18181b&colorB=f472b6" alt="npm version" /></a>
13
+ </p>
14
+
15
+ <br />
16
+
17
+ <p align="center">
18
+ <picture>
19
+ <source media="(prefers-color-scheme: dark)" srcset="assets/screenshot.png" />
20
+ <source media="(prefers-color-scheme: light)" srcset="assets/screenshot-light.png" />
21
+ <img src="assets/screenshot.png" alt="Kanna screenshot" width="800" />
22
+ </picture>
23
+ </p>
24
+
25
+ <br />
4
26
 
5
27
  ## Quickstart
6
28
 
@@ -8,15 +30,17 @@ A web-first chat UI for using Claude Code in style. Remote access coming soon.
8
30
  bun install -g kanna-code
9
31
  ```
10
32
 
11
- Then run from anywhere:
33
+ Then run from any project directory:
12
34
 
13
35
  ```bash
14
36
  kanna
15
37
  ```
16
38
 
39
+ That's it. Kanna opens in your browser at [`localhost:3210`](http://localhost:3210).
40
+
17
41
  ## Features
18
42
 
19
- - **Project-first sidebar** — chats grouped under projects, with status indicators (idle, running, waiting, failed)
43
+ - **Project-first sidebar** — chats grouped under projects, with live status indicators (idle, running, waiting, failed)
20
44
  - **Local project discovery** — auto-discovers projects from `~/.claude/projects`
21
45
  - **Rich transcript rendering** — user messages, assistant responses, collapsible tool call groups, plan mode dialogs, and interactive prompts
22
46
  - **Plan mode** — review and approve agent plans before execution
@@ -45,33 +69,32 @@ Local File System (~/.kanna/data/, project dirs)
45
69
 
46
70
  ## Requirements
47
71
 
48
- - [Bun](https://bun.sh)
49
- - A working Claude Agent SDK environment
72
+ - [Bun](https://bun.sh) v1.0+
73
+ - A working [Claude Code](https://docs.anthropic.com/en/docs/claude-code) environment
50
74
 
51
75
  ## Install
52
76
 
53
- ```bash
54
- bun install
55
- ```
56
-
57
- ## Run
77
+ Install globally via bun:
58
78
 
59
79
  ```bash
60
- bun run build
61
- bun run start
80
+ bun install -g kanna-code
62
81
  ```
63
82
 
64
- Or use the CLI directly:
83
+ Or clone and build from source:
65
84
 
66
85
  ```bash
67
- kanna
86
+ git clone https://github.com/jakemor/kanna.git
87
+ cd kanna
88
+ bun install
89
+ bun run build
68
90
  ```
69
91
 
70
- Flags:
92
+ ## Usage
71
93
 
72
94
  ```bash
73
- bun run start -- --no-open
74
- bun run start -- --port 4000
95
+ kanna # start with defaults
96
+ kanna --port 4000 # custom port
97
+ kanna --no-open # don't open browser
75
98
  ```
76
99
 
77
100
  Default URL: `http://localhost:3210`
@@ -126,7 +149,7 @@ src/
126
149
  └── branding.ts App name, data directory paths
127
150
  ```
128
151
 
129
- ## Data
152
+ ## Data Storage
130
153
 
131
154
  All state is stored locally at `~/.kanna/data/`:
132
155
 
@@ -139,3 +162,7 @@ All state is stored locally at `~/.kanna/data/`:
139
162
  | `snapshot.json` | Compacted state snapshot for fast startup |
140
163
 
141
164
  Event logs are append-only JSONL. On startup, Kanna replays the log tail after the last snapshot, then compacts if the logs exceed 2 MB.
165
+
166
+ ## License
167
+
168
+ [MIT](LICENSE)
@@ -381,7 +381,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${r.do
381
381
  *
382
382
  * This source code is licensed under the ISC license.
383
383
  * See the LICENSE file in the root directory of this source tree.
384
- */const dT=[["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"}]],H0=Se("zap",dT),P0=zA,hT=DA,q0=S.forwardRef(({className:e,...r},l)=>x.jsx(j0,{ref:l,className:xe("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));q0.displayName=j0.displayName;const mT={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},Uh=S.forwardRef(({className:e,children:r,size:l="md",...i},o)=>x.jsxs(hT,{children:[x.jsx(q0,{}),x.jsxs(T0,{ref:o,className:xe("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",mT[l],e),...i,children:[r,x.jsxs(UA,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[x.jsx(so,{className:"h-4 w-4"}),x.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Uh.displayName=T0.displayName;function F0({className:e,...r}){return x.jsx(LA,{className:xe("text-lg font-medium leading-none tracking-tight",e),...r})}function pT({className:e,...r}){return x.jsx(BA,{className:xe("text-sm text-muted-foreground",e),...r})}function V0({className:e,...r}){return x.jsx("div",{className:xe("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...r})}function I0({className:e,...r}){return x.jsx("div",{className:xe("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...r})}const G0=S.createContext(null);function gT({children:e}){const[r,l]=S.useState(null),[i,o]=S.useState(""),u=S.useRef(null);S.useEffect(()=>{(r==null?void 0:r.kind)==="prompt"&&(o(r.options.initialValue??""),setTimeout(()=>{var g,y;(g=u.current)==null||g.focus(),(y=u.current)==null||y.select()},0))},[r]);const c=S.useCallback(()=>{l(null),o("")},[]),f=S.useCallback(g=>new Promise(y=>{l({kind:"confirm",options:g,resolve:y})}),[]),d=S.useCallback(g=>new Promise(y=>{l({kind:"prompt",options:g,resolve:y})}),[]),m=S.useMemo(()=>({confirm:f,prompt:d}),[f,d]);return x.jsxs(G0.Provider,{value:m,children:[e,x.jsx(P0,{open:r!==null,onOpenChange:g=>{g||!r||(r.kind==="confirm"?r.resolve(!1):r.resolve(null),c())},children:x.jsx(Uh,{size:"sm",children:r?x.jsxs(x.Fragment,{children:[x.jsxs(V0,{className:"space-y-4",children:[x.jsx(F0,{children:r.options.title}),r.options.description?x.jsx(pT,{children:r.options.description}):null,r.kind==="prompt"?x.jsx("input",{ref:u,type:"text",value:i,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),r.resolve(i.trim()||null),c())},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:r.options.placeholder}):null]}),x.jsxs(I0,{children:[x.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>{r.kind==="confirm"?r.resolve(!1):r.resolve(null),c()},children:r.options.cancelLabel??"Cancel"}),x.jsx(qe,{variant:r.kind==="confirm"?r.options.confirmVariant??"default":"secondary",size:"sm",onClick:()=>{r.kind==="confirm"?r.resolve(!0):r.resolve(i.trim()||null),c()},disabled:r.kind==="prompt"&&!i.trim(),children:r.options.confirmLabel??"Confirm"})]})]}):null})})]})}function yT(){const e=S.useContext(G0);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const xT=["top","right","bottom","left"],Jr=Math.min,nn=Math.max,ru=Math.round,Ps=Math.floor,Pn=e=>({x:e,y:e}),bT={left:"right",right:"left",bottom:"top",top:"bottom"};function Zd(e,r,l){return nn(e,Jr(r,l))}function mr(e,r){return typeof e=="function"?e(r):e}function pr(e){return e.split("-")[0]}function Pi(e){return e.split("-")[1]}function Hh(e){return e==="x"?"y":"x"}function Ph(e){return e==="y"?"height":"width"}function Un(e){const r=e[0];return r==="t"||r==="b"?"y":"x"}function qh(e){return Hh(Un(e))}function vT(e,r,l){l===void 0&&(l=!1);const i=Pi(e),o=qh(e),u=Ph(o);let c=o==="x"?i===(l?"end":"start")?"right":"left":i==="start"?"bottom":"top";return r.reference[u]>r.floating[u]&&(c=lu(c)),[c,lu(c)]}function wT(e){const r=lu(e);return[Kd(e),r,Kd(r)]}function Kd(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const tb=["left","right"],nb=["right","left"],ST=["top","bottom"],kT=["bottom","top"];function CT(e,r,l){switch(e){case"top":case"bottom":return l?r?nb:tb:r?tb:nb;case"left":case"right":return r?ST:kT;default:return[]}}function ET(e,r,l,i){const o=Pi(e);let u=CT(pr(e),l==="start",i);return o&&(u=u.map(c=>c+"-"+o),r&&(u=u.concat(u.map(Kd)))),u}function lu(e){const r=pr(e);return bT[r]+e.slice(r.length)}function NT(e){return{top:0,right:0,bottom:0,left:0,...e}}function Y0(e){return typeof e!="number"?NT(e):{top:e,right:e,bottom:e,left:e}}function iu(e){const{x:r,y:l,width:i,height:o}=e;return{width:i,height:o,top:l,left:r,right:r+i,bottom:l+o,x:r,y:l}}function rb(e,r,l){let{reference:i,floating:o}=e;const u=Un(r),c=qh(r),f=Ph(c),d=pr(r),m=u==="y",g=i.x+i.width/2-o.width/2,y=i.y+i.height/2-o.height/2,b=i[f]/2-o[f]/2;let v;switch(d){case"top":v={x:g,y:i.y-o.height};break;case"bottom":v={x:g,y:i.y+i.height};break;case"right":v={x:i.x+i.width,y};break;case"left":v={x:i.x-o.width,y};break;default:v={x:i.x,y:i.y}}switch(Pi(r)){case"start":v[c]-=b*(l&&m?-1:1);break;case"end":v[c]+=b*(l&&m?-1:1);break}return v}async function AT(e,r){var l;r===void 0&&(r={});const{x:i,y:o,platform:u,rects:c,elements:f,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:v=0}=mr(r,e),k=Y0(v),A=f[b?y==="floating"?"reference":"floating":y],N=iu(await u.getClippingRect({element:(l=await(u.isElement==null?void 0:u.isElement(A)))==null||l?A:A.contextElement||await(u.getDocumentElement==null?void 0:u.getDocumentElement(f.floating)),boundary:m,rootBoundary:g,strategy:d})),O=y==="floating"?{x:i,y:o,width:c.floating.width,height:c.floating.height}:c.reference,_=await(u.getOffsetParent==null?void 0:u.getOffsetParent(f.floating)),U=await(u.isElement==null?void 0:u.isElement(_))?await(u.getScale==null?void 0:u.getScale(_))||{x:1,y:1}:{x:1,y:1},F=iu(u.convertOffsetParentRelativeRectToViewportRelativeRect?await u.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:O,offsetParent:_,strategy:d}):O);return{top:(N.top-F.top+k.top)/U.y,bottom:(F.bottom-N.bottom+k.bottom)/U.y,left:(N.left-F.left+k.left)/U.x,right:(F.right-N.right+k.right)/U.x}}const jT=50,TT=async(e,r,l)=>{const{placement:i="bottom",strategy:o="absolute",middleware:u=[],platform:c}=l,f=c.detectOverflow?c:{...c,detectOverflow:AT},d=await(c.isRTL==null?void 0:c.isRTL(r));let m=await c.getElementRects({reference:e,floating:r,strategy:o}),{x:g,y}=rb(m,i,d),b=i,v=0;const k={};for(let C=0;C<u.length;C++){const A=u[C];if(!A)continue;const{name:N,fn:O}=A,{x:_,y:U,data:F,reset:z}=await O({x:g,y,initialPlacement:i,placement:b,strategy:o,middlewareData:k,rects:m,platform:f,elements:{reference:e,floating:r}});g=_??g,y=U??y,k[N]={...k[N],...F},z&&v<jT&&(v++,typeof z=="object"&&(z.placement&&(b=z.placement),z.rects&&(m=z.rects===!0?await c.getElementRects({reference:e,floating:r,strategy:o}):z.rects),{x:g,y}=rb(m,b,d)),C=-1)}return{x:g,y,placement:b,strategy:o,middlewareData:k}},_T=e=>({name:"arrow",options:e,async fn(r){const{x:l,y:i,placement:o,rects:u,platform:c,elements:f,middlewareData:d}=r,{element:m,padding:g=0}=mr(e,r)||{};if(m==null)return{};const y=Y0(g),b={x:l,y:i},v=qh(o),k=Ph(v),C=await c.getDimensions(m),A=v==="y",N=A?"top":"left",O=A?"bottom":"right",_=A?"clientHeight":"clientWidth",U=u.reference[k]+u.reference[v]-b[v]-u.floating[k],F=b[v]-u.reference[v],z=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let B=z?z[_]:0;(!B||!await(c.isElement==null?void 0:c.isElement(z)))&&(B=f.floating[_]||u.floating[k]);const $=U/2-F/2,ae=B/2-C[k]/2-1,P=Jr(y[N],ae),re=Jr(y[O],ae),le=P,se=B-C[k]-re,J=B/2-C[k]/2+$,Z=Zd(le,J,se),D=!d.arrow&&Pi(o)!=null&&J!==Z&&u.reference[k]/2-(J<le?P:re)-C[k]/2<0,X=D?J<le?J-le:J-se:0;return{[v]:b[v]+X,data:{[v]:Z,centerOffset:J-Z-X,...D&&{alignmentOffset:X}},reset:D}}}),RT=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(r){var l,i;const{placement:o,middlewareData:u,rects:c,initialPlacement:f,platform:d,elements:m}=r,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:b,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:C=!0,...A}=mr(e,r);if((l=u.arrow)!=null&&l.alignmentOffset)return{};const N=pr(o),O=Un(f),_=pr(f)===f,U=await(d.isRTL==null?void 0:d.isRTL(m.floating)),F=b||(_||!C?[lu(f)]:wT(f)),z=k!=="none";!b&&z&&F.push(...ET(f,C,k,U));const B=[f,...F],$=await d.detectOverflow(r,A),ae=[];let P=((i=u.flip)==null?void 0:i.overflows)||[];if(g&&ae.push($[N]),y){const J=vT(o,c,U);ae.push($[J[0]],$[J[1]])}if(P=[...P,{placement:o,overflows:ae}],!ae.every(J=>J<=0)){var re,le;const J=(((re=u.flip)==null?void 0:re.index)||0)+1,Z=B[J];if(Z&&(!(y==="alignment"?O!==Un(Z):!1)||P.every(ne=>Un(ne.placement)===O?ne.overflows[0]>0:!0)))return{data:{index:J,overflows:P},reset:{placement:Z}};let D=(le=P.filter(X=>X.overflows[0]<=0).sort((X,ne)=>X.overflows[1]-ne.overflows[1])[0])==null?void 0:le.placement;if(!D)switch(v){case"bestFit":{var se;const X=(se=P.filter(ne=>{if(z){const ie=Un(ne.placement);return ie===O||ie==="y"}return!0}).map(ne=>[ne.placement,ne.overflows.filter(ie=>ie>0).reduce((ie,j)=>ie+j,0)]).sort((ne,ie)=>ne[1]-ie[1])[0])==null?void 0:se[0];X&&(D=X);break}case"initialPlacement":D=f;break}if(o!==D)return{reset:{placement:D}}}return{}}}};function lb(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function ib(e){return xT.some(r=>e[r]>=0)}const MT=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(r){const{rects:l,platform:i}=r,{strategy:o="referenceHidden",...u}=mr(e,r);switch(o){case"referenceHidden":{const c=await i.detectOverflow(r,{...u,elementContext:"reference"}),f=lb(c,l.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:ib(f)}}}case"escaped":{const c=await i.detectOverflow(r,{...u,altBoundary:!0}),f=lb(c,l.floating);return{data:{escapedOffsets:f,escaped:ib(f)}}}default:return{}}}}},$0=new Set(["left","top"]);async function OT(e,r){const{placement:l,platform:i,elements:o}=e,u=await(i.isRTL==null?void 0:i.isRTL(o.floating)),c=pr(l),f=Pi(l),d=Un(l)==="y",m=$0.has(c)?-1:1,g=u&&d?-1:1,y=mr(r,e);let{mainAxis:b,crossAxis:v,alignmentAxis:k}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return f&&typeof k=="number"&&(v=f==="end"?k*-1:k),d?{x:v*g,y:b*m}:{x:b*m,y:v*g}}const zT=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(r){var l,i;const{x:o,y:u,placement:c,middlewareData:f}=r,d=await OT(r,e);return c===((l=f.offset)==null?void 0:l.placement)&&(i=f.arrow)!=null&&i.alignmentOffset?{}:{x:o+d.x,y:u+d.y,data:{...d,placement:c}}}}},DT=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(r){const{x:l,y:i,placement:o,platform:u}=r,{mainAxis:c=!0,crossAxis:f=!1,limiter:d={fn:N=>{let{x:O,y:_}=N;return{x:O,y:_}}},...m}=mr(e,r),g={x:l,y:i},y=await u.detectOverflow(r,m),b=Un(pr(o)),v=Hh(b);let k=g[v],C=g[b];if(c){const N=v==="y"?"top":"left",O=v==="y"?"bottom":"right",_=k+y[N],U=k-y[O];k=Zd(_,k,U)}if(f){const N=b==="y"?"top":"left",O=b==="y"?"bottom":"right",_=C+y[N],U=C-y[O];C=Zd(_,C,U)}const A=d.fn({...r,[v]:k,[b]:C});return{...A,data:{x:A.x-l,y:A.y-i,enabled:{[v]:c,[b]:f}}}}}},LT=function(e){return e===void 0&&(e={}),{options:e,fn(r){const{x:l,y:i,placement:o,rects:u,middlewareData:c}=r,{offset:f=0,mainAxis:d=!0,crossAxis:m=!0}=mr(e,r),g={x:l,y:i},y=Un(o),b=Hh(y);let v=g[b],k=g[y];const C=mr(f,r),A=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(d){const _=b==="y"?"height":"width",U=u.reference[b]-u.floating[_]+A.mainAxis,F=u.reference[b]+u.reference[_]-A.mainAxis;v<U?v=U:v>F&&(v=F)}if(m){var N,O;const _=b==="y"?"width":"height",U=$0.has(pr(o)),F=u.reference[y]-u.floating[_]+(U&&((N=c.offset)==null?void 0:N[y])||0)+(U?0:A.crossAxis),z=u.reference[y]+u.reference[_]+(U?0:((O=c.offset)==null?void 0:O[y])||0)-(U?A.crossAxis:0);k<F?k=F:k>z&&(k=z)}return{[b]:v,[y]:k}}}},BT=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(r){var l,i;const{placement:o,rects:u,platform:c,elements:f}=r,{apply:d=()=>{},...m}=mr(e,r),g=await c.detectOverflow(r,m),y=pr(o),b=Pi(o),v=Un(o)==="y",{width:k,height:C}=u.floating;let A,N;y==="top"||y==="bottom"?(A=y,N=b===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(N=y,A=b==="end"?"top":"bottom");const O=C-g.top-g.bottom,_=k-g.left-g.right,U=Jr(C-g[A],O),F=Jr(k-g[N],_),z=!r.middlewareData.shift;let B=U,$=F;if((l=r.middlewareData.shift)!=null&&l.enabled.x&&($=_),(i=r.middlewareData.shift)!=null&&i.enabled.y&&(B=O),z&&!b){const P=nn(g.left,0),re=nn(g.right,0),le=nn(g.top,0),se=nn(g.bottom,0);v?$=k-2*(P!==0||re!==0?P+re:nn(g.left,g.right)):B=C-2*(le!==0||se!==0?le+se:nn(g.top,g.bottom))}await d({...r,availableWidth:$,availableHeight:B});const ae=await c.getDimensions(f.floating);return k!==ae.width||C!==ae.height?{reset:{rects:!0}}:{}}}};function Cu(){return typeof window<"u"}function qi(e){return X0(e)?(e.nodeName||"").toLowerCase():"#document"}function rn(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function Vn(e){var r;return(r=(X0(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function X0(e){return Cu()?e instanceof Node||e instanceof rn(e).Node:!1}function Cn(e){return Cu()?e instanceof Element||e instanceof rn(e).Element:!1}function gr(e){return Cu()?e instanceof HTMLElement||e instanceof rn(e).HTMLElement:!1}function ab(e){return!Cu()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof rn(e).ShadowRoot}function uo(e){const{overflow:r,overflowX:l,overflowY:i,display:o}=En(e);return/auto|scroll|overlay|hidden|clip/.test(r+i+l)&&o!=="inline"&&o!=="contents"}function UT(e){return/^(table|td|th)$/.test(qi(e))}function Eu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const HT=/transform|translate|scale|rotate|perspective|filter/,PT=/paint|layout|strict|content/,Nl=e=>!!e&&e!=="none";let xd;function Fh(e){const r=Cn(e)?En(e):e;return Nl(r.transform)||Nl(r.translate)||Nl(r.scale)||Nl(r.rotate)||Nl(r.perspective)||!Vh()&&(Nl(r.backdropFilter)||Nl(r.filter))||HT.test(r.willChange||"")||PT.test(r.contain||"")}function qT(e){let r=Wr(e);for(;gr(r)&&!Mi(r);){if(Fh(r))return r;if(Eu(r))return null;r=Wr(r)}return null}function Vh(){return xd==null&&(xd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),xd}function Mi(e){return/^(html|body|#document)$/.test(qi(e))}function En(e){return rn(e).getComputedStyle(e)}function Nu(e){return Cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wr(e){if(qi(e)==="html")return e;const r=e.assignedSlot||e.parentNode||ab(e)&&e.host||Vn(e);return ab(r)?r.host:r}function Q0(e){const r=Wr(e);return Mi(r)?e.ownerDocument?e.ownerDocument.body:e.body:gr(r)&&uo(r)?r:Q0(r)}function eo(e,r,l){var i;r===void 0&&(r=[]),l===void 0&&(l=!0);const o=Q0(e),u=o===((i=e.ownerDocument)==null?void 0:i.body),c=rn(o);if(u){const f=Jd(c);return r.concat(c,c.visualViewport||[],uo(o)?o:[],f&&l?eo(f):[])}else return r.concat(o,eo(o,[],l))}function Jd(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Z0(e){const r=En(e);let l=parseFloat(r.width)||0,i=parseFloat(r.height)||0;const o=gr(e),u=o?e.offsetWidth:l,c=o?e.offsetHeight:i,f=ru(l)!==u||ru(i)!==c;return f&&(l=u,i=c),{width:l,height:i,$:f}}function Ih(e){return Cn(e)?e:e.contextElement}function Ti(e){const r=Ih(e);if(!gr(r))return Pn(1);const l=r.getBoundingClientRect(),{width:i,height:o,$:u}=Z0(r);let c=(u?ru(l.width):l.width)/i,f=(u?ru(l.height):l.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const FT=Pn(0);function K0(e){const r=rn(e);return!Vh()||!r.visualViewport?FT:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function VT(e,r,l){return r===void 0&&(r=!1),!l||r&&l!==rn(e)?!1:r}function Rl(e,r,l,i){r===void 0&&(r=!1),l===void 0&&(l=!1);const o=e.getBoundingClientRect(),u=Ih(e);let c=Pn(1);r&&(i?Cn(i)&&(c=Ti(i)):c=Ti(e));const f=VT(u,l,i)?K0(u):Pn(0);let d=(o.left+f.x)/c.x,m=(o.top+f.y)/c.y,g=o.width/c.x,y=o.height/c.y;if(u){const b=rn(u),v=i&&Cn(i)?rn(i):i;let k=b,C=Jd(k);for(;C&&i&&v!==k;){const A=Ti(C),N=C.getBoundingClientRect(),O=En(C),_=N.left+(C.clientLeft+parseFloat(O.paddingLeft))*A.x,U=N.top+(C.clientTop+parseFloat(O.paddingTop))*A.y;d*=A.x,m*=A.y,g*=A.x,y*=A.y,d+=_,m+=U,k=rn(C),C=Jd(k)}}return iu({width:g,height:y,x:d,y:m})}function Au(e,r){const l=Nu(e).scrollLeft;return r?r.left+l:Rl(Vn(e)).left+l}function J0(e,r){const l=e.getBoundingClientRect(),i=l.left+r.scrollLeft-Au(e,l),o=l.top+r.scrollTop;return{x:i,y:o}}function IT(e){let{elements:r,rect:l,offsetParent:i,strategy:o}=e;const u=o==="fixed",c=Vn(i),f=r?Eu(r.floating):!1;if(i===c||f&&u)return l;let d={scrollLeft:0,scrollTop:0},m=Pn(1);const g=Pn(0),y=gr(i);if((y||!y&&!u)&&((qi(i)!=="body"||uo(c))&&(d=Nu(i)),y)){const v=Rl(i);m=Ti(i),g.x=v.x+i.clientLeft,g.y=v.y+i.clientTop}const b=c&&!y&&!u?J0(c,d):Pn(0);return{width:l.width*m.x,height:l.height*m.y,x:l.x*m.x-d.scrollLeft*m.x+g.x+b.x,y:l.y*m.y-d.scrollTop*m.y+g.y+b.y}}function GT(e){return Array.from(e.getClientRects())}function YT(e){const r=Vn(e),l=Nu(e),i=e.ownerDocument.body,o=nn(r.scrollWidth,r.clientWidth,i.scrollWidth,i.clientWidth),u=nn(r.scrollHeight,r.clientHeight,i.scrollHeight,i.clientHeight);let c=-l.scrollLeft+Au(e);const f=-l.scrollTop;return En(i).direction==="rtl"&&(c+=nn(r.clientWidth,i.clientWidth)-o),{width:o,height:u,x:c,y:f}}const ob=25;function $T(e,r){const l=rn(e),i=Vn(e),o=l.visualViewport;let u=i.clientWidth,c=i.clientHeight,f=0,d=0;if(o){u=o.width,c=o.height;const g=Vh();(!g||g&&r==="fixed")&&(f=o.offsetLeft,d=o.offsetTop)}const m=Au(i);if(m<=0){const g=i.ownerDocument,y=g.body,b=getComputedStyle(y),v=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,k=Math.abs(i.clientWidth-y.clientWidth-v);k<=ob&&(u-=k)}else m<=ob&&(u+=m);return{width:u,height:c,x:f,y:d}}function XT(e,r){const l=Rl(e,!0,r==="fixed"),i=l.top+e.clientTop,o=l.left+e.clientLeft,u=gr(e)?Ti(e):Pn(1),c=e.clientWidth*u.x,f=e.clientHeight*u.y,d=o*u.x,m=i*u.y;return{width:c,height:f,x:d,y:m}}function sb(e,r,l){let i;if(r==="viewport")i=$T(e,l);else if(r==="document")i=YT(Vn(e));else if(Cn(r))i=XT(r,l);else{const o=K0(e);i={x:r.x-o.x,y:r.y-o.y,width:r.width,height:r.height}}return iu(i)}function W0(e,r){const l=Wr(e);return l===r||!Cn(l)||Mi(l)?!1:En(l).position==="fixed"||W0(l,r)}function QT(e,r){const l=r.get(e);if(l)return l;let i=eo(e,[],!1).filter(f=>Cn(f)&&qi(f)!=="body"),o=null;const u=En(e).position==="fixed";let c=u?Wr(e):e;for(;Cn(c)&&!Mi(c);){const f=En(c),d=Fh(c);!d&&f.position==="fixed"&&(o=null),(u?!d&&!o:!d&&f.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||uo(c)&&!d&&W0(e,c))?i=i.filter(g=>g!==c):o=f,c=Wr(c)}return r.set(e,i),i}function ZT(e){let{element:r,boundary:l,rootBoundary:i,strategy:o}=e;const c=[...l==="clippingAncestors"?Eu(r)?[]:QT(r,this._c):[].concat(l),i],f=sb(r,c[0],o);let d=f.top,m=f.right,g=f.bottom,y=f.left;for(let b=1;b<c.length;b++){const v=sb(r,c[b],o);d=nn(v.top,d),m=Jr(v.right,m),g=Jr(v.bottom,g),y=nn(v.left,y)}return{width:m-y,height:g-d,x:y,y:d}}function KT(e){const{width:r,height:l}=Z0(e);return{width:r,height:l}}function JT(e,r,l){const i=gr(r),o=Vn(r),u=l==="fixed",c=Rl(e,!0,u,r);let f={scrollLeft:0,scrollTop:0};const d=Pn(0);function m(){d.x=Au(o)}if(i||!i&&!u)if((qi(r)!=="body"||uo(o))&&(f=Nu(r)),i){const v=Rl(r,!0,u,r);d.x=v.x+r.clientLeft,d.y=v.y+r.clientTop}else o&&m();u&&!i&&o&&m();const g=o&&!i&&!u?J0(o,f):Pn(0),y=c.left+f.scrollLeft-d.x-g.x,b=c.top+f.scrollTop-d.y-g.y;return{x:y,y:b,width:c.width,height:c.height}}function bd(e){return En(e).position==="static"}function ub(e,r){if(!gr(e)||En(e).position==="fixed")return null;if(r)return r(e);let l=e.offsetParent;return Vn(e)===l&&(l=l.ownerDocument.body),l}function e1(e,r){const l=rn(e);if(Eu(e))return l;if(!gr(e)){let o=Wr(e);for(;o&&!Mi(o);){if(Cn(o)&&!bd(o))return o;o=Wr(o)}return l}let i=ub(e,r);for(;i&&UT(i)&&bd(i);)i=ub(i,r);return i&&Mi(i)&&bd(i)&&!Fh(i)?l:i||qT(e)||l}const WT=async function(e){const r=this.getOffsetParent||e1,l=this.getDimensions,i=await l(e.floating);return{reference:JT(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function e_(e){return En(e).direction==="rtl"}const t_={convertOffsetParentRelativeRectToViewportRelativeRect:IT,getDocumentElement:Vn,getClippingRect:ZT,getOffsetParent:e1,getElementRects:WT,getClientRects:GT,getDimensions:KT,getScale:Ti,isElement:Cn,isRTL:e_};function t1(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}function n_(e,r){let l=null,i;const o=Vn(e);function u(){var f;clearTimeout(i),(f=l)==null||f.disconnect(),l=null}function c(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),u();const m=e.getBoundingClientRect(),{left:g,top:y,width:b,height:v}=m;if(f||r(),!b||!v)return;const k=Ps(y),C=Ps(o.clientWidth-(g+b)),A=Ps(o.clientHeight-(y+v)),N=Ps(g),_={rootMargin:-k+"px "+-C+"px "+-A+"px "+-N+"px",threshold:nn(0,Jr(1,d))||1};let U=!0;function F(z){const B=z[0].intersectionRatio;if(B!==d){if(!U)return c();B?c(!1,B):i=setTimeout(()=>{c(!1,1e-7)},1e3)}B===1&&!t1(m,e.getBoundingClientRect())&&c(),U=!1}try{l=new IntersectionObserver(F,{..._,root:o.ownerDocument})}catch{l=new IntersectionObserver(F,_)}l.observe(e)}return c(!0),u}function r_(e,r,l,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:u=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,m=Ih(e),g=o||u?[...m?eo(m):[],...r?eo(r):[]]:[];g.forEach(N=>{o&&N.addEventListener("scroll",l,{passive:!0}),u&&N.addEventListener("resize",l)});const y=m&&f?n_(m,l):null;let b=-1,v=null;c&&(v=new ResizeObserver(N=>{let[O]=N;O&&O.target===m&&v&&r&&(v.unobserve(r),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var _;(_=v)==null||_.observe(r)})),l()}),m&&!d&&v.observe(m),r&&v.observe(r));let k,C=d?Rl(e):null;d&&A();function A(){const N=Rl(e);C&&!t1(C,N)&&l(),C=N,k=requestAnimationFrame(A)}return l(),()=>{var N;g.forEach(O=>{o&&O.removeEventListener("scroll",l),u&&O.removeEventListener("resize",l)}),y==null||y(),(N=v)==null||N.disconnect(),v=null,d&&cancelAnimationFrame(k)}}const l_=zT,i_=DT,a_=RT,o_=BT,s_=MT,cb=_T,u_=LT,c_=(e,r,l)=>{const i=new Map,o={platform:t_,...l},u={...o.platform,_c:i};return TT(e,r,{...o,platform:u})};var f_=typeof document<"u",d_=function(){},Ks=f_?S.useLayoutEffect:d_;function au(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(typeof e=="function"&&e.toString()===r.toString())return!0;let l,i,o;if(e&&r&&typeof e=="object"){if(Array.isArray(e)){if(l=e.length,l!==r.length)return!1;for(i=l;i--!==0;)if(!au(e[i],r[i]))return!1;return!0}if(o=Object.keys(e),l=o.length,l!==Object.keys(r).length)return!1;for(i=l;i--!==0;)if(!{}.hasOwnProperty.call(r,o[i]))return!1;for(i=l;i--!==0;){const u=o[i];if(!(u==="_owner"&&e.$$typeof)&&!au(e[u],r[u]))return!1}return!0}return e!==e&&r!==r}function n1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fb(e,r){const l=n1(e);return Math.round(r*l)/l}function vd(e){const r=S.useRef(e);return Ks(()=>{r.current=e}),r}function h_(e){e===void 0&&(e={});const{placement:r="bottom",strategy:l="absolute",middleware:i=[],platform:o,elements:{reference:u,floating:c}={},transform:f=!0,whileElementsMounted:d,open:m}=e,[g,y]=S.useState({x:0,y:0,strategy:l,placement:r,middlewareData:{},isPositioned:!1}),[b,v]=S.useState(i);au(b,i)||v(i);const[k,C]=S.useState(null),[A,N]=S.useState(null),O=S.useCallback(ne=>{ne!==z.current&&(z.current=ne,C(ne))},[]),_=S.useCallback(ne=>{ne!==B.current&&(B.current=ne,N(ne))},[]),U=u||k,F=c||A,z=S.useRef(null),B=S.useRef(null),$=S.useRef(g),ae=d!=null,P=vd(d),re=vd(o),le=vd(m),se=S.useCallback(()=>{if(!z.current||!B.current)return;const ne={placement:r,strategy:l,middleware:b};re.current&&(ne.platform=re.current),c_(z.current,B.current,ne).then(ie=>{const j={...ie,isPositioned:le.current!==!1};J.current&&!au($.current,j)&&($.current=j,kh.flushSync(()=>{y(j)}))})},[b,r,l,re,le]);Ks(()=>{m===!1&&$.current.isPositioned&&($.current.isPositioned=!1,y(ne=>({...ne,isPositioned:!1})))},[m]);const J=S.useRef(!1);Ks(()=>(J.current=!0,()=>{J.current=!1}),[]),Ks(()=>{if(U&&(z.current=U),F&&(B.current=F),U&&F){if(P.current)return P.current(U,F,se);se()}},[U,F,se,P,ae]);const Z=S.useMemo(()=>({reference:z,floating:B,setReference:O,setFloating:_}),[O,_]),D=S.useMemo(()=>({reference:U,floating:F}),[U,F]),X=S.useMemo(()=>{const ne={position:l,left:0,top:0};if(!D.floating)return ne;const ie=fb(D.floating,g.x),j=fb(D.floating,g.y);return f?{...ne,transform:"translate("+ie+"px, "+j+"px)",...n1(D.floating)>=1.5&&{willChange:"transform"}}:{position:l,left:ie,top:j}},[l,f,D.floating,g.x,g.y]);return S.useMemo(()=>({...g,update:se,refs:Z,elements:D,floatingStyles:X}),[g,se,Z,D,X])}const m_=e=>{function r(l){return{}.hasOwnProperty.call(l,"current")}return{name:"arrow",options:e,fn(l){const{element:i,padding:o}=typeof e=="function"?e(l):e;return i&&r(i)?i.current!=null?cb({element:i.current,padding:o}).fn(l):{}:i?cb({element:i,padding:o}).fn(l):{}}}},p_=(e,r)=>{const l=l_(e);return{name:l.name,fn:l.fn,options:[e,r]}},g_=(e,r)=>{const l=i_(e);return{name:l.name,fn:l.fn,options:[e,r]}},y_=(e,r)=>({fn:u_(e).fn,options:[e,r]}),x_=(e,r)=>{const l=a_(e);return{name:l.name,fn:l.fn,options:[e,r]}},b_=(e,r)=>{const l=o_(e);return{name:l.name,fn:l.fn,options:[e,r]}},v_=(e,r)=>{const l=s_(e);return{name:l.name,fn:l.fn,options:[e,r]}},w_=(e,r)=>{const l=m_(e);return{name:l.name,fn:l.fn,options:[e,r]}};var S_="Arrow",r1=S.forwardRef((e,r)=>{const{children:l,width:i=10,height:o=5,...u}=e;return x.jsx(_t.svg,{...u,ref:r,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?l:x.jsx("polygon",{points:"0,0 30,0 15,10"})})});r1.displayName=S_;var k_=r1;function C_(e){const[r,l]=S.useState(void 0);return Zr(()=>{if(e){l({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const u=o[0];let c,f;if("borderBoxSize"in u){const d=u.borderBoxSize,m=Array.isArray(d)?d[0]:d;c=m.inlineSize,f=m.blockSize}else c=e.offsetWidth,f=e.offsetHeight;l({width:c,height:f})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else l(void 0)},[e]),r}var Gh="Popper",[l1,ju]=xu(Gh),[E_,i1]=l1(Gh),a1=e=>{const{__scopePopper:r,children:l}=e,[i,o]=S.useState(null);return x.jsx(E_,{scope:r,anchor:i,onAnchorChange:o,children:l})};a1.displayName=Gh;var o1="PopperAnchor",s1=S.forwardRef((e,r)=>{const{__scopePopper:l,virtualRef:i,...o}=e,u=i1(o1,l),c=S.useRef(null),f=an(r,c),d=S.useRef(null);return S.useEffect(()=>{const m=d.current;d.current=(i==null?void 0:i.current)||c.current,m!==d.current&&u.onAnchorChange(d.current)}),i?null:x.jsx(_t.div,{...o,ref:f})});s1.displayName=o1;var Yh="PopperContent",[N_,A_]=l1(Yh),u1=S.forwardRef((e,r)=>{var Ce,Ue,ve,at,dt,At;const{__scopePopper:l,side:i="bottom",sideOffset:o=0,align:u="center",alignOffset:c=0,arrowPadding:f=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:g=0,sticky:y="partial",hideWhenDetached:b=!1,updatePositionStrategy:v="optimized",onPlaced:k,...C}=e,A=i1(Yh,l),[N,O]=S.useState(null),_=an(r,wt=>O(wt)),[U,F]=S.useState(null),z=C_(U),B=(z==null?void 0:z.width)??0,$=(z==null?void 0:z.height)??0,ae=i+(u!=="center"?"-"+u:""),P=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},re=Array.isArray(m)?m:[m],le=re.length>0,se={padding:P,boundary:re.filter(T_),altBoundary:le},{refs:J,floatingStyles:Z,placement:D,isPositioned:X,middlewareData:ne}=h_({strategy:"fixed",placement:ae,whileElementsMounted:(...wt)=>r_(...wt,{animationFrame:v==="always"}),elements:{reference:A.anchor},middleware:[p_({mainAxis:o+$,alignmentAxis:c}),d&&g_({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?y_():void 0,...se}),d&&x_({...se}),b_({...se,apply:({elements:wt,rects:ht,availableWidth:jn,availableHeight:Tn})=>{const{width:xr,height:br}=ht.reference,$t=wt.floating.style;$t.setProperty("--radix-popper-available-width",`${jn}px`),$t.setProperty("--radix-popper-available-height",`${Tn}px`),$t.setProperty("--radix-popper-anchor-width",`${xr}px`),$t.setProperty("--radix-popper-anchor-height",`${br}px`)}}),U&&w_({element:U,padding:f}),__({arrowWidth:B,arrowHeight:$}),b&&v_({strategy:"referenceHidden",...se})]}),[ie,j]=d1(D),R=Ri(k);Zr(()=>{X&&(R==null||R())},[X,R]);const G=(Ce=ne.arrow)==null?void 0:Ce.x,T=(Ue=ne.arrow)==null?void 0:Ue.y,ue=((ve=ne.arrow)==null?void 0:ve.centerOffset)!==0,[de,ce]=S.useState();return Zr(()=>{N&&ce(window.getComputedStyle(N).zIndex)},[N]),x.jsx("div",{ref:J.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:X?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(at=ne.transformOrigin)==null?void 0:at.x,(dt=ne.transformOrigin)==null?void 0:dt.y].join(" "),...((At=ne.hide)==null?void 0:At.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:x.jsx(N_,{scope:l,placedSide:ie,onArrowChange:F,arrowX:G,arrowY:T,shouldHideArrow:ue,children:x.jsx(_t.div,{"data-side":ie,"data-align":j,...C,ref:_,style:{...C.style,animation:X?void 0:"none"}})})})});u1.displayName=Yh;var c1="PopperArrow",j_={top:"bottom",right:"left",bottom:"top",left:"right"},f1=S.forwardRef(function(r,l){const{__scopePopper:i,...o}=r,u=A_(c1,i),c=j_[u.placedSide];return x.jsx("span",{ref:u.onArrowChange,style:{position:"absolute",left:u.arrowX,top:u.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[u.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[u.placedSide],visibility:u.shouldHideArrow?"hidden":void 0},children:x.jsx(k_,{...o,ref:l,style:{...o.style,display:"block"}})})});f1.displayName=c1;function T_(e){return e!==null}var __=e=>({name:"transformOrigin",options:e,fn(r){var A,N,O;const{placement:l,rects:i,middlewareData:o}=r,c=((A=o.arrow)==null?void 0:A.centerOffset)!==0,f=c?0:e.arrowWidth,d=c?0:e.arrowHeight,[m,g]=d1(l),y={start:"0%",center:"50%",end:"100%"}[g],b=(((N=o.arrow)==null?void 0:N.x)??0)+f/2,v=(((O=o.arrow)==null?void 0:O.y)??0)+d/2;let k="",C="";return m==="bottom"?(k=c?y:`${b}px`,C=`${-d}px`):m==="top"?(k=c?y:`${b}px`,C=`${i.floating.height+d}px`):m==="right"?(k=`${-d}px`,C=c?y:`${v}px`):m==="left"&&(k=`${i.floating.width+d}px`,C=c?y:`${v}px`),{data:{x:k,y:C}}}});function d1(e){const[r,l="center"]=e.split("-");return[r,l]}var h1=a1,$h=s1,m1=u1,p1=f1,R_=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"}),M_="VisuallyHidden",g1=S.forwardRef((e,r)=>x.jsx(_t.span,{...e,ref:r,style:{...R_,...e.style}}));g1.displayName=M_;var O_=g1,[Tu]=xu("Tooltip",[ju]),_u=ju(),y1="TooltipProvider",z_=700,Wd="tooltip.open",[D_,Xh]=Tu(y1),x1=e=>{const{__scopeTooltip:r,delayDuration:l=z_,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:u}=e,c=S.useRef(!0),f=S.useRef(!1),d=S.useRef(0);return S.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),x.jsx(D_,{scope:r,isOpenDelayedRef:c,delayDuration:l,onOpen:S.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,i)},[i]),isPointerInTransitRef:f,onPointerInTransitChange:S.useCallback(m=>{f.current=m},[]),disableHoverableContent:o,children:u})};x1.displayName=y1;var to="Tooltip",[L_,co]=Tu(to),b1=e=>{const{__scopeTooltip:r,children:l,open:i,defaultOpen:o,onOpenChange:u,disableHoverableContent:c,delayDuration:f}=e,d=Xh(to,e.__scopeTooltip),m=_u(r),[g,y]=S.useState(null),b=Xa(),v=S.useRef(0),k=c??d.disableHoverableContent,C=f??d.delayDuration,A=S.useRef(!1),[N,O]=Nh({prop:i,defaultProp:o??!1,onChange:B=>{B?(d.onOpen(),document.dispatchEvent(new CustomEvent(Wd))):d.onClose(),u==null||u(B)},caller:to}),_=S.useMemo(()=>N?A.current?"delayed-open":"instant-open":"closed",[N]),U=S.useCallback(()=>{window.clearTimeout(v.current),v.current=0,A.current=!1,O(!0)},[O]),F=S.useCallback(()=>{window.clearTimeout(v.current),v.current=0,O(!1)},[O]),z=S.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{A.current=!0,O(!0),v.current=0},C)},[C,O]);return S.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),x.jsx(h1,{...m,children:x.jsx(L_,{scope:r,contentId:b,open:N,stateAttribute:_,trigger:g,onTriggerChange:y,onTriggerEnter:S.useCallback(()=>{d.isOpenDelayedRef.current?z():U()},[d.isOpenDelayedRef,z,U]),onTriggerLeave:S.useCallback(()=>{k?F():(window.clearTimeout(v.current),v.current=0)},[F,k]),onOpen:U,onClose:F,disableHoverableContent:k,children:l})})};b1.displayName=to;var eh="TooltipTrigger",v1=S.forwardRef((e,r)=>{const{__scopeTooltip:l,...i}=e,o=co(eh,l),u=Xh(eh,l),c=_u(l),f=S.useRef(null),d=an(r,f,o.onTriggerChange),m=S.useRef(!1),g=S.useRef(!1),y=S.useCallback(()=>m.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),x.jsx($h,{asChild:!0,...c,children:x.jsx(_t.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:d,onPointerMove:yt(e.onPointerMove,b=>{b.pointerType!=="touch"&&!g.current&&!u.isPointerInTransitRef.current&&(o.onTriggerEnter(),g.current=!0)}),onPointerLeave:yt(e.onPointerLeave,()=>{o.onTriggerLeave(),g.current=!1}),onPointerDown:yt(e.onPointerDown,()=>{o.open&&o.onClose(),m.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:yt(e.onFocus,()=>{m.current||o.onOpen()}),onBlur:yt(e.onBlur,o.onClose),onClick:yt(e.onClick,o.onClose)})})});v1.displayName=eh;var Qh="TooltipPortal",[B_,U_]=Tu(Qh,{forceMount:void 0}),w1=e=>{const{__scopeTooltip:r,forceMount:l,children:i,container:o}=e,u=co(Qh,r);return x.jsx(B_,{scope:r,forceMount:l,children:x.jsx(nl,{present:l||u.open,children:x.jsx(vu,{asChild:!0,container:o,children:i})})})};w1.displayName=Qh;var Oi="TooltipContent",S1=S.forwardRef((e,r)=>{const l=U_(Oi,e.__scopeTooltip),{forceMount:i=l.forceMount,side:o="top",...u}=e,c=co(Oi,e.__scopeTooltip);return x.jsx(nl,{present:i||c.open,children:c.disableHoverableContent?x.jsx(k1,{side:o,...u,ref:r}):x.jsx(H_,{side:o,...u,ref:r})})}),H_=S.forwardRef((e,r)=>{const l=co(Oi,e.__scopeTooltip),i=Xh(Oi,e.__scopeTooltip),o=S.useRef(null),u=an(r,o),[c,f]=S.useState(null),{trigger:d,onClose:m}=l,g=o.current,{onPointerInTransitChange:y}=i,b=S.useCallback(()=>{f(null),y(!1)},[y]),v=S.useCallback((k,C)=>{const A=k.currentTarget,N={x:k.clientX,y:k.clientY},O=I_(N,A.getBoundingClientRect()),_=G_(N,O),U=Y_(C.getBoundingClientRect()),F=X_([..._,...U]);f(F),y(!0)},[y]);return S.useEffect(()=>()=>b(),[b]),S.useEffect(()=>{if(d&&g){const k=A=>v(A,g),C=A=>v(A,d);return d.addEventListener("pointerleave",k),g.addEventListener("pointerleave",C),()=>{d.removeEventListener("pointerleave",k),g.removeEventListener("pointerleave",C)}}},[d,g,v,b]),S.useEffect(()=>{if(c){const k=C=>{const A=C.target,N={x:C.clientX,y:C.clientY},O=(d==null?void 0:d.contains(A))||(g==null?void 0:g.contains(A)),_=!$_(N,c);O?b():_&&(b(),m())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[d,g,c,m,b]),x.jsx(k1,{...e,ref:u})}),[P_,q_]=Tu(to,{isInside:!1}),F_=mN("TooltipContent"),k1=S.forwardRef((e,r)=>{const{__scopeTooltip:l,children:i,"aria-label":o,onEscapeKeyDown:u,onPointerDownOutside:c,...f}=e,d=co(Oi,l),m=_u(l),{onClose:g}=d;return S.useEffect(()=>(document.addEventListener(Wd,g),()=>document.removeEventListener(Wd,g)),[g]),S.useEffect(()=>{if(d.trigger){const y=b=>{const v=b.target;v!=null&&v.contains(d.trigger)&&g()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,g]),x.jsx(bu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:g,children:x.jsxs(m1,{"data-state":d.stateAttribute,...m,...f,ref:r,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[x.jsx(F_,{children:i}),x.jsx(P_,{scope:l,isInside:!0,children:x.jsx(O_,{id:d.contentId,role:"tooltip",children:o||i})})]})})});S1.displayName=Oi;var C1="TooltipArrow",V_=S.forwardRef((e,r)=>{const{__scopeTooltip:l,...i}=e,o=_u(l);return q_(C1,l).isInside?null:x.jsx(p1,{...o,...i,ref:r})});V_.displayName=C1;function I_(e,r){const l=Math.abs(r.top-e.y),i=Math.abs(r.bottom-e.y),o=Math.abs(r.right-e.x),u=Math.abs(r.left-e.x);switch(Math.min(l,i,o,u)){case u:return"left";case o:return"right";case l:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function G_(e,r,l=5){const i=[];switch(r){case"top":i.push({x:e.x-l,y:e.y+l},{x:e.x+l,y:e.y+l});break;case"bottom":i.push({x:e.x-l,y:e.y-l},{x:e.x+l,y:e.y-l});break;case"left":i.push({x:e.x+l,y:e.y-l},{x:e.x+l,y:e.y+l});break;case"right":i.push({x:e.x-l,y:e.y-l},{x:e.x-l,y:e.y+l});break}return i}function Y_(e){const{top:r,right:l,bottom:i,left:o}=e;return[{x:o,y:r},{x:l,y:r},{x:l,y:i},{x:o,y:i}]}function $_(e,r){const{x:l,y:i}=e;let o=!1;for(let u=0,c=r.length-1;u<r.length;c=u++){const f=r[u],d=r[c],m=f.x,g=f.y,y=d.x,b=d.y;g>i!=b>i&&l<(y-m)*(i-g)/(b-g)+m&&(o=!o)}return o}function X_(e){const r=e.slice();return r.sort((l,i)=>l.x<i.x?-1:l.x>i.x?1:l.y<i.y?-1:l.y>i.y?1:0),Q_(r)}function Q_(e){if(e.length<=1)return e.slice();const r=[];for(let i=0;i<e.length;i++){const o=e[i];for(;r.length>=2;){const u=r[r.length-1],c=r[r.length-2];if((u.x-c.x)*(o.y-c.y)>=(u.y-c.y)*(o.x-c.x))r.pop();else break}r.push(o)}r.pop();const l=[];for(let i=e.length-1;i>=0;i--){const o=e[i];for(;l.length>=2;){const u=l[l.length-1],c=l[l.length-2];if((u.x-c.x)*(o.y-c.y)>=(u.y-c.y)*(o.x-c.x))l.pop();else break}l.push(o)}return l.pop(),r.length===1&&l.length===1&&r[0].x===l[0].x&&r[0].y===l[0].y?r:r.concat(l)}var Z_=x1,K_=b1,J_=v1,W_=w1,E1=S1;const eR=Z_,ou=K_,su=J_,no=S.forwardRef(({className:e,sideOffset:r=4,...l},i)=>x.jsx(W_,{children:x.jsx(E1,{ref:i,sideOffset:r,className:xe("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...l})}));no.displayName=E1.displayName;const tR="0.1.3",nR={version:tR},zt="Kanna",db="kanna",rR=`kanna/${nR.version}`,lR="[kanna]",iR=`~/${zt}`;function qs(e){return e?`${db} ${e}`:db}const aR={sm:"text-sm px-2.5 py-1",md:"text-sm px-3 py-1.5"};function oR({value:e,onValueChange:r,options:l,size:i="md",className:o,optionClassName:u}){return x.jsx("div",{className:xe("inline-flex items-center rounded-full border border-border p-0.5 ",o),children:l.map(c=>{const f=c.value===e,d=c.icon,m=d?S.isValidElement(d)?d:(()=>{const y=d;return x.jsx(y,{className:i==="sm"?"h-3.5 w-3.5":"h-4 w-4"})})():null,g=x.jsxs("button",{type:"button",onClick:()=>r(c.value),disabled:c.disabled,"aria-pressed":f,className:xe("rounded-full border transition-colors",d?"grid grid-cols-[auto_auto] items-center gap-2":"inline-flex items-center gap-1.5",aR[i],f?"bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 ":"border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",c.disabled&&"opacity-50 pointer-events-none",u),children:[m,x.jsx("span",{children:c.label})]},c.value);return c.tooltip?x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:g}),x.jsx(no,{children:c.tooltip})]},c.value):g})})}function sR(e){return e.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function N1({open:e,onOpenChange:r,onConfirm:l}){const[i,o]=S.useState("new"),[u,c]=S.useState(""),[f,d]=S.useState(""),m=S.useRef(null),g=S.useRef(null);S.useEffect(()=>{e&&(o("new"),c(""),d(""),setTimeout(()=>{var A;return(A=m.current)==null?void 0:A.focus()},0))},[e]),S.useEffect(()=>{e&&setTimeout(()=>{var A,N;i==="new"?(A=m.current)==null||A.focus():(N=g.current)==null||N.focus()},0)},[i,e]);const y=sR(u),b=y?`${iR}/${y}`:"",v=f.trim(),k=i==="new"?!!y:!!v,C=()=>{if(k){if(i==="new")l({mode:"new",localPath:b,title:u.trim()});else{const A=v.split("/").pop()||v;l({mode:"existing",localPath:v,title:A})}r(!1)}};return x.jsx(P0,{open:e,onOpenChange:r,children:x.jsxs(Uh,{size:"sm",children:[x.jsxs(V0,{className:"space-y-4",children:[x.jsx(F0,{children:"Add Project"}),x.jsx(oR,{value:i,onValueChange:o,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full",optionClassName:"flex-1 justify-center"}),i==="new"?x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:m,type:"text",value:u,onChange:A=>c(A.target.value),onKeyDown:A=>{A.key==="Enter"&&C(),A.key==="Escape"&&r(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"Project name"}),b&&x.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:b})]}):x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:g,type:"text",value:f,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&C(),A.key==="Escape"&&r(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"~/Projects/my-app"}),x.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),x.jsxs(I0,{children:[x.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"}),x.jsx(qe,{variant:"secondary",size:"sm",onClick:C,disabled:!k,children:"Create"})]})]})})}const Ru=({children:e,className:r,shimmerWidth:l=100,animate:i=!0,...o})=>x.jsx("span",{style:{"--shiny-width":`${Math.min(l,100)}px`},className:xe("mx-auto max-w-md text-foreground/50",i?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],r),...o,children:e}),uR=new Set(["starting","running"]);function cR({chat:e,activeChatId:r,onSelectChat:l,onDeleteChat:i}){return x.jsxs("div",{"data-chat-id":Bx(e.chatId),className:xe("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-md cursor-pointer border-border/0 hover:border-border hover:bg-muted active:bg-muted border transition-colors",r===Bx(e.chatId)?"bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>l(e.chatId),children:[uR.has(e.status)?x.jsx(zl,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?x.jsx("div",{className:"relative ",children:x.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[x.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),x.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,x.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?x.jsx(Ru,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),x.jsx(qe,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-100 md:opacity-0 md:group-hover:opacity-100 cursor-pointer rounded-sm hover:!bg-transparent",onClick:o=>{o.stopPropagation(),i(e.chatId)},title:"Delete chat",children:x.jsx(so,{className:"size-3.5"})})]},e._id)}function jl(e){return e.split(/[\s_-]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")}function A1(e){return e.split("/").pop()||e}var Mu="Popover",[j1]=xu(Mu,[ju]),fo=ju(),[fR,rl]=j1(Mu),T1=e=>{const{__scopePopover:r,children:l,open:i,defaultOpen:o,onOpenChange:u,modal:c=!1}=e,f=fo(r),d=S.useRef(null),[m,g]=S.useState(!1),[y,b]=Nh({prop:i,defaultProp:o??!1,onChange:u,caller:Mu});return x.jsx(h1,{...f,children:x.jsx(fR,{scope:r,contentId:Xa(),triggerRef:d,open:y,onOpenChange:b,onOpenToggle:S.useCallback(()=>b(v=>!v),[b]),hasCustomAnchor:m,onCustomAnchorAdd:S.useCallback(()=>g(!0),[]),onCustomAnchorRemove:S.useCallback(()=>g(!1),[]),modal:c,children:l})})};T1.displayName=Mu;var _1="PopoverAnchor",dR=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=rl(_1,l),u=fo(l),{onCustomAnchorAdd:c,onCustomAnchorRemove:f}=o;return S.useEffect(()=>(c(),()=>f()),[c,f]),x.jsx($h,{...u,...i,ref:r})});dR.displayName=_1;var R1="PopoverTrigger",M1=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=rl(R1,l),u=fo(l),c=an(r,o.triggerRef),f=x.jsx(_t.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":B1(o.open),...i,ref:c,onClick:yt(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?f:x.jsx($h,{asChild:!0,...u,children:f})});M1.displayName=R1;var Zh="PopoverPortal",[hR,mR]=j1(Zh,{forceMount:void 0}),O1=e=>{const{__scopePopover:r,forceMount:l,children:i,container:o}=e,u=rl(Zh,r);return x.jsx(hR,{scope:r,forceMount:l,children:x.jsx(nl,{present:l||u.open,children:x.jsx(vu,{asChild:!0,container:o,children:i})})})};O1.displayName=Zh;var zi="PopoverContent",z1=S.forwardRef((e,r)=>{const l=mR(zi,e.__scopePopover),{forceMount:i=l.forceMount,...o}=e,u=rl(zi,e.__scopePopover);return x.jsx(nl,{present:i||u.open,children:u.modal?x.jsx(gR,{...o,ref:r}):x.jsx(yR,{...o,ref:r})})});z1.displayName=zi;var pR=Ah("PopoverContent.RemoveScroll"),gR=S.forwardRef((e,r)=>{const l=rl(zi,e.__scopePopover),i=S.useRef(null),o=an(r,i),u=S.useRef(!1);return S.useEffect(()=>{const c=i.current;if(c)return d0(c)},[]),x.jsx(Th,{as:pR,allowPinchZoom:!0,children:x.jsx(D1,{...e,ref:o,trapFocus:l.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:yt(e.onCloseAutoFocus,c=>{var f;c.preventDefault(),u.current||(f=l.triggerRef.current)==null||f.focus()}),onPointerDownOutside:yt(e.onPointerDownOutside,c=>{const f=c.detail.originalEvent,d=f.button===0&&f.ctrlKey===!0,m=f.button===2||d;u.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:yt(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),yR=S.forwardRef((e,r)=>{const l=rl(zi,e.__scopePopover),i=S.useRef(!1),o=S.useRef(!1);return x.jsx(D1,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{var c,f;(c=e.onCloseAutoFocus)==null||c.call(e,u),u.defaultPrevented||(i.current||(f=l.triggerRef.current)==null||f.focus(),u.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:u=>{var d,m;(d=e.onInteractOutside)==null||d.call(e,u),u.defaultPrevented||(i.current=!0,u.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=u.target;((m=l.triggerRef.current)==null?void 0:m.contains(c))&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&o.current&&u.preventDefault()}})}),D1=S.forwardRef((e,r)=>{const{__scopePopover:l,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:u,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:g,...y}=e,b=rl(zi,l),v=fo(l);return r0(),x.jsx(jh,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:u,children:x.jsx(bu,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:g,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onDismiss:()=>b.onOpenChange(!1),children:x.jsx(m1,{"data-state":B1(b.open),role:"dialog",id:b.contentId,...v,...y,ref:r,style:{...y.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),L1="PopoverClose",xR=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=rl(L1,l);return x.jsx(_t.button,{type:"button",...i,ref:r,onClick:yt(e.onClick,()=>o.onOpenChange(!1))})});xR.displayName=L1;var bR="PopoverArrow",vR=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=fo(l);return x.jsx(p1,{...o,...i,ref:r})});vR.displayName=bR;function B1(e){return e?"open":"closed"}var wR=T1,SR=M1,kR=O1,U1=z1;const H1=wR,P1=SR,Kh=S.forwardRef(({className:e,align:r="center",sideOffset:l=4,...i},o)=>x.jsx(kR,{children:x.jsx(U1,{ref:o,align:r,sideOffset:l,className:xe("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden 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),...i})}));Kh.displayName=U1.displayName;function CR({onRemove:e}){const[r,l]=S.useState(!1);return x.jsxs(H1,{open:r,onOpenChange:l,children:[x.jsx(P1,{asChild:!0,children:x.jsx(qe,{variant:"ghost",size:"icon",className:"h-5.5 w-5.5 absolute right-6 !rounded opacity-100 md:opacity-0 md:group-hover/section:opacity-100",onClick:i=>i.stopPropagation(),children:x.jsx(Nj,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"})})}),x.jsx(Kh,{align:"end",className:"p-1 w-auto min-w-[170px]",children:x.jsxs("button",{onClick:i=>{i.stopPropagation(),l(!1),e()},className:"w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-left transition-colors text-destructive dark:text-red-400 hover:bg-destructive/10 dark:hover:bg-red-500/20",children:[x.jsx(uT,{className:"h-4 w-4"}),x.jsx("span",{className:"text-xs font-medium",children:"Remove Project"})]})})]})}function ER({projectGroups:e,collapsedSections:r,expandedGroups:l,onToggleSection:i,onToggleExpandedGroup:o,renderChatRow:u,chatsPerProject:c,onNewLocalChat:f,onRemoveProject:d,isConnected:m,startingLocalPath:g}){return x.jsx(x.Fragment,{children:e.map(({groupKey:y,localPath:b,chats:v})=>{const k=l.has(y),C=k?v:v.slice(0,c),A=v.length>c;return x.jsxs("div",{className:"group/section",children:[x.jsxs("div",{className:"sticky top-0 bg-background dark:bg-card z-10 relative pl-2.5 pr-3 py-2 pt-3 cursor-pointer flex items-center justify-between",onClick:()=>i(y),children:[x.jsxs("div",{className:"flex items-center gap-2",children:[r.has(y)?x.jsx(O0,{className:"translate-y-[1px] size-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):x.jsx(M0,{className:"translate-y-[1px] size-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:x.jsx("span",{className:"truncate max-w-[150px] whitespace-nowrap text-sm text-slate-500 dark:text-slate-400",children:A1(b)})}),x.jsx(no,{side:"right",sideOffset:4,children:b})]}),x.jsx(Kr,{className:xe("size-3.5 translate-y-[1px] text-slate-400 transition-all duration-200",r.has(y)?"opacity-100":"rotate-90 opacity-0 group-hover/section:opacity-100")})]}),d?x.jsx(CR,{onRemove:()=>d(y)}):null,f&&x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:x.jsx(qe,{variant:"ghost",size:"icon",className:xe("h-5.5 w-5.5 absolute right-0 !rounded opacity-100 md:opacity-0 md:group-hover/section:opacity-100",(!m||g===b)&&"opacity-50 cursor-not-allowed"),disabled:!m||g===b,onClick:N=>{N.stopPropagation(),f(b)},children:g===b?x.jsx(zl,{className:"size-4 text-slate-500 dark:text-slate-400 animate-spin"}):x.jsx(Dh,{className:"size-3.5 text-slate-500 dark:text-slate-400"})})}),x.jsx(no,{side:"right",sideOffset:4,children:m?"New chat":`Start ${zt} to connect`})]})]}),!r.has(y)&&x.jsxs("div",{className:"space-y-[2px] mb-2 ",children:[C.map(u),A&&x.jsx("button",{onClick:()=>o(y),className:"pl-3 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:k?"Show less":`Show more (${v.length-c})`})]})]},y)})})}function NR({data:e,activeChatId:r,connectionStatus:l,ready:i,open:o,collapsed:u,showMobileOpenButton:c,onOpen:f,onClose:d,onCollapse:m,onExpand:g,onCreateChat:y,onCreateProject:b,onDeleteChat:v,onRemoveProject:k}){const C=Fn(),A=xh(),N=S.useRef(null),[O,_]=S.useState(new Set),[U,F]=S.useState(new Set),[z,B]=S.useState(!1),$=10,ae=S.useMemo(()=>new Map(e.projectGroups.map(ie=>[ie.localPath,ie.groupKey])),[e.projectGroups]),P=S.useMemo(()=>e.projectGroups.reduce((ie,j)=>ie+j.chats.length,0),[e.projectGroups]),re=S.useCallback(ie=>{_(j=>{const R=new Set(j);return R.has(ie)?R.delete(ie):R.add(ie),R})},[]),le=S.useCallback(ie=>{F(j=>{const R=new Set(j);return R.has(ie)?R.delete(ie):R.add(ie),R})},[]),se=S.useCallback(ie=>x.jsx(cR,{chat:ie,activeChatId:r,onSelectChat:j=>A(`/chat/${j}`),onDeleteChat:()=>v(ie)},ie._id),[r,A,v]);S.useEffect(()=>{!r||!N.current||requestAnimationFrame(()=>{const ie=N.current,j=ie==null?void 0:ie.querySelector(`[data-chat-id="${r}"]`);if(!j||!ie)return;const R=j.getBoundingClientRect(),G=ie.getBoundingClientRect();if(R.top<G.top+38){const T=R.top-G.top+ie.scrollTop;ie.scrollTo({top:T-38,behavior:"smooth"})}else if(R.bottom>G.bottom){const T=R.top+R.height/2-G.top+ie.scrollTop,ue=ie.clientHeight/2;ie.scrollTo({top:T-ue,behavior:"smooth"})}})},[r,P]);const J=P>0,Z=C.pathname==="/projects",D=l==="connecting"||!i,X=D?"Connecting":l==="connected"?"Connected":"Disconnected",ne=l==="connected"?"bg-emerald-500":"bg-amber-500";return x.jsxs(x.Fragment,{children:[!o&&c&&x.jsx(qe,{variant:"ghost",size:"icon",className:"fixed top-3 left-3 z-50 md:hidden",onClick:f,children:x.jsx(z0,{className:"h-5 w-5"})}),u&&Z&&x.jsx("div",{className:"hidden md:flex fixed left-0 top-0 h-full z-40 items-start pt-4 pl-5 border-l border-border/0",children:x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(Qa,{className:"size-6 text-logo"}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:g,title:"Expand sidebar",children:x.jsx(Qd,{className:"h-5 w-5"})})]})}),x.jsxs("div",{"data-sidebar":"open",className:xe("fixed inset-0 z-50 bg-background dark:bg-card flex flex-col h-[100dvh] select-none","md:relative md:inset-auto md:w-[275px] md:mr-2 md:h-[calc(100dvh-16px)] md:my-2 md:ml-2 md:border md:border-border md:rounded-2xl",o?"flex":"hidden md:flex",u&&"md:hidden"),children:[x.jsxs("div",{className:" pl-3 pr-[7px] h-[64px] max-h-[64px] md:h-[55px] md:max-h-[55px] border-b flex items-center justify-between",children:[x.jsxs("div",{className:"group/sidebar-header flex items-center gap-2",children:[x.jsxs("button",{type:"button",onClick:m,title:"Collapse sidebar",className:"hidden md:flex relative items-center justify-center h-5 w-5 sm:h-6 sm:w-6",children:[x.jsx(Qa,{className:"absolute inset-0.5 h-4 w-4 sm:h-5 sm:w-5 text-logo transition-all duration-200 ease-out opacity-100 scale-100 group-hover/sidebar-header:opacity-0 group-hover/sidebar-header:scale-0"}),x.jsx(Qd,{className:"absolute inset-0 h-4 w-4 sm:h-6 sm:w-6 text-slate-500 dark:text-slate-400 transition-all duration-200 ease-out opacity-0 scale-0 group-hover/sidebar-header:opacity-100 group-hover/sidebar-header:scale-80 hover:opacity-50"})]}),x.jsx(Qa,{className:"h-5 w-5 sm:h-6 sm:w-6 text-logo md:hidden"}),x.jsx("span",{className:"font-logo text-base uppercase sm:text-md text-slate-600 dark:text-slate-100",children:zt})]}),x.jsxs("div",{className:"flex items-center",children:[x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>B(!0),title:"New project",children:x.jsx(U0,{className:"size-4"})}),x.jsx(qe,{variant:"ghost",size:"icon",className:"md:hidden",onClick:d,children:x.jsx(so,{className:"h-5 w-5"})})]})]}),x.jsx("div",{ref:N,className:"flex-1 min-h-0 overflow-y-auto scrollbar-hide",style:{WebkitOverflowScrolling:"touch"},children:x.jsxs("div",{className:"pb-2 px-2 pt-1.5",children:[!J&&D?x.jsx("div",{className:"space-y-5 px-1 pt-3",children:[0,1,2].map(ie=>x.jsxs("div",{className:"space-y-2 animate-pulse",children:[x.jsx("div",{className:"h-4 w-28 rounded bg-muted"}),x.jsx("div",{className:"space-y-1",children:[0,1,2].map(j=>x.jsxs("div",{className:"flex items-center gap-2 rounded-md px-3 py-2",children:[x.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-muted"}),x.jsx("div",{className:xe("h-3.5 rounded bg-muted",j===0?"w-32":j===1?"w-40":"w-28")})]},j))})]},ie))}):null,!J&&!D&&e.projectGroups.length===0?x.jsx("p",{className:"text-sm text-slate-400 p-2 mt-6 text-center",children:"No conversations yet"}):null,x.jsx(ER,{projectGroups:e.projectGroups,collapsedSections:O,expandedGroups:U,onToggleSection:re,onToggleExpandedGroup:le,renderChatRow:se,chatsPerProject:$,onNewLocalChat:ie=>{const j=ae.get(ie);j&&y(j)},onRemoveProject:k,isConnected:l==="connected"})]})}),x.jsx("div",{className:"border-t border-border p-2",children:x.jsx("button",{type:"button",onClick:()=>{A("/projects"),d()},className:xe("w-full rounded-xl rounded-t-md border px-3 py-2 text-left transition-colors",Z?"bg-muted border-border":"border-border/0 hover:bg-muted hover:border-border active:bg-muted/80"),children:x.jsxs("div",{className:"flex items- justify-between gap-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Oh,{className:"h-4 w-4 text-muted-foreground"}),x.jsx("span",{className:"text-sm",children:"Projects"})]}),x.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[x.jsx("span",{children:X}),D?x.jsx(zl,{className:"h-2 w-2 animate-spin"}):x.jsx("span",{className:xe("h-2 w-2 rounded-full",ne)})]})]})})})]}),x.jsx(N1,{open:z,onOpenChange:B,onConfirm:b}),o?x.jsx("div",{className:"fixed inset-0 bg-black/40 z-40 md:hidden",onClick:d}):null]})}const q1=S.forwardRef(({className:e,...r},l)=>x.jsx("textarea",{"data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false","data-1p-ignore":!0,autoComplete:"off",className:xe("flex w-full rounded-lg border border-border bg-background px-2.5 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),ref:l,...r}));q1.displayName="Textarea";function AR(){const[e,r]=S.useState(()=>{if(typeof window>"u")return!1;const l=navigator.standalone===!0,i=window.matchMedia("(display-mode: standalone)").matches;return l||i});return S.useEffect(()=>{const l=window.matchMedia("(display-mode: standalone)"),i=o=>{r(o.matches||navigator.standalone===!0)};return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[]),e}const hb=e=>{let r;const l=new Set,i=(m,g)=>{const y=typeof m=="function"?m(r):m;if(!Object.is(y,r)){const b=r;r=g??(typeof y!="object"||y===null)?y:Object.assign({},r,y),l.forEach(v=>v(r,b))}},o=()=>r,f={setState:i,getState:o,getInitialState:()=>d,subscribe:m=>(l.add(m),()=>l.delete(m))},d=r=e(i,o,f);return f},jR=(e=>e?hb(e):hb),TR=e=>e;function _R(e,r=TR){const l=Ya.useSyncExternalStore(e.subscribe,Ya.useCallback(()=>r(e.getState()),[e,r]),Ya.useCallback(()=>r(e.getInitialState()),[e,r]));return Ya.useDebugValue(l),l}const RR=e=>{const r=jR(e),l=i=>_R(r,i);return Object.assign(l,r),l},F1=(e=>RR);function MR(e,r){let l;try{l=e()}catch{return}return{getItem:o=>{var u;const c=d=>d===null?null:JSON.parse(d,void 0),f=(u=l.getItem(o))!=null?u:null;return f instanceof Promise?f.then(c):c(f)},setItem:(o,u)=>l.setItem(o,JSON.stringify(u,void 0)),removeItem:o=>l.removeItem(o)}}const th=e=>r=>{try{const l=e(r);return l instanceof Promise?l:{then(i){return th(i)(l)},catch(i){return this}}}catch(l){return{then(i){return this},catch(i){return th(i)(l)}}}},OR=(e,r)=>(l,i,o)=>{let u={storage:MR(()=>window.localStorage),partialize:A=>A,version:0,merge:(A,N)=>({...N,...A}),...r},c=!1,f=0;const d=new Set,m=new Set;let g=u.storage;if(!g)return e((...A)=>{console.warn(`[zustand persist middleware] Unable to update item '${u.name}', the given storage is currently unavailable.`),l(...A)},i,o);const y=()=>{const A=u.partialize({...i()});return g.setItem(u.name,{state:A,version:u.version})},b=o.setState;o.setState=(A,N)=>(b(A,N),y());const v=e((...A)=>(l(...A),y()),i,o);o.getInitialState=()=>v;let k;const C=()=>{var A,N;if(!g)return;const O=++f;c=!1,d.forEach(U=>{var F;return U((F=i())!=null?F:v)});const _=((N=u.onRehydrateStorage)==null?void 0:N.call(u,(A=i())!=null?A:v))||void 0;return th(g.getItem.bind(g))(u.name).then(U=>{if(U)if(typeof U.version=="number"&&U.version!==u.version){if(u.migrate){const F=u.migrate(U.state,U.version);return F instanceof Promise?F.then(z=>[!0,z]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,U.state];return[!1,void 0]}).then(U=>{var F;if(O!==f)return;const[z,B]=U;if(k=u.merge(B,(F=i())!=null?F:v),l(k,!0),z)return y()}).then(()=>{O===f&&(_==null||_(k,void 0),k=i(),c=!0,m.forEach(U=>U(k)))}).catch(U=>{O===f&&(_==null||_(void 0,U))})};return o.persist={setOptions:A=>{u={...u,...A},A.storage&&(g=A.storage)},clearStorage:()=>{g==null||g.removeItem(u.name)},getOptions:()=>u,rehydrate:()=>C(),hasHydrated:()=>c,onHydrate:A=>(d.add(A),()=>{d.delete(A)}),onFinishHydration:A=>(m.add(A),()=>{m.delete(A)})},u.skipHydration||C(),k||v},V1=OR,zR=F1()(V1((e,r)=>({drafts:{},setDraft:(l,i)=>e(o=>{if(!i){const{[l]:u,...c}=o.drafts;return{drafts:c}}return{drafts:{...o.drafts,[l]:i}}}),clearDraft:l=>e(i=>{const{[l]:o,...u}=i.drafts;return{drafts:u}}),getDraft:l=>r().drafts[l]??""}),{name:"chat-input-drafts"})),I1=F1()(V1(e=>({model:"opus",effort:"high",planMode:!1,setModel:r=>e(l=>r!=="opus"&&l.effort==="max"?{model:r,effort:"high"}:{model:r}),setEffort:r=>e({effort:r}),setPlanMode:r=>e({planMode:r})}),{name:"chat-preferences"}));function dr({onClick:e,selected:r,icon:l,label:i,description:o,disabled:u}){return x.jsxs("button",{onClick:e,disabled:u,className:xe("w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity",r?"bg-muted border-border":"hover:opacity-60",u&&"opacity-40 cursor-not-allowed"),children:[l,x.jsxs("div",{children:[x.jsx("div",{className:"text-sm font-medium",children:i}),x.jsx("div",{className:"text-xs text-muted-foreground",children:o})]})]})}function wd({trigger:e,triggerClassName:r,children:l}){return x.jsxs(H1,{children:[x.jsx(P1,{asChild:!0,children:x.jsx("button",{className:xe("flex items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0","hover:bg-muted/50",r),children:e})}),x.jsx(Kh,{align:"center",className:"w-64 p-1",children:x.jsx("div",{className:"space-y-1",children:l})})]})}const DR={opus:zh,sonnet:H0,haiku:R0},LR={opus:"Opus",sonnet:"Sonnet",haiku:"Haiku"},BR={low:"Low",medium:"Medium",high:"High",max:"Max"},UR=S.memo(function({onSubmit:r,onCancel:l,disabled:i,canCancel:o,chatId:u}){const{getDraft:c,setDraft:f,clearDraft:d}=zR(),{model:m,effort:g,planMode:y,setModel:b,setEffort:v,setPlanMode:k}=I1(),[C,A]=S.useState(()=>u?c(u):""),N=S.useRef(null),O=AR(),_=S.useCallback(()=>{const B=N.current;B&&(B.style.height="auto",B.style.height=`${B.scrollHeight}px`)},[]);S.useEffect(()=>{_()},[C,_]),S.useEffect(()=>(window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)),[_]),S.useEffect(()=>{var B;(B=N.current)==null||B.focus()},[u]);async function U(){if(!C.trim())return;const B=C;A(""),u&&d(u),N.current&&(N.current.style.height="auto");try{await r(B,{model:m,effort:g,planMode:y})}catch($){console.error("[ChatInput] Submit failed:",$),A(B),u&&f(u,B)}}function F(B){if(B.key==="Tab"&&B.shiftKey){B.preventDefault(),k(!y);return}if(B.key==="Escape"&&o){B.preventDefault(),l==null||l();return}const $="ontouchstart"in window||navigator.maxTouchPoints>0;B.key==="Enter"&&!B.shiftKey&&!o&&!$&&(B.preventDefault(),U())}const z=DR[m];return x.jsxs("div",{className:xe("p-3 pt-0 md:pb-2",O&&"px-5 pb-5"),children:[x.jsxs("div",{className:"flex items-end gap-2 max-w-[840px] mx-auto border dark:bg-card/40 backdrop-blur-lg border-border rounded-[29px] pr-1.5",children:[x.jsx(q1,{ref:N,placeholder:"Ask something...",value:C,autoFocus:!0,rows:1,onChange:B=>{A(B.target.value),u&&f(u,B.target.value),_()},onKeyDown:F,disabled:i,className:"flex-1 text-base p-3 md:p-4 pl-4.5 md:pl-6 resize-none max-h-[200px] outline-none bg-transparent border-0 shadow-none"}),x.jsx(qe,{type:"button",onPointerDown:B=>{B.preventDefault(),o?l==null||l():!i&&C.trim()&&U()},disabled:!o&&(i||!C.trim()),size:"icon",className:"flex-shrink-0 bg-slate-600 text-white dark:bg-white dark:text-slate-900 rounded-full cursor-pointer h-10 w-10 md:h-11 md:w-11 mb-1 -mr-0.5 md:mr-0 md:mb-1.5 touch-manipulation disabled:bg-white/60 disabled:text-slate-700",children:o?x.jsx("div",{className:"w-3 h-3 md:w-4 md:h-4 rounded-xs bg-current"}):x.jsx(KA,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),x.jsxs("div",{className:"flex justify-center items-center gap-0.5 max-w-[840px] mx-auto mt-2 animate-fade-in",children:[x.jsxs(wd,{trigger:x.jsxs(x.Fragment,{children:[x.jsx(z,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:LR[m]})]}),children:[x.jsx(dr,{onClick:()=>b("opus"),selected:m==="opus",icon:x.jsx(zh,{className:"h-4 w-4 text-muted-foreground"}),label:"Opus",description:"Highest capability, deep reasoning"}),x.jsx(dr,{onClick:()=>b("sonnet"),selected:m==="sonnet",icon:x.jsx(H0,{className:"h-4 w-4 text-muted-foreground"}),label:"Sonnet",description:"Balanced speed and intelligence"}),x.jsx(dr,{onClick:()=>b("haiku"),selected:m==="haiku",icon:x.jsx(R0,{className:"h-4 w-4 text-muted-foreground"}),label:"Haiku",description:"Fastest responses, lightweight tasks"})]}),x.jsxs(wd,{trigger:x.jsxs(x.Fragment,{children:[x.jsx(Pa,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:BR[g]})]}),triggerClassName:g==="max"?"text-amber-400 dark:text-amber-300":void 0,children:[x.jsx(dr,{onClick:()=>v("low"),selected:g==="low",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"Low",description:"Minimal thinking, fastest responses"}),x.jsx(dr,{onClick:()=>v("medium"),selected:g==="medium",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"Medium",description:"Moderate thinking for typical tasks"}),x.jsx(dr,{onClick:()=>v("high"),selected:g==="high",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"High",description:"Deep reasoning for complex problems"}),x.jsx(dr,{onClick:()=>v("max"),selected:g==="max",disabled:m!=="opus",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"Max",description:m!=="opus"?"Only available with Opus":"Maximum effort, deepest reasoning"})]}),x.jsxs(wd,{trigger:y?x.jsxs(x.Fragment,{children:[x.jsx(nu,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:"Plan Mode"})]}):x.jsxs(x.Fragment,{children:[x.jsx(Wx,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:"Full Access"})]}),triggerClassName:y?"text-blue-400 dark:text-blue-300":void 0,children:[x.jsx(dr,{onClick:()=>k(!1),selected:!y,icon:x.jsx(Wx,{className:"h-4 w-4 text-muted-foreground"}),label:"Full Access",description:"Claude can read and edit files"}),x.jsx(dr,{onClick:()=>k(!0),selected:y,icon:x.jsx(nu,{className:"h-4 w-4 text-muted-foreground"}),label:"Plan Mode",description:"Claude can only read, not edit"}),x.jsxs("p",{className:"text-xs text-muted-foreground/90 px-2 py-2",children:["Press ",x.jsx("kbd",{className:"px-1 mx-0.5 py-0.5 text-[12px] bg-muted/90 rounded font-mono",children:"shift+tab"})," to toggle"]})]})]})]})}),G1=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("bg-card text-card-foreground",e),...r}));G1.displayName="Card";const Y1=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("flex flex-col space-y-1.5 p-2",e),...r}));Y1.displayName="CardHeader";const HR=S.forwardRef(({className:e,...r},l)=>x.jsx("h3",{ref:l,className:xe("text-2xl font-semibold leading-none tracking-tight",e),...r}));HR.displayName="CardTitle";const PR=S.forwardRef(({className:e,...r},l)=>x.jsx("p",{ref:l,className:xe("text-sm text-muted-foreground",e),...r}));PR.displayName="CardDescription";const $1=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("p-6 pt-0",e),...r}));$1.displayName="CardContent";const qR=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("flex items-center p-6 pt-0",e),...r}));qR.displayName="CardFooter";function FR({sidebarCollapsed:e,onOpenSidebar:r,onExpandSidebar:l,onNewChat:i,localPath:o,onOpenExternal:u}){return x.jsx(Y1,{className:xe("absolute top-0 md:top-2 left-0 right-0 z-10 px-2.5 pr-4 border-border/0 md:pb-0 flex items-center justify-center","backdrop-blur-lg md:backdrop-blur-none bg-gradient-to-b from-background md:from-transparent border-b border-x-0 md:border-x border-border md:border-none"),children:x.jsxs("div",{className:"relative flex items-center gap-2 w-full",children:[x.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 border-l border-border/0",children:[x.jsx(qe,{variant:"ghost",size:"icon",className:"md:hidden",onClick:r,children:x.jsx(z0,{className:"h-5 w-5"})}),e&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"flex items-center justify-center w-[40px] h-[40px]",children:x.jsx(Qa,{className:"h-4 w-4 sm:h-5 sm:w-5 text-logo ml-1 hidden md:block"})}),x.jsx(qe,{variant:"ghost",size:"icon",className:"hidden md:flex",onClick:l,title:"Expand sidebar",children:x.jsx(Qd,{className:"h-5 w-5"})})]}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:i,title:"Compose",children:x.jsx(Dh,{className:"h-5 w-5"})})]}),x.jsx("div",{className:"flex-1 min-w-0"}),x.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:o&&u&&x.jsxs(x.Fragment,{children:[x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>u("open_finder"),title:"Open in Finder",className:"border border-border/0",children:x.jsx(M0,{className:"h-4.5 w-4.5"})}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>u("open_terminal"),title:"Open in Terminal",className:"border border-border/0",children:x.jsx(Lh,{className:"h-4.5 w-4.5"})}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>u("open_editor"),title:"Open in Cursor",className:"border border-border/0",children:x.jsx(bj,{className:"h-4.5 w-4.5"})})]})})]})})}const nh={Task:nu,TaskOutput:nu,Bash:Lh,Glob:yd,Grep:yd,ExitPlanMode:eb,Read:Mj,Edit:jj,Write:_j,NotebookEdit:B0,WebFetch:GA,TodoWrite:aj,WebSearch:yd,KillShell:lT,AskUserQuestion:D0,Skill:zh,EnterPlanMode:eb},X1=oT;function Q1(e){return nh[e]?nh[e]:/^mcp__db__.+_query$/.test(e)?Cj:e==="mcp__lever__show_chart"?nj:X1}function ll({children:e,className:r}){return x.jsx("div",{className:xe("flex gap-3 justify-start items-center",r),children:e})}function VR({children:e,className:r}){return x.jsx("div",{className:xe("flex items-center gap-1.5 text-xs",r),children:e})}function el({children:e,className:r}){return x.jsx("span",{className:xe("font-medium text-foreground/80",r),children:e})}function IR({children:e}){return x.jsx("span",{className:"text-muted-foreground",children:e})}function Ou({children:e,expandedContent:r,defaultExpanded:l=!1}){const[i,o]=S.useState(l);return x.jsxs("div",{className:"flex flex-col w-full",children:[x.jsxs("button",{onClick:()=>o(!i),className:`group/expandable-row cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${i?"":"hover:opacity-60 transition-opacity"}`,children:[x.jsx("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:e}),x.jsx(Kr,{className:`h-4.5 w-4.5 text-muted-icon translate-y-[0.5px] transition-all duration-200 opacity-0 group-hover/expandable-row:opacity-100 ${i?"rotate-90 opacity-100":""}`})]}),i&&r]})}function qa({label:e,children:r,copyText:l}){const[i,o]=S.useState(!1),u=l??uu(r),c=S.useCallback(async()=>{await navigator.clipboard.writeText(u),o(!0),setTimeout(()=>o(!1),2e3)},[u]);return x.jsxs("div",{children:[x.jsx("span",{className:"font-medium text-muted-foreground",children:e}),x.jsxs("div",{className:"relative group/codeblock",children:[x.jsx("pre",{className:"my-1 text-xs font-mono whitespace-no-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto w-full",children:r}),x.jsx(qe,{variant:"ghost",size:"icon",className:xe("absolute top-2.5 right-1.5 z-10 h-8 w-8 rounded-md text-muted-foreground opacity-0 group-hover/codeblock:opacity-100 transition-opacity",!i&&"hover:text-foreground",i&&"hover:!bg-transparent hover:!border-transparent"),onClick:c,children:i?x.jsx(_l,{className:"h-4 w-4 text-green-400"}):x.jsx(ku,{className:"h-4 w-4"})})]})]})}function Z1({children:e,icon:r,className:l}){return x.jsxs("span",{className:xe("inline-flex items-center gap-1 px-2 py-1 bg-muted border border-border rounded-full",l),children:[r&&x.jsx(r,{className:"h-3 w-3 text-muted-foreground"}),e]})}function zu({children:e,className:r}){return x.jsxs("div",{className:xe("grid grid-cols-[auto_1fr] gap-2 min-w-0",r),children:[x.jsx("div",{className:" min-w-5 flex flex-col relative items-center justify-center",children:x.jsx("div",{className:"min-h-full w-[1px] bg-muted-foreground/20"})}),x.jsx("div",{className:"-ml-[1px] min-w-0 overflow-hidden",children:e})]})}function uu(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(Array.isArray(e))return e.map(uu).join("");if(e&&typeof e=="object"&&"props"in e){const r=e.props;return uu(r.children)}return""}const Du={pre:({children:e,...r})=>{const[l,i]=S.useState(!1),o=uu(e),u=async()=>{await navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),2e3)};return x.jsxs("div",{className:"relative overflow-x-auto max-w-full min-w-0 no-code-highlight group/pre",children:[x.jsx("pre",{className:"min-w-0 rounded-xl py-2.5 px-3.5 [.no-pre-highlight_&]:bg-background",...r,children:e}),x.jsx(qe,{variant:"ghost",size:"icon",className:xe("absolute top-[35px] -translate-y-[50%] -translate-x-[1px] rounded-md right-1.5 h-8 w-8 text-muted-foreground opacity-0 group-hover/pre:opacity-100 transition-opacity",!l&&"hover:text-foreground",l&&"hover:!bg-transparent hover:!border-transparent"),onClick:u,children:l?x.jsx(_l,{className:"h-4 w-4 text-green-400"}):x.jsx(ku,{className:"h-4 w-4"})})]})},code:({children:e,className:r,...l})=>r?x.jsx("code",{className:"block text-xs whitespace-pre",...l,children:e}):x.jsx("code",{className:"break-all px-1 bg-border/60 dark:[.no-pre-highlight_&]:bg-background dark:[.text-pretty_&]:bg-neutral [.no-code-highlight_&]:!bg-transparent py-0.5 rounded text-sm whitespace-wrap",...l,children:e}),table:({children:e,...r})=>x.jsx("div",{className:"border border-border rounded-xl overflow-x-auto",children:x.jsx("table",{className:"table-auto min-w-full divide-y divide-border bg-background",...r,children:e})}),tbody:({children:e,...r})=>x.jsx("tbody",{className:"divide-y divide-border",...r,children:e}),th:({children:e,...r})=>x.jsx("th",{className:"text-left text-xs uppercase text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold",...r,children:e}),td:({children:e,...r})=>x.jsx("td",{className:"text-left p-2 pl-0 first:pl-3 [&_*]:font-normal ",...r,children:e}),p:({children:e,...r})=>x.jsx("p",{className:"break-words",...r,children:e}),a:({children:e,...r})=>x.jsx("a",{className:"transition-all underline decoration-2 text-orange-500 decoration-orange-500/50 hover:text-orange-500/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40 ",target:"_blank",rel:"noopener noreferrer",...r,children:e})},rh={...Du,h1:({children:e})=>x.jsx("h1",{className:"text-2xl font-bold mt-6 mb-4 first:mt-0",children:e}),h2:({children:e})=>x.jsx("h2",{className:"text-xl font-semibold mt-5 mb-3 first:mt-0",children:e}),h3:({children:e})=>x.jsx("h3",{className:"text-lg font-semibold mt-4 mb-2 first:mt-0",children:e}),h4:({children:e})=>x.jsx("h4",{className:"text-base font-semibold mt-3 mb-2 first:mt-0",children:e}),h5:({children:e})=>x.jsx("h5",{className:"text-sm font-semibold mt-3 mb-1 first:mt-0",children:e}),h6:({children:e})=>x.jsx("h6",{className:"text-sm font-medium mt-3 mb-1 first:mt-0",children:e})},GR={connecting:"Connecting...",acquiring_sandbox:"Booting...",initializing:"Initializing...",starting:"Starting...",running:"Running...",waiting_for_user:"Waiting...",failed:"Failed"};function YR({status:e}){const r=(e?GR[e]:void 0)||"Processing...",l=e==="failed";return x.jsx(ll,{className:"ml-[1px]",children:x.jsxs(VR,{children:[l?x.jsx(so,{className:"size-4.5 text-red-500"}):x.jsx(zl,{className:"size-4.5 animate-spin text-muted-icon"}),x.jsx(Ru,{className:"ml-[1px] text-sm",shimmerWidth:44,children:r})]})})}const K1=S.forwardRef(({className:e,children:r,...l},i)=>x.jsx("div",{ref:i,className:xe("relative overflow-y-auto overscroll-contain touch-pan-y scrollbar-hide",e),style:{WebkitOverflowScrolling:"touch"},...l,children:r}));K1.displayName="ScrollArea";function $R(e,r){const l={};return(e[e.length-1]===""?[...e,""]:e).join((l.padRight?" ":"")+","+(l.padLeft===!1?"":" ")).trim()}const XR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZR={};function mb(e,r){return(ZR.jsx?QR:XR).test(e)}const KR=/[ \t\n\f\r]/g;function JR(e){return typeof e=="object"?e.type==="text"?pb(e.value):!1:pb(e)}function pb(e){return e.replace(KR,"")===""}class ho{constructor(r,l,i){this.normal=l,this.property=r,i&&(this.space=i)}}ho.prototype.normal={};ho.prototype.property={};ho.prototype.space=void 0;function J1(e,r){const l={},i={};for(const o of e)Object.assign(l,o.property),Object.assign(i,o.normal);return new ho(l,i,r)}function lh(e){return e.toLowerCase()}class Yt{constructor(r,l){this.attribute=l,this.property=r}}Yt.prototype.attribute="";Yt.prototype.booleanish=!1;Yt.prototype.boolean=!1;Yt.prototype.commaOrSpaceSeparated=!1;Yt.prototype.commaSeparated=!1;Yt.prototype.defined=!1;Yt.prototype.mustUseProperty=!1;Yt.prototype.number=!1;Yt.prototype.overloadedBoolean=!1;Yt.prototype.property="";Yt.prototype.spaceSeparated=!1;Yt.prototype.space=void 0;let WR=0;const Te=Dl(),ft=Dl(),ih=Dl(),oe=Dl(),Ke=Dl(),_i=Dl(),tn=Dl();function Dl(){return 2**++WR}const ah=Object.freeze(Object.defineProperty({__proto__:null,boolean:Te,booleanish:ft,commaOrSpaceSeparated:tn,commaSeparated:_i,number:oe,overloadedBoolean:ih,spaceSeparated:Ke},Symbol.toStringTag,{value:"Module"})),Sd=Object.keys(ah);class Jh extends Yt{constructor(r,l,i,o){let u=-1;if(super(r,l),gb(this,"space",o),typeof i=="number")for(;++u<Sd.length;){const c=Sd[u];gb(this,Sd[u],(i&ah[c])===ah[c])}}}Jh.prototype.defined=!0;function gb(e,r,l){l&&(e[r]=l)}function Fi(e){const r={},l={};for(const[i,o]of Object.entries(e.properties)){const u=new Jh(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),r[i]=u,l[lh(i)]=i,l[lh(u.attribute)]=i}return new ho(r,l,e.space)}const W1=Fi({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:oe,ariaColIndex:oe,ariaColSpan:oe,ariaControls:Ke,ariaCurrent:null,ariaDescribedBy:Ke,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:Ke,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:Ke,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ke,ariaLevel:oe,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:Ke,ariaPlaceholder:null,ariaPosInSet:oe,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:Ke,ariaRowCount:oe,ariaRowIndex:oe,ariaRowSpan:oe,ariaSelected:ft,ariaSetSize:oe,ariaSort:null,ariaValueMax:oe,ariaValueMin:oe,ariaValueNow:oe,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function ew(e,r){return r in e?e[r]:r}function tw(e,r){return ew(e,r.toLowerCase())}const e4=Fi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_i,acceptCharset:Ke,accessKey:Ke,action:null,allow:null,allowFullScreen:Te,allowPaymentRequest:Te,allowUserMedia:Te,alt:null,as:null,async:Te,autoCapitalize:null,autoComplete:Ke,autoFocus:Te,autoPlay:Te,blocking:Ke,capture:null,charSet:null,checked:Te,cite:null,className:Ke,cols:oe,colSpan:null,content:null,contentEditable:ft,controls:Te,controlsList:Ke,coords:oe|_i,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Te,defer:Te,dir:null,dirName:null,disabled:Te,download:ih,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Te,formTarget:null,headers:Ke,height:oe,hidden:ih,high:oe,href:null,hrefLang:null,htmlFor:Ke,httpEquiv:Ke,id:null,imageSizes:null,imageSrcSet:null,inert:Te,inputMode:null,integrity:null,is:null,isMap:Te,itemId:null,itemProp:Ke,itemRef:Ke,itemScope:Te,itemType:Ke,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Te,low:oe,manifest:null,max:null,maxLength:oe,media:null,method:null,min:null,minLength:oe,multiple:Te,muted:Te,name:null,nonce:null,noModule:Te,noValidate:Te,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Te,optimum:oe,pattern:null,ping:Ke,placeholder:null,playsInline:Te,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Te,referrerPolicy:null,rel:Ke,required:Te,reversed:Te,rows:oe,rowSpan:oe,sandbox:Ke,scope:null,scoped:Te,seamless:Te,selected:Te,shadowRootClonable:Te,shadowRootDelegatesFocus:Te,shadowRootMode:null,shape:null,size:oe,sizes:null,slot:null,span:oe,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:oe,step:null,style:null,tabIndex:oe,target:null,title:null,translate:null,type:null,typeMustMatch:Te,useMap:null,value:ft,width:oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ke,axis:null,background:null,bgColor:null,border:oe,borderColor:null,bottomMargin:oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Te,declare:Te,event:null,face:null,frame:null,frameBorder:null,hSpace:oe,leftMargin:oe,link:null,longDesc:null,lowSrc:null,marginHeight:oe,marginWidth:oe,noResize:Te,noHref:Te,noShade:Te,noWrap:Te,object:null,profile:null,prompt:null,rev:null,rightMargin:oe,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Te,disableRemotePlayback:Te,prefix:null,property:null,results:oe,security:null,unselectable:null},space:"html",transform:tw}),t4=Fi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:tn,accentHeight:oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:oe,amplitude:oe,arabicForm:null,ascent:oe,attributeName:null,attributeType:null,azimuth:oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:oe,by:null,calcMode:null,capHeight:oe,className:Ke,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:oe,diffuseConstant:oe,direction:null,display:null,dur:null,divisor:oe,dominantBaseline:null,download:Te,dx:null,dy:null,edgeMode:null,editable:null,elevation:oe,enableBackground:null,end:null,event:null,exponent:oe,externalResourcesRequired:null,fill:null,fillOpacity:oe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_i,g2:_i,glyphName:_i,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:oe,horizOriginX:oe,horizOriginY:oe,id:null,ideographic:oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:oe,k:oe,k1:oe,k2:oe,k3:oe,k4:oe,kernelMatrix:tn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:oe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:oe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:oe,overlineThickness:oe,paintOrder:null,panose1:null,path:null,pathLength:oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ke,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:oe,pointsAtY:oe,pointsAtZ:oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:tn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:tn,rev:tn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:tn,requiredFeatures:tn,requiredFonts:tn,requiredFormats:tn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:oe,specularExponent:oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:oe,strikethroughThickness:oe,string:null,stroke:null,strokeDashArray:tn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:oe,strokeOpacity:oe,strokeWidth:null,style:null,surfaceScale:oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:tn,tabIndex:oe,tableValues:null,target:null,targetX:oe,targetY:oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:tn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:oe,underlineThickness:oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:oe,values:null,vAlphabetic:oe,vMathematical:oe,vectorEffect:null,vHanging:oe,vIdeographic:oe,version:null,vertAdvY:oe,vertOriginX:oe,vertOriginY:oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ew}),nw=Fi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),rw=Fi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:tw}),lw=Fi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),n4={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},r4=/[A-Z]/g,yb=/-[a-z]/g,l4=/^data[-\w.:]+$/i;function i4(e,r){const l=lh(r);let i=r,o=Yt;if(l in e.normal)return e.property[e.normal[l]];if(l.length>4&&l.slice(0,4)==="data"&&l4.test(r)){if(r.charAt(4)==="-"){const u=r.slice(5).replace(yb,o4);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=r.slice(4);if(!yb.test(u)){let c=u.replace(r4,a4);c.charAt(0)!=="-"&&(c="-"+c),r="data"+c}}o=Jh}return new o(i,r)}function a4(e){return"-"+e.toLowerCase()}function o4(e){return e.charAt(1).toUpperCase()}const s4=J1([W1,e4,nw,rw,lw],"html"),Wh=J1([W1,t4,nw,rw,lw],"svg");function u4(e){return e.join(" ").trim()}var Ei={},kd,xb;function c4(){if(xb)return kd;xb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,l=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,d=`
384
+ */const dT=[["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"}]],H0=Se("zap",dT),P0=zA,hT=DA,q0=S.forwardRef(({className:e,...r},l)=>x.jsx(j0,{ref:l,className:xe("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));q0.displayName=j0.displayName;const mT={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},Uh=S.forwardRef(({className:e,children:r,size:l="md",...i},o)=>x.jsxs(hT,{children:[x.jsx(q0,{}),x.jsxs(T0,{ref:o,className:xe("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",mT[l],e),...i,children:[r,x.jsxs(UA,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[x.jsx(so,{className:"h-4 w-4"}),x.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Uh.displayName=T0.displayName;function F0({className:e,...r}){return x.jsx(LA,{className:xe("text-lg font-medium leading-none tracking-tight",e),...r})}function pT({className:e,...r}){return x.jsx(BA,{className:xe("text-sm text-muted-foreground",e),...r})}function V0({className:e,...r}){return x.jsx("div",{className:xe("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...r})}function I0({className:e,...r}){return x.jsx("div",{className:xe("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...r})}const G0=S.createContext(null);function gT({children:e}){const[r,l]=S.useState(null),[i,o]=S.useState(""),u=S.useRef(null);S.useEffect(()=>{(r==null?void 0:r.kind)==="prompt"&&(o(r.options.initialValue??""),setTimeout(()=>{var g,y;(g=u.current)==null||g.focus(),(y=u.current)==null||y.select()},0))},[r]);const c=S.useCallback(()=>{l(null),o("")},[]),f=S.useCallback(g=>new Promise(y=>{l({kind:"confirm",options:g,resolve:y})}),[]),d=S.useCallback(g=>new Promise(y=>{l({kind:"prompt",options:g,resolve:y})}),[]),m=S.useMemo(()=>({confirm:f,prompt:d}),[f,d]);return x.jsxs(G0.Provider,{value:m,children:[e,x.jsx(P0,{open:r!==null,onOpenChange:g=>{g||!r||(r.kind==="confirm"?r.resolve(!1):r.resolve(null),c())},children:x.jsx(Uh,{size:"sm",children:r?x.jsxs(x.Fragment,{children:[x.jsxs(V0,{className:"space-y-4",children:[x.jsx(F0,{children:r.options.title}),r.options.description?x.jsx(pT,{children:r.options.description}):null,r.kind==="prompt"?x.jsx("input",{ref:u,type:"text",value:i,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),r.resolve(i.trim()||null),c())},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:r.options.placeholder}):null]}),x.jsxs(I0,{children:[x.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>{r.kind==="confirm"?r.resolve(!1):r.resolve(null),c()},children:r.options.cancelLabel??"Cancel"}),x.jsx(qe,{variant:r.kind==="confirm"?r.options.confirmVariant??"default":"secondary",size:"sm",onClick:()=>{r.kind==="confirm"?r.resolve(!0):r.resolve(i.trim()||null),c()},disabled:r.kind==="prompt"&&!i.trim(),children:r.options.confirmLabel??"Confirm"})]})]}):null})})]})}function yT(){const e=S.useContext(G0);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const xT=["top","right","bottom","left"],Jr=Math.min,nn=Math.max,ru=Math.round,Ps=Math.floor,Pn=e=>({x:e,y:e}),bT={left:"right",right:"left",bottom:"top",top:"bottom"};function Zd(e,r,l){return nn(e,Jr(r,l))}function mr(e,r){return typeof e=="function"?e(r):e}function pr(e){return e.split("-")[0]}function Pi(e){return e.split("-")[1]}function Hh(e){return e==="x"?"y":"x"}function Ph(e){return e==="y"?"height":"width"}function Un(e){const r=e[0];return r==="t"||r==="b"?"y":"x"}function qh(e){return Hh(Un(e))}function vT(e,r,l){l===void 0&&(l=!1);const i=Pi(e),o=qh(e),u=Ph(o);let c=o==="x"?i===(l?"end":"start")?"right":"left":i==="start"?"bottom":"top";return r.reference[u]>r.floating[u]&&(c=lu(c)),[c,lu(c)]}function wT(e){const r=lu(e);return[Kd(e),r,Kd(r)]}function Kd(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const tb=["left","right"],nb=["right","left"],ST=["top","bottom"],kT=["bottom","top"];function CT(e,r,l){switch(e){case"top":case"bottom":return l?r?nb:tb:r?tb:nb;case"left":case"right":return r?ST:kT;default:return[]}}function ET(e,r,l,i){const o=Pi(e);let u=CT(pr(e),l==="start",i);return o&&(u=u.map(c=>c+"-"+o),r&&(u=u.concat(u.map(Kd)))),u}function lu(e){const r=pr(e);return bT[r]+e.slice(r.length)}function NT(e){return{top:0,right:0,bottom:0,left:0,...e}}function Y0(e){return typeof e!="number"?NT(e):{top:e,right:e,bottom:e,left:e}}function iu(e){const{x:r,y:l,width:i,height:o}=e;return{width:i,height:o,top:l,left:r,right:r+i,bottom:l+o,x:r,y:l}}function rb(e,r,l){let{reference:i,floating:o}=e;const u=Un(r),c=qh(r),f=Ph(c),d=pr(r),m=u==="y",g=i.x+i.width/2-o.width/2,y=i.y+i.height/2-o.height/2,b=i[f]/2-o[f]/2;let v;switch(d){case"top":v={x:g,y:i.y-o.height};break;case"bottom":v={x:g,y:i.y+i.height};break;case"right":v={x:i.x+i.width,y};break;case"left":v={x:i.x-o.width,y};break;default:v={x:i.x,y:i.y}}switch(Pi(r)){case"start":v[c]-=b*(l&&m?-1:1);break;case"end":v[c]+=b*(l&&m?-1:1);break}return v}async function AT(e,r){var l;r===void 0&&(r={});const{x:i,y:o,platform:u,rects:c,elements:f,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:v=0}=mr(r,e),k=Y0(v),A=f[b?y==="floating"?"reference":"floating":y],N=iu(await u.getClippingRect({element:(l=await(u.isElement==null?void 0:u.isElement(A)))==null||l?A:A.contextElement||await(u.getDocumentElement==null?void 0:u.getDocumentElement(f.floating)),boundary:m,rootBoundary:g,strategy:d})),O=y==="floating"?{x:i,y:o,width:c.floating.width,height:c.floating.height}:c.reference,_=await(u.getOffsetParent==null?void 0:u.getOffsetParent(f.floating)),U=await(u.isElement==null?void 0:u.isElement(_))?await(u.getScale==null?void 0:u.getScale(_))||{x:1,y:1}:{x:1,y:1},F=iu(u.convertOffsetParentRelativeRectToViewportRelativeRect?await u.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:O,offsetParent:_,strategy:d}):O);return{top:(N.top-F.top+k.top)/U.y,bottom:(F.bottom-N.bottom+k.bottom)/U.y,left:(N.left-F.left+k.left)/U.x,right:(F.right-N.right+k.right)/U.x}}const jT=50,TT=async(e,r,l)=>{const{placement:i="bottom",strategy:o="absolute",middleware:u=[],platform:c}=l,f=c.detectOverflow?c:{...c,detectOverflow:AT},d=await(c.isRTL==null?void 0:c.isRTL(r));let m=await c.getElementRects({reference:e,floating:r,strategy:o}),{x:g,y}=rb(m,i,d),b=i,v=0;const k={};for(let C=0;C<u.length;C++){const A=u[C];if(!A)continue;const{name:N,fn:O}=A,{x:_,y:U,data:F,reset:z}=await O({x:g,y,initialPlacement:i,placement:b,strategy:o,middlewareData:k,rects:m,platform:f,elements:{reference:e,floating:r}});g=_??g,y=U??y,k[N]={...k[N],...F},z&&v<jT&&(v++,typeof z=="object"&&(z.placement&&(b=z.placement),z.rects&&(m=z.rects===!0?await c.getElementRects({reference:e,floating:r,strategy:o}):z.rects),{x:g,y}=rb(m,b,d)),C=-1)}return{x:g,y,placement:b,strategy:o,middlewareData:k}},_T=e=>({name:"arrow",options:e,async fn(r){const{x:l,y:i,placement:o,rects:u,platform:c,elements:f,middlewareData:d}=r,{element:m,padding:g=0}=mr(e,r)||{};if(m==null)return{};const y=Y0(g),b={x:l,y:i},v=qh(o),k=Ph(v),C=await c.getDimensions(m),A=v==="y",N=A?"top":"left",O=A?"bottom":"right",_=A?"clientHeight":"clientWidth",U=u.reference[k]+u.reference[v]-b[v]-u.floating[k],F=b[v]-u.reference[v],z=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let B=z?z[_]:0;(!B||!await(c.isElement==null?void 0:c.isElement(z)))&&(B=f.floating[_]||u.floating[k]);const $=U/2-F/2,ae=B/2-C[k]/2-1,P=Jr(y[N],ae),re=Jr(y[O],ae),le=P,se=B-C[k]-re,J=B/2-C[k]/2+$,Z=Zd(le,J,se),D=!d.arrow&&Pi(o)!=null&&J!==Z&&u.reference[k]/2-(J<le?P:re)-C[k]/2<0,X=D?J<le?J-le:J-se:0;return{[v]:b[v]+X,data:{[v]:Z,centerOffset:J-Z-X,...D&&{alignmentOffset:X}},reset:D}}}),RT=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(r){var l,i;const{placement:o,middlewareData:u,rects:c,initialPlacement:f,platform:d,elements:m}=r,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:b,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:C=!0,...A}=mr(e,r);if((l=u.arrow)!=null&&l.alignmentOffset)return{};const N=pr(o),O=Un(f),_=pr(f)===f,U=await(d.isRTL==null?void 0:d.isRTL(m.floating)),F=b||(_||!C?[lu(f)]:wT(f)),z=k!=="none";!b&&z&&F.push(...ET(f,C,k,U));const B=[f,...F],$=await d.detectOverflow(r,A),ae=[];let P=((i=u.flip)==null?void 0:i.overflows)||[];if(g&&ae.push($[N]),y){const J=vT(o,c,U);ae.push($[J[0]],$[J[1]])}if(P=[...P,{placement:o,overflows:ae}],!ae.every(J=>J<=0)){var re,le;const J=(((re=u.flip)==null?void 0:re.index)||0)+1,Z=B[J];if(Z&&(!(y==="alignment"?O!==Un(Z):!1)||P.every(ne=>Un(ne.placement)===O?ne.overflows[0]>0:!0)))return{data:{index:J,overflows:P},reset:{placement:Z}};let D=(le=P.filter(X=>X.overflows[0]<=0).sort((X,ne)=>X.overflows[1]-ne.overflows[1])[0])==null?void 0:le.placement;if(!D)switch(v){case"bestFit":{var se;const X=(se=P.filter(ne=>{if(z){const ie=Un(ne.placement);return ie===O||ie==="y"}return!0}).map(ne=>[ne.placement,ne.overflows.filter(ie=>ie>0).reduce((ie,j)=>ie+j,0)]).sort((ne,ie)=>ne[1]-ie[1])[0])==null?void 0:se[0];X&&(D=X);break}case"initialPlacement":D=f;break}if(o!==D)return{reset:{placement:D}}}return{}}}};function lb(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function ib(e){return xT.some(r=>e[r]>=0)}const MT=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(r){const{rects:l,platform:i}=r,{strategy:o="referenceHidden",...u}=mr(e,r);switch(o){case"referenceHidden":{const c=await i.detectOverflow(r,{...u,elementContext:"reference"}),f=lb(c,l.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:ib(f)}}}case"escaped":{const c=await i.detectOverflow(r,{...u,altBoundary:!0}),f=lb(c,l.floating);return{data:{escapedOffsets:f,escaped:ib(f)}}}default:return{}}}}},$0=new Set(["left","top"]);async function OT(e,r){const{placement:l,platform:i,elements:o}=e,u=await(i.isRTL==null?void 0:i.isRTL(o.floating)),c=pr(l),f=Pi(l),d=Un(l)==="y",m=$0.has(c)?-1:1,g=u&&d?-1:1,y=mr(r,e);let{mainAxis:b,crossAxis:v,alignmentAxis:k}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return f&&typeof k=="number"&&(v=f==="end"?k*-1:k),d?{x:v*g,y:b*m}:{x:b*m,y:v*g}}const zT=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(r){var l,i;const{x:o,y:u,placement:c,middlewareData:f}=r,d=await OT(r,e);return c===((l=f.offset)==null?void 0:l.placement)&&(i=f.arrow)!=null&&i.alignmentOffset?{}:{x:o+d.x,y:u+d.y,data:{...d,placement:c}}}}},DT=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(r){const{x:l,y:i,placement:o,platform:u}=r,{mainAxis:c=!0,crossAxis:f=!1,limiter:d={fn:N=>{let{x:O,y:_}=N;return{x:O,y:_}}},...m}=mr(e,r),g={x:l,y:i},y=await u.detectOverflow(r,m),b=Un(pr(o)),v=Hh(b);let k=g[v],C=g[b];if(c){const N=v==="y"?"top":"left",O=v==="y"?"bottom":"right",_=k+y[N],U=k-y[O];k=Zd(_,k,U)}if(f){const N=b==="y"?"top":"left",O=b==="y"?"bottom":"right",_=C+y[N],U=C-y[O];C=Zd(_,C,U)}const A=d.fn({...r,[v]:k,[b]:C});return{...A,data:{x:A.x-l,y:A.y-i,enabled:{[v]:c,[b]:f}}}}}},LT=function(e){return e===void 0&&(e={}),{options:e,fn(r){const{x:l,y:i,placement:o,rects:u,middlewareData:c}=r,{offset:f=0,mainAxis:d=!0,crossAxis:m=!0}=mr(e,r),g={x:l,y:i},y=Un(o),b=Hh(y);let v=g[b],k=g[y];const C=mr(f,r),A=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(d){const _=b==="y"?"height":"width",U=u.reference[b]-u.floating[_]+A.mainAxis,F=u.reference[b]+u.reference[_]-A.mainAxis;v<U?v=U:v>F&&(v=F)}if(m){var N,O;const _=b==="y"?"width":"height",U=$0.has(pr(o)),F=u.reference[y]-u.floating[_]+(U&&((N=c.offset)==null?void 0:N[y])||0)+(U?0:A.crossAxis),z=u.reference[y]+u.reference[_]+(U?0:((O=c.offset)==null?void 0:O[y])||0)-(U?A.crossAxis:0);k<F?k=F:k>z&&(k=z)}return{[b]:v,[y]:k}}}},BT=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(r){var l,i;const{placement:o,rects:u,platform:c,elements:f}=r,{apply:d=()=>{},...m}=mr(e,r),g=await c.detectOverflow(r,m),y=pr(o),b=Pi(o),v=Un(o)==="y",{width:k,height:C}=u.floating;let A,N;y==="top"||y==="bottom"?(A=y,N=b===(await(c.isRTL==null?void 0:c.isRTL(f.floating))?"start":"end")?"left":"right"):(N=y,A=b==="end"?"top":"bottom");const O=C-g.top-g.bottom,_=k-g.left-g.right,U=Jr(C-g[A],O),F=Jr(k-g[N],_),z=!r.middlewareData.shift;let B=U,$=F;if((l=r.middlewareData.shift)!=null&&l.enabled.x&&($=_),(i=r.middlewareData.shift)!=null&&i.enabled.y&&(B=O),z&&!b){const P=nn(g.left,0),re=nn(g.right,0),le=nn(g.top,0),se=nn(g.bottom,0);v?$=k-2*(P!==0||re!==0?P+re:nn(g.left,g.right)):B=C-2*(le!==0||se!==0?le+se:nn(g.top,g.bottom))}await d({...r,availableWidth:$,availableHeight:B});const ae=await c.getDimensions(f.floating);return k!==ae.width||C!==ae.height?{reset:{rects:!0}}:{}}}};function Cu(){return typeof window<"u"}function qi(e){return X0(e)?(e.nodeName||"").toLowerCase():"#document"}function rn(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function Vn(e){var r;return(r=(X0(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function X0(e){return Cu()?e instanceof Node||e instanceof rn(e).Node:!1}function Cn(e){return Cu()?e instanceof Element||e instanceof rn(e).Element:!1}function gr(e){return Cu()?e instanceof HTMLElement||e instanceof rn(e).HTMLElement:!1}function ab(e){return!Cu()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof rn(e).ShadowRoot}function uo(e){const{overflow:r,overflowX:l,overflowY:i,display:o}=En(e);return/auto|scroll|overlay|hidden|clip/.test(r+i+l)&&o!=="inline"&&o!=="contents"}function UT(e){return/^(table|td|th)$/.test(qi(e))}function Eu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const HT=/transform|translate|scale|rotate|perspective|filter/,PT=/paint|layout|strict|content/,Nl=e=>!!e&&e!=="none";let xd;function Fh(e){const r=Cn(e)?En(e):e;return Nl(r.transform)||Nl(r.translate)||Nl(r.scale)||Nl(r.rotate)||Nl(r.perspective)||!Vh()&&(Nl(r.backdropFilter)||Nl(r.filter))||HT.test(r.willChange||"")||PT.test(r.contain||"")}function qT(e){let r=Wr(e);for(;gr(r)&&!Mi(r);){if(Fh(r))return r;if(Eu(r))return null;r=Wr(r)}return null}function Vh(){return xd==null&&(xd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),xd}function Mi(e){return/^(html|body|#document)$/.test(qi(e))}function En(e){return rn(e).getComputedStyle(e)}function Nu(e){return Cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wr(e){if(qi(e)==="html")return e;const r=e.assignedSlot||e.parentNode||ab(e)&&e.host||Vn(e);return ab(r)?r.host:r}function Q0(e){const r=Wr(e);return Mi(r)?e.ownerDocument?e.ownerDocument.body:e.body:gr(r)&&uo(r)?r:Q0(r)}function eo(e,r,l){var i;r===void 0&&(r=[]),l===void 0&&(l=!0);const o=Q0(e),u=o===((i=e.ownerDocument)==null?void 0:i.body),c=rn(o);if(u){const f=Jd(c);return r.concat(c,c.visualViewport||[],uo(o)?o:[],f&&l?eo(f):[])}else return r.concat(o,eo(o,[],l))}function Jd(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Z0(e){const r=En(e);let l=parseFloat(r.width)||0,i=parseFloat(r.height)||0;const o=gr(e),u=o?e.offsetWidth:l,c=o?e.offsetHeight:i,f=ru(l)!==u||ru(i)!==c;return f&&(l=u,i=c),{width:l,height:i,$:f}}function Ih(e){return Cn(e)?e:e.contextElement}function Ti(e){const r=Ih(e);if(!gr(r))return Pn(1);const l=r.getBoundingClientRect(),{width:i,height:o,$:u}=Z0(r);let c=(u?ru(l.width):l.width)/i,f=(u?ru(l.height):l.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!f||!Number.isFinite(f))&&(f=1),{x:c,y:f}}const FT=Pn(0);function K0(e){const r=rn(e);return!Vh()||!r.visualViewport?FT:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function VT(e,r,l){return r===void 0&&(r=!1),!l||r&&l!==rn(e)?!1:r}function Rl(e,r,l,i){r===void 0&&(r=!1),l===void 0&&(l=!1);const o=e.getBoundingClientRect(),u=Ih(e);let c=Pn(1);r&&(i?Cn(i)&&(c=Ti(i)):c=Ti(e));const f=VT(u,l,i)?K0(u):Pn(0);let d=(o.left+f.x)/c.x,m=(o.top+f.y)/c.y,g=o.width/c.x,y=o.height/c.y;if(u){const b=rn(u),v=i&&Cn(i)?rn(i):i;let k=b,C=Jd(k);for(;C&&i&&v!==k;){const A=Ti(C),N=C.getBoundingClientRect(),O=En(C),_=N.left+(C.clientLeft+parseFloat(O.paddingLeft))*A.x,U=N.top+(C.clientTop+parseFloat(O.paddingTop))*A.y;d*=A.x,m*=A.y,g*=A.x,y*=A.y,d+=_,m+=U,k=rn(C),C=Jd(k)}}return iu({width:g,height:y,x:d,y:m})}function Au(e,r){const l=Nu(e).scrollLeft;return r?r.left+l:Rl(Vn(e)).left+l}function J0(e,r){const l=e.getBoundingClientRect(),i=l.left+r.scrollLeft-Au(e,l),o=l.top+r.scrollTop;return{x:i,y:o}}function IT(e){let{elements:r,rect:l,offsetParent:i,strategy:o}=e;const u=o==="fixed",c=Vn(i),f=r?Eu(r.floating):!1;if(i===c||f&&u)return l;let d={scrollLeft:0,scrollTop:0},m=Pn(1);const g=Pn(0),y=gr(i);if((y||!y&&!u)&&((qi(i)!=="body"||uo(c))&&(d=Nu(i)),y)){const v=Rl(i);m=Ti(i),g.x=v.x+i.clientLeft,g.y=v.y+i.clientTop}const b=c&&!y&&!u?J0(c,d):Pn(0);return{width:l.width*m.x,height:l.height*m.y,x:l.x*m.x-d.scrollLeft*m.x+g.x+b.x,y:l.y*m.y-d.scrollTop*m.y+g.y+b.y}}function GT(e){return Array.from(e.getClientRects())}function YT(e){const r=Vn(e),l=Nu(e),i=e.ownerDocument.body,o=nn(r.scrollWidth,r.clientWidth,i.scrollWidth,i.clientWidth),u=nn(r.scrollHeight,r.clientHeight,i.scrollHeight,i.clientHeight);let c=-l.scrollLeft+Au(e);const f=-l.scrollTop;return En(i).direction==="rtl"&&(c+=nn(r.clientWidth,i.clientWidth)-o),{width:o,height:u,x:c,y:f}}const ob=25;function $T(e,r){const l=rn(e),i=Vn(e),o=l.visualViewport;let u=i.clientWidth,c=i.clientHeight,f=0,d=0;if(o){u=o.width,c=o.height;const g=Vh();(!g||g&&r==="fixed")&&(f=o.offsetLeft,d=o.offsetTop)}const m=Au(i);if(m<=0){const g=i.ownerDocument,y=g.body,b=getComputedStyle(y),v=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,k=Math.abs(i.clientWidth-y.clientWidth-v);k<=ob&&(u-=k)}else m<=ob&&(u+=m);return{width:u,height:c,x:f,y:d}}function XT(e,r){const l=Rl(e,!0,r==="fixed"),i=l.top+e.clientTop,o=l.left+e.clientLeft,u=gr(e)?Ti(e):Pn(1),c=e.clientWidth*u.x,f=e.clientHeight*u.y,d=o*u.x,m=i*u.y;return{width:c,height:f,x:d,y:m}}function sb(e,r,l){let i;if(r==="viewport")i=$T(e,l);else if(r==="document")i=YT(Vn(e));else if(Cn(r))i=XT(r,l);else{const o=K0(e);i={x:r.x-o.x,y:r.y-o.y,width:r.width,height:r.height}}return iu(i)}function W0(e,r){const l=Wr(e);return l===r||!Cn(l)||Mi(l)?!1:En(l).position==="fixed"||W0(l,r)}function QT(e,r){const l=r.get(e);if(l)return l;let i=eo(e,[],!1).filter(f=>Cn(f)&&qi(f)!=="body"),o=null;const u=En(e).position==="fixed";let c=u?Wr(e):e;for(;Cn(c)&&!Mi(c);){const f=En(c),d=Fh(c);!d&&f.position==="fixed"&&(o=null),(u?!d&&!o:!d&&f.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||uo(c)&&!d&&W0(e,c))?i=i.filter(g=>g!==c):o=f,c=Wr(c)}return r.set(e,i),i}function ZT(e){let{element:r,boundary:l,rootBoundary:i,strategy:o}=e;const c=[...l==="clippingAncestors"?Eu(r)?[]:QT(r,this._c):[].concat(l),i],f=sb(r,c[0],o);let d=f.top,m=f.right,g=f.bottom,y=f.left;for(let b=1;b<c.length;b++){const v=sb(r,c[b],o);d=nn(v.top,d),m=Jr(v.right,m),g=Jr(v.bottom,g),y=nn(v.left,y)}return{width:m-y,height:g-d,x:y,y:d}}function KT(e){const{width:r,height:l}=Z0(e);return{width:r,height:l}}function JT(e,r,l){const i=gr(r),o=Vn(r),u=l==="fixed",c=Rl(e,!0,u,r);let f={scrollLeft:0,scrollTop:0};const d=Pn(0);function m(){d.x=Au(o)}if(i||!i&&!u)if((qi(r)!=="body"||uo(o))&&(f=Nu(r)),i){const v=Rl(r,!0,u,r);d.x=v.x+r.clientLeft,d.y=v.y+r.clientTop}else o&&m();u&&!i&&o&&m();const g=o&&!i&&!u?J0(o,f):Pn(0),y=c.left+f.scrollLeft-d.x-g.x,b=c.top+f.scrollTop-d.y-g.y;return{x:y,y:b,width:c.width,height:c.height}}function bd(e){return En(e).position==="static"}function ub(e,r){if(!gr(e)||En(e).position==="fixed")return null;if(r)return r(e);let l=e.offsetParent;return Vn(e)===l&&(l=l.ownerDocument.body),l}function e1(e,r){const l=rn(e);if(Eu(e))return l;if(!gr(e)){let o=Wr(e);for(;o&&!Mi(o);){if(Cn(o)&&!bd(o))return o;o=Wr(o)}return l}let i=ub(e,r);for(;i&&UT(i)&&bd(i);)i=ub(i,r);return i&&Mi(i)&&bd(i)&&!Fh(i)?l:i||qT(e)||l}const WT=async function(e){const r=this.getOffsetParent||e1,l=this.getDimensions,i=await l(e.floating);return{reference:JT(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function e_(e){return En(e).direction==="rtl"}const t_={convertOffsetParentRelativeRectToViewportRelativeRect:IT,getDocumentElement:Vn,getClippingRect:ZT,getOffsetParent:e1,getElementRects:WT,getClientRects:GT,getDimensions:KT,getScale:Ti,isElement:Cn,isRTL:e_};function t1(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}function n_(e,r){let l=null,i;const o=Vn(e);function u(){var f;clearTimeout(i),(f=l)==null||f.disconnect(),l=null}function c(f,d){f===void 0&&(f=!1),d===void 0&&(d=1),u();const m=e.getBoundingClientRect(),{left:g,top:y,width:b,height:v}=m;if(f||r(),!b||!v)return;const k=Ps(y),C=Ps(o.clientWidth-(g+b)),A=Ps(o.clientHeight-(y+v)),N=Ps(g),_={rootMargin:-k+"px "+-C+"px "+-A+"px "+-N+"px",threshold:nn(0,Jr(1,d))||1};let U=!0;function F(z){const B=z[0].intersectionRatio;if(B!==d){if(!U)return c();B?c(!1,B):i=setTimeout(()=>{c(!1,1e-7)},1e3)}B===1&&!t1(m,e.getBoundingClientRect())&&c(),U=!1}try{l=new IntersectionObserver(F,{..._,root:o.ownerDocument})}catch{l=new IntersectionObserver(F,_)}l.observe(e)}return c(!0),u}function r_(e,r,l,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:u=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,m=Ih(e),g=o||u?[...m?eo(m):[],...r?eo(r):[]]:[];g.forEach(N=>{o&&N.addEventListener("scroll",l,{passive:!0}),u&&N.addEventListener("resize",l)});const y=m&&f?n_(m,l):null;let b=-1,v=null;c&&(v=new ResizeObserver(N=>{let[O]=N;O&&O.target===m&&v&&r&&(v.unobserve(r),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var _;(_=v)==null||_.observe(r)})),l()}),m&&!d&&v.observe(m),r&&v.observe(r));let k,C=d?Rl(e):null;d&&A();function A(){const N=Rl(e);C&&!t1(C,N)&&l(),C=N,k=requestAnimationFrame(A)}return l(),()=>{var N;g.forEach(O=>{o&&O.removeEventListener("scroll",l),u&&O.removeEventListener("resize",l)}),y==null||y(),(N=v)==null||N.disconnect(),v=null,d&&cancelAnimationFrame(k)}}const l_=zT,i_=DT,a_=RT,o_=BT,s_=MT,cb=_T,u_=LT,c_=(e,r,l)=>{const i=new Map,o={platform:t_,...l},u={...o.platform,_c:i};return TT(e,r,{...o,platform:u})};var f_=typeof document<"u",d_=function(){},Ks=f_?S.useLayoutEffect:d_;function au(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(typeof e=="function"&&e.toString()===r.toString())return!0;let l,i,o;if(e&&r&&typeof e=="object"){if(Array.isArray(e)){if(l=e.length,l!==r.length)return!1;for(i=l;i--!==0;)if(!au(e[i],r[i]))return!1;return!0}if(o=Object.keys(e),l=o.length,l!==Object.keys(r).length)return!1;for(i=l;i--!==0;)if(!{}.hasOwnProperty.call(r,o[i]))return!1;for(i=l;i--!==0;){const u=o[i];if(!(u==="_owner"&&e.$$typeof)&&!au(e[u],r[u]))return!1}return!0}return e!==e&&r!==r}function n1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fb(e,r){const l=n1(e);return Math.round(r*l)/l}function vd(e){const r=S.useRef(e);return Ks(()=>{r.current=e}),r}function h_(e){e===void 0&&(e={});const{placement:r="bottom",strategy:l="absolute",middleware:i=[],platform:o,elements:{reference:u,floating:c}={},transform:f=!0,whileElementsMounted:d,open:m}=e,[g,y]=S.useState({x:0,y:0,strategy:l,placement:r,middlewareData:{},isPositioned:!1}),[b,v]=S.useState(i);au(b,i)||v(i);const[k,C]=S.useState(null),[A,N]=S.useState(null),O=S.useCallback(ne=>{ne!==z.current&&(z.current=ne,C(ne))},[]),_=S.useCallback(ne=>{ne!==B.current&&(B.current=ne,N(ne))},[]),U=u||k,F=c||A,z=S.useRef(null),B=S.useRef(null),$=S.useRef(g),ae=d!=null,P=vd(d),re=vd(o),le=vd(m),se=S.useCallback(()=>{if(!z.current||!B.current)return;const ne={placement:r,strategy:l,middleware:b};re.current&&(ne.platform=re.current),c_(z.current,B.current,ne).then(ie=>{const j={...ie,isPositioned:le.current!==!1};J.current&&!au($.current,j)&&($.current=j,kh.flushSync(()=>{y(j)}))})},[b,r,l,re,le]);Ks(()=>{m===!1&&$.current.isPositioned&&($.current.isPositioned=!1,y(ne=>({...ne,isPositioned:!1})))},[m]);const J=S.useRef(!1);Ks(()=>(J.current=!0,()=>{J.current=!1}),[]),Ks(()=>{if(U&&(z.current=U),F&&(B.current=F),U&&F){if(P.current)return P.current(U,F,se);se()}},[U,F,se,P,ae]);const Z=S.useMemo(()=>({reference:z,floating:B,setReference:O,setFloating:_}),[O,_]),D=S.useMemo(()=>({reference:U,floating:F}),[U,F]),X=S.useMemo(()=>{const ne={position:l,left:0,top:0};if(!D.floating)return ne;const ie=fb(D.floating,g.x),j=fb(D.floating,g.y);return f?{...ne,transform:"translate("+ie+"px, "+j+"px)",...n1(D.floating)>=1.5&&{willChange:"transform"}}:{position:l,left:ie,top:j}},[l,f,D.floating,g.x,g.y]);return S.useMemo(()=>({...g,update:se,refs:Z,elements:D,floatingStyles:X}),[g,se,Z,D,X])}const m_=e=>{function r(l){return{}.hasOwnProperty.call(l,"current")}return{name:"arrow",options:e,fn(l){const{element:i,padding:o}=typeof e=="function"?e(l):e;return i&&r(i)?i.current!=null?cb({element:i.current,padding:o}).fn(l):{}:i?cb({element:i,padding:o}).fn(l):{}}}},p_=(e,r)=>{const l=l_(e);return{name:l.name,fn:l.fn,options:[e,r]}},g_=(e,r)=>{const l=i_(e);return{name:l.name,fn:l.fn,options:[e,r]}},y_=(e,r)=>({fn:u_(e).fn,options:[e,r]}),x_=(e,r)=>{const l=a_(e);return{name:l.name,fn:l.fn,options:[e,r]}},b_=(e,r)=>{const l=o_(e);return{name:l.name,fn:l.fn,options:[e,r]}},v_=(e,r)=>{const l=s_(e);return{name:l.name,fn:l.fn,options:[e,r]}},w_=(e,r)=>{const l=m_(e);return{name:l.name,fn:l.fn,options:[e,r]}};var S_="Arrow",r1=S.forwardRef((e,r)=>{const{children:l,width:i=10,height:o=5,...u}=e;return x.jsx(_t.svg,{...u,ref:r,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?l:x.jsx("polygon",{points:"0,0 30,0 15,10"})})});r1.displayName=S_;var k_=r1;function C_(e){const[r,l]=S.useState(void 0);return Zr(()=>{if(e){l({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const u=o[0];let c,f;if("borderBoxSize"in u){const d=u.borderBoxSize,m=Array.isArray(d)?d[0]:d;c=m.inlineSize,f=m.blockSize}else c=e.offsetWidth,f=e.offsetHeight;l({width:c,height:f})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else l(void 0)},[e]),r}var Gh="Popper",[l1,ju]=xu(Gh),[E_,i1]=l1(Gh),a1=e=>{const{__scopePopper:r,children:l}=e,[i,o]=S.useState(null);return x.jsx(E_,{scope:r,anchor:i,onAnchorChange:o,children:l})};a1.displayName=Gh;var o1="PopperAnchor",s1=S.forwardRef((e,r)=>{const{__scopePopper:l,virtualRef:i,...o}=e,u=i1(o1,l),c=S.useRef(null),f=an(r,c),d=S.useRef(null);return S.useEffect(()=>{const m=d.current;d.current=(i==null?void 0:i.current)||c.current,m!==d.current&&u.onAnchorChange(d.current)}),i?null:x.jsx(_t.div,{...o,ref:f})});s1.displayName=o1;var Yh="PopperContent",[N_,A_]=l1(Yh),u1=S.forwardRef((e,r)=>{var Ce,Ue,ve,at,dt,At;const{__scopePopper:l,side:i="bottom",sideOffset:o=0,align:u="center",alignOffset:c=0,arrowPadding:f=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:g=0,sticky:y="partial",hideWhenDetached:b=!1,updatePositionStrategy:v="optimized",onPlaced:k,...C}=e,A=i1(Yh,l),[N,O]=S.useState(null),_=an(r,wt=>O(wt)),[U,F]=S.useState(null),z=C_(U),B=(z==null?void 0:z.width)??0,$=(z==null?void 0:z.height)??0,ae=i+(u!=="center"?"-"+u:""),P=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},re=Array.isArray(m)?m:[m],le=re.length>0,se={padding:P,boundary:re.filter(T_),altBoundary:le},{refs:J,floatingStyles:Z,placement:D,isPositioned:X,middlewareData:ne}=h_({strategy:"fixed",placement:ae,whileElementsMounted:(...wt)=>r_(...wt,{animationFrame:v==="always"}),elements:{reference:A.anchor},middleware:[p_({mainAxis:o+$,alignmentAxis:c}),d&&g_({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?y_():void 0,...se}),d&&x_({...se}),b_({...se,apply:({elements:wt,rects:ht,availableWidth:jn,availableHeight:Tn})=>{const{width:xr,height:br}=ht.reference,$t=wt.floating.style;$t.setProperty("--radix-popper-available-width",`${jn}px`),$t.setProperty("--radix-popper-available-height",`${Tn}px`),$t.setProperty("--radix-popper-anchor-width",`${xr}px`),$t.setProperty("--radix-popper-anchor-height",`${br}px`)}}),U&&w_({element:U,padding:f}),__({arrowWidth:B,arrowHeight:$}),b&&v_({strategy:"referenceHidden",...se})]}),[ie,j]=d1(D),R=Ri(k);Zr(()=>{X&&(R==null||R())},[X,R]);const G=(Ce=ne.arrow)==null?void 0:Ce.x,T=(Ue=ne.arrow)==null?void 0:Ue.y,ue=((ve=ne.arrow)==null?void 0:ve.centerOffset)!==0,[de,ce]=S.useState();return Zr(()=>{N&&ce(window.getComputedStyle(N).zIndex)},[N]),x.jsx("div",{ref:J.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:X?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(at=ne.transformOrigin)==null?void 0:at.x,(dt=ne.transformOrigin)==null?void 0:dt.y].join(" "),...((At=ne.hide)==null?void 0:At.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:x.jsx(N_,{scope:l,placedSide:ie,onArrowChange:F,arrowX:G,arrowY:T,shouldHideArrow:ue,children:x.jsx(_t.div,{"data-side":ie,"data-align":j,...C,ref:_,style:{...C.style,animation:X?void 0:"none"}})})})});u1.displayName=Yh;var c1="PopperArrow",j_={top:"bottom",right:"left",bottom:"top",left:"right"},f1=S.forwardRef(function(r,l){const{__scopePopper:i,...o}=r,u=A_(c1,i),c=j_[u.placedSide];return x.jsx("span",{ref:u.onArrowChange,style:{position:"absolute",left:u.arrowX,top:u.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[u.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[u.placedSide],visibility:u.shouldHideArrow?"hidden":void 0},children:x.jsx(k_,{...o,ref:l,style:{...o.style,display:"block"}})})});f1.displayName=c1;function T_(e){return e!==null}var __=e=>({name:"transformOrigin",options:e,fn(r){var A,N,O;const{placement:l,rects:i,middlewareData:o}=r,c=((A=o.arrow)==null?void 0:A.centerOffset)!==0,f=c?0:e.arrowWidth,d=c?0:e.arrowHeight,[m,g]=d1(l),y={start:"0%",center:"50%",end:"100%"}[g],b=(((N=o.arrow)==null?void 0:N.x)??0)+f/2,v=(((O=o.arrow)==null?void 0:O.y)??0)+d/2;let k="",C="";return m==="bottom"?(k=c?y:`${b}px`,C=`${-d}px`):m==="top"?(k=c?y:`${b}px`,C=`${i.floating.height+d}px`):m==="right"?(k=`${-d}px`,C=c?y:`${v}px`):m==="left"&&(k=`${i.floating.width+d}px`,C=c?y:`${v}px`),{data:{x:k,y:C}}}});function d1(e){const[r,l="center"]=e.split("-");return[r,l]}var h1=a1,$h=s1,m1=u1,p1=f1,R_=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"}),M_="VisuallyHidden",g1=S.forwardRef((e,r)=>x.jsx(_t.span,{...e,ref:r,style:{...R_,...e.style}}));g1.displayName=M_;var O_=g1,[Tu]=xu("Tooltip",[ju]),_u=ju(),y1="TooltipProvider",z_=700,Wd="tooltip.open",[D_,Xh]=Tu(y1),x1=e=>{const{__scopeTooltip:r,delayDuration:l=z_,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:u}=e,c=S.useRef(!0),f=S.useRef(!1),d=S.useRef(0);return S.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),x.jsx(D_,{scope:r,isOpenDelayedRef:c,delayDuration:l,onOpen:S.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,i)},[i]),isPointerInTransitRef:f,onPointerInTransitChange:S.useCallback(m=>{f.current=m},[]),disableHoverableContent:o,children:u})};x1.displayName=y1;var to="Tooltip",[L_,co]=Tu(to),b1=e=>{const{__scopeTooltip:r,children:l,open:i,defaultOpen:o,onOpenChange:u,disableHoverableContent:c,delayDuration:f}=e,d=Xh(to,e.__scopeTooltip),m=_u(r),[g,y]=S.useState(null),b=Xa(),v=S.useRef(0),k=c??d.disableHoverableContent,C=f??d.delayDuration,A=S.useRef(!1),[N,O]=Nh({prop:i,defaultProp:o??!1,onChange:B=>{B?(d.onOpen(),document.dispatchEvent(new CustomEvent(Wd))):d.onClose(),u==null||u(B)},caller:to}),_=S.useMemo(()=>N?A.current?"delayed-open":"instant-open":"closed",[N]),U=S.useCallback(()=>{window.clearTimeout(v.current),v.current=0,A.current=!1,O(!0)},[O]),F=S.useCallback(()=>{window.clearTimeout(v.current),v.current=0,O(!1)},[O]),z=S.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{A.current=!0,O(!0),v.current=0},C)},[C,O]);return S.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),x.jsx(h1,{...m,children:x.jsx(L_,{scope:r,contentId:b,open:N,stateAttribute:_,trigger:g,onTriggerChange:y,onTriggerEnter:S.useCallback(()=>{d.isOpenDelayedRef.current?z():U()},[d.isOpenDelayedRef,z,U]),onTriggerLeave:S.useCallback(()=>{k?F():(window.clearTimeout(v.current),v.current=0)},[F,k]),onOpen:U,onClose:F,disableHoverableContent:k,children:l})})};b1.displayName=to;var eh="TooltipTrigger",v1=S.forwardRef((e,r)=>{const{__scopeTooltip:l,...i}=e,o=co(eh,l),u=Xh(eh,l),c=_u(l),f=S.useRef(null),d=an(r,f,o.onTriggerChange),m=S.useRef(!1),g=S.useRef(!1),y=S.useCallback(()=>m.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),x.jsx($h,{asChild:!0,...c,children:x.jsx(_t.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:d,onPointerMove:yt(e.onPointerMove,b=>{b.pointerType!=="touch"&&!g.current&&!u.isPointerInTransitRef.current&&(o.onTriggerEnter(),g.current=!0)}),onPointerLeave:yt(e.onPointerLeave,()=>{o.onTriggerLeave(),g.current=!1}),onPointerDown:yt(e.onPointerDown,()=>{o.open&&o.onClose(),m.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:yt(e.onFocus,()=>{m.current||o.onOpen()}),onBlur:yt(e.onBlur,o.onClose),onClick:yt(e.onClick,o.onClose)})})});v1.displayName=eh;var Qh="TooltipPortal",[B_,U_]=Tu(Qh,{forceMount:void 0}),w1=e=>{const{__scopeTooltip:r,forceMount:l,children:i,container:o}=e,u=co(Qh,r);return x.jsx(B_,{scope:r,forceMount:l,children:x.jsx(nl,{present:l||u.open,children:x.jsx(vu,{asChild:!0,container:o,children:i})})})};w1.displayName=Qh;var Oi="TooltipContent",S1=S.forwardRef((e,r)=>{const l=U_(Oi,e.__scopeTooltip),{forceMount:i=l.forceMount,side:o="top",...u}=e,c=co(Oi,e.__scopeTooltip);return x.jsx(nl,{present:i||c.open,children:c.disableHoverableContent?x.jsx(k1,{side:o,...u,ref:r}):x.jsx(H_,{side:o,...u,ref:r})})}),H_=S.forwardRef((e,r)=>{const l=co(Oi,e.__scopeTooltip),i=Xh(Oi,e.__scopeTooltip),o=S.useRef(null),u=an(r,o),[c,f]=S.useState(null),{trigger:d,onClose:m}=l,g=o.current,{onPointerInTransitChange:y}=i,b=S.useCallback(()=>{f(null),y(!1)},[y]),v=S.useCallback((k,C)=>{const A=k.currentTarget,N={x:k.clientX,y:k.clientY},O=I_(N,A.getBoundingClientRect()),_=G_(N,O),U=Y_(C.getBoundingClientRect()),F=X_([..._,...U]);f(F),y(!0)},[y]);return S.useEffect(()=>()=>b(),[b]),S.useEffect(()=>{if(d&&g){const k=A=>v(A,g),C=A=>v(A,d);return d.addEventListener("pointerleave",k),g.addEventListener("pointerleave",C),()=>{d.removeEventListener("pointerleave",k),g.removeEventListener("pointerleave",C)}}},[d,g,v,b]),S.useEffect(()=>{if(c){const k=C=>{const A=C.target,N={x:C.clientX,y:C.clientY},O=(d==null?void 0:d.contains(A))||(g==null?void 0:g.contains(A)),_=!$_(N,c);O?b():_&&(b(),m())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[d,g,c,m,b]),x.jsx(k1,{...e,ref:u})}),[P_,q_]=Tu(to,{isInside:!1}),F_=mN("TooltipContent"),k1=S.forwardRef((e,r)=>{const{__scopeTooltip:l,children:i,"aria-label":o,onEscapeKeyDown:u,onPointerDownOutside:c,...f}=e,d=co(Oi,l),m=_u(l),{onClose:g}=d;return S.useEffect(()=>(document.addEventListener(Wd,g),()=>document.removeEventListener(Wd,g)),[g]),S.useEffect(()=>{if(d.trigger){const y=b=>{const v=b.target;v!=null&&v.contains(d.trigger)&&g()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,g]),x.jsx(bu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:g,children:x.jsxs(m1,{"data-state":d.stateAttribute,...m,...f,ref:r,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[x.jsx(F_,{children:i}),x.jsx(P_,{scope:l,isInside:!0,children:x.jsx(O_,{id:d.contentId,role:"tooltip",children:o||i})})]})})});S1.displayName=Oi;var C1="TooltipArrow",V_=S.forwardRef((e,r)=>{const{__scopeTooltip:l,...i}=e,o=_u(l);return q_(C1,l).isInside?null:x.jsx(p1,{...o,...i,ref:r})});V_.displayName=C1;function I_(e,r){const l=Math.abs(r.top-e.y),i=Math.abs(r.bottom-e.y),o=Math.abs(r.right-e.x),u=Math.abs(r.left-e.x);switch(Math.min(l,i,o,u)){case u:return"left";case o:return"right";case l:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function G_(e,r,l=5){const i=[];switch(r){case"top":i.push({x:e.x-l,y:e.y+l},{x:e.x+l,y:e.y+l});break;case"bottom":i.push({x:e.x-l,y:e.y-l},{x:e.x+l,y:e.y-l});break;case"left":i.push({x:e.x+l,y:e.y-l},{x:e.x+l,y:e.y+l});break;case"right":i.push({x:e.x-l,y:e.y-l},{x:e.x-l,y:e.y+l});break}return i}function Y_(e){const{top:r,right:l,bottom:i,left:o}=e;return[{x:o,y:r},{x:l,y:r},{x:l,y:i},{x:o,y:i}]}function $_(e,r){const{x:l,y:i}=e;let o=!1;for(let u=0,c=r.length-1;u<r.length;c=u++){const f=r[u],d=r[c],m=f.x,g=f.y,y=d.x,b=d.y;g>i!=b>i&&l<(y-m)*(i-g)/(b-g)+m&&(o=!o)}return o}function X_(e){const r=e.slice();return r.sort((l,i)=>l.x<i.x?-1:l.x>i.x?1:l.y<i.y?-1:l.y>i.y?1:0),Q_(r)}function Q_(e){if(e.length<=1)return e.slice();const r=[];for(let i=0;i<e.length;i++){const o=e[i];for(;r.length>=2;){const u=r[r.length-1],c=r[r.length-2];if((u.x-c.x)*(o.y-c.y)>=(u.y-c.y)*(o.x-c.x))r.pop();else break}r.push(o)}r.pop();const l=[];for(let i=e.length-1;i>=0;i--){const o=e[i];for(;l.length>=2;){const u=l[l.length-1],c=l[l.length-2];if((u.x-c.x)*(o.y-c.y)>=(u.y-c.y)*(o.x-c.x))l.pop();else break}l.push(o)}return l.pop(),r.length===1&&l.length===1&&r[0].x===l[0].x&&r[0].y===l[0].y?r:r.concat(l)}var Z_=x1,K_=b1,J_=v1,W_=w1,E1=S1;const eR=Z_,ou=K_,su=J_,no=S.forwardRef(({className:e,sideOffset:r=4,...l},i)=>x.jsx(W_,{children:x.jsx(E1,{ref:i,sideOffset:r,className:xe("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...l})}));no.displayName=E1.displayName;const tR="0.1.4",nR={version:tR},zt="Kanna",db="kanna",rR=`kanna/${nR.version}`,lR="[kanna]",iR=`~/${zt}`;function qs(e){return e?`${db} ${e}`:db}const aR={sm:"text-sm px-2.5 py-1",md:"text-sm px-3 py-1.5"};function oR({value:e,onValueChange:r,options:l,size:i="md",className:o,optionClassName:u}){return x.jsx("div",{className:xe("inline-flex items-center rounded-full border border-border p-0.5 ",o),children:l.map(c=>{const f=c.value===e,d=c.icon,m=d?S.isValidElement(d)?d:(()=>{const y=d;return x.jsx(y,{className:i==="sm"?"h-3.5 w-3.5":"h-4 w-4"})})():null,g=x.jsxs("button",{type:"button",onClick:()=>r(c.value),disabled:c.disabled,"aria-pressed":f,className:xe("rounded-full border transition-colors",d?"grid grid-cols-[auto_auto] items-center gap-2":"inline-flex items-center gap-1.5",aR[i],f?"bg-white dark:bg-muted text-slate-900 dark:text-slate-200 border-slate-300 dark:border-white/10 bg-slate-200 ":"border-transparent text-slate-800 hover:text-slate-900 dark:text-muted-foreground dark:hover:text-foreground",c.disabled&&"opacity-50 pointer-events-none",u),children:[m,x.jsx("span",{children:c.label})]},c.value);return c.tooltip?x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:g}),x.jsx(no,{children:c.tooltip})]},c.value):g})})}function sR(e){return e.toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function N1({open:e,onOpenChange:r,onConfirm:l}){const[i,o]=S.useState("new"),[u,c]=S.useState(""),[f,d]=S.useState(""),m=S.useRef(null),g=S.useRef(null);S.useEffect(()=>{e&&(o("new"),c(""),d(""),setTimeout(()=>{var A;return(A=m.current)==null?void 0:A.focus()},0))},[e]),S.useEffect(()=>{e&&setTimeout(()=>{var A,N;i==="new"?(A=m.current)==null||A.focus():(N=g.current)==null||N.focus()},0)},[i,e]);const y=sR(u),b=y?`${iR}/${y}`:"",v=f.trim(),k=i==="new"?!!y:!!v,C=()=>{if(k){if(i==="new")l({mode:"new",localPath:b,title:u.trim()});else{const A=v.split("/").pop()||v;l({mode:"existing",localPath:v,title:A})}r(!1)}};return x.jsx(P0,{open:e,onOpenChange:r,children:x.jsxs(Uh,{size:"sm",children:[x.jsxs(V0,{className:"space-y-4",children:[x.jsx(F0,{children:"Add Project"}),x.jsx(oR,{value:i,onValueChange:o,options:[{value:"new",label:"New Folder"},{value:"existing",label:"Existing Path"}],className:"w-full",optionClassName:"flex-1 justify-center"}),i==="new"?x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:m,type:"text",value:u,onChange:A=>c(A.target.value),onKeyDown:A=>{A.key==="Enter"&&C(),A.key==="Escape"&&r(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"Project name"}),b&&x.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:b})]}):x.jsxs("div",{className:"space-y-2",children:[x.jsx("input",{ref:g,type:"text",value:f,onChange:A=>d(A.target.value),onKeyDown:A=>{A.key==="Enter"&&C(),A.key==="Escape"&&r(!1)},className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background outline-none",placeholder:"~/Projects/my-app"}),x.jsx("p",{className:"text-xs text-muted-foreground",children:"The folder will be created if it doesn't exist."})]})]}),x.jsxs(I0,{children:[x.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"}),x.jsx(qe,{variant:"secondary",size:"sm",onClick:C,disabled:!k,children:"Create"})]})]})})}const Ru=({children:e,className:r,shimmerWidth:l=100,animate:i=!0,...o})=>x.jsx("span",{style:{"--shiny-width":`${Math.min(l,100)}px`},className:xe("mx-auto max-w-md text-foreground/50",i?["animate-shiny-text [background-size:var(--shiny-width)_100%] bg-clip-text [background-position:0_0] bg-no-repeat [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]","bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80"]:["text-neutral"],r),...o,children:e}),uR=new Set(["starting","running"]);function cR({chat:e,activeChatId:r,onSelectChat:l,onDeleteChat:i}){return x.jsxs("div",{"data-chat-id":Bx(e.chatId),className:xe("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-md cursor-pointer border-border/0 hover:border-border hover:bg-muted active:bg-muted border transition-colors",r===Bx(e.chatId)?"bg-muted border-border":"border-border/0 dark:hover:border-slate-400/10 "),onClick:()=>l(e.chatId),children:[uR.has(e.status)?x.jsx(zl,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):e.status==="waiting_for_user"?x.jsx("div",{className:"relative ",children:x.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[x.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),x.jsx("div",{className:" rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,x.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?x.jsx(Ru,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.title}),x.jsx(qe,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-100 md:opacity-0 md:group-hover:opacity-100 cursor-pointer rounded-sm hover:!bg-transparent",onClick:o=>{o.stopPropagation(),i(e.chatId)},title:"Delete chat",children:x.jsx(so,{className:"size-3.5"})})]},e._id)}function jl(e){return e.split(/[\s_-]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")}function A1(e){return e.split("/").pop()||e}var Mu="Popover",[j1]=xu(Mu,[ju]),fo=ju(),[fR,rl]=j1(Mu),T1=e=>{const{__scopePopover:r,children:l,open:i,defaultOpen:o,onOpenChange:u,modal:c=!1}=e,f=fo(r),d=S.useRef(null),[m,g]=S.useState(!1),[y,b]=Nh({prop:i,defaultProp:o??!1,onChange:u,caller:Mu});return x.jsx(h1,{...f,children:x.jsx(fR,{scope:r,contentId:Xa(),triggerRef:d,open:y,onOpenChange:b,onOpenToggle:S.useCallback(()=>b(v=>!v),[b]),hasCustomAnchor:m,onCustomAnchorAdd:S.useCallback(()=>g(!0),[]),onCustomAnchorRemove:S.useCallback(()=>g(!1),[]),modal:c,children:l})})};T1.displayName=Mu;var _1="PopoverAnchor",dR=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=rl(_1,l),u=fo(l),{onCustomAnchorAdd:c,onCustomAnchorRemove:f}=o;return S.useEffect(()=>(c(),()=>f()),[c,f]),x.jsx($h,{...u,...i,ref:r})});dR.displayName=_1;var R1="PopoverTrigger",M1=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=rl(R1,l),u=fo(l),c=an(r,o.triggerRef),f=x.jsx(_t.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":B1(o.open),...i,ref:c,onClick:yt(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?f:x.jsx($h,{asChild:!0,...u,children:f})});M1.displayName=R1;var Zh="PopoverPortal",[hR,mR]=j1(Zh,{forceMount:void 0}),O1=e=>{const{__scopePopover:r,forceMount:l,children:i,container:o}=e,u=rl(Zh,r);return x.jsx(hR,{scope:r,forceMount:l,children:x.jsx(nl,{present:l||u.open,children:x.jsx(vu,{asChild:!0,container:o,children:i})})})};O1.displayName=Zh;var zi="PopoverContent",z1=S.forwardRef((e,r)=>{const l=mR(zi,e.__scopePopover),{forceMount:i=l.forceMount,...o}=e,u=rl(zi,e.__scopePopover);return x.jsx(nl,{present:i||u.open,children:u.modal?x.jsx(gR,{...o,ref:r}):x.jsx(yR,{...o,ref:r})})});z1.displayName=zi;var pR=Ah("PopoverContent.RemoveScroll"),gR=S.forwardRef((e,r)=>{const l=rl(zi,e.__scopePopover),i=S.useRef(null),o=an(r,i),u=S.useRef(!1);return S.useEffect(()=>{const c=i.current;if(c)return d0(c)},[]),x.jsx(Th,{as:pR,allowPinchZoom:!0,children:x.jsx(D1,{...e,ref:o,trapFocus:l.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:yt(e.onCloseAutoFocus,c=>{var f;c.preventDefault(),u.current||(f=l.triggerRef.current)==null||f.focus()}),onPointerDownOutside:yt(e.onPointerDownOutside,c=>{const f=c.detail.originalEvent,d=f.button===0&&f.ctrlKey===!0,m=f.button===2||d;u.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:yt(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),yR=S.forwardRef((e,r)=>{const l=rl(zi,e.__scopePopover),i=S.useRef(!1),o=S.useRef(!1);return x.jsx(D1,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{var c,f;(c=e.onCloseAutoFocus)==null||c.call(e,u),u.defaultPrevented||(i.current||(f=l.triggerRef.current)==null||f.focus(),u.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:u=>{var d,m;(d=e.onInteractOutside)==null||d.call(e,u),u.defaultPrevented||(i.current=!0,u.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=u.target;((m=l.triggerRef.current)==null?void 0:m.contains(c))&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&o.current&&u.preventDefault()}})}),D1=S.forwardRef((e,r)=>{const{__scopePopover:l,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:u,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:g,...y}=e,b=rl(zi,l),v=fo(l);return r0(),x.jsx(jh,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:u,children:x.jsx(bu,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:g,onEscapeKeyDown:f,onPointerDownOutside:d,onFocusOutside:m,onDismiss:()=>b.onOpenChange(!1),children:x.jsx(m1,{"data-state":B1(b.open),role:"dialog",id:b.contentId,...v,...y,ref:r,style:{...y.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),L1="PopoverClose",xR=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=rl(L1,l);return x.jsx(_t.button,{type:"button",...i,ref:r,onClick:yt(e.onClick,()=>o.onOpenChange(!1))})});xR.displayName=L1;var bR="PopoverArrow",vR=S.forwardRef((e,r)=>{const{__scopePopover:l,...i}=e,o=fo(l);return x.jsx(p1,{...o,...i,ref:r})});vR.displayName=bR;function B1(e){return e?"open":"closed"}var wR=T1,SR=M1,kR=O1,U1=z1;const H1=wR,P1=SR,Kh=S.forwardRef(({className:e,align:r="center",sideOffset:l=4,...i},o)=>x.jsx(kR,{children:x.jsx(U1,{ref:o,align:r,sideOffset:l,className:xe("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden 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),...i})}));Kh.displayName=U1.displayName;function CR({onRemove:e}){const[r,l]=S.useState(!1);return x.jsxs(H1,{open:r,onOpenChange:l,children:[x.jsx(P1,{asChild:!0,children:x.jsx(qe,{variant:"ghost",size:"icon",className:"h-5.5 w-5.5 absolute right-6 !rounded opacity-100 md:opacity-0 md:group-hover/section:opacity-100",onClick:i=>i.stopPropagation(),children:x.jsx(Nj,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"})})}),x.jsx(Kh,{align:"end",className:"p-1 w-auto min-w-[170px]",children:x.jsxs("button",{onClick:i=>{i.stopPropagation(),l(!1),e()},className:"w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-left transition-colors text-destructive dark:text-red-400 hover:bg-destructive/10 dark:hover:bg-red-500/20",children:[x.jsx(uT,{className:"h-4 w-4"}),x.jsx("span",{className:"text-xs font-medium",children:"Remove Project"})]})})]})}function ER({projectGroups:e,collapsedSections:r,expandedGroups:l,onToggleSection:i,onToggleExpandedGroup:o,renderChatRow:u,chatsPerProject:c,onNewLocalChat:f,onRemoveProject:d,isConnected:m,startingLocalPath:g}){return x.jsx(x.Fragment,{children:e.map(({groupKey:y,localPath:b,chats:v})=>{const k=l.has(y),C=k?v:v.slice(0,c),A=v.length>c;return x.jsxs("div",{className:"group/section",children:[x.jsxs("div",{className:"sticky top-0 bg-background dark:bg-card z-10 relative pl-2.5 pr-3 py-2 pt-3 cursor-pointer flex items-center justify-between",onClick:()=>i(y),children:[x.jsxs("div",{className:"flex items-center gap-2",children:[r.has(y)?x.jsx(O0,{className:"translate-y-[1px] size-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):x.jsx(M0,{className:"translate-y-[1px] size-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:x.jsx("span",{className:"truncate max-w-[150px] whitespace-nowrap text-sm text-slate-500 dark:text-slate-400",children:A1(b)})}),x.jsx(no,{side:"right",sideOffset:4,children:b})]}),x.jsx(Kr,{className:xe("size-3.5 translate-y-[1px] text-slate-400 transition-all duration-200",r.has(y)?"opacity-100":"rotate-90 opacity-0 group-hover/section:opacity-100")})]}),d?x.jsx(CR,{onRemove:()=>d(y)}):null,f&&x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:x.jsx(qe,{variant:"ghost",size:"icon",className:xe("h-5.5 w-5.5 absolute right-0 !rounded opacity-100 md:opacity-0 md:group-hover/section:opacity-100",(!m||g===b)&&"opacity-50 cursor-not-allowed"),disabled:!m||g===b,onClick:N=>{N.stopPropagation(),f(b)},children:g===b?x.jsx(zl,{className:"size-4 text-slate-500 dark:text-slate-400 animate-spin"}):x.jsx(Dh,{className:"size-3.5 text-slate-500 dark:text-slate-400"})})}),x.jsx(no,{side:"right",sideOffset:4,children:m?"New chat":`Start ${zt} to connect`})]})]}),!r.has(y)&&x.jsxs("div",{className:"space-y-[2px] mb-2 ",children:[C.map(u),A&&x.jsx("button",{onClick:()=>o(y),className:"pl-3 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:k?"Show less":`Show more (${v.length-c})`})]})]},y)})})}function NR({data:e,activeChatId:r,connectionStatus:l,ready:i,open:o,collapsed:u,showMobileOpenButton:c,onOpen:f,onClose:d,onCollapse:m,onExpand:g,onCreateChat:y,onCreateProject:b,onDeleteChat:v,onRemoveProject:k}){const C=Fn(),A=xh(),N=S.useRef(null),[O,_]=S.useState(new Set),[U,F]=S.useState(new Set),[z,B]=S.useState(!1),$=10,ae=S.useMemo(()=>new Map(e.projectGroups.map(ie=>[ie.localPath,ie.groupKey])),[e.projectGroups]),P=S.useMemo(()=>e.projectGroups.reduce((ie,j)=>ie+j.chats.length,0),[e.projectGroups]),re=S.useCallback(ie=>{_(j=>{const R=new Set(j);return R.has(ie)?R.delete(ie):R.add(ie),R})},[]),le=S.useCallback(ie=>{F(j=>{const R=new Set(j);return R.has(ie)?R.delete(ie):R.add(ie),R})},[]),se=S.useCallback(ie=>x.jsx(cR,{chat:ie,activeChatId:r,onSelectChat:j=>A(`/chat/${j}`),onDeleteChat:()=>v(ie)},ie._id),[r,A,v]);S.useEffect(()=>{!r||!N.current||requestAnimationFrame(()=>{const ie=N.current,j=ie==null?void 0:ie.querySelector(`[data-chat-id="${r}"]`);if(!j||!ie)return;const R=j.getBoundingClientRect(),G=ie.getBoundingClientRect();if(R.top<G.top+38){const T=R.top-G.top+ie.scrollTop;ie.scrollTo({top:T-38,behavior:"smooth"})}else if(R.bottom>G.bottom){const T=R.top+R.height/2-G.top+ie.scrollTop,ue=ie.clientHeight/2;ie.scrollTo({top:T-ue,behavior:"smooth"})}})},[r,P]);const J=P>0,Z=C.pathname==="/projects",D=l==="connecting"||!i,X=D?"Connecting":l==="connected"?"Connected":"Disconnected",ne=l==="connected"?"bg-emerald-500":"bg-amber-500";return x.jsxs(x.Fragment,{children:[!o&&c&&x.jsx(qe,{variant:"ghost",size:"icon",className:"fixed top-3 left-3 z-50 md:hidden",onClick:f,children:x.jsx(z0,{className:"h-5 w-5"})}),u&&Z&&x.jsx("div",{className:"hidden md:flex fixed left-0 top-0 h-full z-40 items-start pt-4 pl-5 border-l border-border/0",children:x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(Qa,{className:"size-6 text-logo"}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:g,title:"Expand sidebar",children:x.jsx(Qd,{className:"h-5 w-5"})})]})}),x.jsxs("div",{"data-sidebar":"open",className:xe("fixed inset-0 z-50 bg-background dark:bg-card flex flex-col h-[100dvh] select-none","md:relative md:inset-auto md:w-[275px] md:mr-2 md:h-[calc(100dvh-16px)] md:my-2 md:ml-2 md:border md:border-border md:rounded-2xl",o?"flex":"hidden md:flex",u&&"md:hidden"),children:[x.jsxs("div",{className:" pl-3 pr-[7px] h-[64px] max-h-[64px] md:h-[55px] md:max-h-[55px] border-b flex items-center justify-between",children:[x.jsxs("div",{className:"group/sidebar-header flex items-center gap-2",children:[x.jsxs("button",{type:"button",onClick:m,title:"Collapse sidebar",className:"hidden md:flex relative items-center justify-center h-5 w-5 sm:h-6 sm:w-6",children:[x.jsx(Qa,{className:"absolute inset-0.5 h-4 w-4 sm:h-5 sm:w-5 text-logo transition-all duration-200 ease-out opacity-100 scale-100 group-hover/sidebar-header:opacity-0 group-hover/sidebar-header:scale-0"}),x.jsx(Qd,{className:"absolute inset-0 h-4 w-4 sm:h-6 sm:w-6 text-slate-500 dark:text-slate-400 transition-all duration-200 ease-out opacity-0 scale-0 group-hover/sidebar-header:opacity-100 group-hover/sidebar-header:scale-80 hover:opacity-50"})]}),x.jsx(Qa,{className:"h-5 w-5 sm:h-6 sm:w-6 text-logo md:hidden"}),x.jsx("span",{className:"font-logo text-base uppercase sm:text-md text-slate-600 dark:text-slate-100",children:zt})]}),x.jsxs("div",{className:"flex items-center",children:[x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>B(!0),title:"New project",children:x.jsx(U0,{className:"size-4"})}),x.jsx(qe,{variant:"ghost",size:"icon",className:"md:hidden",onClick:d,children:x.jsx(so,{className:"h-5 w-5"})})]})]}),x.jsx("div",{ref:N,className:"flex-1 min-h-0 overflow-y-auto scrollbar-hide",style:{WebkitOverflowScrolling:"touch"},children:x.jsxs("div",{className:"pb-2 px-2 pt-1.5",children:[!J&&D?x.jsx("div",{className:"space-y-5 px-1 pt-3",children:[0,1,2].map(ie=>x.jsxs("div",{className:"space-y-2 animate-pulse",children:[x.jsx("div",{className:"h-4 w-28 rounded bg-muted"}),x.jsx("div",{className:"space-y-1",children:[0,1,2].map(j=>x.jsxs("div",{className:"flex items-center gap-2 rounded-md px-3 py-2",children:[x.jsx("div",{className:"h-3.5 w-3.5 rounded-full bg-muted"}),x.jsx("div",{className:xe("h-3.5 rounded bg-muted",j===0?"w-32":j===1?"w-40":"w-28")})]},j))})]},ie))}):null,!J&&!D&&e.projectGroups.length===0?x.jsx("p",{className:"text-sm text-slate-400 p-2 mt-6 text-center",children:"No conversations yet"}):null,x.jsx(ER,{projectGroups:e.projectGroups,collapsedSections:O,expandedGroups:U,onToggleSection:re,onToggleExpandedGroup:le,renderChatRow:se,chatsPerProject:$,onNewLocalChat:ie=>{const j=ae.get(ie);j&&y(j)},onRemoveProject:k,isConnected:l==="connected"})]})}),x.jsx("div",{className:"border-t border-border p-2",children:x.jsx("button",{type:"button",onClick:()=>{A("/projects"),d()},className:xe("w-full rounded-xl rounded-t-md border px-3 py-2 text-left transition-colors",Z?"bg-muted border-border":"border-border/0 hover:bg-muted hover:border-border active:bg-muted/80"),children:x.jsxs("div",{className:"flex items- justify-between gap-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(Oh,{className:"h-4 w-4 text-muted-foreground"}),x.jsx("span",{className:"text-sm",children:"Projects"})]}),x.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[x.jsx("span",{children:X}),D?x.jsx(zl,{className:"h-2 w-2 animate-spin"}):x.jsx("span",{className:xe("h-2 w-2 rounded-full",ne)})]})]})})})]}),x.jsx(N1,{open:z,onOpenChange:B,onConfirm:b}),o?x.jsx("div",{className:"fixed inset-0 bg-black/40 z-40 md:hidden",onClick:d}):null]})}const q1=S.forwardRef(({className:e,...r},l)=>x.jsx("textarea",{"data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false","data-1p-ignore":!0,autoComplete:"off",className:xe("flex w-full rounded-lg border border-border bg-background px-2.5 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),ref:l,...r}));q1.displayName="Textarea";function AR(){const[e,r]=S.useState(()=>{if(typeof window>"u")return!1;const l=navigator.standalone===!0,i=window.matchMedia("(display-mode: standalone)").matches;return l||i});return S.useEffect(()=>{const l=window.matchMedia("(display-mode: standalone)"),i=o=>{r(o.matches||navigator.standalone===!0)};return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[]),e}const hb=e=>{let r;const l=new Set,i=(m,g)=>{const y=typeof m=="function"?m(r):m;if(!Object.is(y,r)){const b=r;r=g??(typeof y!="object"||y===null)?y:Object.assign({},r,y),l.forEach(v=>v(r,b))}},o=()=>r,f={setState:i,getState:o,getInitialState:()=>d,subscribe:m=>(l.add(m),()=>l.delete(m))},d=r=e(i,o,f);return f},jR=(e=>e?hb(e):hb),TR=e=>e;function _R(e,r=TR){const l=Ya.useSyncExternalStore(e.subscribe,Ya.useCallback(()=>r(e.getState()),[e,r]),Ya.useCallback(()=>r(e.getInitialState()),[e,r]));return Ya.useDebugValue(l),l}const RR=e=>{const r=jR(e),l=i=>_R(r,i);return Object.assign(l,r),l},F1=(e=>RR);function MR(e,r){let l;try{l=e()}catch{return}return{getItem:o=>{var u;const c=d=>d===null?null:JSON.parse(d,void 0),f=(u=l.getItem(o))!=null?u:null;return f instanceof Promise?f.then(c):c(f)},setItem:(o,u)=>l.setItem(o,JSON.stringify(u,void 0)),removeItem:o=>l.removeItem(o)}}const th=e=>r=>{try{const l=e(r);return l instanceof Promise?l:{then(i){return th(i)(l)},catch(i){return this}}}catch(l){return{then(i){return this},catch(i){return th(i)(l)}}}},OR=(e,r)=>(l,i,o)=>{let u={storage:MR(()=>window.localStorage),partialize:A=>A,version:0,merge:(A,N)=>({...N,...A}),...r},c=!1,f=0;const d=new Set,m=new Set;let g=u.storage;if(!g)return e((...A)=>{console.warn(`[zustand persist middleware] Unable to update item '${u.name}', the given storage is currently unavailable.`),l(...A)},i,o);const y=()=>{const A=u.partialize({...i()});return g.setItem(u.name,{state:A,version:u.version})},b=o.setState;o.setState=(A,N)=>(b(A,N),y());const v=e((...A)=>(l(...A),y()),i,o);o.getInitialState=()=>v;let k;const C=()=>{var A,N;if(!g)return;const O=++f;c=!1,d.forEach(U=>{var F;return U((F=i())!=null?F:v)});const _=((N=u.onRehydrateStorage)==null?void 0:N.call(u,(A=i())!=null?A:v))||void 0;return th(g.getItem.bind(g))(u.name).then(U=>{if(U)if(typeof U.version=="number"&&U.version!==u.version){if(u.migrate){const F=u.migrate(U.state,U.version);return F instanceof Promise?F.then(z=>[!0,z]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,U.state];return[!1,void 0]}).then(U=>{var F;if(O!==f)return;const[z,B]=U;if(k=u.merge(B,(F=i())!=null?F:v),l(k,!0),z)return y()}).then(()=>{O===f&&(_==null||_(k,void 0),k=i(),c=!0,m.forEach(U=>U(k)))}).catch(U=>{O===f&&(_==null||_(void 0,U))})};return o.persist={setOptions:A=>{u={...u,...A},A.storage&&(g=A.storage)},clearStorage:()=>{g==null||g.removeItem(u.name)},getOptions:()=>u,rehydrate:()=>C(),hasHydrated:()=>c,onHydrate:A=>(d.add(A),()=>{d.delete(A)}),onFinishHydration:A=>(m.add(A),()=>{m.delete(A)})},u.skipHydration||C(),k||v},V1=OR,zR=F1()(V1((e,r)=>({drafts:{},setDraft:(l,i)=>e(o=>{if(!i){const{[l]:u,...c}=o.drafts;return{drafts:c}}return{drafts:{...o.drafts,[l]:i}}}),clearDraft:l=>e(i=>{const{[l]:o,...u}=i.drafts;return{drafts:u}}),getDraft:l=>r().drafts[l]??""}),{name:"chat-input-drafts"})),I1=F1()(V1(e=>({model:"opus",effort:"high",planMode:!1,setModel:r=>e(l=>r!=="opus"&&l.effort==="max"?{model:r,effort:"high"}:{model:r}),setEffort:r=>e({effort:r}),setPlanMode:r=>e({planMode:r})}),{name:"chat-preferences"}));function dr({onClick:e,selected:r,icon:l,label:i,description:o,disabled:u}){return x.jsxs("button",{onClick:e,disabled:u,className:xe("w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity",r?"bg-muted border-border":"hover:opacity-60",u&&"opacity-40 cursor-not-allowed"),children:[l,x.jsxs("div",{children:[x.jsx("div",{className:"text-sm font-medium",children:i}),x.jsx("div",{className:"text-xs text-muted-foreground",children:o})]})]})}function wd({trigger:e,triggerClassName:r,children:l}){return x.jsxs(H1,{children:[x.jsx(P1,{asChild:!0,children:x.jsx("button",{className:xe("flex items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0","hover:bg-muted/50",r),children:e})}),x.jsx(Kh,{align:"center",className:"w-64 p-1",children:x.jsx("div",{className:"space-y-1",children:l})})]})}const DR={opus:zh,sonnet:H0,haiku:R0},LR={opus:"Opus",sonnet:"Sonnet",haiku:"Haiku"},BR={low:"Low",medium:"Medium",high:"High",max:"Max"},UR=S.memo(function({onSubmit:r,onCancel:l,disabled:i,canCancel:o,chatId:u}){const{getDraft:c,setDraft:f,clearDraft:d}=zR(),{model:m,effort:g,planMode:y,setModel:b,setEffort:v,setPlanMode:k}=I1(),[C,A]=S.useState(()=>u?c(u):""),N=S.useRef(null),O=AR(),_=S.useCallback(()=>{const B=N.current;B&&(B.style.height="auto",B.style.height=`${B.scrollHeight}px`)},[]);S.useEffect(()=>{_()},[C,_]),S.useEffect(()=>(window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)),[_]),S.useEffect(()=>{var B;(B=N.current)==null||B.focus()},[u]);async function U(){if(!C.trim())return;const B=C;A(""),u&&d(u),N.current&&(N.current.style.height="auto");try{await r(B,{model:m,effort:g,planMode:y})}catch($){console.error("[ChatInput] Submit failed:",$),A(B),u&&f(u,B)}}function F(B){if(B.key==="Tab"&&B.shiftKey){B.preventDefault(),k(!y);return}if(B.key==="Escape"&&o){B.preventDefault(),l==null||l();return}const $="ontouchstart"in window||navigator.maxTouchPoints>0;B.key==="Enter"&&!B.shiftKey&&!o&&!$&&(B.preventDefault(),U())}const z=DR[m];return x.jsxs("div",{className:xe("p-3 pt-0 md:pb-2",O&&"px-5 pb-5"),children:[x.jsxs("div",{className:"flex items-end gap-2 max-w-[840px] mx-auto border dark:bg-card/40 backdrop-blur-lg border-border rounded-[29px] pr-1.5",children:[x.jsx(q1,{ref:N,placeholder:"Ask something...",value:C,autoFocus:!0,rows:1,onChange:B=>{A(B.target.value),u&&f(u,B.target.value),_()},onKeyDown:F,disabled:i,className:"flex-1 text-base p-3 md:p-4 pl-4.5 md:pl-6 resize-none max-h-[200px] outline-none bg-transparent border-0 shadow-none"}),x.jsx(qe,{type:"button",onPointerDown:B=>{B.preventDefault(),o?l==null||l():!i&&C.trim()&&U()},disabled:!o&&(i||!C.trim()),size:"icon",className:"flex-shrink-0 bg-slate-600 text-white dark:bg-white dark:text-slate-900 rounded-full cursor-pointer h-10 w-10 md:h-11 md:w-11 mb-1 -mr-0.5 md:mr-0 md:mb-1.5 touch-manipulation disabled:bg-white/60 disabled:text-slate-700",children:o?x.jsx("div",{className:"w-3 h-3 md:w-4 md:h-4 rounded-xs bg-current"}):x.jsx(KA,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),x.jsxs("div",{className:"flex justify-center items-center gap-0.5 max-w-[840px] mx-auto mt-2 animate-fade-in",children:[x.jsxs(wd,{trigger:x.jsxs(x.Fragment,{children:[x.jsx(z,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:LR[m]})]}),children:[x.jsx(dr,{onClick:()=>b("opus"),selected:m==="opus",icon:x.jsx(zh,{className:"h-4 w-4 text-muted-foreground"}),label:"Opus",description:"Highest capability, deep reasoning"}),x.jsx(dr,{onClick:()=>b("sonnet"),selected:m==="sonnet",icon:x.jsx(H0,{className:"h-4 w-4 text-muted-foreground"}),label:"Sonnet",description:"Balanced speed and intelligence"}),x.jsx(dr,{onClick:()=>b("haiku"),selected:m==="haiku",icon:x.jsx(R0,{className:"h-4 w-4 text-muted-foreground"}),label:"Haiku",description:"Fastest responses, lightweight tasks"})]}),x.jsxs(wd,{trigger:x.jsxs(x.Fragment,{children:[x.jsx(Pa,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:BR[g]})]}),triggerClassName:g==="max"?"text-amber-400 dark:text-amber-300":void 0,children:[x.jsx(dr,{onClick:()=>v("low"),selected:g==="low",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"Low",description:"Minimal thinking, fastest responses"}),x.jsx(dr,{onClick:()=>v("medium"),selected:g==="medium",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"Medium",description:"Moderate thinking for typical tasks"}),x.jsx(dr,{onClick:()=>v("high"),selected:g==="high",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"High",description:"Deep reasoning for complex problems"}),x.jsx(dr,{onClick:()=>v("max"),selected:g==="max",disabled:m!=="opus",icon:x.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"}),label:"Max",description:m!=="opus"?"Only available with Opus":"Maximum effort, deepest reasoning"})]}),x.jsxs(wd,{trigger:y?x.jsxs(x.Fragment,{children:[x.jsx(nu,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:"Plan Mode"})]}):x.jsxs(x.Fragment,{children:[x.jsx(Wx,{className:"h-3.5 w-3.5"}),x.jsx("span",{children:"Full Access"})]}),triggerClassName:y?"text-blue-400 dark:text-blue-300":void 0,children:[x.jsx(dr,{onClick:()=>k(!1),selected:!y,icon:x.jsx(Wx,{className:"h-4 w-4 text-muted-foreground"}),label:"Full Access",description:"Claude can read and edit files"}),x.jsx(dr,{onClick:()=>k(!0),selected:y,icon:x.jsx(nu,{className:"h-4 w-4 text-muted-foreground"}),label:"Plan Mode",description:"Claude can only read, not edit"}),x.jsxs("p",{className:"text-xs text-muted-foreground/90 px-2 py-2",children:["Press ",x.jsx("kbd",{className:"px-1 mx-0.5 py-0.5 text-[12px] bg-muted/90 rounded font-mono",children:"shift+tab"})," to toggle"]})]})]})]})}),G1=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("bg-card text-card-foreground",e),...r}));G1.displayName="Card";const Y1=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("flex flex-col space-y-1.5 p-2",e),...r}));Y1.displayName="CardHeader";const HR=S.forwardRef(({className:e,...r},l)=>x.jsx("h3",{ref:l,className:xe("text-2xl font-semibold leading-none tracking-tight",e),...r}));HR.displayName="CardTitle";const PR=S.forwardRef(({className:e,...r},l)=>x.jsx("p",{ref:l,className:xe("text-sm text-muted-foreground",e),...r}));PR.displayName="CardDescription";const $1=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("p-6 pt-0",e),...r}));$1.displayName="CardContent";const qR=S.forwardRef(({className:e,...r},l)=>x.jsx("div",{ref:l,className:xe("flex items-center p-6 pt-0",e),...r}));qR.displayName="CardFooter";function FR({sidebarCollapsed:e,onOpenSidebar:r,onExpandSidebar:l,onNewChat:i,localPath:o,onOpenExternal:u}){return x.jsx(Y1,{className:xe("absolute top-0 md:top-2 left-0 right-0 z-10 px-2.5 pr-4 border-border/0 md:pb-0 flex items-center justify-center","backdrop-blur-lg md:backdrop-blur-none bg-gradient-to-b from-background md:from-transparent border-b border-x-0 md:border-x border-border md:border-none"),children:x.jsxs("div",{className:"relative flex items-center gap-2 w-full",children:[x.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 border-l border-border/0",children:[x.jsx(qe,{variant:"ghost",size:"icon",className:"md:hidden",onClick:r,children:x.jsx(z0,{className:"h-5 w-5"})}),e&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"flex items-center justify-center w-[40px] h-[40px]",children:x.jsx(Qa,{className:"h-4 w-4 sm:h-5 sm:w-5 text-logo ml-1 hidden md:block"})}),x.jsx(qe,{variant:"ghost",size:"icon",className:"hidden md:flex",onClick:l,title:"Expand sidebar",children:x.jsx(Qd,{className:"h-5 w-5"})})]}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:i,title:"Compose",children:x.jsx(Dh,{className:"h-5 w-5"})})]}),x.jsx("div",{className:"flex-1 min-w-0"}),x.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:o&&u&&x.jsxs(x.Fragment,{children:[x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>u("open_finder"),title:"Open in Finder",className:"border border-border/0",children:x.jsx(M0,{className:"h-4.5 w-4.5"})}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>u("open_terminal"),title:"Open in Terminal",className:"border border-border/0",children:x.jsx(Lh,{className:"h-4.5 w-4.5"})}),x.jsx(qe,{variant:"ghost",size:"icon",onClick:()=>u("open_editor"),title:"Open in Cursor",className:"border border-border/0",children:x.jsx(bj,{className:"h-4.5 w-4.5"})})]})})]})})}const nh={Task:nu,TaskOutput:nu,Bash:Lh,Glob:yd,Grep:yd,ExitPlanMode:eb,Read:Mj,Edit:jj,Write:_j,NotebookEdit:B0,WebFetch:GA,TodoWrite:aj,WebSearch:yd,KillShell:lT,AskUserQuestion:D0,Skill:zh,EnterPlanMode:eb},X1=oT;function Q1(e){return nh[e]?nh[e]:/^mcp__db__.+_query$/.test(e)?Cj:e==="mcp__lever__show_chart"?nj:X1}function ll({children:e,className:r}){return x.jsx("div",{className:xe("flex gap-3 justify-start items-center",r),children:e})}function VR({children:e,className:r}){return x.jsx("div",{className:xe("flex items-center gap-1.5 text-xs",r),children:e})}function el({children:e,className:r}){return x.jsx("span",{className:xe("font-medium text-foreground/80",r),children:e})}function IR({children:e}){return x.jsx("span",{className:"text-muted-foreground",children:e})}function Ou({children:e,expandedContent:r,defaultExpanded:l=!1}){const[i,o]=S.useState(l);return x.jsxs("div",{className:"flex flex-col w-full",children:[x.jsxs("button",{onClick:()=>o(!i),className:`group/expandable-row cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${i?"":"hover:opacity-60 transition-opacity"}`,children:[x.jsx("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:e}),x.jsx(Kr,{className:`h-4.5 w-4.5 text-muted-icon translate-y-[0.5px] transition-all duration-200 opacity-0 group-hover/expandable-row:opacity-100 ${i?"rotate-90 opacity-100":""}`})]}),i&&r]})}function qa({label:e,children:r,copyText:l}){const[i,o]=S.useState(!1),u=l??uu(r),c=S.useCallback(async()=>{await navigator.clipboard.writeText(u),o(!0),setTimeout(()=>o(!1),2e3)},[u]);return x.jsxs("div",{children:[x.jsx("span",{className:"font-medium text-muted-foreground",children:e}),x.jsxs("div",{className:"relative group/codeblock",children:[x.jsx("pre",{className:"my-1 text-xs font-mono whitespace-no-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto w-full",children:r}),x.jsx(qe,{variant:"ghost",size:"icon",className:xe("absolute top-2.5 right-1.5 z-10 h-8 w-8 rounded-md text-muted-foreground opacity-0 group-hover/codeblock:opacity-100 transition-opacity",!i&&"hover:text-foreground",i&&"hover:!bg-transparent hover:!border-transparent"),onClick:c,children:i?x.jsx(_l,{className:"h-4 w-4 text-green-400"}):x.jsx(ku,{className:"h-4 w-4"})})]})]})}function Z1({children:e,icon:r,className:l}){return x.jsxs("span",{className:xe("inline-flex items-center gap-1 px-2 py-1 bg-muted border border-border rounded-full",l),children:[r&&x.jsx(r,{className:"h-3 w-3 text-muted-foreground"}),e]})}function zu({children:e,className:r}){return x.jsxs("div",{className:xe("grid grid-cols-[auto_1fr] gap-2 min-w-0",r),children:[x.jsx("div",{className:" min-w-5 flex flex-col relative items-center justify-center",children:x.jsx("div",{className:"min-h-full w-[1px] bg-muted-foreground/20"})}),x.jsx("div",{className:"-ml-[1px] min-w-0 overflow-hidden",children:e})]})}function uu(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(Array.isArray(e))return e.map(uu).join("");if(e&&typeof e=="object"&&"props"in e){const r=e.props;return uu(r.children)}return""}const Du={pre:({children:e,...r})=>{const[l,i]=S.useState(!1),o=uu(e),u=async()=>{await navigator.clipboard.writeText(o),i(!0),setTimeout(()=>i(!1),2e3)};return x.jsxs("div",{className:"relative overflow-x-auto max-w-full min-w-0 no-code-highlight group/pre",children:[x.jsx("pre",{className:"min-w-0 rounded-xl py-2.5 px-3.5 [.no-pre-highlight_&]:bg-background",...r,children:e}),x.jsx(qe,{variant:"ghost",size:"icon",className:xe("absolute top-[35px] -translate-y-[50%] -translate-x-[1px] rounded-md right-1.5 h-8 w-8 text-muted-foreground opacity-0 group-hover/pre:opacity-100 transition-opacity",!l&&"hover:text-foreground",l&&"hover:!bg-transparent hover:!border-transparent"),onClick:u,children:l?x.jsx(_l,{className:"h-4 w-4 text-green-400"}):x.jsx(ku,{className:"h-4 w-4"})})]})},code:({children:e,className:r,...l})=>r?x.jsx("code",{className:"block text-xs whitespace-pre",...l,children:e}):x.jsx("code",{className:"break-all px-1 bg-border/60 dark:[.no-pre-highlight_&]:bg-background dark:[.text-pretty_&]:bg-neutral [.no-code-highlight_&]:!bg-transparent py-0.5 rounded text-sm whitespace-wrap",...l,children:e}),table:({children:e,...r})=>x.jsx("div",{className:"border border-border rounded-xl overflow-x-auto",children:x.jsx("table",{className:"table-auto min-w-full divide-y divide-border bg-background",...r,children:e})}),tbody:({children:e,...r})=>x.jsx("tbody",{className:"divide-y divide-border",...r,children:e}),th:({children:e,...r})=>x.jsx("th",{className:"text-left text-xs uppercase text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold",...r,children:e}),td:({children:e,...r})=>x.jsx("td",{className:"text-left p-2 pl-0 first:pl-3 [&_*]:font-normal ",...r,children:e}),p:({children:e,...r})=>x.jsx("p",{className:"break-words",...r,children:e}),a:({children:e,...r})=>x.jsx("a",{className:"transition-all underline decoration-2 text-orange-500 decoration-orange-500/50 hover:text-orange-500/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40 ",target:"_blank",rel:"noopener noreferrer",...r,children:e})},rh={...Du,h1:({children:e})=>x.jsx("h1",{className:"text-2xl font-bold mt-6 mb-4 first:mt-0",children:e}),h2:({children:e})=>x.jsx("h2",{className:"text-xl font-semibold mt-5 mb-3 first:mt-0",children:e}),h3:({children:e})=>x.jsx("h3",{className:"text-lg font-semibold mt-4 mb-2 first:mt-0",children:e}),h4:({children:e})=>x.jsx("h4",{className:"text-base font-semibold mt-3 mb-2 first:mt-0",children:e}),h5:({children:e})=>x.jsx("h5",{className:"text-sm font-semibold mt-3 mb-1 first:mt-0",children:e}),h6:({children:e})=>x.jsx("h6",{className:"text-sm font-medium mt-3 mb-1 first:mt-0",children:e})},GR={connecting:"Connecting...",acquiring_sandbox:"Booting...",initializing:"Initializing...",starting:"Starting...",running:"Running...",waiting_for_user:"Waiting...",failed:"Failed"};function YR({status:e}){const r=(e?GR[e]:void 0)||"Processing...",l=e==="failed";return x.jsx(ll,{className:"ml-[1px]",children:x.jsxs(VR,{children:[l?x.jsx(so,{className:"size-4.5 text-red-500"}):x.jsx(zl,{className:"size-4.5 animate-spin text-muted-icon"}),x.jsx(Ru,{className:"ml-[1px] text-sm",shimmerWidth:44,children:r})]})})}const K1=S.forwardRef(({className:e,children:r,...l},i)=>x.jsx("div",{ref:i,className:xe("relative overflow-y-auto overscroll-contain touch-pan-y scrollbar-hide",e),style:{WebkitOverflowScrolling:"touch"},...l,children:r}));K1.displayName="ScrollArea";function $R(e,r){const l={};return(e[e.length-1]===""?[...e,""]:e).join((l.padRight?" ":"")+","+(l.padLeft===!1?"":" ")).trim()}const XR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZR={};function mb(e,r){return(ZR.jsx?QR:XR).test(e)}const KR=/[ \t\n\f\r]/g;function JR(e){return typeof e=="object"?e.type==="text"?pb(e.value):!1:pb(e)}function pb(e){return e.replace(KR,"")===""}class ho{constructor(r,l,i){this.normal=l,this.property=r,i&&(this.space=i)}}ho.prototype.normal={};ho.prototype.property={};ho.prototype.space=void 0;function J1(e,r){const l={},i={};for(const o of e)Object.assign(l,o.property),Object.assign(i,o.normal);return new ho(l,i,r)}function lh(e){return e.toLowerCase()}class Yt{constructor(r,l){this.attribute=l,this.property=r}}Yt.prototype.attribute="";Yt.prototype.booleanish=!1;Yt.prototype.boolean=!1;Yt.prototype.commaOrSpaceSeparated=!1;Yt.prototype.commaSeparated=!1;Yt.prototype.defined=!1;Yt.prototype.mustUseProperty=!1;Yt.prototype.number=!1;Yt.prototype.overloadedBoolean=!1;Yt.prototype.property="";Yt.prototype.spaceSeparated=!1;Yt.prototype.space=void 0;let WR=0;const Te=Dl(),ft=Dl(),ih=Dl(),oe=Dl(),Ke=Dl(),_i=Dl(),tn=Dl();function Dl(){return 2**++WR}const ah=Object.freeze(Object.defineProperty({__proto__:null,boolean:Te,booleanish:ft,commaOrSpaceSeparated:tn,commaSeparated:_i,number:oe,overloadedBoolean:ih,spaceSeparated:Ke},Symbol.toStringTag,{value:"Module"})),Sd=Object.keys(ah);class Jh extends Yt{constructor(r,l,i,o){let u=-1;if(super(r,l),gb(this,"space",o),typeof i=="number")for(;++u<Sd.length;){const c=Sd[u];gb(this,Sd[u],(i&ah[c])===ah[c])}}}Jh.prototype.defined=!0;function gb(e,r,l){l&&(e[r]=l)}function Fi(e){const r={},l={};for(const[i,o]of Object.entries(e.properties)){const u=new Jh(i,e.transform(e.attributes||{},i),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(u.mustUseProperty=!0),r[i]=u,l[lh(i)]=i,l[lh(u.attribute)]=i}return new ho(r,l,e.space)}const W1=Fi({properties:{ariaActiveDescendant:null,ariaAtomic:ft,ariaAutoComplete:null,ariaBusy:ft,ariaChecked:ft,ariaColCount:oe,ariaColIndex:oe,ariaColSpan:oe,ariaControls:Ke,ariaCurrent:null,ariaDescribedBy:Ke,ariaDetails:null,ariaDisabled:ft,ariaDropEffect:Ke,ariaErrorMessage:null,ariaExpanded:ft,ariaFlowTo:Ke,ariaGrabbed:ft,ariaHasPopup:null,ariaHidden:ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ke,ariaLevel:oe,ariaLive:null,ariaModal:ft,ariaMultiLine:ft,ariaMultiSelectable:ft,ariaOrientation:null,ariaOwns:Ke,ariaPlaceholder:null,ariaPosInSet:oe,ariaPressed:ft,ariaReadOnly:ft,ariaRelevant:null,ariaRequired:ft,ariaRoleDescription:Ke,ariaRowCount:oe,ariaRowIndex:oe,ariaRowSpan:oe,ariaSelected:ft,ariaSetSize:oe,ariaSort:null,ariaValueMax:oe,ariaValueMin:oe,ariaValueNow:oe,ariaValueText:null,role:null},transform(e,r){return r==="role"?r:"aria-"+r.slice(4).toLowerCase()}});function ew(e,r){return r in e?e[r]:r}function tw(e,r){return ew(e,r.toLowerCase())}const e4=Fi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_i,acceptCharset:Ke,accessKey:Ke,action:null,allow:null,allowFullScreen:Te,allowPaymentRequest:Te,allowUserMedia:Te,alt:null,as:null,async:Te,autoCapitalize:null,autoComplete:Ke,autoFocus:Te,autoPlay:Te,blocking:Ke,capture:null,charSet:null,checked:Te,cite:null,className:Ke,cols:oe,colSpan:null,content:null,contentEditable:ft,controls:Te,controlsList:Ke,coords:oe|_i,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Te,defer:Te,dir:null,dirName:null,disabled:Te,download:ih,draggable:ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Te,formTarget:null,headers:Ke,height:oe,hidden:ih,high:oe,href:null,hrefLang:null,htmlFor:Ke,httpEquiv:Ke,id:null,imageSizes:null,imageSrcSet:null,inert:Te,inputMode:null,integrity:null,is:null,isMap:Te,itemId:null,itemProp:Ke,itemRef:Ke,itemScope:Te,itemType:Ke,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Te,low:oe,manifest:null,max:null,maxLength:oe,media:null,method:null,min:null,minLength:oe,multiple:Te,muted:Te,name:null,nonce:null,noModule:Te,noValidate:Te,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Te,optimum:oe,pattern:null,ping:Ke,placeholder:null,playsInline:Te,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Te,referrerPolicy:null,rel:Ke,required:Te,reversed:Te,rows:oe,rowSpan:oe,sandbox:Ke,scope:null,scoped:Te,seamless:Te,selected:Te,shadowRootClonable:Te,shadowRootDelegatesFocus:Te,shadowRootMode:null,shape:null,size:oe,sizes:null,slot:null,span:oe,spellCheck:ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:oe,step:null,style:null,tabIndex:oe,target:null,title:null,translate:null,type:null,typeMustMatch:Te,useMap:null,value:ft,width:oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ke,axis:null,background:null,bgColor:null,border:oe,borderColor:null,bottomMargin:oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Te,declare:Te,event:null,face:null,frame:null,frameBorder:null,hSpace:oe,leftMargin:oe,link:null,longDesc:null,lowSrc:null,marginHeight:oe,marginWidth:oe,noResize:Te,noHref:Te,noShade:Te,noWrap:Te,object:null,profile:null,prompt:null,rev:null,rightMargin:oe,rules:null,scheme:null,scrolling:ft,standby:null,summary:null,text:null,topMargin:oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Te,disableRemotePlayback:Te,prefix:null,property:null,results:oe,security:null,unselectable:null},space:"html",transform:tw}),t4=Fi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:tn,accentHeight:oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:oe,amplitude:oe,arabicForm:null,ascent:oe,attributeName:null,attributeType:null,azimuth:oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:oe,by:null,calcMode:null,capHeight:oe,className:Ke,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:oe,diffuseConstant:oe,direction:null,display:null,dur:null,divisor:oe,dominantBaseline:null,download:Te,dx:null,dy:null,edgeMode:null,editable:null,elevation:oe,enableBackground:null,end:null,event:null,exponent:oe,externalResourcesRequired:null,fill:null,fillOpacity:oe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_i,g2:_i,glyphName:_i,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:oe,horizOriginX:oe,horizOriginY:oe,id:null,ideographic:oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:oe,k:oe,k1:oe,k2:oe,k3:oe,k4:oe,kernelMatrix:tn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:oe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:oe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:oe,overlineThickness:oe,paintOrder:null,panose1:null,path:null,pathLength:oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ke,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:oe,pointsAtY:oe,pointsAtZ:oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:tn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:tn,rev:tn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:tn,requiredFeatures:tn,requiredFonts:tn,requiredFormats:tn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:oe,specularExponent:oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:oe,strikethroughThickness:oe,string:null,stroke:null,strokeDashArray:tn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:oe,strokeOpacity:oe,strokeWidth:null,style:null,surfaceScale:oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:tn,tabIndex:oe,tableValues:null,target:null,targetX:oe,targetY:oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:tn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:oe,underlineThickness:oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:oe,values:null,vAlphabetic:oe,vMathematical:oe,vectorEffect:null,vHanging:oe,vIdeographic:oe,version:null,vertAdvY:oe,vertOriginX:oe,vertOriginY:oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ew}),nw=Fi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,r){return"xlink:"+r.slice(5).toLowerCase()}}),rw=Fi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:tw}),lw=Fi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,r){return"xml:"+r.slice(3).toLowerCase()}}),n4={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},r4=/[A-Z]/g,yb=/-[a-z]/g,l4=/^data[-\w.:]+$/i;function i4(e,r){const l=lh(r);let i=r,o=Yt;if(l in e.normal)return e.property[e.normal[l]];if(l.length>4&&l.slice(0,4)==="data"&&l4.test(r)){if(r.charAt(4)==="-"){const u=r.slice(5).replace(yb,o4);i="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=r.slice(4);if(!yb.test(u)){let c=u.replace(r4,a4);c.charAt(0)!=="-"&&(c="-"+c),r="data"+c}}o=Jh}return new o(i,r)}function a4(e){return"-"+e.toLowerCase()}function o4(e){return e.charAt(1).toUpperCase()}const s4=J1([W1,e4,nw,rw,lw],"html"),Wh=J1([W1,t4,nw,rw,lw],"svg");function u4(e){return e.join(" ").trim()}var Ei={},kd,xb;function c4(){if(xb)return kd;xb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,l=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,d=`
385
385
  `,m="/",g="*",y="",b="comment",v="declaration";function k(A,N){if(typeof A!="string")throw new TypeError("First argument must be a string");if(!A)return[];N=N||{};var O=1,_=1;function U(J){var Z=J.match(r);Z&&(O+=Z.length);var D=J.lastIndexOf(d);_=~D?J.length-D:_+J.length}function F(){var J={line:O,column:_};return function(Z){return Z.position=new z(J),ae(),Z}}function z(J){this.start=J,this.end={line:O,column:_},this.source=N.source}z.prototype.content=A;function B(J){var Z=new Error(N.source+":"+O+":"+_+": "+J);if(Z.reason=J,Z.filename=N.source,Z.line=O,Z.column=_,Z.source=A,!N.silent)throw Z}function $(J){var Z=J.exec(A);if(Z){var D=Z[0];return U(D),A=A.slice(D.length),Z}}function ae(){$(l)}function P(J){var Z;for(J=J||[];Z=re();)Z!==!1&&J.push(Z);return J}function re(){var J=F();if(!(m!=A.charAt(0)||g!=A.charAt(1))){for(var Z=2;y!=A.charAt(Z)&&(g!=A.charAt(Z)||m!=A.charAt(Z+1));)++Z;if(Z+=2,y===A.charAt(Z-1))return B("End of comment missing");var D=A.slice(2,Z-2);return _+=2,U(D),A=A.slice(Z),_+=2,J({type:b,comment:D})}}function le(){var J=F(),Z=$(i);if(Z){if(re(),!$(o))return B("property missing ':'");var D=$(u),X=J({type:v,property:C(Z[0].replace(e,y)),value:D?C(D[0].replace(e,y)):y});return $(c),X}}function se(){var J=[];P(J);for(var Z;Z=le();)Z!==!1&&(J.push(Z),P(J));return J}return ae(),se()}function C(A){return A?A.replace(f,y):y}return kd=k,kd}var bb;function f4(){if(bb)return Ei;bb=1;var e=Ei&&Ei.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ei,"__esModule",{value:!0}),Ei.default=l;const r=e(c4());function l(i,o){let u=null;if(!i||typeof i!="string")return u;const c=(0,r.default)(i),f=typeof o=="function";return c.forEach(d=>{if(d.type!=="declaration")return;const{property:m,value:g}=d;f?o(m,g,d):g&&(u=u||{},u[m]=g)}),u}return Ei}var Fa={},vb;function d4(){if(vb)return Fa;vb=1,Object.defineProperty(Fa,"__esModule",{value:!0}),Fa.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,l=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(m){return!m||l.test(m)||e.test(m)},c=function(m,g){return g.toUpperCase()},f=function(m,g){return"".concat(g,"-")},d=function(m,g){return g===void 0&&(g={}),u(m)?m:(m=m.toLowerCase(),g.reactCompat?m=m.replace(o,f):m=m.replace(i,f),m.replace(r,c))};return Fa.camelCase=d,Fa}var Va,wb;function h4(){if(wb)return Va;wb=1;var e=Va&&Va.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=e(f4()),l=d4();function i(o,u){var c={};return!o||typeof o!="string"||(0,r.default)(o,function(f,d){f&&d&&(c[(0,l.camelCase)(f,u)]=d)}),c}return i.default=i,Va=i,Va}var m4=h4();const p4=pu(m4),iw=aw("end"),em=aw("start");function aw(e){return r;function r(l){const i=l&&l.position&&l.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function g4(e){const r=em(e),l=iw(e);if(r&&l)return{start:r,end:l}}function Za(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Sb(e.position):"start"in e||"end"in e?Sb(e):"line"in e||"column"in e?oh(e):""}function oh(e){return kb(e&&e.line)+":"+kb(e&&e.column)}function Sb(e){return oh(e&&e.start)+"-"+oh(e&&e.end)}function kb(e){return e&&typeof e=="number"?e:1}class Rt extends Error{constructor(r,l,i){super(),typeof l=="string"&&(i=l,l=void 0);let o="",u={},c=!1;if(l&&("line"in l&&"column"in l?u={place:l}:"start"in l&&"end"in l?u={place:l}:"type"in l?u={ancestors:[l],place:l.position}:u={...l}),typeof r=="string"?o=r:!u.cause&&r&&(c=!0,o=r.message,u.cause=r),!u.ruleId&&!u.source&&typeof i=="string"){const d=i.indexOf(":");d===-1?u.ruleId=i:(u.source=i.slice(0,d),u.ruleId=i.slice(d+1))}if(!u.place&&u.ancestors&&u.ancestors){const d=u.ancestors[u.ancestors.length-1];d&&(u.place=d.position)}const f=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=Za(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=c&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Rt.prototype.file="";Rt.prototype.name="";Rt.prototype.reason="";Rt.prototype.message="";Rt.prototype.stack="";Rt.prototype.column=void 0;Rt.prototype.line=void 0;Rt.prototype.ancestors=void 0;Rt.prototype.cause=void 0;Rt.prototype.fatal=void 0;Rt.prototype.place=void 0;Rt.prototype.ruleId=void 0;Rt.prototype.source=void 0;const tm={}.hasOwnProperty,y4=new Map,x4=/[A-Z]/g,b4=new Set(["table","tbody","thead","tfoot","tr"]),v4=new Set(["td","th"]),ow="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function w4(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const l=r.filePath||void 0;let i;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=T4(l,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=j4(l,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:i,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?Wh:s4,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},u=sw(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function sw(e,r,l){if(r.type==="element")return S4(e,r,l);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return k4(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return E4(e,r,l);if(r.type==="mdxjsEsm")return C4(e,r);if(r.type==="root")return N4(e,r,l);if(r.type==="text")return A4(e,r)}function S4(e,r,l){const i=e.schema;let o=i;r.tagName.toLowerCase()==="svg"&&i.space==="html"&&(o=Wh,e.schema=o),e.ancestors.push(r);const u=cw(e,r.tagName,!1),c=_4(e,r);let f=rm(e,r);return b4.has(r.tagName)&&(f=f.filter(function(d){return typeof d=="string"?!JR(d):!0})),uw(e,c,u,r),nm(c,f),e.ancestors.pop(),e.schema=i,e.create(r,u,c,l)}function k4(e,r){if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}ro(e,r.position)}function C4(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);ro(e,r.position)}function E4(e,r,l){const i=e.schema;let o=i;r.name==="svg"&&i.space==="html"&&(o=Wh,e.schema=o),e.ancestors.push(r);const u=r.name===null?e.Fragment:cw(e,r.name,!0),c=R4(e,r),f=rm(e,r);return uw(e,c,u,r),nm(c,f),e.ancestors.pop(),e.schema=i,e.create(r,u,c,l)}function N4(e,r,l){const i={};return nm(i,rm(e,r)),e.create(r,e.Fragment,i,l)}function A4(e,r){return r.value}function uw(e,r,l,i){typeof l!="string"&&l!==e.Fragment&&e.passNode&&(r.node=i)}function nm(e,r){if(r.length>0){const l=r.length>1?r:r[0];l&&(e.children=l)}}function j4(e,r,l){return i;function i(o,u,c,f){const m=Array.isArray(c.children)?l:r;return f?m(u,c,f):m(u,c)}}function T4(e,r){return l;function l(i,o,u,c){const f=Array.isArray(u.children),d=em(i);return r(o,u,c,f,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function _4(e,r){const l={};let i,o;for(o in r.properties)if(o!=="children"&&tm.call(r.properties,o)){const u=M4(e,o,r.properties[o]);if(u){const[c,f]=u;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&v4.has(r.tagName)?i=f:l[c]=f}}if(i){const u=l.style||(l.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return l}function R4(e,r){const l={};for(const i of r.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const u=i.data.estree.body[0];u.type;const c=u.expression;c.type;const f=c.properties[0];f.type,Object.assign(l,e.evaluater.evaluateExpression(f.argument))}else ro(e,r.position);else{const o=i.name;let u;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const f=i.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else ro(e,r.position);else u=i.value===null?!0:i.value;l[o]=u}return l}function rm(e,r){const l=[];let i=-1;const o=e.passKeys?new Map:y4;for(;++i<r.children.length;){const u=r.children[i];let c;if(e.passKeys){const d=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(d){const m=o.get(d)||0;c=d+"-"+m,o.set(d,m+1)}}const f=sw(e,u,c);f!==void 0&&l.push(f)}return l}function M4(e,r,l){const i=i4(e.schema,r);if(!(l==null||typeof l=="number"&&Number.isNaN(l))){if(Array.isArray(l)&&(l=i.commaSeparated?$R(l):u4(l)),i.property==="style"){let o=typeof l=="object"?l:O4(e,String(l));return e.stylePropertyNameCase==="css"&&(o=z4(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&i.space?n4[i.property]||i.property:i.attribute,l]}}function O4(e,r){try{return p4(r,{reactCompat:!0})}catch(l){if(e.ignoreInvalidStyle)return{};const i=l,o=new Rt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=ow+"#cannot-parse-style-attribute",o}}function cw(e,r,l){let i;if(!l)i={type:"Literal",value:r};else if(r.includes(".")){const o=r.split(".");let u=-1,c;for(;++u<o.length;){const f=mb(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};c=c?{type:"MemberExpression",object:c,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}i=c}else i=mb(r)&&!/^[a-z]/.test(r)?{type:"Identifier",name:r}:{type:"Literal",value:r};if(i.type==="Literal"){const o=i.value;return tm.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(i);ro(e)}function ro(e,r){const l=new Rt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:r,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=ow+"#cannot-handle-mdx-estrees-without-createevaluater",l}function z4(e){const r={};let l;for(l in e)tm.call(e,l)&&(r[D4(l)]=e[l]);return r}function D4(e){let r=e.replace(x4,L4);return r.slice(0,3)==="ms-"&&(r="-"+r),r}function L4(e){return"-"+e.toLowerCase()}const Cd={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},B4={};function lm(e,r){const l=B4,i=typeof l.includeImageAlt=="boolean"?l.includeImageAlt:!0,o=typeof l.includeHtml=="boolean"?l.includeHtml:!0;return fw(e,i,o)}function fw(e,r,l){if(U4(e)){if("value"in e)return e.type==="html"&&!l?"":e.value;if(r&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Cb(e.children,r,l)}return Array.isArray(e)?Cb(e,r,l):""}function Cb(e,r,l){const i=[];let o=-1;for(;++o<e.length;)i[o]=fw(e[o],r,l);return i.join("")}function U4(e){return!!(e&&typeof e=="object")}const Eb=document.createElement("i");function im(e){const r="&"+e+";";Eb.innerHTML=r;const l=Eb.textContent;return l.charCodeAt(l.length-1)===59&&e!=="semi"||l===r?!1:l}function ln(e,r,l,i){const o=e.length;let u=0,c;if(r<0?r=-r>o?0:o+r:r=r>o?o:r,l=l>0?l:0,i.length<1e4)c=Array.from(i),c.unshift(r,l),e.splice(...c);else for(l&&e.splice(r,l);u<i.length;)c=i.slice(u,u+1e4),c.unshift(r,0),e.splice(...c),u+=1e4,r+=1e4}function yn(e,r){return e.length>0?(ln(e,e.length,0,r),e):r}const Nb={}.hasOwnProperty;function dw(e){const r={};let l=-1;for(;++l<e.length;)H4(r,e[l]);return r}function H4(e,r){let l;for(l in r){const o=(Nb.call(e,l)?e[l]:void 0)||(e[l]={}),u=r[l];let c;if(u)for(c in u){Nb.call(o,c)||(o[c]=[]);const f=u[c];P4(o[c],Array.isArray(f)?f:f?[f]:[])}}}function P4(e,r){let l=-1;const i=[];for(;++l<r.length;)(r[l].add==="after"?e:i).push(r[l]);ln(e,0,0,i)}function hw(e,r){const l=Number.parseInt(e,r);return l<9||l===11||l>13&&l<32||l>126&&l<160||l>55295&&l<57344||l>64975&&l<65008||(l&65535)===65535||(l&65535)===65534||l>1114111?"�":String.fromCodePoint(l)}function kn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Dt=il(/[A-Za-z]/),Tt=il(/[\dA-Za-z]/),q4=il(/[#-'*+\--9=?A-Z^-~]/);function cu(e){return e!==null&&(e<32||e===127)}const sh=il(/\d/),F4=il(/[\dA-Fa-f]/),V4=il(/[!-/:-@[-`{-~]/);function we(e){return e!==null&&e<-2}function Ze(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const Lu=il(new RegExp("\\p{P}|\\p{S}","u")),Ml=il(/\s/);function il(e){return r;function r(l){return l!==null&&l>-1&&e.test(String.fromCharCode(l))}}function Vi(e){const r=[];let l=-1,i=0,o=0;for(;++l<e.length;){const u=e.charCodeAt(l);let c="";if(u===37&&Tt(e.charCodeAt(l+1))&&Tt(e.charCodeAt(l+2)))o=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(c=String.fromCharCode(u));else if(u>55295&&u<57344){const f=e.charCodeAt(l+1);u<56320&&f>56319&&f<57344?(c=String.fromCharCode(u,f),o=1):c="�"}else c=String.fromCharCode(u);c&&(r.push(e.slice(i,l),encodeURIComponent(c)),i=l+o+1,c=""),o&&(l+=o,o=0)}return r.join("")+e.slice(i)}function Be(e,r,l,i){const o=i?i-1:Number.POSITIVE_INFINITY;let u=0;return c;function c(d){return Oe(d)?(e.enter(l),f(d)):r(d)}function f(d){return Oe(d)&&u++<o?(e.consume(d),f):(e.exit(l),r(d))}}const I4={tokenize:G4};function G4(e){const r=e.attempt(this.parser.constructs.contentInitial,i,o);let l;return r;function i(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Be(e,r,"linePrefix")}function o(f){return e.enter("paragraph"),u(f)}function u(f){const d=e.enter("chunkText",{contentType:"text",previous:l});return l&&(l.next=d),l=d,c(f)}function c(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return we(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),c)}}const Y4={tokenize:$4},Ab={tokenize:X4};function $4(e){const r=this,l=[];let i=0,o,u,c;return f;function f(_){if(i<l.length){const U=l[i];return r.containerState=U[1],e.attempt(U[0].continuation,d,m)(_)}return m(_)}function d(_){if(i++,r.containerState._closeFlow){r.containerState._closeFlow=void 0,o&&O();const U=r.events.length;let F=U,z;for(;F--;)if(r.events[F][0]==="exit"&&r.events[F][1].type==="chunkFlow"){z=r.events[F][1].end;break}N(i);let B=U;for(;B<r.events.length;)r.events[B][1].end={...z},B++;return ln(r.events,F+1,0,r.events.slice(U)),r.events.length=B,m(_)}return f(_)}function m(_){if(i===l.length){if(!o)return b(_);if(o.currentConstruct&&o.currentConstruct.concrete)return k(_);r.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return r.containerState={},e.check(Ab,g,y)(_)}function g(_){return o&&O(),N(i),b(_)}function y(_){return r.parser.lazy[r.now().line]=i!==l.length,c=r.now().offset,k(_)}function b(_){return r.containerState={},e.attempt(Ab,v,k)(_)}function v(_){return i++,l.push([r.currentConstruct,r.containerState]),b(_)}function k(_){if(_===null){o&&O(),N(0),e.consume(_);return}return o=o||r.parser.flow(r.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:u}),C(_)}function C(_){if(_===null){A(e.exit("chunkFlow"),!0),N(0),e.consume(_);return}return we(_)?(e.consume(_),A(e.exit("chunkFlow")),i=0,r.interrupt=void 0,f):(e.consume(_),C)}function A(_,U){const F=r.sliceStream(_);if(U&&F.push(null),_.previous=u,u&&(u.next=_),u=_,o.defineSkip(_.start),o.write(F),r.parser.lazy[_.start.line]){let z=o.events.length;for(;z--;)if(o.events[z][1].start.offset<c&&(!o.events[z][1].end||o.events[z][1].end.offset>c))return;const B=r.events.length;let $=B,ae,P;for(;$--;)if(r.events[$][0]==="exit"&&r.events[$][1].type==="chunkFlow"){if(ae){P=r.events[$][1].end;break}ae=!0}for(N(i),z=B;z<r.events.length;)r.events[z][1].end={...P},z++;ln(r.events,$+1,0,r.events.slice(B)),r.events.length=z}}function N(_){let U=l.length;for(;U-- >_;){const F=l[U];r.containerState=F[1],F[0].exit.call(r,e)}l.length=_}function O(){o.write([null]),u=void 0,o=void 0,r.containerState._closeFlow=void 0}}function X4(e,r,l){return Be(e,e.attempt(this.parser.constructs.document,r,l),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Di(e){if(e===null||Ze(e)||Ml(e))return 1;if(Lu(e))return 2}function Bu(e,r,l){const i=[];let o=-1;for(;++o<e.length;){const u=e[o].resolveAll;u&&!i.includes(u)&&(r=u(r,l),i.push(u))}return r}const uh={name:"attention",resolveAll:Q4,tokenize:Z4};function Q4(e,r){let l=-1,i,o,u,c,f,d,m,g;for(;++l<e.length;)if(e[l][0]==="enter"&&e[l][1].type==="attentionSequence"&&e[l][1]._close){for(i=l;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&r.sliceSerialize(e[i][1]).charCodeAt(0)===r.sliceSerialize(e[l][1]).charCodeAt(0)){if((e[i][1]._close||e[l][1]._open)&&(e[l][1].end.offset-e[l][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[l][1].end.offset-e[l][1].start.offset)%3))continue;d=e[i][1].end.offset-e[i][1].start.offset>1&&e[l][1].end.offset-e[l][1].start.offset>1?2:1;const y={...e[i][1].end},b={...e[l][1].start};jb(y,-d),jb(b,d),c={type:d>1?"strongSequence":"emphasisSequence",start:y,end:{...e[i][1].end}},f={type:d>1?"strongSequence":"emphasisSequence",start:{...e[l][1].start},end:b},u={type:d>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[l][1].start}},o={type:d>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[i][1].end={...c.start},e[l][1].start={...f.end},m=[],e[i][1].end.offset-e[i][1].start.offset&&(m=yn(m,[["enter",e[i][1],r],["exit",e[i][1],r]])),m=yn(m,[["enter",o,r],["enter",c,r],["exit",c,r],["enter",u,r]]),m=yn(m,Bu(r.parser.constructs.insideSpan.null,e.slice(i+1,l),r)),m=yn(m,[["exit",u,r],["enter",f,r],["exit",f,r],["exit",o,r]]),e[l][1].end.offset-e[l][1].start.offset?(g=2,m=yn(m,[["enter",e[l][1],r],["exit",e[l][1],r]])):g=0,ln(e,i-1,l-i+3,m),l=i+m.length-g-2;break}}for(l=-1;++l<e.length;)e[l][1].type==="attentionSequence"&&(e[l][1].type="data");return e}function Z4(e,r){const l=this.parser.constructs.attentionMarkers.null,i=this.previous,o=Di(i);let u;return c;function c(d){return u=d,e.enter("attentionSequence"),f(d)}function f(d){if(d===u)return e.consume(d),f;const m=e.exit("attentionSequence"),g=Di(d),y=!g||g===2&&o||l.includes(d),b=!o||o===2&&g||l.includes(i);return m._open=!!(u===42?y:y&&(o||!b)),m._close=!!(u===42?b:b&&(g||!y)),r(d)}}function jb(e,r){e.column+=r,e.offset+=r,e._bufferIndex+=r}const K4={name:"autolink",tokenize:J4};function J4(e,r,l){let i=0;return o;function o(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(v){return Dt(v)?(e.consume(v),c):v===64?l(v):m(v)}function c(v){return v===43||v===45||v===46||Tt(v)?(i=1,f(v)):m(v)}function f(v){return v===58?(e.consume(v),i=0,d):(v===43||v===45||v===46||Tt(v))&&i++<32?(e.consume(v),f):(i=0,m(v))}function d(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),r):v===null||v===32||v===60||cu(v)?l(v):(e.consume(v),d)}function m(v){return v===64?(e.consume(v),g):q4(v)?(e.consume(v),m):l(v)}function g(v){return Tt(v)?y(v):l(v)}function y(v){return v===46?(e.consume(v),i=0,g):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),r):b(v)}function b(v){if((v===45||Tt(v))&&i++<63){const k=v===45?b:y;return e.consume(v),k}return l(v)}}const mo={partial:!0,tokenize:W4};function W4(e,r,l){return i;function i(u){return Oe(u)?Be(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||we(u)?r(u):l(u)}}const mw={continuation:{tokenize:tM},exit:nM,name:"blockQuote",tokenize:eM};function eM(e,r,l){const i=this;return o;function o(c){if(c===62){const f=i.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),u}return l(c)}function u(c){return Oe(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),r):(e.exit("blockQuotePrefix"),r(c))}}function tM(e,r,l){const i=this;return o;function o(c){return Oe(c)?Be(e,u,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):u(c)}function u(c){return e.attempt(mw,r,l)(c)}}function nM(e){e.exit("blockQuote")}const pw={name:"characterEscape",tokenize:rM};function rM(e,r,l){return i;function i(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),o}function o(u){return V4(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),r):l(u)}}const gw={name:"characterReference",tokenize:lM};function lM(e,r,l){const i=this;let o=0,u,c;return f;function f(y){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),d}function d(y){return y===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(y),e.exit("characterReferenceMarkerNumeric"),m):(e.enter("characterReferenceValue"),u=31,c=Tt,g(y))}function m(y){return y===88||y===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(y),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,c=F4,g):(e.enter("characterReferenceValue"),u=7,c=sh,g(y))}function g(y){if(y===59&&o){const b=e.exit("characterReferenceValue");return c===Tt&&!im(i.sliceSerialize(b))?l(y):(e.enter("characterReferenceMarker"),e.consume(y),e.exit("characterReferenceMarker"),e.exit("characterReference"),r)}return c(y)&&o++<u?(e.consume(y),g):l(y)}}const Tb={partial:!0,tokenize:aM},_b={concrete:!0,name:"codeFenced",tokenize:iM};function iM(e,r,l){const i=this,o={partial:!0,tokenize:F};let u=0,c=0,f;return d;function d(z){return m(z)}function m(z){const B=i.events[i.events.length-1];return u=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,f=z,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(z)}function g(z){return z===f?(c++,e.consume(z),g):c<3?l(z):(e.exit("codeFencedFenceSequence"),Oe(z)?Be(e,y,"whitespace")(z):y(z))}function y(z){return z===null||we(z)?(e.exit("codeFencedFence"),i.interrupt?r(z):e.check(Tb,C,U)(z)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(z))}function b(z){return z===null||we(z)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),y(z)):Oe(z)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Be(e,v,"whitespace")(z)):z===96&&z===f?l(z):(e.consume(z),b)}function v(z){return z===null||we(z)?y(z):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(z))}function k(z){return z===null||we(z)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),y(z)):z===96&&z===f?l(z):(e.consume(z),k)}function C(z){return e.attempt(o,U,A)(z)}function A(z){return e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),N}function N(z){return u>0&&Oe(z)?Be(e,O,"linePrefix",u+1)(z):O(z)}function O(z){return z===null||we(z)?e.check(Tb,C,U)(z):(e.enter("codeFlowValue"),_(z))}function _(z){return z===null||we(z)?(e.exit("codeFlowValue"),O(z)):(e.consume(z),_)}function U(z){return e.exit("codeFenced"),r(z)}function F(z,B,$){let ae=0;return P;function P(Z){return z.enter("lineEnding"),z.consume(Z),z.exit("lineEnding"),re}function re(Z){return z.enter("codeFencedFence"),Oe(Z)?Be(z,le,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):le(Z)}function le(Z){return Z===f?(z.enter("codeFencedFenceSequence"),se(Z)):$(Z)}function se(Z){return Z===f?(ae++,z.consume(Z),se):ae>=c?(z.exit("codeFencedFenceSequence"),Oe(Z)?Be(z,J,"whitespace")(Z):J(Z)):$(Z)}function J(Z){return Z===null||we(Z)?(z.exit("codeFencedFence"),B(Z)):$(Z)}}}function aM(e,r,l){const i=this;return o;function o(c){return c===null?l(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u)}function u(c){return i.parser.lazy[i.now().line]?l(c):r(c)}}const Ed={name:"codeIndented",tokenize:sM},oM={partial:!0,tokenize:uM};function sM(e,r,l){const i=this;return o;function o(m){return e.enter("codeIndented"),Be(e,u,"linePrefix",5)(m)}function u(m){const g=i.events[i.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?c(m):l(m)}function c(m){return m===null?d(m):we(m)?e.attempt(oM,c,d)(m):(e.enter("codeFlowValue"),f(m))}function f(m){return m===null||we(m)?(e.exit("codeFlowValue"),c(m)):(e.consume(m),f)}function d(m){return e.exit("codeIndented"),r(m)}}function uM(e,r,l){const i=this;return o;function o(c){return i.parser.lazy[i.now().line]?l(c):we(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):Be(e,u,"linePrefix",5)(c)}function u(c){const f=i.events[i.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?r(c):we(c)?o(c):l(c)}}const cM={name:"codeText",previous:dM,resolve:fM,tokenize:hM};function fM(e){let r=e.length-4,l=3,i,o;if((e[l][1].type==="lineEnding"||e[l][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(i=l;++i<r;)if(e[i][1].type==="codeTextData"){e[l][1].type="codeTextPadding",e[r][1].type="codeTextPadding",l+=2,r-=2;break}}for(i=l-1,r++;++i<=r;)o===void 0?i!==r&&e[i][1].type!=="lineEnding"&&(o=i):(i===r||e[i][1].type==="lineEnding")&&(e[o][1].type="codeTextData",i!==o+2&&(e[o][1].end=e[i-1][1].end,e.splice(o+2,i-o-2),r-=i-o-2,i=o+2),o=void 0);return e}function dM(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hM(e,r,l){let i=0,o,u;return c;function c(y){return e.enter("codeText"),e.enter("codeTextSequence"),f(y)}function f(y){return y===96?(e.consume(y),i++,f):(e.exit("codeTextSequence"),d(y))}function d(y){return y===null?l(y):y===32?(e.enter("space"),e.consume(y),e.exit("space"),d):y===96?(u=e.enter("codeTextSequence"),o=0,g(y)):we(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),d):(e.enter("codeTextData"),m(y))}function m(y){return y===null||y===32||y===96||we(y)?(e.exit("codeTextData"),d(y)):(e.consume(y),m)}function g(y){return y===96?(e.consume(y),o++,g):o===i?(e.exit("codeTextSequence"),e.exit("codeText"),r(y)):(u.type="codeTextData",m(y))}}class mM{constructor(r){this.left=r?[...r]:[],this.right=[]}get(r){if(r<0||r>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return r<this.left.length?this.left[r]:this.right[this.right.length-r+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(r,l){const i=l??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(r,i):r>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(r,l,i){const o=l||0;this.setCursor(Math.trunc(r));const u=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return i&&Ia(this.left,i),u.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),Ia(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),Ia(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r<this.left.length){const l=this.left.splice(r,Number.POSITIVE_INFINITY);Ia(this.right,l.reverse())}else{const l=this.right.splice(this.left.length+this.right.length-r,Number.POSITIVE_INFINITY);Ia(this.left,l.reverse())}}}function Ia(e,r){let l=0;if(r.length<1e4)e.push(...r);else for(;l<r.length;)e.push(...r.slice(l,l+1e4)),l+=1e4}function yw(e){const r={};let l=-1,i,o,u,c,f,d,m;const g=new mM(e);for(;++l<g.length;){for(;l in r;)l=r[l];if(i=g.get(l),l&&i[1].type==="chunkFlow"&&g.get(l-1)[1].type==="listItemPrefix"&&(d=i[1]._tokenizer.events,u=0,u<d.length&&d[u][1].type==="lineEndingBlank"&&(u+=2),u<d.length&&d[u][1].type==="content"))for(;++u<d.length&&d[u][1].type!=="content";)d[u][1].type==="chunkText"&&(d[u][1]._isInFirstContentOfListItem=!0,u++);if(i[0]==="enter")i[1].contentType&&(Object.assign(r,pM(g,l)),l=r[l],m=!0);else if(i[1]._container){for(u=l,o=void 0;u--;)if(c=g.get(u),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(g.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=u);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(i[1].end={...g.get(o)[1].start},f=g.slice(o,l),f.unshift(i),g.splice(o,l-o+1,f))}}return ln(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!m}function pM(e,r){const l=e.get(r)[1],i=e.get(r)[2];let o=r-1;const u=[];let c=l._tokenizer;c||(c=i.parser[l.contentType](l.start),l._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const f=c.events,d=[],m={};let g,y,b=-1,v=l,k=0,C=0;const A=[C];for(;v;){for(;e.get(++o)[1]!==v;);u.push(o),v._tokenizer||(g=i.sliceStream(v),v.next||g.push(null),y&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(g),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),y=v,v=v.next}for(v=l;++b<f.length;)f[b][0]==="exit"&&f[b-1][0]==="enter"&&f[b][1].type===f[b-1][1].type&&f[b][1].start.line!==f[b][1].end.line&&(C=b+1,A.push(C),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(c.events=[],v?(v._tokenizer=void 0,v.previous=void 0):A.pop(),b=A.length;b--;){const N=f.slice(A[b],A[b+1]),O=u.pop();d.push([O,O+N.length-1]),e.splice(O,2,N)}for(d.reverse(),b=-1;++b<d.length;)m[k+d[b][0]]=k+d[b][1],k+=d[b][1]-d[b][0]-1;return m}const gM={resolve:xM,tokenize:bM},yM={partial:!0,tokenize:vM};function xM(e){return yw(e),e}function bM(e,r){let l;return i;function i(f){return e.enter("content"),l=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?u(f):we(f)?e.check(yM,c,u)(f):(e.consume(f),o)}function u(f){return e.exit("chunkContent"),e.exit("content"),r(f)}function c(f){return e.consume(f),e.exit("chunkContent"),l.next=e.enter("chunkContent",{contentType:"content",previous:l}),l=l.next,o}}function vM(e,r,l){const i=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Be(e,u,"linePrefix")}function u(c){if(c===null||we(c))return l(c);const f=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?r(c):e.interrupt(i.parser.constructs.flow,l,r)(c)}}function xw(e,r,l,i,o,u,c,f,d){const m=d||Number.POSITIVE_INFINITY;let g=0;return y;function y(N){return N===60?(e.enter(i),e.enter(o),e.enter(u),e.consume(N),e.exit(u),b):N===null||N===32||N===41||cu(N)?l(N):(e.enter(i),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),C(N))}function b(N){return N===62?(e.enter(u),e.consume(N),e.exit(u),e.exit(o),e.exit(i),r):(e.enter(f),e.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===62?(e.exit("chunkString"),e.exit(f),b(N)):N===null||N===60||we(N)?l(N):(e.consume(N),N===92?k:v)}function k(N){return N===60||N===62||N===92?(e.consume(N),v):v(N)}function C(N){return!g&&(N===null||N===41||Ze(N))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(i),r(N)):g<m&&N===40?(e.consume(N),g++,C):N===41?(e.consume(N),g--,C):N===null||N===32||N===40||cu(N)?l(N):(e.consume(N),N===92?A:C)}function A(N){return N===40||N===41||N===92?(e.consume(N),C):C(N)}}function bw(e,r,l,i,o,u){const c=this;let f=0,d;return m;function m(v){return e.enter(i),e.enter(o),e.consume(v),e.exit(o),e.enter(u),g}function g(v){return f>999||v===null||v===91||v===93&&!d||v===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?l(v):v===93?(e.exit(u),e.enter(o),e.consume(v),e.exit(o),e.exit(i),r):we(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===null||v===91||v===93||we(v)||f++>999?(e.exit("chunkString"),g(v)):(e.consume(v),d||(d=!Oe(v)),v===92?b:y)}function b(v){return v===91||v===92||v===93?(e.consume(v),f++,y):y(v)}}function vw(e,r,l,i,o,u){let c;return f;function f(b){return b===34||b===39||b===40?(e.enter(i),e.enter(o),e.consume(b),e.exit(o),c=b===40?41:b,d):l(b)}function d(b){return b===c?(e.enter(o),e.consume(b),e.exit(o),e.exit(i),r):(e.enter(u),m(b))}function m(b){return b===c?(e.exit(u),d(c)):b===null?l(b):we(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Be(e,m,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===c||b===null||we(b)?(e.exit("chunkString"),m(b)):(e.consume(b),b===92?y:g)}function y(b){return b===c||b===92?(e.consume(b),g):g(b)}}function Ka(e,r){let l;return i;function i(o){return we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l=!0,i):Oe(o)?Be(e,i,l?"linePrefix":"lineSuffix")(o):r(o)}}const wM={name:"definition",tokenize:kM},SM={partial:!0,tokenize:CM};function kM(e,r,l){const i=this;let o;return u;function u(v){return e.enter("definition"),c(v)}function c(v){return bw.call(i,e,f,l,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function f(v){return o=kn(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),d):l(v)}function d(v){return Ze(v)?Ka(e,m)(v):m(v)}function m(v){return xw(e,g,l,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function g(v){return e.attempt(SM,y,y)(v)}function y(v){return Oe(v)?Be(e,b,"whitespace")(v):b(v)}function b(v){return v===null||we(v)?(e.exit("definition"),i.parser.defined.push(o),r(v)):l(v)}}function CM(e,r,l){return i;function i(f){return Ze(f)?Ka(e,o)(f):l(f)}function o(f){return vw(e,u,l,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return Oe(f)?Be(e,c,"whitespace")(f):c(f)}function c(f){return f===null||we(f)?r(f):l(f)}}const EM={name:"hardBreakEscape",tokenize:NM};function NM(e,r,l){return i;function i(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return we(u)?(e.exit("hardBreakEscape"),r(u)):l(u)}}const AM={name:"headingAtx",resolve:jM,tokenize:TM};function jM(e,r){let l=e.length-2,i=3,o,u;return e[i][1].type==="whitespace"&&(i+=2),l-2>i&&e[l][1].type==="whitespace"&&(l-=2),e[l][1].type==="atxHeadingSequence"&&(i===l-1||l-4>i&&e[l-2][1].type==="whitespace")&&(l-=i+1===l?2:4),l>i&&(o={type:"atxHeadingText",start:e[i][1].start,end:e[l][1].end},u={type:"chunkText",start:e[i][1].start,end:e[l][1].end,contentType:"text"},ln(e,i,l-i+1,[["enter",o,r],["enter",u,r],["exit",u,r],["exit",o,r]])),e}function TM(e,r,l){let i=0;return o;function o(g){return e.enter("atxHeading"),u(g)}function u(g){return e.enter("atxHeadingSequence"),c(g)}function c(g){return g===35&&i++<6?(e.consume(g),c):g===null||Ze(g)?(e.exit("atxHeadingSequence"),f(g)):l(g)}function f(g){return g===35?(e.enter("atxHeadingSequence"),d(g)):g===null||we(g)?(e.exit("atxHeading"),r(g)):Oe(g)?Be(e,f,"whitespace")(g):(e.enter("atxHeadingText"),m(g))}function d(g){return g===35?(e.consume(g),d):(e.exit("atxHeadingSequence"),f(g))}function m(g){return g===null||g===35||Ze(g)?(e.exit("atxHeadingText"),f(g)):(e.consume(g),m)}}const _M=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Rb=["pre","script","style","textarea"],RM={concrete:!0,name:"htmlFlow",resolveTo:zM,tokenize:DM},MM={partial:!0,tokenize:BM},OM={partial:!0,tokenize:LM};function zM(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function DM(e,r,l){const i=this;let o,u,c,f,d;return m;function m(T){return g(T)}function g(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),y}function y(T){return T===33?(e.consume(T),b):T===47?(e.consume(T),u=!0,C):T===63?(e.consume(T),o=3,i.interrupt?r:j):Dt(T)?(e.consume(T),c=String.fromCharCode(T),A):l(T)}function b(T){return T===45?(e.consume(T),o=2,v):T===91?(e.consume(T),o=5,f=0,k):Dt(T)?(e.consume(T),o=4,i.interrupt?r:j):l(T)}function v(T){return T===45?(e.consume(T),i.interrupt?r:j):l(T)}function k(T){const ue="CDATA[";return T===ue.charCodeAt(f++)?(e.consume(T),f===ue.length?i.interrupt?r:le:k):l(T)}function C(T){return Dt(T)?(e.consume(T),c=String.fromCharCode(T),A):l(T)}function A(T){if(T===null||T===47||T===62||Ze(T)){const ue=T===47,de=c.toLowerCase();return!ue&&!u&&Rb.includes(de)?(o=1,i.interrupt?r(T):le(T)):_M.includes(c.toLowerCase())?(o=6,ue?(e.consume(T),N):i.interrupt?r(T):le(T)):(o=7,i.interrupt&&!i.parser.lazy[i.now().line]?l(T):u?O(T):_(T))}return T===45||Tt(T)?(e.consume(T),c+=String.fromCharCode(T),A):l(T)}function N(T){return T===62?(e.consume(T),i.interrupt?r:le):l(T)}function O(T){return Oe(T)?(e.consume(T),O):P(T)}function _(T){return T===47?(e.consume(T),P):T===58||T===95||Dt(T)?(e.consume(T),U):Oe(T)?(e.consume(T),_):P(T)}function U(T){return T===45||T===46||T===58||T===95||Tt(T)?(e.consume(T),U):F(T)}function F(T){return T===61?(e.consume(T),z):Oe(T)?(e.consume(T),F):_(T)}function z(T){return T===null||T===60||T===61||T===62||T===96?l(T):T===34||T===39?(e.consume(T),d=T,B):Oe(T)?(e.consume(T),z):$(T)}function B(T){return T===d?(e.consume(T),d=null,ae):T===null||we(T)?l(T):(e.consume(T),B)}function $(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||Ze(T)?F(T):(e.consume(T),$)}function ae(T){return T===47||T===62||Oe(T)?_(T):l(T)}function P(T){return T===62?(e.consume(T),re):l(T)}function re(T){return T===null||we(T)?le(T):Oe(T)?(e.consume(T),re):l(T)}function le(T){return T===45&&o===2?(e.consume(T),D):T===60&&o===1?(e.consume(T),X):T===62&&o===4?(e.consume(T),R):T===63&&o===3?(e.consume(T),j):T===93&&o===5?(e.consume(T),ie):we(T)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(MM,G,se)(T)):T===null||we(T)?(e.exit("htmlFlowData"),se(T)):(e.consume(T),le)}function se(T){return e.check(OM,J,G)(T)}function J(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),Z}function Z(T){return T===null||we(T)?se(T):(e.enter("htmlFlowData"),le(T))}function D(T){return T===45?(e.consume(T),j):le(T)}function X(T){return T===47?(e.consume(T),c="",ne):le(T)}function ne(T){if(T===62){const ue=c.toLowerCase();return Rb.includes(ue)?(e.consume(T),R):le(T)}return Dt(T)&&c.length<8?(e.consume(T),c+=String.fromCharCode(T),ne):le(T)}function ie(T){return T===93?(e.consume(T),j):le(T)}function j(T){return T===62?(e.consume(T),R):T===45&&o===2?(e.consume(T),j):le(T)}function R(T){return T===null||we(T)?(e.exit("htmlFlowData"),G(T)):(e.consume(T),R)}function G(T){return e.exit("htmlFlow"),r(T)}}function LM(e,r,l){const i=this;return o;function o(c){return we(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):l(c)}function u(c){return i.parser.lazy[i.now().line]?l(c):r(c)}}function BM(e,r,l){return i;function i(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(mo,r,l)}}const UM={name:"htmlText",tokenize:HM};function HM(e,r,l){const i=this;let o,u,c;return f;function f(j){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),m):j===47?(e.consume(j),F):j===63?(e.consume(j),_):Dt(j)?(e.consume(j),$):l(j)}function m(j){return j===45?(e.consume(j),g):j===91?(e.consume(j),u=0,k):Dt(j)?(e.consume(j),O):l(j)}function g(j){return j===45?(e.consume(j),v):l(j)}function y(j){return j===null?l(j):j===45?(e.consume(j),b):we(j)?(c=y,X(j)):(e.consume(j),y)}function b(j){return j===45?(e.consume(j),v):y(j)}function v(j){return j===62?D(j):j===45?b(j):y(j)}function k(j){const R="CDATA[";return j===R.charCodeAt(u++)?(e.consume(j),u===R.length?C:k):l(j)}function C(j){return j===null?l(j):j===93?(e.consume(j),A):we(j)?(c=C,X(j)):(e.consume(j),C)}function A(j){return j===93?(e.consume(j),N):C(j)}function N(j){return j===62?D(j):j===93?(e.consume(j),N):C(j)}function O(j){return j===null||j===62?D(j):we(j)?(c=O,X(j)):(e.consume(j),O)}function _(j){return j===null?l(j):j===63?(e.consume(j),U):we(j)?(c=_,X(j)):(e.consume(j),_)}function U(j){return j===62?D(j):_(j)}function F(j){return Dt(j)?(e.consume(j),z):l(j)}function z(j){return j===45||Tt(j)?(e.consume(j),z):B(j)}function B(j){return we(j)?(c=B,X(j)):Oe(j)?(e.consume(j),B):D(j)}function $(j){return j===45||Tt(j)?(e.consume(j),$):j===47||j===62||Ze(j)?ae(j):l(j)}function ae(j){return j===47?(e.consume(j),D):j===58||j===95||Dt(j)?(e.consume(j),P):we(j)?(c=ae,X(j)):Oe(j)?(e.consume(j),ae):D(j)}function P(j){return j===45||j===46||j===58||j===95||Tt(j)?(e.consume(j),P):re(j)}function re(j){return j===61?(e.consume(j),le):we(j)?(c=re,X(j)):Oe(j)?(e.consume(j),re):ae(j)}function le(j){return j===null||j===60||j===61||j===62||j===96?l(j):j===34||j===39?(e.consume(j),o=j,se):we(j)?(c=le,X(j)):Oe(j)?(e.consume(j),le):(e.consume(j),J)}function se(j){return j===o?(e.consume(j),o=void 0,Z):j===null?l(j):we(j)?(c=se,X(j)):(e.consume(j),se)}function J(j){return j===null||j===34||j===39||j===60||j===61||j===96?l(j):j===47||j===62||Ze(j)?ae(j):(e.consume(j),J)}function Z(j){return j===47||j===62||Ze(j)?ae(j):l(j)}function D(j){return j===62?(e.consume(j),e.exit("htmlTextData"),e.exit("htmlText"),r):l(j)}function X(j){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),ne}function ne(j){return Oe(j)?Be(e,ie,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):ie(j)}function ie(j){return e.enter("htmlTextData"),c(j)}}const am={name:"labelEnd",resolveAll:VM,resolveTo:IM,tokenize:GM},PM={tokenize:YM},qM={tokenize:$M},FM={tokenize:XM};function VM(e){let r=-1;const l=[];for(;++r<e.length;){const i=e[r][1];if(l.push(e[r]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const o=i.type==="labelImage"?4:2;i.type="data",r+=o}}return e.length!==l.length&&ln(e,0,e.length,l),e}function IM(e,r){let l=e.length,i=0,o,u,c,f;for(;l--;)if(o=e[l][1],u){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[l][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[l][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(u=l,o.type!=="labelLink")){i=2;break}}else o.type==="labelEnd"&&(c=l);const d={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},m={type:"label",start:{...e[u][1].start},end:{...e[c][1].end}},g={type:"labelText",start:{...e[u+i+2][1].end},end:{...e[c-2][1].start}};return f=[["enter",d,r],["enter",m,r]],f=yn(f,e.slice(u+1,u+i+3)),f=yn(f,[["enter",g,r]]),f=yn(f,Bu(r.parser.constructs.insideSpan.null,e.slice(u+i+4,c-3),r)),f=yn(f,[["exit",g,r],e[c-2],e[c-1],["exit",m,r]]),f=yn(f,e.slice(c+1)),f=yn(f,[["exit",d,r]]),ln(e,u,e.length,f),e}function GM(e,r,l){const i=this;let o=i.events.length,u,c;for(;o--;)if((i.events[o][1].type==="labelImage"||i.events[o][1].type==="labelLink")&&!i.events[o][1]._balanced){u=i.events[o][1];break}return f;function f(b){return u?u._inactive?y(b):(c=i.parser.defined.includes(kn(i.sliceSerialize({start:u.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),d):l(b)}function d(b){return b===40?e.attempt(PM,g,c?g:y)(b):b===91?e.attempt(qM,g,c?m:y)(b):c?g(b):y(b)}function m(b){return e.attempt(FM,g,y)(b)}function g(b){return r(b)}function y(b){return u._balanced=!0,l(b)}}function YM(e,r,l){return i;function i(y){return e.enter("resource"),e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),o}function o(y){return Ze(y)?Ka(e,u)(y):u(y)}function u(y){return y===41?g(y):xw(e,c,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(y)}function c(y){return Ze(y)?Ka(e,d)(y):g(y)}function f(y){return l(y)}function d(y){return y===34||y===39||y===40?vw(e,m,l,"resourceTitle","resourceTitleMarker","resourceTitleString")(y):g(y)}function m(y){return Ze(y)?Ka(e,g)(y):g(y)}function g(y){return y===41?(e.enter("resourceMarker"),e.consume(y),e.exit("resourceMarker"),e.exit("resource"),r):l(y)}}function $M(e,r,l){const i=this;return o;function o(f){return bw.call(i,e,u,c,"reference","referenceMarker","referenceString")(f)}function u(f){return i.parser.defined.includes(kn(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?r(f):l(f)}function c(f){return l(f)}}function XM(e,r,l){return i;function i(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),o}function o(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),r):l(u)}}const QM={name:"labelStartImage",resolveAll:am.resolveAll,tokenize:ZM};function ZM(e,r,l){const i=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),u}function u(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),c):l(f)}function c(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?l(f):r(f)}}const KM={name:"labelStartLink",resolveAll:am.resolveAll,tokenize:JM};function JM(e,r,l){const i=this;return o;function o(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),u}function u(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?l(c):r(c)}}const Nd={name:"lineEnding",tokenize:WM};function WM(e,r){return l;function l(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Be(e,r,"linePrefix")}}const Js={name:"thematicBreak",tokenize:eO};function eO(e,r,l){let i=0,o;return u;function u(m){return e.enter("thematicBreak"),c(m)}function c(m){return o=m,f(m)}function f(m){return m===o?(e.enter("thematicBreakSequence"),d(m)):i>=3&&(m===null||we(m))?(e.exit("thematicBreak"),r(m)):l(m)}function d(m){return m===o?(e.consume(m),i++,d):(e.exit("thematicBreakSequence"),Oe(m)?Be(e,f,"whitespace")(m):f(m))}}const Gt={continuation:{tokenize:lO},exit:aO,name:"list",tokenize:rO},tO={partial:!0,tokenize:oO},nO={partial:!0,tokenize:iO};function rO(e,r,l){const i=this,o=i.events[i.events.length-1];let u=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return f;function f(v){const k=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:sh(v)){if(i.containerState.type||(i.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(Js,l,m)(v):m(v);if(!i.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(v)}return l(v)}function d(v){return sh(v)&&++c<10?(e.consume(v),d):(!i.interrupt||c<2)&&(i.containerState.marker?v===i.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),m(v)):l(v)}function m(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||v,e.check(mo,i.interrupt?l:g,e.attempt(tO,b,y))}function g(v){return i.containerState.initialBlankLine=!0,u++,b(v)}function y(v){return Oe(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),b):l(v)}function b(v){return i.containerState.size=u+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(v)}}function lO(e,r,l){const i=this;return i.containerState._closeFlow=void 0,e.check(mo,o,u);function o(f){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Be(e,r,"listItemIndent",i.containerState.size+1)(f)}function u(f){return i.containerState.furtherBlankLines||!Oe(f)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,c(f)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(nO,r,c)(f))}function c(f){return i.containerState._closeFlow=!0,i.interrupt=void 0,Be(e,e.attempt(Gt,r,l),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function iO(e,r,l){const i=this;return Be(e,o,"listItemIndent",i.containerState.size+1);function o(u){const c=i.events[i.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===i.containerState.size?r(u):l(u)}}function aO(e){e.exit(this.containerState.type)}function oO(e,r,l){const i=this;return Be(e,o,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(u){const c=i.events[i.events.length-1];return!Oe(u)&&c&&c[1].type==="listItemPrefixWhitespace"?r(u):l(u)}}const Mb={name:"setextUnderline",resolveTo:sO,tokenize:uO};function sO(e,r){let l=e.length,i,o,u;for(;l--;)if(e[l][0]==="enter"){if(e[l][1].type==="content"){i=l;break}e[l][1].type==="paragraph"&&(o=l)}else e[l][1].type==="content"&&e.splice(l,1),!u&&e[l][1].type==="definition"&&(u=l);const c={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",u?(e.splice(o,0,["enter",c,r]),e.splice(u+1,0,["exit",e[i][1],r]),e[i][1].end={...e[u][1].end}):e[i][1]=c,e.push(["exit",c,r]),e}function uO(e,r,l){const i=this;let o;return u;function u(m){let g=i.events.length,y;for(;g--;)if(i.events[g][1].type!=="lineEnding"&&i.events[g][1].type!=="linePrefix"&&i.events[g][1].type!=="content"){y=i.events[g][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||y)?(e.enter("setextHeadingLine"),o=m,c(m)):l(m)}function c(m){return e.enter("setextHeadingLineSequence"),f(m)}function f(m){return m===o?(e.consume(m),f):(e.exit("setextHeadingLineSequence"),Oe(m)?Be(e,d,"lineSuffix")(m):d(m))}function d(m){return m===null||we(m)?(e.exit("setextHeadingLine"),r(m)):l(m)}}const cO={tokenize:fO};function fO(e){const r=this,l=e.attempt(mo,i,e.attempt(this.parser.constructs.flowInitial,o,Be(e,e.attempt(this.parser.constructs.flow,o,e.attempt(gM,o)),"linePrefix")));return l;function i(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),r.currentConstruct=void 0,l}function o(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),r.currentConstruct=void 0,l}}const dO={resolveAll:Sw()},hO=ww("string"),mO=ww("text");function ww(e){return{resolveAll:Sw(e==="text"?pO:void 0),tokenize:r};function r(l){const i=this,o=this.parser.constructs[e],u=l.attempt(o,c,f);return c;function c(g){return m(g)?u(g):f(g)}function f(g){if(g===null){l.consume(g);return}return l.enter("data"),l.consume(g),d}function d(g){return m(g)?(l.exit("data"),u(g)):(l.consume(g),d)}function m(g){if(g===null)return!0;const y=o[g];let b=-1;if(y)for(;++b<y.length;){const v=y[b];if(!v.previous||v.previous.call(i,i.previous))return!0}return!1}}}function Sw(e){return r;function r(l,i){let o=-1,u;for(;++o<=l.length;)u===void 0?l[o]&&l[o][1].type==="data"&&(u=o,o++):(!l[o]||l[o][1].type!=="data")&&(o!==u+2&&(l[u][1].end=l[o-1][1].end,l.splice(u+2,o-u-2),o=u+2),u=void 0);return e?e(l,i):l}}function pO(e,r){let l=0;for(;++l<=e.length;)if((l===e.length||e[l][1].type==="lineEnding")&&e[l-1][1].type==="data"){const i=e[l-1][1],o=r.sliceStream(i);let u=o.length,c=-1,f=0,d;for(;u--;){const m=o[u];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(m===-2)d=!0,f++;else if(m!==-1){u++;break}}if(r._contentTypeTextTrailing&&l===e.length&&(f=0),f){const m={type:l===e.length||d||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?c:i.start._bufferIndex+c,_index:i.start._index+u,line:i.end.line,column:i.end.column-f,offset:i.end.offset-f},end:{...i.end}};i.end={...m.start},i.start.offset===i.end.offset?Object.assign(i,m):(e.splice(l,0,["enter",m,r],["exit",m,r]),l+=2)}l++}return e}const gO={42:Gt,43:Gt,45:Gt,48:Gt,49:Gt,50:Gt,51:Gt,52:Gt,53:Gt,54:Gt,55:Gt,56:Gt,57:Gt,62:mw},yO={91:wM},xO={[-2]:Ed,[-1]:Ed,32:Ed},bO={35:AM,42:Js,45:[Mb,Js],60:RM,61:Mb,95:Js,96:_b,126:_b},vO={38:gw,92:pw},wO={[-5]:Nd,[-4]:Nd,[-3]:Nd,33:QM,38:gw,42:uh,60:[K4,UM],91:KM,92:[EM,pw],93:am,95:uh,96:cM},SO={null:[uh,dO]},kO={null:[42,95]},CO={null:[]},EO=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kO,contentInitial:yO,disable:CO,document:gO,flow:bO,flowInitial:xO,insideSpan:SO,string:vO,text:wO},Symbol.toStringTag,{value:"Module"}));function NO(e,r,l){let i={_bufferIndex:-1,_index:0,line:l&&l.line||1,column:l&&l.column||1,offset:l&&l.offset||0};const o={},u=[];let c=[],f=[];const d={attempt:B(F),check:B(z),consume:O,enter:_,exit:U,interrupt:B(z,{interrupt:!0})},m={code:null,containerState:{},defineSkip:C,events:[],now:k,parser:e,previous:null,sliceSerialize:b,sliceStream:v,write:y};let g=r.tokenize.call(m,d);return r.resolveAll&&u.push(r),m;function y(re){return c=yn(c,re),A(),c[c.length-1]!==null?[]:($(r,0),m.events=Bu(u,m.events,m),m.events)}function b(re,le){return jO(v(re),le)}function v(re){return AO(c,re)}function k(){const{_bufferIndex:re,_index:le,line:se,column:J,offset:Z}=i;return{_bufferIndex:re,_index:le,line:se,column:J,offset:Z}}function C(re){o[re.line]=re.column,P()}function A(){let re;for(;i._index<c.length;){const le=c[i._index];if(typeof le=="string")for(re=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===re&&i._bufferIndex<le.length;)N(le.charCodeAt(i._bufferIndex));else N(le)}}function N(re){g=g(re)}function O(re){we(re)?(i.line++,i.column=1,i.offset+=re===-3?2:1,P()):re!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===c[i._index].length&&(i._bufferIndex=-1,i._index++)),m.previous=re}function _(re,le){const se=le||{};return se.type=re,se.start=k(),m.events.push(["enter",se,m]),f.push(se),se}function U(re){const le=f.pop();return le.end=k(),m.events.push(["exit",le,m]),le}function F(re,le){$(re,le.from)}function z(re,le){le.restore()}function B(re,le){return se;function se(J,Z,D){let X,ne,ie,j;return Array.isArray(J)?G(J):"tokenize"in J?G([J]):R(J);function R(ce){return Ce;function Ce(Ue){const ve=Ue!==null&&ce[Ue],at=Ue!==null&&ce.null,dt=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(at)?at:at?[at]:[]];return G(dt)(Ue)}}function G(ce){return X=ce,ne=0,ce.length===0?D:T(ce[ne])}function T(ce){return Ce;function Ce(Ue){return j=ae(),ie=ce,ce.partial||(m.currentConstruct=ce),ce.name&&m.parser.constructs.disable.null.includes(ce.name)?de():ce.tokenize.call(le?Object.assign(Object.create(m),le):m,d,ue,de)(Ue)}}function ue(ce){return re(ie,j),Z}function de(ce){return j.restore(),++ne<X.length?T(X[ne]):D}}}function $(re,le){re.resolveAll&&!u.includes(re)&&u.push(re),re.resolve&&ln(m.events,le,m.events.length-le,re.resolve(m.events.slice(le),m)),re.resolveTo&&(m.events=re.resolveTo(m.events,m))}function ae(){const re=k(),le=m.previous,se=m.currentConstruct,J=m.events.length,Z=Array.from(f);return{from:J,restore:D};function D(){i=re,m.previous=le,m.currentConstruct=se,m.events.length=J,f=Z,P()}}function P(){i.line in o&&i.column<2&&(i.column=o[i.line],i.offset+=o[i.line]-1)}}function AO(e,r){const l=r.start._index,i=r.start._bufferIndex,o=r.end._index,u=r.end._bufferIndex;let c;if(l===o)c=[e[l].slice(i,u)];else{if(c=e.slice(l,o),i>-1){const f=c[0];typeof f=="string"?c[0]=f.slice(i):c.shift()}u>0&&c.push(e[o].slice(0,u))}return c}function jO(e,r){let l=-1;const i=[];let o;for(;++l<e.length;){const u=e[l];let c;if(typeof u=="string")c=u;else switch(u){case-5:{c="\r";break}case-4:{c=`
386
386
  `;break}case-3:{c=`\r
387
387
  `;break}case-2:{c=r?" ":" ";break}case-1:{if(!r&&o)continue;c=" ";break}default:c=String.fromCharCode(u)}o=u===-2,i.push(c)}return i.join("")}function TO(e){const i={constructs:dw([EO,...(e||{}).extensions||[]]),content:o(I4),defined:[],document:o(Y4),flow:o(cO),lazy:{},string:o(hO),text:o(mO)};return i;function o(u){return c;function c(f){return NO(i,u,f)}}}function _O(e){for(;!yw(e););return e}const Ob=/[\0\t\n\r]/g;function RO(){let e=1,r="",l=!0,i;return o;function o(u,c,f){const d=[];let m,g,y,b,v;for(u=r+(typeof u=="string"?u.toString():new TextDecoder(c||void 0).decode(u)),y=0,r="",l&&(u.charCodeAt(0)===65279&&y++,l=void 0);y<u.length;){if(Ob.lastIndex=y,m=Ob.exec(u),b=m&&m.index!==void 0?m.index:u.length,v=u.charCodeAt(b),!m){r=u.slice(y);break}if(v===10&&y===b&&i)d.push(-3),i=void 0;else switch(i&&(d.push(-5),i=void 0),y<b&&(d.push(u.slice(y,b)),e+=b-y),v){case 0:{d.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,d.push(-2);e++<g;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:i=!0,e=1}y=b+1}return f&&(i&&d.push(-5),r&&d.push(r),d.push(null)),d}}const MO=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function OO(e){return e.replace(MO,zO)}function zO(e,r,l){if(r)return r;if(l.charCodeAt(0)===35){const o=l.charCodeAt(1),u=o===120||o===88;return hw(l.slice(u?2:1),u?16:10)}return im(l)||e}const kw={}.hasOwnProperty;function DO(e,r,l){return r&&typeof r=="object"&&(l=r,r=void 0),LO(l)(_O(TO(l).document().write(RO()(e,r,!0))))}function LO(e){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u($t),autolinkProtocol:ae,autolinkEmail:ae,atxHeading:u(jn),blockQuote:u(at),characterEscape:ae,characterReference:ae,codeFenced:u(dt),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:u(dt,c),codeText:u(At,c),codeTextData:ae,data:ae,codeFlowValue:ae,definition:u(wt),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:u(ht),hardBreakEscape:u(Tn),hardBreakTrailing:u(Tn),htmlFlow:u(xr,c),htmlFlowData:ae,htmlText:u(xr,c),htmlTextData:ae,image:u(br),label:c,link:u($t),listItem:u(al),listItemValue:b,listOrdered:u(vr,y),listUnordered:u(vr),paragraph:u(Ii),reference:T,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:u(jn),strong:u(Ll),thematicBreak:u(Bl)},exit:{atxHeading:d(),atxHeadingSequence:F,autolink:d(),autolinkEmail:ve,autolinkProtocol:Ue,blockQuote:d(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:de,characterReferenceMarkerNumeric:de,characterReferenceValue:ce,characterReference:Ce,codeFenced:d(A),codeFencedFence:C,codeFencedFenceInfo:v,codeFencedFenceMeta:k,codeFlowValue:P,codeIndented:d(N),codeText:d(Z),codeTextData:P,data:P,definition:d(),definitionDestinationString:U,definitionLabelString:O,definitionTitleString:_,emphasis:d(),hardBreakEscape:d(le),hardBreakTrailing:d(le),htmlFlow:d(se),htmlFlowData:P,htmlText:d(J),htmlTextData:P,image:d(X),label:ie,labelText:ne,lineEnding:re,link:d(D),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ue,resourceDestinationString:j,resourceTitleString:R,resource:G,setextHeading:d($),setextHeadingLineSequence:B,setextHeadingText:z,strong:d(),thematicBreak:d()}};Cw(r,(e||{}).mdastExtensions||[]);const l={};return i;function i(H){let K={type:"root",children:[]};const fe={stack:[K],tokenStack:[],config:r,enter:f,exit:m,buffer:c,resume:g,data:l},ge=[];let Ee=-1;for(;++Ee<H.length;)if(H[Ee][1].type==="listOrdered"||H[Ee][1].type==="listUnordered")if(H[Ee][0]==="enter")ge.push(Ee);else{const Lt=ge.pop();Ee=o(H,Lt,Ee)}for(Ee=-1;++Ee<H.length;){const Lt=r[H[Ee][0]];kw.call(Lt,H[Ee][1].type)&&Lt[H[Ee][1].type].call(Object.assign({sliceSerialize:H[Ee][2].sliceSerialize},fe),H[Ee][1])}if(fe.tokenStack.length>0){const Lt=fe.tokenStack[fe.tokenStack.length-1];(Lt[1]||zb).call(fe,void 0,Lt[0])}for(K.position={start:Xr(H.length>0?H[0][1].start:{line:1,column:1,offset:0}),end:Xr(H.length>0?H[H.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<r.transforms.length;)K=r.transforms[Ee](K)||K;return K}function o(H,K,fe){let ge=K-1,Ee=-1,Lt=!1,Gn,Mt,mt,Bt;for(;++ge<=fe;){const Xe=H[ge];switch(Xe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Xe[0]==="enter"?Ee++:Ee--,Bt=void 0;break}case"lineEndingBlank":{Xe[0]==="enter"&&(Gn&&!Bt&&!Ee&&!mt&&(mt=ge),Bt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Bt=void 0}if(!Ee&&Xe[0]==="enter"&&Xe[1].type==="listItemPrefix"||Ee===-1&&Xe[0]==="exit"&&(Xe[1].type==="listUnordered"||Xe[1].type==="listOrdered")){if(Gn){let wr=ge;for(Mt=void 0;wr--;){const bn=H[wr];if(bn[1].type==="lineEnding"||bn[1].type==="lineEndingBlank"){if(bn[0]==="exit")continue;Mt&&(H[Mt][1].type="lineEndingBlank",Lt=!0),bn[1].type="lineEnding",Mt=wr}else if(!(bn[1].type==="linePrefix"||bn[1].type==="blockQuotePrefix"||bn[1].type==="blockQuotePrefixWhitespace"||bn[1].type==="blockQuoteMarker"||bn[1].type==="listItemIndent"))break}mt&&(!Mt||mt<Mt)&&(Gn._spread=!0),Gn.end=Object.assign({},Mt?H[Mt][1].start:Xe[1].end),H.splice(Mt||ge,0,["exit",Gn,Xe[2]]),ge++,fe++}if(Xe[1].type==="listItemPrefix"){const wr={type:"listItem",_spread:!1,start:Object.assign({},Xe[1].start),end:void 0};Gn=wr,H.splice(ge,0,["enter",wr,Xe[2]]),ge++,fe++,mt=void 0,Bt=!0}}}return H[K][1]._spread=Lt,fe}function u(H,K){return fe;function fe(ge){f.call(this,H(ge),ge),K&&K.call(this,ge)}}function c(){this.stack.push({type:"fragment",children:[]})}function f(H,K,fe){this.stack[this.stack.length-1].children.push(H),this.stack.push(H),this.tokenStack.push([K,fe||void 0]),H.position={start:Xr(K.start),end:void 0}}function d(H){return K;function K(fe){H&&H.call(this,fe),m.call(this,fe)}}function m(H,K){const fe=this.stack.pop(),ge=this.tokenStack.pop();if(ge)ge[0].type!==H.type&&(K?K.call(this,H,ge[0]):(ge[1]||zb).call(this,H,ge[0]));else throw new Error("Cannot close `"+H.type+"` ("+Za({start:H.start,end:H.end})+"): it’s not open");fe.position.end=Xr(H.end)}function g(){return lm(this.stack.pop())}function y(){this.data.expectingFirstListItemValue=!0}function b(H){if(this.data.expectingFirstListItemValue){const K=this.stack[this.stack.length-2];K.start=Number.parseInt(this.sliceSerialize(H),10),this.data.expectingFirstListItemValue=void 0}}function v(){const H=this.resume(),K=this.stack[this.stack.length-1];K.lang=H}function k(){const H=this.resume(),K=this.stack[this.stack.length-1];K.meta=H}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function A(){const H=this.resume(),K=this.stack[this.stack.length-1];K.value=H.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function N(){const H=this.resume(),K=this.stack[this.stack.length-1];K.value=H.replace(/(\r?\n|\r)$/g,"")}function O(H){const K=this.resume(),fe=this.stack[this.stack.length-1];fe.label=K,fe.identifier=kn(this.sliceSerialize(H)).toLowerCase()}function _(){const H=this.resume(),K=this.stack[this.stack.length-1];K.title=H}function U(){const H=this.resume(),K=this.stack[this.stack.length-1];K.url=H}function F(H){const K=this.stack[this.stack.length-1];if(!K.depth){const fe=this.sliceSerialize(H).length;K.depth=fe}}function z(){this.data.setextHeadingSlurpLineEnding=!0}function B(H){const K=this.stack[this.stack.length-1];K.depth=this.sliceSerialize(H).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function ae(H){const fe=this.stack[this.stack.length-1].children;let ge=fe[fe.length-1];(!ge||ge.type!=="text")&&(ge=xt(),ge.position={start:Xr(H.start),end:void 0},fe.push(ge)),this.stack.push(ge)}function P(H){const K=this.stack.pop();K.value+=this.sliceSerialize(H),K.position.end=Xr(H.end)}function re(H){const K=this.stack[this.stack.length-1];if(this.data.atHardBreak){const fe=K.children[K.children.length-1];fe.position.end=Xr(H.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(K.type)&&(ae.call(this,H),P.call(this,H))}function le(){this.data.atHardBreak=!0}function se(){const H=this.resume(),K=this.stack[this.stack.length-1];K.value=H}function J(){const H=this.resume(),K=this.stack[this.stack.length-1];K.value=H}function Z(){const H=this.resume(),K=this.stack[this.stack.length-1];K.value=H}function D(){const H=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";H.type+="Reference",H.referenceType=K,delete H.url,delete H.title}else delete H.identifier,delete H.label;this.data.referenceType=void 0}function X(){const H=this.stack[this.stack.length-1];if(this.data.inReference){const K=this.data.referenceType||"shortcut";H.type+="Reference",H.referenceType=K,delete H.url,delete H.title}else delete H.identifier,delete H.label;this.data.referenceType=void 0}function ne(H){const K=this.sliceSerialize(H),fe=this.stack[this.stack.length-2];fe.label=OO(K),fe.identifier=kn(K).toLowerCase()}function ie(){const H=this.stack[this.stack.length-1],K=this.resume(),fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,fe.type==="link"){const ge=H.children;fe.children=ge}else fe.alt=K}function j(){const H=this.resume(),K=this.stack[this.stack.length-1];K.url=H}function R(){const H=this.resume(),K=this.stack[this.stack.length-1];K.title=H}function G(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function ue(H){const K=this.resume(),fe=this.stack[this.stack.length-1];fe.label=K,fe.identifier=kn(this.sliceSerialize(H)).toLowerCase(),this.data.referenceType="full"}function de(H){this.data.characterReferenceType=H.type}function ce(H){const K=this.sliceSerialize(H),fe=this.data.characterReferenceType;let ge;fe?(ge=hw(K,fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ge=im(K);const Ee=this.stack[this.stack.length-1];Ee.value+=ge}function Ce(H){const K=this.stack.pop();K.position.end=Xr(H.end)}function Ue(H){P.call(this,H);const K=this.stack[this.stack.length-1];K.url=this.sliceSerialize(H)}function ve(H){P.call(this,H);const K=this.stack[this.stack.length-1];K.url="mailto:"+this.sliceSerialize(H)}function at(){return{type:"blockquote",children:[]}}function dt(){return{type:"code",lang:null,meta:null,value:""}}function At(){return{type:"inlineCode",value:""}}function wt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ht(){return{type:"emphasis",children:[]}}function jn(){return{type:"heading",depth:0,children:[]}}function Tn(){return{type:"break"}}function xr(){return{type:"html",value:""}}function br(){return{type:"image",title:null,url:"",alt:null}}function $t(){return{type:"link",title:null,url:"",children:[]}}function vr(H){return{type:"list",ordered:H.type==="listOrdered",start:null,spread:H._spread,children:[]}}function al(H){return{type:"listItem",spread:H._spread,checked:null,children:[]}}function Ii(){return{type:"paragraph",children:[]}}function Ll(){return{type:"strong",children:[]}}function xt(){return{type:"text",value:""}}function Bl(){return{type:"thematicBreak"}}}function Xr(e){return{line:e.line,column:e.column,offset:e.offset}}function Cw(e,r){let l=-1;for(;++l<r.length;){const i=r[l];Array.isArray(i)?Cw(e,i):BO(e,i)}}function BO(e,r){let l;for(l in r)if(kw.call(r,l))switch(l){case"canContainEols":{const i=r[l];i&&e[l].push(...i);break}case"transforms":{const i=r[l];i&&e[l].push(...i);break}case"enter":case"exit":{const i=r[l];i&&Object.assign(e[l],i);break}}}function zb(e,r){throw e?new Error("Cannot close `"+e.type+"` ("+Za({start:e.start,end:e.end})+"): a different token (`"+r.type+"`, "+Za({start:r.start,end:r.end})+") is open"):new Error("Cannot close document, a token (`"+r.type+"`, "+Za({start:r.start,end:r.end})+") is still open")}function UO(e){const r=this;r.parser=l;function l(i){return DO(i,{...r.data("settings"),...e,extensions:r.data("micromarkExtensions")||[],mdastExtensions:r.data("fromMarkdownExtensions")||[]})}}function HO(e,r){const l={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(r),!0)};return e.patch(r,l),e.applyData(r,l)}function PO(e,r){const l={type:"element",tagName:"br",properties:{},children:[]};return e.patch(r,l),[e.applyData(r,l),{type:"text",value:`
@@ -415,4 +415,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${r.do
415
415
  `),o=DD(l,i),u=LD(l,i,o);return BD(u)}function DD(e,r){const l=e.length,i=r.length,o=Array.from({length:l+1},()=>Array(i+1).fill(0));for(let u=1;u<=l;u++)for(let c=1;c<=i;c++)o[u][c]=e[u-1]===r[c-1]?o[u-1][c-1]+1:Math.max(o[u-1][c],o[u][c-1]);return o}function LD(e,r,l){const i=[];let o=e.length,u=r.length;for(;o>0||u>0;)o>0&&u>0&&e[o-1]===r[u-1]?(i.push({type:"context",text:e[o-1],oldIdx:o,newIdx:u}),o--,u--):u>0&&(o===0||l[o][u-1]>=l[o-1][u])?(i.push({type:"added",text:r[u-1],oldIdx:o,newIdx:u}),u--):(i.push({type:"removed",text:e[o-1],oldIdx:o,newIdx:u}),o--);return i.reverse()}function BD(e){return e.map(r=>{const l=r.type==="removed"?"-":r.type==="added"?"+":" ";return{type:r.type,content:`${l}${r.text}`}})}function qd({content:e,isDiff:r=!1,oldString:l,newString:i}){const o=S.useMemo(()=>r&&l&&i?zD(l,i):[],[r,l,i]),u=S.useMemo(()=>r?[]:MD(e),[e,r]),c=S.useMemo(()=>u.some(f=>f.lineNumber!==null),[u]);return r&&o.length>0?x.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:x.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:x.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:x.jsx("tbody",{children:o.map((f,d)=>{const m=f.type==="removed"?"bg-red-500/10 dark:bg-red-500/15":f.type==="added"?"bg-green-500/10 dark:bg-green-500/15":"",g=f.type==="removed"?"text-red-700 dark:text-red-400":f.type==="added"?"text-green-700 dark:text-green-400":"text-foreground";return x.jsxs("tr",{className:m,children:[x.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${f.type==="removed"?"text-red-500/50":f.type==="added"?"text-green-500/50":"text-muted-foreground/50"}`,children:f.type==="removed"?"-":f.type==="added"?"+":" "}),x.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${g}`,children:f.content.slice(1)})]},d)})})})})}):x.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:x.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:x.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:x.jsx("tbody",{children:u.map((f,d)=>x.jsxs("tr",{children:[c&&x.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:f.lineNumber!==null?f.lineNumber:""}),x.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:OD(f.content)})]},d))})})})})}function UD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function iS({message:e,isLoading:r=!1,outputsUrl:l,localPath:i}){var U;const o=e.result!==void 0,u=!o&&r,c=S.useMemo(()=>{if(e.toolName==="Skill")return e.input.skill;if(e.toolName==="Glob")return`Search files ${e.input.pattern==="**/*"?"in all directories":`matching ${e.input.pattern}`}`;if(e.toolName==="Grep"){const B=e.input.pattern,$=e.input.output_mode;return $==="count"?`Count \`${B}\` occurrences`:$==="content"?`Find \`${B}\` in text`:`Find \`${B}\` in files`}if(e.toolName==="Bash")return`${e.input.description||e.input.command||"Bash"}`;if(e.toolName==="WebSearch")return e.input.query||"Web Search";if(e.toolName==="Read")return`Read ${Pd(e.input.file_path,i)}`;if(e.toolName==="Write")return`Write ${Pd(e.input.file_path,i)}`;if(e.toolName==="Edit")return`Edit ${Pd(e.input.file_path,i)}`;if(e.toolName==="mcp__lever__read_db_context"){const B=e.input.connection_name;return B?`Read ${jl(B)} Context`:"Read DB Context"}if(e.toolName==="mcp__lever__edit_db_context"){const B=e.input.connection_name;return B?`Edit ${jl(B)} Context`:"Edit DB Context"}if(e.toolName==="mcp__lever__write_db_context"){const B=e.input.connection_name;return B?`Update ${jl(B)} Context`:"Update DB Context"}const F=e.toolName.match(/^mcp__db__(.+)_query$/);if(F){const B=e.input.description;return B?`${B} from ${jl(F[1])}`:`Query ${F[1]}`}const z=e.toolName.match(/^mcp__(.+?)__(.+)$/);return z?`${jl(z[2])} from ${jl(z[1])}`:e.input.subagent_type||e.toolName},[e.input,e.toolName,i]),f=S.useMemo(()=>e.input.subagent_type!==void 0,[e.input]),d=S.useMemo(()=>{if(e.toolName==="Skill")return e.input.skill},[e.input,e.toolName]),m=e.toolName==="Bash",g=/^mcp__db__.+_query$/.test(e.toolName),y=e.toolName==="Write",b=e.toolName==="mcp__lever__write_db_context",v=e.toolName==="mcp__lever__edit_db_context",k=e.toolName==="Edit",C=e.toolName==="Read",A=e.toolName==="mcp__lever__read_db_context",{result:N,outputFile:O}=S.useMemo(()=>{let F={};if(typeof e.result=="string")try{F=JSON.parse(e.result)}catch{F={output:e.result}}else F=e.result??{};return{result:F,outputFile:RD(F.fullOutputFile,i)}},[e.result,i]),_=S.useMemo(()=>{if(!A||!e.result)return"";try{const F=typeof e.result=="string"?JSON.parse(e.result):e.result;if(Array.isArray(F))return F.map(z=>z.text).join(`
416
416
  `)}catch{}return typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2)},[e.result,A]);return x.jsx(ll,{className:"w-full",children:x.jsxs(Ou,{expandedContent:x.jsx(zu,{className:"my-4 text-sm",children:x.jsxs("div",{className:"flex flex-col gap-2",children:[b?x.jsxs("div",{children:[x.jsxs("span",{className:"font-medium text-muted-foreground",children:["Context (",(e.input.context.length/1e3).toFixed(1),"/20kb)"]}),x.jsx("div",{className:"my-1 max-h-64 md:max-h-[50vh] overflow-auto rounded-lg border border-border bg-muted p-3 prose prose-sm dark:prose-invert max-w-none",children:x.jsx(Li,{remarkPlugins:[Bi],components:rh,children:e.input.context})})]}):k?x.jsx(qd,{content:"",isDiff:!0,oldString:e.input.old_string,newString:e.input.new_string}):v?x.jsxs("div",{className:"flex flex-col gap-2",children:[x.jsx(qa,{label:"Find",copyText:e.input.old_string,children:e.input.old_string}),x.jsx(qa,{label:"Replace",copyText:e.input.new_string,children:e.input.new_string})]}):!C&&!y&&x.jsx(qa,{label:m?x.jsxs("span",{className:"flex items-center gap-2 w-full",children:[x.jsx("span",{children:"Command"}),!!e.input.timeout&&x.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeout),"ms"]}),!!e.input.run_in_background&&x.jsx("span",{className:"text-muted-foreground",children:"background"})]}):g?x.jsxs("span",{className:"flex items-center gap-2 w-full",children:[x.jsx("span",{children:"Query"}),!!e.input.timeout&&x.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeout),"s"]})]}):y?"Contents":"Input",copyText:m?e.input.command:g?e.input.query:y?e.input.content:JSON.stringify(e.input,null,2),children:m?e.input.command:g?e.input.query:y?e.input.content:JSON.stringify(e.input,null,2)}),o&&A&&x.jsxs("div",{children:[x.jsxs("span",{className:"font-medium text-muted-foreground",children:["Context (",(_.length/1e3).toFixed(1),"/20kb)"]}),x.jsx("div",{className:"my-1 max-h-64 md:max-h-[50vh] overflow-auto rounded-lg border border-border bg-muted p-3 prose prose-sm dark:prose-invert max-w-none",children:x.jsx(Li,{remarkPlugins:[Bi],components:rh,children:_})})]}),o&&C&&!e.isError&&x.jsx(qd,{content:typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2)}),y&&!e.isError&&x.jsx(qd,{content:e.input.content}),o&&!g&&!A&&!C&&!(y&&!e.isError)&&!(k&&!e.isError)&&x.jsx(qa,{label:e.isError?"Error":"Result",copyText:typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2),children:typeof e.result=="string"?e.result:JSON.stringify(e.result,null,2)}),o&&g&&x.jsx(qa,{label:e.isError?"Error":x.jsxs("span",{className:"flex items-center justify-between w-full",children:[x.jsxs("span",{children:["Preview",N.isOutputTruncated?" (~25kb)":""]}),O&&l&&x.jsxs("a",{href:`${l}/api/file?path=${encodeURIComponent(O)}`,download:!0,onClick:F=>F.stopPropagation(),target:"_blank",className:"text-muted-foreground hover:text-foreground transition-colors",children:["Download (",UD(N.fullOutputLength),")"]})]}),copyText:N.output.replaceAll("\\n",`
417
417
  `),children:N.output.replaceAll("\\n",`
418
- `)})]})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:(()=>{if(e.isError)return x.jsx(so,{className:"size-4 text-destructive"});if(f)return x.jsx(Bh,{className:"size-4 text-muted-icon"});const F=Q1(e.toolName);return x.jsx(F,{className:"size-4 text-muted-icon"})})()}),x.jsx(el,{className:"text-left transition-opacity duration-200 truncate",children:x.jsx(Ru,{animate:u,shimmerWidth:Math.max(20,((U=d||c)==null?void 0:U.length)??99),children:d||c})})]})})}function HD({message:e}){const r=l=>{if(l<1e3)return`${l}ms`;const i=Math.floor(l/1e3),o=Math.floor(i/3600),u=Math.floor(i%3600/60),c=i%60;return o>0?`${o}h${u>0?` ${u}m`:""}`:u>0?`${u}m${c>0?` ${c}s`:""}`:`${c}s`};return x.jsxs(ll,{className:`px-0.5 text-xs tracking-wide ${e.durationMs>6e4?"":"hidden"}`,children:[x.jsx("div",{className:"w-full h-[1px] bg-border"}),x.jsxs(el,{className:"whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0",children:["Worked for ",r(e.durationMs)]}),x.jsx("div",{className:"w-full h-[1px] bg-border"})]})}function PD({message:e}){return x.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground my-3",children:x.jsxs("div",{className:"inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full",children:[x.jsx(mj,{className:"h-4 w-4 ml-1.5"}),x.jsx("em",{children:"Interrupted"})]})})}function mu({size:e=4}){return x.jsxs("svg",{className:"flex-1",viewBox:`0 0 100 ${e}`,preserveAspectRatio:"none",style:{height:`${e}px`},children:[x.jsx("pattern",{id:"zigzag",width:e,height:e,patternUnits:"userSpaceOnUse",children:x.jsx("path",{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:{stroke:"currentColor"}})}),x.jsx("rect",{width:"100%",height:e,fill:"url(#zigzag)",className:"text-muted-foreground/30"})]})}function qD(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(mu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),x.jsx(mu,{})]})}function FD(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(mu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),x.jsx(mu,{})]})}function VD({message:e}){return x.jsx(ll,{children:x.jsxs(Ou,{expandedContent:x.jsx(zu,{className:"my-4 text-xs",children:x.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:x.jsx(Li,{remarkPlugins:[Bi],components:Du,children:e.summary})})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(L0,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(el,{children:"Summarized"})]})})}const ID={compacting:"Compacting..."};function GD({message:e}){const r=ID[e.status]||e.status;return x.jsxs(ll,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(L0,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(el,{className:"text-left transition-opacity duration-200 truncate",children:r})]})}const iv={Read:{key:"read",singular:"read",plural:"reads"},Edit:{key:"edit",singular:"edit",plural:"edits"},Write:{key:"write",singular:"write",plural:"writes"},Bash:{key:"bash",singular:"command",plural:"commands"},Grep:{key:"grep",singular:"search",plural:"searches"},Glob:{key:"glob",singular:"glob",plural:"globs"},Task:{key:"task",singular:"agent",plural:"agents"},WebFetch:{key:"webfetch",singular:"fetch",plural:"fetches"},WebSearch:{key:"websearch",singular:"web search",plural:"web searches"},Skill:{key:"skill",singular:"skill",plural:"skills"},TodoWrite:{key:"todo",singular:"todo update",plural:"todo updates"}},YD={key:"dbquery",singular:"query",plural:"queries"},$D={key:"other",singular:"tool call",plural:"tool calls"};function XD(e){return iv[e]?iv[e]:/^mcp__db__.+_query$/.test(e)?YD:$D}function QD(e){const r=new Map,l=[];for(const i of e){const o=i.processed.toolName,u=XD(o),c=r.get(u.key);c?c.count++:(r.set(u.key,{category:u,count:1}),l.push(u.key))}return l.map(i=>{const{category:o,count:u}=r.get(i);return`${u} ${u===1?o.singular:o.plural}`}).join(", ")}function ZD({messages:e,isLoading:r,outputsUrl:l,localPath:i}){const[o,u]=S.useState(!1),c=S.useMemo(()=>QD(e),[e]),d=e.some(m=>m.processed.result===void 0)&&r;return x.jsx(ll,{className:"w-full",children:x.jsxs("div",{className:"flex flex-col w-full",children:[x.jsx("button",{onClick:()=>u(!o),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!o&&!d?"hover:opacity-60 transition-opacity":""}`,children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Kr,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${o?"rotate-90":""}`})}),x.jsx(el,{className:"text-left",children:x.jsx(Ru,{animate:d,children:c})})]})}),o&&x.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[e.map(m=>x.jsx(iS,{message:m.processed,isLoading:r,outputsUrl:l,localPath:i},m.id)),e.length>5&&x.jsx("button",{onClick:()=>u(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Kr,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),x.jsx(el,{className:"text-left",children:"Collapse"})]})})]})]})})}const KD=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite"]);function av(e){var l;if(((l=e.processed)==null?void 0:l.kind)!=="tool")return!1;const r=e.processed.toolName;return!KD.has(r)}function JD(e){const r=[];let l=0;for(;l<e.length;){const i=e[l];if(av(i)){const o=[i],u=l;for(l+=1;l<e.length&&av(e[l]);)o.push(e[l]),l+=1;o.length>=2?r.push({type:"tool-group",messages:o,startIndex:u}):r.push({type:"single",message:i,index:u});continue}r.push({type:"single",message:i,index:l}),l+=1}return r}function WD({messages:e,isLoading:r,localPath:l,latestToolIds:i,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:u}){const c=S.useMemo(()=>JD(e),[e]);function f(d,m){var y,b;if(d.role==="user")return x.jsx(pD,{content:d.content},d.id);const g=d.processed;if(!g)return x.jsx(gD,{json:d.content},d.id);switch(g.kind){case"system":return x.jsx(wD,{message:g,rawJson:d.rawJson},d.id);case"account_info":return e.findIndex(k=>{var C;return((C=k.processed)==null?void 0:C.kind)==="account_info"})===m?x.jsx(SD,{message:g},d.id):null;case"text":return x.jsx(kD,{message:g},d.id);case"tool":return g.toolName==="AskUserQuestion"?x.jsx(AD,{message:g,onSubmit:o,isLatest:g.id===i.AskUserQuestion},d.id):g.toolName==="ExitPlanMode"?x.jsx(jD,{message:g,onConfirm:u,isLatest:g.id===i.ExitPlanMode},d.id):g.toolName==="TodoWrite"?g.id!==i.TodoWrite?null:x.jsx(_D,{message:g},d.id):x.jsx(iS,{message:g,isLoading:r,localPath:l},d.id);case"result":{const v=e[m+1],k=e[m-1];return((y=v==null?void 0:v.processed)==null?void 0:y.kind)==="context_cleared"||((b=k==null?void 0:k.processed)==null?void 0:b.kind)==="context_cleared"?null:x.jsx(HD,{message:g},d.id)}case"interrupted":return x.jsx(PD,{message:g},d.id);case"compact_boundary":return x.jsx(qD,{},d.id);case"context_cleared":return x.jsx(FD,{},d.id);case"compact_summary":return x.jsx(VD,{message:g},d.id);case"status":return m===e.length-1?x.jsx(GD,{message:g},d.id):null}}return x.jsx(x.Fragment,{children:c.map(d=>{if(d.type==="tool-group")return x.jsx("div",{className:"group relative",children:x.jsx(ZD,{messages:d.messages,isLoading:r,localPath:l})},`group-${d.startIndex}`);const m=f(d.message,d.index);return m?x.jsx("div",{id:`msg-${d.message.id}`,className:"group relative",children:m},d.message.id):null})})}function ov(){var r,l,i;const e=Av();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsxs(G1,{className:"bg-background flex-1 flex flex-col overflow-hidden border-0 rounded-none relative",children:[x.jsxs($1,{className:"flex-1 p-0 overflow-hidden relative",children:[x.jsx(FR,{sidebarCollapsed:e.sidebarCollapsed,onOpenSidebar:e.openSidebar,onExpandSidebar:e.expandSidebar,onNewChat:e.handleCompose,localPath:e.navbarLocalPath,onOpenExternal:o=>{e.handleOpenExternal(o)}}),x.jsx(K1,{ref:e.scrollRef,onScroll:e.updateScrollState,className:"h-full px-4 scroll-pt-[72px]",children:x.jsxs("div",{className:"animate-fade-in space-y-5 pt-[72px] max-w-[800px] mx-auto",style:{paddingBottom:e.transcriptPaddingBottom},children:[e.messages.length===0?x.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[40vh] text-muted-foreground gap-4",children:[x.jsx(Qa,{strokeWidth:1.5,className:"size-8 text-muted-foreground"}),x.jsx("div",{className:"text-base font-normal text-muted-foreground text-center max-w-xs",children:"What are we making?"})]}):x.jsx(WD,{messages:e.messages,isLoading:e.isProcessing,localPath:(r=e.runtime)==null?void 0:r.localPath,latestToolIds:e.latestToolIds,onAskUserQuestionSubmit:e.handleAskUserQuestion,onExitPlanModeConfirm:e.handleExitPlanMode}),e.isProcessing?x.jsx(YR,{status:(l=e.runtime)==null?void 0:l.status}):null,e.commandError?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3",children:e.commandError}):null,x.jsx("div",{className:"flex-1 min-h-[10vh]","aria-hidden":"true"})]})}),x.jsx("div",{style:{bottom:e.transcriptPaddingBottom-36},className:xe("absolute left-1/2 -translate-x-1/2 z-10 transition-all",e.showScrollButton?"scale-100 duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]":"scale-60 duration-300 ease-out pointer-events-none blur-sm opacity-0"),children:x.jsx("button",{onClick:e.scrollToBottom,className:"flex items-center transition-colors gap-1.5 px-2 bg-white hover:bg-muted border border-border rounded-full aspect-square cursor-pointer text-sm text-primary hover:text-foreground dark:bg-slate-700 dark:hover:bg-slate-600 dark:text-slate-100 dark:border-slate-600",children:x.jsx($A,{className:"h-5 w-5"})})})]}),x.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:x.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:e.inputRef,children:x.jsx(UR,{onSubmit:e.handleSend,onCancel:()=>{e.handleCancel()},disabled:!e.hasSelectedProject||((i=e.runtime)==null?void 0:i.status)==="waiting_for_user",canCancel:e.canCancel,chatId:e.activeChatId},e.activeChatId??"new-chat")})})]})})}function e6({text:e}){const[r,l]=S.useState(!1);async function i(){await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3)}return x.jsx(qe,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void i(),children:r?x.jsx(_l,{className:"h-4 w-4 text-green-400"}):x.jsx(ku,{className:"h-4 w-4"})})}function sv({children:e}){return x.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[x.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[x.jsx(Kr,{className:"inline h-4 w-4 opacity-40"}),x.jsx("code",{children:e})]}),x.jsx(e6,{text:e})]})}function Ys({children:e}){return x.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:e})}function Fd({children:e}){return x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider mb-3",children:e})}function uv({narrow:e=!1,title:r,subtitle:l,icon:i=Oh}){return x.jsxs("div",{className:xe("w-full",e?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[x.jsxs("div",{className:xe("flex items-center gap-3 mb-2",e&&"justify-center"),children:[x.jsx("div",{className:"p-2 pl-0 rounded-lg",children:x.jsx(i,{className:"h-6 w-6 text-muted-foreground"})}),x.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:r})]}),x.jsx("p",{className:xe("text-muted-foreground",e&&"mb-10 text-center"),children:l})]})}function Vd({icon:e,title:r,subtitle:l,iconClassName:i}){return x.jsxs("div",{className:"flex flex-col items-center gap-0",children:[x.jsx("div",{className:"p-3 mb-2 rounded-xl bg-background border border-border",children:x.jsx(e,{className:i||"h-8 w-8 text-muted-foreground"})}),x.jsx("span",{className:"text-sm font-medium",children:r}),x.jsx("span",{className:"text-xs text-muted-foreground",children:l})]})}function cv(){return x.jsx(QA,{className:"h-4 w-4 text-muted-foreground"})}function fv({number:e,title:r,children:l}){return x.jsx("div",{className:"flex gap-4",children:x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[x.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[e,"."]}),x.jsx("h3",{className:"font-medium text-foreground mb-2",children:r})]}),x.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:l})]})})}function t6({localPath:e,loading:r,onClick:l}){return x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:x.jsxs("button",{className:xe("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",r&&"opacity-50 cursor-not-allowed"),disabled:r,onClick:l,children:[x.jsx(O0,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),x.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:A1(e)}),r?x.jsx(zl,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):x.jsx(Dh,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),x.jsx(no,{children:x.jsx("p",{children:e})})]})}function n6({connectionStatus:e,ready:r,snapshot:l,startingLocalPath:i,commandError:o,onOpenProject:u,onCreateProject:c}){const[f,d]=S.useState(!1),m=S.useMemo(()=>(l==null?void 0:l.projects)??[],[l==null?void 0:l.projects]),g=e==="connecting"||!r,y=e==="connected"&&r;return x.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[y?x.jsxs(x.Fragment,{children:[x.jsx(uv,{title:(l==null?void 0:l.machine.displayName)??"Local Projects",subtitle:`${zt} is connected, choose a project below to get started.`}),x.jsxs("div",{className:"w-full px-6 mb-10",children:[x.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider",children:"Projects"}),x.jsxs(qe,{variant:"default",size:"sm",onClick:()=>d(!0),children:[x.jsx(U0,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),m.length>0?x.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4 3xl:grid-cols-5 gap-2",children:m.map(b=>x.jsx(t6,{localPath:b.localPath,loading:i===b.localPath,onClick:()=>{u(b.localPath)}},b.localPath))}):x.jsx(Ys,{children:x.jsx("p",{className:"text-sm text-muted-foreground",children:"No Claude projects discovered yet. Open one with Claude Code or create a new project here."})}),o?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:o}):null]})]}):x.jsxs(x.Fragment,{children:[x.jsx(uv,{narrow:!0,icon:Jx,title:g?`Connecting ${zt}`:`Connect ${zt}`,subtitle:g?`${zt} is starting up and loading your local projects.`:`Run ${zt} directly on your machine with full access to your local files and Claude projects.`}),x.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[x.jsx(Fd,{children:"Status"}),x.jsx("div",{className:"mb-8",children:x.jsx(Ys,{children:x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(zl,{className:"h-4 w-4 text-muted-foreground animate-spin"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:g?`Connecting to your local ${zt} server...`:x.jsxs(x.Fragment,{children:["Not connected. Run ",x.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:qs()})," from any terminal on this machine."]})})]})})}),g?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(Fd,{children:"How it works"}),x.jsx(Ys,{children:x.jsxs("div",{className:"flex items-center justify-around gap-6 py-4 px-2",children:[x.jsx(Vd,{icon:Lh,title:`${zt} CLI`,subtitle:"On Your Machine"}),x.jsx(cv,{}),x.jsx(Vd,{icon:Oh,title:`${zt} Server`,subtitle:"Local WebSocket"}),x.jsx(cv,{}),x.jsx(Vd,{icon:Jx,title:`${zt} UI`,subtitle:"Project Chat"})]})})]}),g?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(Fd,{children:"Setup"}),x.jsx(Ys,{children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs(fv,{number:1,title:`Start ${zt}`,children:[x.jsx("p",{children:"Run this command in your terminal:"}),x.jsx(sv,{children:qs()})]}),x.jsxs(fv,{number:2,title:"Open the local UI",children:[x.jsxs("p",{children:[zt," serves the app locally and opens the Local Projects page in an app-style browser window."]}),x.jsx(sv,{children:"http://localhost:3210/local"})]}),x.jsxs("div",{className:"mt-8",children:[x.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-4",children:"Notes"}),x.jsxs("div",{className:"space-y-3 text-sm",children:[x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:qs("").trim()}),x.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:qs("--no-open")}),x.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),x.jsx(N1,{open:f,onOpenChange:d,onConfirm:b=>{c(b)}}),x.jsx("div",{className:"py-4 text-center",children:x.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",rR.split("/")[1]]})})]})}function r6(){const e=Av();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsx(n6,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}function l6(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Dn(){return new Date().toISOString()}function i6(e,r){var o,u,c,f;const l=l6(e),i={processed:null,rawJson:l};try{const d=JSON.parse(e);if(d.type==="user_prompt"&&d.content)return{...i,isUserMessage:!0,userContent:d.content};if(d.type==="system"&&d.subtype==="init")return{processed:{id:zn(),kind:"system",model:d.model||"unknown",tools:d.tools||[],agents:d.agents||[],slashCommands:((o=d.slash_commands)==null?void 0:o.filter(m=>!m.startsWith("._")))||[],mcpServers:d.mcp_servers||[],timestamp:Dn()},rawJson:l};if(d.type==="system"&&d.subtype==="account_info")return{processed:{id:zn(),kind:"account_info",accountInfo:d.accountInfo,timestamp:Dn()},rawJson:l};if(d.type==="assistant"&&((u=d.message)!=null&&u.content))for(const m of d.message.content){if(m.type==="text"&&m.text)return{processed:{id:zn(),kind:"text",text:m.text,timestamp:Dn()},rawJson:l};if(m.type==="tool_use"){const g={id:zn(),kind:"tool",toolName:m.name,toolId:m.id,input:m.input||{},timestamp:Dn()};return r.set(m.id,g),{processed:g,rawJson:l}}}if(d.type==="user"&&((c=d.message)!=null&&c.content)){for(const m of d.message.content)if(m.type==="tool_result"&&m.tool_use_id){const g=r.get(m.tool_use_id);if(g)return g.result=m.content||"(empty)",g.isError=m.is_error||!1,r.delete(m.tool_use_id),i}}return d.type==="result"?d.subtype==="cancelled"?{processed:{id:zn(),kind:"interrupted",timestamp:Dn()},rawJson:l}:{processed:{id:zn(),kind:"result",success:!d.is_error,result:d.result||"",durationMs:d.duration_ms||0,costUsd:d.total_cost_usd,timestamp:Dn()},rawJson:l}:d.type==="system"&&d.subtype==="status"&&d.status?{processed:{id:zn(),kind:"status",status:d.status,timestamp:Dn()},rawJson:l}:d.type==="system"&&d.subtype==="compact_boundary"?{processed:{id:zn(),kind:"compact_boundary",timestamp:Dn()},rawJson:l}:d.type==="system"&&d.subtype==="context_cleared"?{processed:{id:zn(),kind:"context_cleared",timestamp:Dn()},rawJson:l}:d.type==="user"&&((f=d.message)==null?void 0:f.role)==="user"&&typeof d.message.content=="string"&&d.message.content.startsWith("This session is being continued")?{processed:{id:zn(),kind:"compact_summary",summary:d.message.content,timestamp:Dn()},rawJson:l}:i}catch{return i}}function a6(e){const r=new Map,l=[];for(const i of e){const{processed:o,rawJson:u,isUserMessage:c,userContent:f}=i6(i.message,r);if(c&&f){l.push({id:i._id,messageId:i.messageId,role:"user",content:f,timestamp:new Date(i.createdAt).toISOString(),hidden:i.hidden});continue}o!==null&&l.push({id:i._id,messageId:i.messageId,role:"assistant",content:u,timestamp:new Date(i.createdAt).toISOString(),processed:o,rawJson:u,hidden:i.hidden})}return l}const o6=["AskUserQuestion","ExitPlanMode","TodoWrite"],s6=new Set(["TodoWrite"]);function u6(e,r){var l;for(let i=e.length-1;i>=0;i-=1){const o=e[i];if(((l=o.processed)==null?void 0:l.kind)!=="tool")continue;const u=o.processed;if(u.toolName===r&&!u.result)return u.id}return null}function c6(e,r){var l;for(let i=e.length-1;i>=0;i-=1){const o=e[i];if(((l=o.processed)==null?void 0:l.kind)!=="tool")continue;const u=o.processed;if(u.toolName===r)return u.id}return null}function f6(e){const r={};for(const l of o6)r[l]=s6.has(l)?c6(e,l):u6(e,l);return r}function d6(e){return e==="starting"||e==="running"||e==="waiting_for_user"}function h6(e){return e==="starting"||e==="running"||e==="waiting_for_user"}class m6{constructor(r){cr(this,"url");cr(this,"ws",null);cr(this,"reconnectTimer",null);cr(this,"reconnectDelayMs",750);cr(this,"subscriptions",new Map);cr(this,"pending",new Map);cr(this,"outboundQueue",[]);cr(this,"statusListeners",new Set);this.url=r,this.connect()}dispose(){var r;this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(r=this.ws)==null||r.close(),this.ws=null;for(const l of this.pending.values())l.reject(new Error("Socket disposed"));this.pending.clear()}onStatus(r){return this.statusListeners.add(r),r(this.getStatus()),()=>{this.statusListeners.delete(r)}}subscribe(r,l){const i=crypto.randomUUID();return this.subscriptions.set(i,{topic:r,listener:l}),this.enqueue({v:1,type:"subscribe",id:i,topic:r}),()=>{this.subscriptions.delete(i),this.enqueue({v:1,type:"unsubscribe",id:i})}}command(r){const l=crypto.randomUUID(),i={v:1,type:"command",id:l,command:r};return new Promise((o,u)=>{this.pending.set(l,{resolve:o,reject:u}),this.enqueue(i)})}connect(){this.emitStatus("connecting"),this.ws=new WebSocket(this.url),this.ws.addEventListener("open",()=>{this.reconnectDelayMs=750,this.emitStatus("connected");for(const[r,l]of this.subscriptions.entries())this.sendNow({v:1,type:"subscribe",id:r,topic:l.topic});for(;this.outboundQueue.length>0;){const r=this.outboundQueue.shift();r&&this.sendNow(r)}}),this.ws.addEventListener("message",r=>{let l;try{l=JSON.parse(String(r.data))}catch{return}if(l.type==="snapshot"){const i=this.subscriptions.get(l.id);i==null||i.listener(l.snapshot.data);return}if(l.type==="ack"){const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.resolve(l.result);return}if(l.type==="error"){if(!l.id){console.error(lR,l.message);return}const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.reject(new Error(l.message))}}),this.ws.addEventListener("close",()=>{this.emitStatus("disconnected");for(const r of this.pending.values())r.reject(new Error("Disconnected"));this.pending.clear(),this.scheduleReconnect()})}scheduleReconnect(){this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect(),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,5e3)},this.reconnectDelayMs))}getStatus(){var r,l;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN?"connected":((l=this.ws)==null?void 0:l.readyState)===WebSocket.CONNECTING?"connecting":"disconnected"}emitStatus(r){for(const l of this.statusListeners)l(r)}enqueue(r){var l;if(((l=this.ws)==null?void 0:l.readyState)===WebSocket.OPEN){this.sendNow(r);return}this.outboundQueue.push(r)}sendNow(r){var l;(l=this.ws)==null||l.send(JSON.stringify(r))}}function p6(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}function g6(){const e=S.useRef(null);return e.current||(e.current=new m6(p6())),S.useEffect(()=>{const r=e.current;return()=>{r==null||r.dispose()}},[]),e.current}function y6(e){var Ll,xt,Bl;const r=xh(),l=g6(),i=yT(),[o,u]=S.useState({projectGroups:[]}),[c,f]=S.useState(null),[d,m]=S.useState(null),[g,y]=S.useState("connecting"),[b,v]=S.useState(!1),[k,C]=S.useState(!1),[A,N]=S.useState(!1),[O,_]=S.useState(null),[U,F]=S.useState(!1),[z,B]=S.useState(!1),[$,ae]=S.useState(148),[P,re]=S.useState(!0),[le,se]=S.useState(null),[J,Z]=S.useState(null),[D,X]=S.useState(null),ne=S.useRef(null),ie=S.useRef(null);S.useEffect(()=>l.onStatus(y),[l]),S.useEffect(()=>l.subscribe({type:"sidebar"},H=>{u(H),v(!0),se(null)}),[l]),S.useEffect(()=>l.subscribe({type:"local-projects"},H=>{f(H),C(!0),se(null)}),[l]),S.useEffect(()=>{if(!e){m(null),N(!0);return}return N(!1),l.subscribe({type:"chat",chatId:e},H=>{m(H),N(!0),se(null)})},[e,l]),S.useEffect(()=>{if(O)return;const H=o.projectGroups[0];H&&_(H.groupKey)},[O,o.projectGroups]),S.useEffect(()=>{if(!e||!b||!A)return;if(o.projectGroups.some(K=>K.chats.some(fe=>fe.chatId===e))){D===e&&X(null);return}D!==e&&r("/")},[e,A,r,D,o.projectGroups,b]),S.useEffect(()=>{d&&(_(d.runtime.projectId),D===d.runtime.chatId&&X(null))},[d,D]),S.useLayoutEffect(()=>{const H=ie.current;if(!H)return;const K=new ResizeObserver(()=>{ae(H.getBoundingClientRect().height)});return K.observe(H),ae(H.getBoundingClientRect().height),()=>K.disconnect()},[]);const j=S.useMemo(()=>a6((d==null?void 0:d.messages)??[]),[d==null?void 0:d.messages]),R=S.useMemo(()=>f6(j),[j]),G=(d==null?void 0:d.runtime)??null,T=h6(G==null?void 0:G.status),ue=d6(G==null?void 0:G.status),de=$+48,ce=!P&&j.length>0,Ce=((Ll=c==null?void 0:c.projects[0])==null?void 0:Ll.localPath)??null,Ue=(G==null?void 0:G.localPath)??Ce??((xt=o.projectGroups[0])==null?void 0:xt.localPath),ve=!!(O??(G==null?void 0:G.projectId)??((Bl=o.projectGroups[0])==null?void 0:Bl.groupKey)??Ce);S.useEffect(()=>{const H=ne.current;if(!H)return;H.scrollHeight-H.scrollTop-H.clientHeight<120&&H.scrollTo({top:H.scrollHeight,behavior:"smooth"})},[e,j.length,G==null?void 0:G.status]);function at(){const H=ne.current;if(!H)return;const K=H.scrollHeight-H.scrollTop-H.clientHeight;re(K<24)}function dt(){const H=ne.current;H&&H.scrollTo({top:H.scrollHeight,behavior:"smooth"})}async function At(H){try{const K=await l.command({type:"chat.create",projectId:H});_(H),X(K.chatId),r(`/chat/${K.chatId}`),F(!1)}catch(K){se(K instanceof Error?K.message:String(K))}}async function wt(H){try{Z(H);const K=await l.command({type:"project.open",localPath:H});_(K.projectId);const fe=await l.command({type:"chat.create",projectId:K.projectId});X(fe.chatId),r(`/chat/${fe.chatId}`),F(!1),se(null)}catch(K){se(K instanceof Error?K.message:String(K))}finally{Z(null)}}async function ht(H){try{Z(H.localPath);const K=await l.command(H.mode==="new"?{type:"project.create",localPath:H.localPath,title:H.title}:{type:"project.open",localPath:H.localPath});_(K.projectId);const fe=await l.command({type:"chat.create",projectId:K.projectId});X(fe.chatId),r(`/chat/${fe.chatId}`),F(!1),se(null)}catch(K){se(K instanceof Error?K.message:String(K))}finally{Z(null)}}async function jn(H,K){var fe;try{let ge=O??((fe=o.projectGroups[0])==null?void 0:fe.groupKey)??null;if(!e&&!ge&&Ce&&(ge=(await l.command({type:"project.open",localPath:Ce})).projectId,_(ge)),!e&&!ge)throw new Error("Open a project first");const Ee=await l.command({type:"chat.send",chatId:e??void 0,projectId:e?void 0:ge??void 0,content:H,model:K==null?void 0:K.model,effort:K==null?void 0:K.effort,planMode:K==null?void 0:K.planMode});!e&&Ee.chatId&&(X(Ee.chatId),r(`/chat/${Ee.chatId}`)),se(null)}catch(ge){throw se(ge instanceof Error?ge.message:String(ge)),ge}}async function Tn(){if(e)try{await l.command({type:"chat.cancel",chatId:e})}catch(H){se(H instanceof Error?H.message:String(H))}}async function xr(H){if(await i.confirm({title:"Delete Chat",description:`Delete "${H.title}"? This cannot be undone.`,confirmLabel:"Delete",confirmVariant:"destructive"}))try{await l.command({type:"chat.delete",chatId:H.chatId}),H.chatId===e&&r("/")}catch(fe){se(fe instanceof Error?fe.message:String(fe))}}async function br(H){const K=o.projectGroups.find(Ee=>Ee.groupKey===H);if(!K)return;const fe=K.localPath.split("/").filter(Boolean).pop()??K.localPath;if(await i.confirm({title:"Remove Project",description:`Remove "${fe}" from the sidebar? Existing chats will be removed from ${zt}.`,confirmLabel:"Remove",confirmVariant:"destructive"}))try{await l.command({type:"project.remove",projectId:H}),(G==null?void 0:G.projectId)===H&&r("/projects"),se(null)}catch(Ee){se(Ee instanceof Error?Ee.message:String(Ee))}}async function $t(H){var fe,ge;const K=(G==null?void 0:G.localPath)??((fe=c==null?void 0:c.projects[0])==null?void 0:fe.localPath)??((ge=o.projectGroups[0])==null?void 0:ge.localPath);if(K)try{await l.command({type:"system.openExternal",action:H,localPath:K})}catch(Ee){se(Ee instanceof Error?Ee.message:String(Ee))}}function vr(){var fe,ge;const H=O??((fe=o.projectGroups[0])==null?void 0:fe.groupKey);if(H){At(H);return}const K=(ge=c==null?void 0:c.projects[0])==null?void 0:ge.localPath;if(K){wt(K);return}r("/projects")}async function al(H,K,fe){if(e)try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:H,result:{questions:K,answers:fe}})}catch(ge){se(ge instanceof Error?ge.message:String(ge))}}async function Ii(H,K,fe,ge){if(e){K&&I1.getState().setPlanMode(!1);try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:H,result:{confirmed:K,...fe?{clearContext:!0}:{},...ge?{message:ge}:{}}})}catch(Ee){se(Ee instanceof Error?Ee.message:String(Ee))}}}return{activeChatId:e,sidebarData:o,localProjects:c,chatSnapshot:d,connectionStatus:g,sidebarReady:b,localProjectsReady:k,commandError:le,startingLocalPath:J,sidebarOpen:U,sidebarCollapsed:z,scrollRef:ne,inputRef:ie,messages:j,latestToolIds:R,runtime:G,isProcessing:T,canCancel:ue,transcriptPaddingBottom:de,showScrollButton:ce,navbarLocalPath:Ue,hasSelectedProject:ve,openSidebar:()=>F(!0),closeSidebar:()=>F(!1),collapseSidebar:()=>B(!0),expandSidebar:()=>B(!1),updateScrollState:at,scrollToBottom:dt,handleCreateChat:At,handleOpenLocalProject:wt,handleCreateProject:ht,handleSend:jn,handleCancel:Tn,handleDeleteChat:xr,handleRemoveProject:br,handleOpenExternal:$t,handleCompose:vr,handleAskUserQuestion:al,handleExitPlanMode:Ii}}function x6(){const e=Fn(),r=xC(),l=y6(r.chatId??null),i=e.pathname==="/projects";return x.jsxs("div",{className:"flex h-[100dvh] min-h-[100dvh] overflow-hidden",children:[x.jsx(NR,{data:l.sidebarData,activeChatId:l.activeChatId,connectionStatus:l.connectionStatus,ready:l.sidebarReady,open:l.sidebarOpen,collapsed:l.sidebarCollapsed,showMobileOpenButton:i,onOpen:l.openSidebar,onClose:l.closeSidebar,onCollapse:l.collapseSidebar,onExpand:l.expandSidebar,onCreateChat:o=>{l.handleCreateChat(o)},onCreateProject:o=>{l.handleCreateProject(o)},onDeleteChat:o=>{l.handleDeleteChat(o)},onRemoveProject:o=>{l.handleRemoveProject(o)}}),x.jsx(MC,{context:l})]})}function b6(){return x.jsx(eR,{children:x.jsx(gT,{children:x.jsx(zC,{children:x.jsxs($a,{element:x.jsx(x6,{}),children:[x.jsx($a,{path:"/",element:x.jsx(ov,{})}),x.jsx($a,{path:"/projects",element:x.jsx(r6,{})}),x.jsx($a,{path:"/chat/:chatId",element:x.jsx(ov,{})})]})})})})}const aS="lever-theme",v6=S.createContext(void 0),w6=e=>e==="light"||e==="dark"||e==="system",oS=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",dv=e=>{if(typeof document>"u")return;const r=e==="system"?oS():e;document.documentElement.classList.toggle("dark",r==="dark")},S6=()=>{if(typeof window>"u")return"system";const e=window.localStorage.getItem(aS);return w6(e)?e:"system"};function k6({children:e}){const[r,l]=S.useState(S6);S.useEffect(()=>{dv(r),typeof window<"u"&&window.localStorage.setItem(aS,r)},[r]),S.useEffect(()=>{if(r!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>dv("system");return o.addEventListener?(o.addEventListener("change",u),()=>o.removeEventListener("change",u)):(o.addListener(u),()=>o.removeListener(u))},[r]);const i=S.useMemo(()=>{const o=r==="system"?oS():r;return{theme:r,resolvedTheme:o,setTheme:l}},[r]);return x.jsx(v6.Provider,{value:i,children:e})}const sS=document.getElementById("root");if(!sS)throw new Error("Missing #root");z2.createRoot(sS).render(x.jsx(S.StrictMode,{children:x.jsx(lE,{children:x.jsx(k6,{children:x.jsx(b6,{})})})}));
418
+ `)})]})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:(()=>{if(e.isError)return x.jsx(so,{className:"size-4 text-destructive"});if(f)return x.jsx(Bh,{className:"size-4 text-muted-icon"});const F=Q1(e.toolName);return x.jsx(F,{className:"size-4 text-muted-icon"})})()}),x.jsx(el,{className:"text-left transition-opacity duration-200 truncate",children:x.jsx(Ru,{animate:u,shimmerWidth:Math.max(20,((U=d||c)==null?void 0:U.length)??99),children:d||c})})]})})}function HD({message:e}){const r=l=>{if(l<1e3)return`${l}ms`;const i=Math.floor(l/1e3),o=Math.floor(i/3600),u=Math.floor(i%3600/60),c=i%60;return o>0?`${o}h${u>0?` ${u}m`:""}`:u>0?`${u}m${c>0?` ${c}s`:""}`:`${c}s`};return x.jsxs(ll,{className:`px-0.5 text-xs tracking-wide ${e.durationMs>6e4?"":"hidden"}`,children:[x.jsx("div",{className:"w-full h-[1px] bg-border"}),x.jsxs(el,{className:"whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0",children:["Worked for ",r(e.durationMs)]}),x.jsx("div",{className:"w-full h-[1px] bg-border"})]})}function PD({message:e}){return x.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground my-3",children:x.jsxs("div",{className:"inline-flex gap-1.5 items-center justify-center whitespace-nowrap text-sm font-medium bg-background text-foreground/60 border border-border h-9 pl-1 pr-4 rounded-full",children:[x.jsx(mj,{className:"h-4 w-4 ml-1.5"}),x.jsx("em",{children:"Interrupted"})]})})}function mu({size:e=4}){return x.jsxs("svg",{className:"flex-1",viewBox:`0 0 100 ${e}`,preserveAspectRatio:"none",style:{height:`${e}px`},children:[x.jsx("pattern",{id:"zigzag",width:e,height:e,patternUnits:"userSpaceOnUse",children:x.jsx("path",{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:{stroke:"currentColor"}})}),x.jsx("rect",{width:"100%",height:e,fill:"url(#zigzag)",className:"text-muted-foreground/30"})]})}function qD(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(mu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),x.jsx(mu,{})]})}function FD(){return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(mu,{}),x.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),x.jsx(mu,{})]})}function VD({message:e}){return x.jsx(ll,{children:x.jsxs(Ou,{expandedContent:x.jsx(zu,{className:"my-4 text-xs",children:x.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:x.jsx(Li,{remarkPlugins:[Bi],components:Du,children:e.summary})})}),children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(L0,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(el,{children:"Summarized"})]})})}const ID={compacting:"Compacting..."};function GD({message:e}){const r=ID[e.status]||e.status;return x.jsxs(ll,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(L0,{className:"h-4.5 w-4.5 text-muted-foreground"})}),x.jsx(el,{className:"text-left transition-opacity duration-200 truncate",children:r})]})}const iv={Read:{key:"read",singular:"read",plural:"reads"},Edit:{key:"edit",singular:"edit",plural:"edits"},Write:{key:"write",singular:"write",plural:"writes"},Bash:{key:"bash",singular:"command",plural:"commands"},Grep:{key:"grep",singular:"search",plural:"searches"},Glob:{key:"glob",singular:"glob",plural:"globs"},Task:{key:"task",singular:"agent",plural:"agents"},WebFetch:{key:"webfetch",singular:"fetch",plural:"fetches"},WebSearch:{key:"websearch",singular:"web search",plural:"web searches"},Skill:{key:"skill",singular:"skill",plural:"skills"},TodoWrite:{key:"todo",singular:"todo update",plural:"todo updates"}},YD={key:"dbquery",singular:"query",plural:"queries"},$D={key:"other",singular:"tool call",plural:"tool calls"};function XD(e){return iv[e]?iv[e]:/^mcp__db__.+_query$/.test(e)?YD:$D}function QD(e){const r=new Map,l=[];for(const i of e){const o=i.processed.toolName,u=XD(o),c=r.get(u.key);c?c.count++:(r.set(u.key,{category:u,count:1}),l.push(u.key))}return l.map(i=>{const{category:o,count:u}=r.get(i);return`${u} ${u===1?o.singular:o.plural}`}).join(", ")}function ZD({messages:e,isLoading:r,outputsUrl:l,localPath:i}){const[o,u]=S.useState(!1),c=S.useMemo(()=>QD(e),[e]),d=e.some(m=>m.processed.result===void 0)&&r;return x.jsx(ll,{className:"w-full",children:x.jsxs("div",{className:"flex flex-col w-full",children:[x.jsx("button",{onClick:()=>u(!o),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!o&&!d?"hover:opacity-60 transition-opacity":""}`,children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Kr,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${o?"rotate-90":""}`})}),x.jsx(el,{className:"text-left",children:x.jsx(Ru,{animate:d,children:c})})]})}),o&&x.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[e.map(m=>x.jsx(iS,{message:m.processed,isLoading:r,outputsUrl:l,localPath:i},m.id)),e.length>5&&x.jsx("button",{onClick:()=>u(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:x.jsx(Kr,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),x.jsx(el,{className:"text-left",children:"Collapse"})]})})]})]})})}const KD=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite"]);function av(e){var l;if(((l=e.processed)==null?void 0:l.kind)!=="tool")return!1;const r=e.processed.toolName;return!KD.has(r)}function JD(e){const r=[];let l=0;for(;l<e.length;){const i=e[l];if(av(i)){const o=[i],u=l;for(l+=1;l<e.length&&av(e[l]);)o.push(e[l]),l+=1;o.length>=2?r.push({type:"tool-group",messages:o,startIndex:u}):r.push({type:"single",message:i,index:u});continue}r.push({type:"single",message:i,index:l}),l+=1}return r}function WD({messages:e,isLoading:r,localPath:l,latestToolIds:i,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:u}){const c=S.useMemo(()=>JD(e),[e]);function f(d,m){var y,b;if(d.role==="user")return x.jsx(pD,{content:d.content},d.id);const g=d.processed;if(!g)return x.jsx(gD,{json:d.content},d.id);switch(g.kind){case"system":return e.findIndex(k=>{var C;return((C=k.processed)==null?void 0:C.kind)==="system"})===m?x.jsx(wD,{message:g,rawJson:d.rawJson},d.id):null;case"account_info":return e.findIndex(k=>{var C;return((C=k.processed)==null?void 0:C.kind)==="account_info"})===m?x.jsx(SD,{message:g},d.id):null;case"text":return x.jsx(kD,{message:g},d.id);case"tool":return g.toolName==="AskUserQuestion"?x.jsx(AD,{message:g,onSubmit:o,isLatest:g.id===i.AskUserQuestion},d.id):g.toolName==="ExitPlanMode"?x.jsx(jD,{message:g,onConfirm:u,isLatest:g.id===i.ExitPlanMode},d.id):g.toolName==="TodoWrite"?g.id!==i.TodoWrite?null:x.jsx(_D,{message:g},d.id):x.jsx(iS,{message:g,isLoading:r,localPath:l},d.id);case"result":{const v=e[m+1],k=e[m-1];return((y=v==null?void 0:v.processed)==null?void 0:y.kind)==="context_cleared"||((b=k==null?void 0:k.processed)==null?void 0:b.kind)==="context_cleared"?null:x.jsx(HD,{message:g},d.id)}case"interrupted":return x.jsx(PD,{message:g},d.id);case"compact_boundary":return x.jsx(qD,{},d.id);case"context_cleared":return x.jsx(FD,{},d.id);case"compact_summary":return x.jsx(VD,{message:g},d.id);case"status":return m===e.length-1?x.jsx(GD,{message:g},d.id):null}}return x.jsx(x.Fragment,{children:c.map(d=>{if(d.type==="tool-group")return x.jsx("div",{className:"group relative",children:x.jsx(ZD,{messages:d.messages,isLoading:r,localPath:l})},`group-${d.startIndex}`);const m=f(d.message,d.index);return m?x.jsx("div",{id:`msg-${d.message.id}`,className:"group relative",children:m},d.message.id):null})})}function ov(){var r,l,i;const e=Av();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsxs(G1,{className:"bg-background flex-1 flex flex-col overflow-hidden border-0 rounded-none relative",children:[x.jsxs($1,{className:"flex-1 p-0 overflow-hidden relative",children:[x.jsx(FR,{sidebarCollapsed:e.sidebarCollapsed,onOpenSidebar:e.openSidebar,onExpandSidebar:e.expandSidebar,onNewChat:e.handleCompose,localPath:e.navbarLocalPath,onOpenExternal:o=>{e.handleOpenExternal(o)}}),x.jsx(K1,{ref:e.scrollRef,onScroll:e.updateScrollState,className:"h-full px-4 scroll-pt-[72px]",children:x.jsxs("div",{className:"animate-fade-in space-y-5 pt-[72px] max-w-[800px] mx-auto",style:{paddingBottom:e.transcriptPaddingBottom},children:[e.messages.length===0?x.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[40vh] text-muted-foreground gap-4",children:[x.jsx(Qa,{strokeWidth:1.5,className:"size-8 text-muted-foreground"}),x.jsx("div",{className:"text-base font-normal text-muted-foreground text-center max-w-xs",children:"What are we making?"})]}):x.jsx(WD,{messages:e.messages,isLoading:e.isProcessing,localPath:(r=e.runtime)==null?void 0:r.localPath,latestToolIds:e.latestToolIds,onAskUserQuestionSubmit:e.handleAskUserQuestion,onExitPlanModeConfirm:e.handleExitPlanMode}),e.isProcessing?x.jsx(YR,{status:(l=e.runtime)==null?void 0:l.status}):null,e.commandError?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3",children:e.commandError}):null,x.jsx("div",{className:"flex-1 min-h-[10vh]","aria-hidden":"true"})]})}),x.jsx("div",{style:{bottom:e.transcriptPaddingBottom-36},className:xe("absolute left-1/2 -translate-x-1/2 z-10 transition-all",e.showScrollButton?"scale-100 duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)]":"scale-60 duration-300 ease-out pointer-events-none blur-sm opacity-0"),children:x.jsx("button",{onClick:e.scrollToBottom,className:"flex items-center transition-colors gap-1.5 px-2 bg-white hover:bg-muted border border-border rounded-full aspect-square cursor-pointer text-sm text-primary hover:text-foreground dark:bg-slate-700 dark:hover:bg-slate-600 dark:text-slate-100 dark:border-slate-600",children:x.jsx($A,{className:"h-5 w-5"})})})]}),x.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:x.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:e.inputRef,children:x.jsx(UR,{onSubmit:e.handleSend,onCancel:()=>{e.handleCancel()},disabled:!e.hasSelectedProject||((i=e.runtime)==null?void 0:i.status)==="waiting_for_user",canCancel:e.canCancel,chatId:e.activeChatId},e.activeChatId??"new-chat")})})]})})}function e6({text:e}){const[r,l]=S.useState(!1);async function i(){await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3)}return x.jsx(qe,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void i(),children:r?x.jsx(_l,{className:"h-4 w-4 text-green-400"}):x.jsx(ku,{className:"h-4 w-4"})})}function sv({children:e}){return x.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm",children:[x.jsxs("pre",{className:"inline-flex items-center gap-2 overflow-x-auto",children:[x.jsx(Kr,{className:"inline h-4 w-4 opacity-40"}),x.jsx("code",{children:e})]}),x.jsx(e6,{text:e})]})}function Ys({children:e}){return x.jsx("div",{className:"bg-card border border-border rounded-2xl p-4",children:e})}function Fd({children:e}){return x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider mb-3",children:e})}function uv({narrow:e=!1,title:r,subtitle:l,icon:i=Oh}){return x.jsxs("div",{className:xe("w-full",e?"max-w-2xl px-6 pt-16 mx-auto":"px-6 pt-16 mb-10"),children:[x.jsxs("div",{className:xe("flex items-center gap-3 mb-2",e&&"justify-center"),children:[x.jsx("div",{className:"p-2 pl-0 rounded-lg",children:x.jsx(i,{className:"h-6 w-6 text-muted-foreground"})}),x.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:r})]}),x.jsx("p",{className:xe("text-muted-foreground",e&&"mb-10 text-center"),children:l})]})}function Vd({icon:e,title:r,subtitle:l,iconClassName:i}){return x.jsxs("div",{className:"flex flex-col items-center gap-0",children:[x.jsx("div",{className:"p-3 mb-2 rounded-xl bg-background border border-border",children:x.jsx(e,{className:i||"h-8 w-8 text-muted-foreground"})}),x.jsx("span",{className:"text-sm font-medium",children:r}),x.jsx("span",{className:"text-xs text-muted-foreground",children:l})]})}function cv(){return x.jsx(QA,{className:"h-4 w-4 text-muted-foreground"})}function fv({number:e,title:r,children:l}){return x.jsx("div",{className:"flex gap-4",children:x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-baseline gap-3",children:[x.jsxs("div",{className:"flex-shrink-0 flex items-center justify-center font-medium text-logo",children:[e,"."]}),x.jsx("h3",{className:"font-medium text-foreground mb-2",children:r})]}),x.jsx("div",{className:"text-muted-foreground text-sm space-y-3",children:l})]})})}function t6({localPath:e,loading:r,onClick:l}){return x.jsxs(ou,{children:[x.jsx(su,{asChild:!0,children:x.jsxs("button",{className:xe("border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors",r&&"opacity-50 cursor-not-allowed"),disabled:r,onClick:l,children:[x.jsx(O0,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),x.jsx("span",{className:"font-medium text-foreground truncate flex-1",children:A1(e)}),r?x.jsx(zl,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0"}):x.jsx(Dh,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0"})]})}),x.jsx(no,{children:x.jsx("p",{children:e})})]})}function n6({connectionStatus:e,ready:r,snapshot:l,startingLocalPath:i,commandError:o,onOpenProject:u,onCreateProject:c}){const[f,d]=S.useState(!1),m=S.useMemo(()=>(l==null?void 0:l.projects)??[],[l==null?void 0:l.projects]),g=e==="connecting"||!r,y=e==="connected"&&r;return x.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-y-auto",children:[y?x.jsxs(x.Fragment,{children:[x.jsx(uv,{title:(l==null?void 0:l.machine.displayName)??"Local Projects",subtitle:`${zt} is connected, choose a project below to get started.`}),x.jsxs("div",{className:"w-full px-6 mb-10",children:[x.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[x.jsx("h2",{className:"text-[13px] font-medium text-muted-foreground uppercase tracking-wider",children:"Projects"}),x.jsxs(qe,{variant:"default",size:"sm",onClick:()=>d(!0),children:[x.jsx(U0,{className:"h-4 w-4 mr-1.5"}),"Add Project"]})]}),m.length>0?x.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4 3xl:grid-cols-5 gap-2",children:m.map(b=>x.jsx(t6,{localPath:b.localPath,loading:i===b.localPath,onClick:()=>{u(b.localPath)}},b.localPath))}):x.jsx(Ys,{children:x.jsx("p",{className:"text-sm text-muted-foreground",children:"No Claude projects discovered yet. Open one with Claude Code or create a new project here."})}),o?x.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4",children:o}):null]})]}):x.jsxs(x.Fragment,{children:[x.jsx(uv,{narrow:!0,icon:Jx,title:g?`Connecting ${zt}`:`Connect ${zt}`,subtitle:g?`${zt} is starting up and loading your local projects.`:`Run ${zt} directly on your machine with full access to your local files and Claude projects.`}),x.jsxs("div",{className:"max-w-2xl w-full mx-auto pb-12 px-6",children:[x.jsx(Fd,{children:"Status"}),x.jsx("div",{className:"mb-8",children:x.jsx(Ys,{children:x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx(zl,{className:"h-4 w-4 text-muted-foreground animate-spin"}),x.jsx("span",{className:"text-sm text-muted-foreground",children:g?`Connecting to your local ${zt} server...`:x.jsxs(x.Fragment,{children:["Not connected. Run ",x.jsx("code",{className:"bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground",children:qs()})," from any terminal on this machine."]})})]})})}),g?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(Fd,{children:"How it works"}),x.jsx(Ys,{children:x.jsxs("div",{className:"flex items-center justify-around gap-6 py-4 px-2",children:[x.jsx(Vd,{icon:Lh,title:`${zt} CLI`,subtitle:"On Your Machine"}),x.jsx(cv,{}),x.jsx(Vd,{icon:Oh,title:`${zt} Server`,subtitle:"Local WebSocket"}),x.jsx(cv,{}),x.jsx(Vd,{icon:Jx,title:`${zt} UI`,subtitle:"Project Chat"})]})})]}),g?null:x.jsxs("div",{className:"mb-10",children:[x.jsx(Fd,{children:"Setup"}),x.jsx(Ys,{children:x.jsxs("div",{className:"space-y-4",children:[x.jsxs(fv,{number:1,title:`Start ${zt}`,children:[x.jsx("p",{children:"Run this command in your terminal:"}),x.jsx(sv,{children:qs()})]}),x.jsxs(fv,{number:2,title:"Open the local UI",children:[x.jsxs("p",{children:[zt," serves the app locally and opens the Local Projects page in an app-style browser window."]}),x.jsx(sv,{children:"http://localhost:3210/local"})]}),x.jsxs("div",{className:"mt-8",children:[x.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-4",children:"Notes"}),x.jsxs("div",{className:"space-y-3 text-sm",children:[x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:qs("").trim()}),x.jsx("span",{className:"text-muted-foreground",children:"Start in the current directory"})]}),x.jsxs("div",{className:"flex gap-4",children:[x.jsx("code",{className:"font-mono text-foreground whitespace-nowrap",children:qs("--no-open")}),x.jsx("span",{className:"text-muted-foreground",children:"Start the server without opening the browser"})]})]})]})]})})]})]})]}),x.jsx(N1,{open:f,onOpenChange:d,onConfirm:b=>{c(b)}}),x.jsx("div",{className:"py-4 text-center",children:x.jsxs("span",{className:"text-xs text-muted-foreground/50",children:["v",rR.split("/")[1]]})})]})}function r6(){const e=Av();return x.jsx("div",{className:"flex-1 flex flex-col min-w-0 relative",children:x.jsx(n6,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}function l6(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Dn(){return new Date().toISOString()}function i6(e,r){var o,u,c,f;const l=l6(e),i={processed:null,rawJson:l};try{const d=JSON.parse(e);if(d.type==="user_prompt"&&d.content)return{...i,isUserMessage:!0,userContent:d.content};if(d.type==="system"&&d.subtype==="init")return{processed:{id:zn(),kind:"system",model:d.model||"unknown",tools:d.tools||[],agents:d.agents||[],slashCommands:((o=d.slash_commands)==null?void 0:o.filter(m=>!m.startsWith("._")))||[],mcpServers:d.mcp_servers||[],timestamp:Dn()},rawJson:l};if(d.type==="system"&&d.subtype==="account_info")return{processed:{id:zn(),kind:"account_info",accountInfo:d.accountInfo,timestamp:Dn()},rawJson:l};if(d.type==="assistant"&&((u=d.message)!=null&&u.content))for(const m of d.message.content){if(m.type==="text"&&m.text)return{processed:{id:zn(),kind:"text",text:m.text,timestamp:Dn()},rawJson:l};if(m.type==="tool_use"){const g={id:zn(),kind:"tool",toolName:m.name,toolId:m.id,input:m.input||{},timestamp:Dn()};return r.set(m.id,g),{processed:g,rawJson:l}}}if(d.type==="user"&&((c=d.message)!=null&&c.content)){for(const m of d.message.content)if(m.type==="tool_result"&&m.tool_use_id){const g=r.get(m.tool_use_id);if(g)return g.result=m.content||"(empty)",g.isError=m.is_error||!1,r.delete(m.tool_use_id),i}}return d.type==="result"?d.subtype==="cancelled"?{processed:{id:zn(),kind:"interrupted",timestamp:Dn()},rawJson:l}:{processed:{id:zn(),kind:"result",success:!d.is_error,result:d.result||"",durationMs:d.duration_ms||0,costUsd:d.total_cost_usd,timestamp:Dn()},rawJson:l}:d.type==="system"&&d.subtype==="status"&&d.status?{processed:{id:zn(),kind:"status",status:d.status,timestamp:Dn()},rawJson:l}:d.type==="system"&&d.subtype==="compact_boundary"?{processed:{id:zn(),kind:"compact_boundary",timestamp:Dn()},rawJson:l}:d.type==="system"&&d.subtype==="context_cleared"?{processed:{id:zn(),kind:"context_cleared",timestamp:Dn()},rawJson:l}:d.type==="user"&&((f=d.message)==null?void 0:f.role)==="user"&&typeof d.message.content=="string"&&d.message.content.startsWith("This session is being continued")?{processed:{id:zn(),kind:"compact_summary",summary:d.message.content,timestamp:Dn()},rawJson:l}:i}catch{return i}}function a6(e){const r=new Map,l=[];for(const i of e){const{processed:o,rawJson:u,isUserMessage:c,userContent:f}=i6(i.message,r);if(c&&f){l.push({id:i._id,messageId:i.messageId,role:"user",content:f,timestamp:new Date(i.createdAt).toISOString(),hidden:i.hidden});continue}o!==null&&l.push({id:i._id,messageId:i.messageId,role:"assistant",content:u,timestamp:new Date(i.createdAt).toISOString(),processed:o,rawJson:u,hidden:i.hidden})}return l}const o6=["AskUserQuestion","ExitPlanMode","TodoWrite"],s6=new Set(["TodoWrite"]);function u6(e,r){var l;for(let i=e.length-1;i>=0;i-=1){const o=e[i];if(((l=o.processed)==null?void 0:l.kind)!=="tool")continue;const u=o.processed;if(u.toolName===r&&!u.result)return u.id}return null}function c6(e,r){var l;for(let i=e.length-1;i>=0;i-=1){const o=e[i];if(((l=o.processed)==null?void 0:l.kind)!=="tool")continue;const u=o.processed;if(u.toolName===r)return u.id}return null}function f6(e){const r={};for(const l of o6)r[l]=s6.has(l)?c6(e,l):u6(e,l);return r}function d6(e){return e==="starting"||e==="running"||e==="waiting_for_user"}function h6(e){return e==="starting"||e==="running"||e==="waiting_for_user"}class m6{constructor(r){cr(this,"url");cr(this,"ws",null);cr(this,"reconnectTimer",null);cr(this,"reconnectDelayMs",750);cr(this,"subscriptions",new Map);cr(this,"pending",new Map);cr(this,"outboundQueue",[]);cr(this,"statusListeners",new Set);this.url=r,this.connect()}dispose(){var r;this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(r=this.ws)==null||r.close(),this.ws=null;for(const l of this.pending.values())l.reject(new Error("Socket disposed"));this.pending.clear()}onStatus(r){return this.statusListeners.add(r),r(this.getStatus()),()=>{this.statusListeners.delete(r)}}subscribe(r,l){const i=crypto.randomUUID();return this.subscriptions.set(i,{topic:r,listener:l}),this.enqueue({v:1,type:"subscribe",id:i,topic:r}),()=>{this.subscriptions.delete(i),this.enqueue({v:1,type:"unsubscribe",id:i})}}command(r){const l=crypto.randomUUID(),i={v:1,type:"command",id:l,command:r};return new Promise((o,u)=>{this.pending.set(l,{resolve:o,reject:u}),this.enqueue(i)})}connect(){this.emitStatus("connecting"),this.ws=new WebSocket(this.url),this.ws.addEventListener("open",()=>{this.reconnectDelayMs=750,this.emitStatus("connected");for(const[r,l]of this.subscriptions.entries())this.sendNow({v:1,type:"subscribe",id:r,topic:l.topic});for(;this.outboundQueue.length>0;){const r=this.outboundQueue.shift();r&&this.sendNow(r)}}),this.ws.addEventListener("message",r=>{let l;try{l=JSON.parse(String(r.data))}catch{return}if(l.type==="snapshot"){const i=this.subscriptions.get(l.id);i==null||i.listener(l.snapshot.data);return}if(l.type==="ack"){const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.resolve(l.result);return}if(l.type==="error"){if(!l.id){console.error(lR,l.message);return}const i=this.pending.get(l.id);if(!i)return;this.pending.delete(l.id),i.reject(new Error(l.message))}}),this.ws.addEventListener("close",()=>{this.emitStatus("disconnected");for(const r of this.pending.values())r.reject(new Error("Disconnected"));this.pending.clear(),this.scheduleReconnect()})}scheduleReconnect(){this.reconnectTimer===null&&(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect(),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,5e3)},this.reconnectDelayMs))}getStatus(){var r,l;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN?"connected":((l=this.ws)==null?void 0:l.readyState)===WebSocket.CONNECTING?"connecting":"disconnected"}emitStatus(r){for(const l of this.statusListeners)l(r)}enqueue(r){var l;if(((l=this.ws)==null?void 0:l.readyState)===WebSocket.OPEN){this.sendNow(r);return}this.outboundQueue.push(r)}sendNow(r){var l;(l=this.ws)==null||l.send(JSON.stringify(r))}}function p6(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}function g6(){const e=S.useRef(null);return e.current||(e.current=new m6(p6())),S.useEffect(()=>{const r=e.current;return()=>{r==null||r.dispose()}},[]),e.current}function y6(e){var Ll,xt,Bl;const r=xh(),l=g6(),i=yT(),[o,u]=S.useState({projectGroups:[]}),[c,f]=S.useState(null),[d,m]=S.useState(null),[g,y]=S.useState("connecting"),[b,v]=S.useState(!1),[k,C]=S.useState(!1),[A,N]=S.useState(!1),[O,_]=S.useState(null),[U,F]=S.useState(!1),[z,B]=S.useState(!1),[$,ae]=S.useState(148),[P,re]=S.useState(!0),[le,se]=S.useState(null),[J,Z]=S.useState(null),[D,X]=S.useState(null),ne=S.useRef(null),ie=S.useRef(null);S.useEffect(()=>l.onStatus(y),[l]),S.useEffect(()=>l.subscribe({type:"sidebar"},H=>{u(H),v(!0),se(null)}),[l]),S.useEffect(()=>l.subscribe({type:"local-projects"},H=>{f(H),C(!0),se(null)}),[l]),S.useEffect(()=>{if(!e){m(null),N(!0);return}return N(!1),l.subscribe({type:"chat",chatId:e},H=>{m(H),N(!0),se(null)})},[e,l]),S.useEffect(()=>{if(O)return;const H=o.projectGroups[0];H&&_(H.groupKey)},[O,o.projectGroups]),S.useEffect(()=>{if(!e||!b||!A)return;if(o.projectGroups.some(K=>K.chats.some(fe=>fe.chatId===e))){D===e&&X(null);return}D!==e&&r("/")},[e,A,r,D,o.projectGroups,b]),S.useEffect(()=>{d&&(_(d.runtime.projectId),D===d.runtime.chatId&&X(null))},[d,D]),S.useLayoutEffect(()=>{const H=ie.current;if(!H)return;const K=new ResizeObserver(()=>{ae(H.getBoundingClientRect().height)});return K.observe(H),ae(H.getBoundingClientRect().height),()=>K.disconnect()},[]);const j=S.useMemo(()=>a6((d==null?void 0:d.messages)??[]),[d==null?void 0:d.messages]),R=S.useMemo(()=>f6(j),[j]),G=(d==null?void 0:d.runtime)??null,T=h6(G==null?void 0:G.status),ue=d6(G==null?void 0:G.status),de=$+48,ce=!P&&j.length>0,Ce=((Ll=c==null?void 0:c.projects[0])==null?void 0:Ll.localPath)??null,Ue=(G==null?void 0:G.localPath)??Ce??((xt=o.projectGroups[0])==null?void 0:xt.localPath),ve=!!(O??(G==null?void 0:G.projectId)??((Bl=o.projectGroups[0])==null?void 0:Bl.groupKey)??Ce);S.useEffect(()=>{const H=ne.current;if(!H)return;H.scrollHeight-H.scrollTop-H.clientHeight<120&&H.scrollTo({top:H.scrollHeight,behavior:"smooth"})},[e,j.length,G==null?void 0:G.status]);function at(){const H=ne.current;if(!H)return;const K=H.scrollHeight-H.scrollTop-H.clientHeight;re(K<24)}function dt(){const H=ne.current;H&&H.scrollTo({top:H.scrollHeight,behavior:"smooth"})}async function At(H){try{const K=await l.command({type:"chat.create",projectId:H});_(H),X(K.chatId),r(`/chat/${K.chatId}`),F(!1)}catch(K){se(K instanceof Error?K.message:String(K))}}async function wt(H){try{Z(H);const K=await l.command({type:"project.open",localPath:H});_(K.projectId);const fe=await l.command({type:"chat.create",projectId:K.projectId});X(fe.chatId),r(`/chat/${fe.chatId}`),F(!1),se(null)}catch(K){se(K instanceof Error?K.message:String(K))}finally{Z(null)}}async function ht(H){try{Z(H.localPath);const K=await l.command(H.mode==="new"?{type:"project.create",localPath:H.localPath,title:H.title}:{type:"project.open",localPath:H.localPath});_(K.projectId);const fe=await l.command({type:"chat.create",projectId:K.projectId});X(fe.chatId),r(`/chat/${fe.chatId}`),F(!1),se(null)}catch(K){se(K instanceof Error?K.message:String(K))}finally{Z(null)}}async function jn(H,K){var fe;try{let ge=O??((fe=o.projectGroups[0])==null?void 0:fe.groupKey)??null;if(!e&&!ge&&Ce&&(ge=(await l.command({type:"project.open",localPath:Ce})).projectId,_(ge)),!e&&!ge)throw new Error("Open a project first");const Ee=await l.command({type:"chat.send",chatId:e??void 0,projectId:e?void 0:ge??void 0,content:H,model:K==null?void 0:K.model,effort:K==null?void 0:K.effort,planMode:K==null?void 0:K.planMode});!e&&Ee.chatId&&(X(Ee.chatId),r(`/chat/${Ee.chatId}`)),se(null)}catch(ge){throw se(ge instanceof Error?ge.message:String(ge)),ge}}async function Tn(){if(e)try{await l.command({type:"chat.cancel",chatId:e})}catch(H){se(H instanceof Error?H.message:String(H))}}async function xr(H){if(await i.confirm({title:"Delete Chat",description:`Delete "${H.title}"? This cannot be undone.`,confirmLabel:"Delete",confirmVariant:"destructive"}))try{await l.command({type:"chat.delete",chatId:H.chatId}),H.chatId===e&&r("/")}catch(fe){se(fe instanceof Error?fe.message:String(fe))}}async function br(H){const K=o.projectGroups.find(Ee=>Ee.groupKey===H);if(!K)return;const fe=K.localPath.split("/").filter(Boolean).pop()??K.localPath;if(await i.confirm({title:"Remove Project",description:`Remove "${fe}" from the sidebar? Existing chats will be removed from ${zt}.`,confirmLabel:"Remove",confirmVariant:"destructive"}))try{await l.command({type:"project.remove",projectId:H}),(G==null?void 0:G.projectId)===H&&r("/projects"),se(null)}catch(Ee){se(Ee instanceof Error?Ee.message:String(Ee))}}async function $t(H){var fe,ge;const K=(G==null?void 0:G.localPath)??((fe=c==null?void 0:c.projects[0])==null?void 0:fe.localPath)??((ge=o.projectGroups[0])==null?void 0:ge.localPath);if(K)try{await l.command({type:"system.openExternal",action:H,localPath:K})}catch(Ee){se(Ee instanceof Error?Ee.message:String(Ee))}}function vr(){var fe,ge;const H=O??((fe=o.projectGroups[0])==null?void 0:fe.groupKey);if(H){At(H);return}const K=(ge=c==null?void 0:c.projects[0])==null?void 0:ge.localPath;if(K){wt(K);return}r("/projects")}async function al(H,K,fe){if(e)try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:H,result:{questions:K,answers:fe}})}catch(ge){se(ge instanceof Error?ge.message:String(ge))}}async function Ii(H,K,fe,ge){if(e){K&&I1.getState().setPlanMode(!1);try{await l.command({type:"chat.respondTool",chatId:e,toolUseId:H,result:{confirmed:K,...fe?{clearContext:!0}:{},...ge?{message:ge}:{}}})}catch(Ee){se(Ee instanceof Error?Ee.message:String(Ee))}}}return{activeChatId:e,sidebarData:o,localProjects:c,chatSnapshot:d,connectionStatus:g,sidebarReady:b,localProjectsReady:k,commandError:le,startingLocalPath:J,sidebarOpen:U,sidebarCollapsed:z,scrollRef:ne,inputRef:ie,messages:j,latestToolIds:R,runtime:G,isProcessing:T,canCancel:ue,transcriptPaddingBottom:de,showScrollButton:ce,navbarLocalPath:Ue,hasSelectedProject:ve,openSidebar:()=>F(!0),closeSidebar:()=>F(!1),collapseSidebar:()=>B(!0),expandSidebar:()=>B(!1),updateScrollState:at,scrollToBottom:dt,handleCreateChat:At,handleOpenLocalProject:wt,handleCreateProject:ht,handleSend:jn,handleCancel:Tn,handleDeleteChat:xr,handleRemoveProject:br,handleOpenExternal:$t,handleCompose:vr,handleAskUserQuestion:al,handleExitPlanMode:Ii}}function x6(){const e=Fn(),r=xC(),l=y6(r.chatId??null),i=e.pathname==="/projects";return x.jsxs("div",{className:"flex h-[100dvh] min-h-[100dvh] overflow-hidden",children:[x.jsx(NR,{data:l.sidebarData,activeChatId:l.activeChatId,connectionStatus:l.connectionStatus,ready:l.sidebarReady,open:l.sidebarOpen,collapsed:l.sidebarCollapsed,showMobileOpenButton:i,onOpen:l.openSidebar,onClose:l.closeSidebar,onCollapse:l.collapseSidebar,onExpand:l.expandSidebar,onCreateChat:o=>{l.handleCreateChat(o)},onCreateProject:o=>{l.handleCreateProject(o)},onDeleteChat:o=>{l.handleDeleteChat(o)},onRemoveProject:o=>{l.handleRemoveProject(o)}}),x.jsx(MC,{context:l})]})}function b6(){return x.jsx(eR,{children:x.jsx(gT,{children:x.jsx(zC,{children:x.jsxs($a,{element:x.jsx(x6,{}),children:[x.jsx($a,{path:"/",element:x.jsx(ov,{})}),x.jsx($a,{path:"/projects",element:x.jsx(r6,{})}),x.jsx($a,{path:"/chat/:chatId",element:x.jsx(ov,{})})]})})})})}const aS="lever-theme",v6=S.createContext(void 0),w6=e=>e==="light"||e==="dark"||e==="system",oS=()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",dv=e=>{if(typeof document>"u")return;const r=e==="system"?oS():e;document.documentElement.classList.toggle("dark",r==="dark")},S6=()=>{if(typeof window>"u")return"system";const e=window.localStorage.getItem(aS);return w6(e)?e:"system"};function k6({children:e}){const[r,l]=S.useState(S6);S.useEffect(()=>{dv(r),typeof window<"u"&&window.localStorage.setItem(aS,r)},[r]),S.useEffect(()=>{if(r!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>dv("system");return o.addEventListener?(o.addEventListener("change",u),()=>o.removeEventListener("change",u)):(o.addListener(u),()=>o.removeListener(u))},[r]);const i=S.useMemo(()=>{const o=r==="system"?oS():r;return{theme:r,resolvedTheme:o,setTheme:l}},[r]);return x.jsx(v6.Provider,{value:i,children:e})}const sS=document.getElementById("root");if(!sS)throw new Error("Missing #root");z2.createRoot(sS).render(x.jsx(S.StrictMode,{children:x.jsx(lE,{children:x.jsx(k6,{children:x.jsx(b6,{})})})}));
@@ -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-DelZ0MyD.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CjRaPaQM.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BRiM6Nxc.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,8 +1,20 @@
1
1
  {
2
2
  "name": "kanna-code",
3
3
  "type": "module",
4
- "version": "0.1.3",
5
- "description": "Local-only project chat UI",
4
+ "version": "0.1.4",
5
+ "description": "A beautiful web UI for Claude Code",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "claude",
9
+ "claude-code",
10
+ "ai",
11
+ "chat",
12
+ "ui",
13
+ "agent",
14
+ "anthropic",
15
+ "bun",
16
+ "react"
17
+ ],
6
18
  "repository": {
7
19
  "type": "git",
8
20
  "url": "git+https://github.com/jakemor/kanna.git"