kaizenai 0.7.1 → 0.7.2

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.
Files changed (30) hide show
  1. package/dist/client/assets/{FeatureOverviewPage-DGosnNE0.js → FeatureOverviewPage-Cbp5uhtA.js} +1 -1
  2. package/dist/client/assets/FeatureOverviewPage-Cbp5uhtA.js.br +0 -0
  3. package/dist/client/assets/FeatureOverviewPage-Cbp5uhtA.js.gz +0 -0
  4. package/dist/client/assets/{LocalProjectsPage-gWrmUSs2.js → LocalProjectsPage-CihqlQOs.js} +1 -1
  5. package/dist/client/assets/LocalProjectsPage-CihqlQOs.js.br +0 -0
  6. package/dist/client/assets/LocalProjectsPage-CihqlQOs.js.gz +0 -0
  7. package/dist/client/assets/SettingsPage-jZce-i3Z.js +51 -0
  8. package/dist/client/assets/SettingsPage-jZce-i3Z.js.br +0 -0
  9. package/dist/client/assets/SettingsPage-jZce-i3Z.js.gz +0 -0
  10. package/dist/client/assets/{eye-BXpLGEx5.js → eye-BkdZGixK.js} +1 -1
  11. package/dist/client/assets/eye-BkdZGixK.js.br +0 -0
  12. package/dist/client/assets/eye-BkdZGixK.js.gz +0 -0
  13. package/dist/client/assets/{index-SgSBQKg3.js → index-B7C7C1FY.js} +3 -3
  14. package/dist/client/assets/index-B7C7C1FY.js.br +0 -0
  15. package/dist/client/assets/{index-SgSBQKg3.js.gz → index-B7C7C1FY.js.gz} +0 -0
  16. package/dist/client/index.html +1 -1
  17. package/dist/server/build-target.json +1 -1
  18. package/dist/server/cli-supervisor.js +1 -3
  19. package/dist/server/cli.js +1 -3
  20. package/package.json +1 -3
  21. package/dist/client/assets/FeatureOverviewPage-DGosnNE0.js.br +0 -0
  22. package/dist/client/assets/FeatureOverviewPage-DGosnNE0.js.gz +0 -0
  23. package/dist/client/assets/LocalProjectsPage-gWrmUSs2.js.br +0 -0
  24. package/dist/client/assets/LocalProjectsPage-gWrmUSs2.js.gz +0 -0
  25. package/dist/client/assets/SettingsPage-BPpmk_eT.js +0 -51
  26. package/dist/client/assets/SettingsPage-BPpmk_eT.js.br +0 -0
  27. package/dist/client/assets/SettingsPage-BPpmk_eT.js.gz +0 -0
  28. package/dist/client/assets/eye-BXpLGEx5.js.br +0 -0
  29. package/dist/client/assets/eye-BXpLGEx5.js.gz +0 -0
  30. package/dist/client/assets/index-SgSBQKg3.js.br +0 -0
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FeatureOverviewPage-DGosnNE0.js","assets/eye-BXpLGEx5.js","assets/SettingsPage-BPpmk_eT.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FeatureOverviewPage-Cbp5uhtA.js","assets/eye-BkdZGixK.js","assets/SettingsPage-jZce-i3Z.js"])))=>i.map(i=>d[i]);
2
2
  var Qj=Object.defineProperty;var BC=t=>{throw TypeError(t)};var Zj=(t,e,n)=>e in t?Qj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var pn=(t,e,n)=>Zj(t,typeof e!="symbol"?e+"":e,n),FC=(t,e,n)=>e.has(t)||BC("Cannot "+n);var Ad=(t,e,n)=>(FC(t,e,"read from private field"),n?n.call(t):e.get(t)),HC=(t,e,n)=>e.has(t)?BC("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),$C=(t,e,n,r)=>(FC(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);function Jj(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function tg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var K0={exports:{}},Nd={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -465,7 +465,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
465
465
  3. Refresh the page.
466
466
  4. Right-click the get-current-period-usage request.
467
467
  5. Copy > Copy as cURL.
468
- 6. Paste it here.`;function q7(t){const e=ke.c(44),{open:n,onOpenChange:r,onSubmit:i}=t,s=_.useRef(null),[a,c]=_.useState(""),[d,u]=_.useState(!1);let f,m;e[0]!==n?(f=()=>{n&&(c(""),setTimeout(()=>{var I;return(I=s.current)==null?void 0:I.focus()},0))},m=[n],e[0]=n,e[1]=f,e[2]=m):(f=e[1],m=e[2]),_.useEffect(f,m);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=async function(){const $=await navigator.clipboard.readText();c($)},e[3]=v):v=e[3];const b=v;let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=async function(){await navigator.clipboard.writeText(Hk),u(!0),setTimeout(()=>u(!1),2e3)},e[4]=S):S=e[4];const x=S;let C;e[5]!==a?(C=a.trim(),e[5]=a,e[6]=C):C=e[6];const k=C.length>0;let E;e[7]!==k||e[8]!==a||e[9]!==i?(E=I=>{I.preventDefault(),k&&i(a.trim())},e[7]=k,e[8]=a,e[9]=i,e[10]=E):E=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=g.jsx(Ay,{children:"Import Cursor Session"}),e[11]=R):R=e[11];let M,O;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=g.jsxs(Ny,{children:["Paste the copied ",g.jsx("code",{children:"get-current-period-usage"})," curl command and Kaizen will import the session for you."]}),O=g.jsx("div",{className:"rounded-xl border border-border bg-card px-3 py-3 text-sm text-muted-foreground whitespace-pre-line",children:Hk}),e[12]=M,e[13]=O):(M=e[12],O=e[13]);let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=g.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>void b(),children:"Paste Clipboard"}),e[14]=D):D=e[14];let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=()=>void x(),e[15]=P):P=e[15];let z;e[16]!==d?(z=d?g.jsx(di,{className:"h-4 w-4"}):g.jsx(lu,{className:"h-4 w-4"}),e[16]=d,e[17]=z):z=e[17];const Y=d?"Copied":"Copy Steps";let L;e[18]!==Y?(L=g.jsx("span",{className:"ml-1",children:Y}),e[18]=Y,e[19]=L):L=e[19];let W;e[20]!==z||e[21]!==L?(W=g.jsxs("div",{className:"flex gap-2",children:[D,g.jsxs(vt,{type:"button",variant:"ghost",size:"sm",onClick:P,children:[z,L]})]}),e[20]=z,e[21]=L,e[22]=W):W=e[22];let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=I=>c(I.target.value),e[23]=V):V=e[23];let F;e[24]!==a?(F=g.jsx(fg,{ref:s,value:a,onChange:V,rows:10,placeholder:"Paste the copied curl command here",className:"font-mono text-xs"}),e[24]=a,e[25]=F):F=e[25];let U;e[26]!==W||e[27]!==F?(U=g.jsxs(Dy,{className:"space-y-4",children:[R,M,O,W,F]}),e[26]=W,e[27]=F,e[28]=U):U=e[28];let H;e[29]!==r?(H=g.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"}),e[29]=r,e[30]=H):H=e[30];const j=!k;let G;e[31]!==j?(G=g.jsx(vt,{type:"submit",variant:"secondary",size:"sm",disabled:j,children:"Import Session"}),e[31]=j,e[32]=G):G=e[32];let B;e[33]!==H||e[34]!==G?(B=g.jsxs(Oy,{children:[H,G]}),e[33]=H,e[34]=G,e[35]=B):B=e[35];let K;e[36]!==U||e[37]!==B||e[38]!==E?(K=g.jsx(hg,{size:"lg",children:g.jsxs("form",{onSubmit:E,children:[U,B]})}),e[36]=U,e[37]=B,e[38]=E,e[39]=K):K=e[39];let A;return e[40]!==r||e[41]!==n||e[42]!==K?(A=g.jsx(My,{open:n,onOpenChange:r,children:K}),e[40]=r,e[41]=n,e[42]=K,e[43]=A):A=e[43],A}const K7=["top","right","bottom","left"],nl=Math.min,Mi=Math.max,wp=Math.round,bm=Math.floor,Js=t=>({x:t,y:t}),G7={left:"right",right:"left",bottom:"top",top:"bottom"};function A1(t,e,n){return Mi(t,nl(e,n))}function qo(t,e){return typeof t=="function"?t(e):t}function Ko(t){return t.split("-")[0]}function Du(t){return t.split("-")[1]}function Iy(t){return t==="x"?"y":"x"}function Py(t){return t==="y"?"height":"width"}function Ys(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function zy(t){return Iy(Ys(t))}function Y7(t,e,n){n===void 0&&(n=!1);const r=Du(t),i=zy(t),s=Py(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(a=Cp(a)),[a,Cp(a)]}function X7(t){const e=Cp(t);return[N1(t),e,N1(e)]}function N1(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const $k=["left","right"],Uk=["right","left"],Q7=["top","bottom"],Z7=["bottom","top"];function J7(t,e,n){switch(t){case"top":case"bottom":return n?e?Uk:$k:e?$k:Uk;case"left":case"right":return e?Q7:Z7;default:return[]}}function e9(t,e,n,r){const i=Du(t);let s=J7(Ko(t),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),e&&(s=s.concat(s.map(N1)))),s}function Cp(t){const e=Ko(t);return G7[e]+t.slice(e.length)}function t9(t){return{top:0,right:0,bottom:0,left:0,...t}}function Q4(t){return typeof t!="number"?t9(t):{top:t,right:t,bottom:t,left:t}}function kp(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Wk(t,e,n){let{reference:r,floating:i}=t;const s=Ys(e),a=zy(e),c=Py(a),d=Ko(e),u=s==="y",f=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,v=r[c]/2-i[c]/2;let b;switch(d){case"top":b={x:f,y:r.y-i.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-i.width,y:m};break;default:b={x:r.x,y:r.y}}switch(Du(e)){case"start":b[a]-=v*(n&&u?-1:1);break;case"end":b[a]+=v*(n&&u?-1:1);break}return b}async function n9(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:a,elements:c,strategy:d}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:v=!1,padding:b=0}=qo(e,t),S=Q4(b),C=c[v?m==="floating"?"reference":"floating":m],k=kp(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:u,rootBoundary:f,strategy:d})),E=m==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),M=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},O=kp(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:R,strategy:d}):E);return{top:(k.top-O.top+S.top)/M.y,bottom:(O.bottom-k.bottom+S.bottom)/M.y,left:(k.left-O.left+S.left)/M.x,right:(O.right-k.right+S.right)/M.x}}const r9=50,i9=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,c=a.detectOverflow?a:{...a,detectOverflow:n9},d=await(a.isRTL==null?void 0:a.isRTL(e));let u=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:m}=Wk(u,r,d),v=r,b=0;const S={};for(let x=0;x<s.length;x++){const C=s[x];if(!C)continue;const{name:k,fn:E}=C,{x:R,y:M,data:O,reset:D}=await E({x:f,y:m,initialPlacement:r,placement:v,strategy:i,middlewareData:S,rects:u,platform:c,elements:{reference:t,floating:e}});f=R??f,m=M??m,S[k]={...S[k],...O},D&&b<r9&&(b++,typeof D=="object"&&(D.placement&&(v=D.placement),D.rects&&(u=D.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:i}):D.rects),{x:f,y:m}=Wk(u,v,d)),x=-1)}return{x:f,y:m,placement:v,strategy:i,middlewareData:S}},s9=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:a,elements:c,middlewareData:d}=e,{element:u,padding:f=0}=qo(t,e)||{};if(u==null)return{};const m=Q4(f),v={x:n,y:r},b=zy(i),S=Py(b),x=await a.getDimensions(u),C=b==="y",k=C?"top":"left",E=C?"bottom":"right",R=C?"clientHeight":"clientWidth",M=s.reference[S]+s.reference[b]-v[b]-s.floating[S],O=v[b]-s.reference[b],D=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let P=D?D[R]:0;(!P||!await(a.isElement==null?void 0:a.isElement(D)))&&(P=c.floating[R]||s.floating[S]);const z=M/2-O/2,Y=P/2-x[S]/2-1,L=nl(m[k],Y),W=nl(m[E],Y),V=L,F=P-x[S]-W,U=P/2-x[S]/2+z,H=A1(V,U,F),j=!d.arrow&&Du(i)!=null&&U!==H&&s.reference[S]/2-(U<V?L:W)-x[S]/2<0,G=j?U<V?U-V:U-F:0;return{[b]:v[b]+G,data:{[b]:H,centerOffset:U-H-G,...j&&{alignmentOffset:G}},reset:j}}}),o9=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:c,platform:d,elements:u}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:x=!0,...C}=qo(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const k=Ko(i),E=Ys(c),R=Ko(c)===c,M=await(d.isRTL==null?void 0:d.isRTL(u.floating)),O=v||(R||!x?[Cp(c)]:X7(c)),D=S!=="none";!v&&D&&O.push(...e9(c,x,S,M));const P=[c,...O],z=await d.detectOverflow(e,C),Y=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&Y.push(z[k]),m){const U=Y7(i,a,M);Y.push(z[U[0]],z[U[1]])}if(L=[...L,{placement:i,overflows:Y}],!Y.every(U=>U<=0)){var W,V;const U=(((W=s.flip)==null?void 0:W.index)||0)+1,H=P[U];if(H&&(!(m==="alignment"?E!==Ys(H):!1)||L.every(B=>Ys(B.placement)===E?B.overflows[0]>0:!0)))return{data:{index:U,overflows:L},reset:{placement:H}};let j=(V=L.filter(G=>G.overflows[0]<=0).sort((G,B)=>G.overflows[1]-B.overflows[1])[0])==null?void 0:V.placement;if(!j)switch(b){case"bestFit":{var F;const G=(F=L.filter(B=>{if(D){const K=Ys(B.placement);return K===E||K==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(K=>K>0).reduce((K,A)=>K+A,0)]).sort((B,K)=>B[1]-K[1])[0])==null?void 0:F[0];G&&(j=G);break}case"initialPlacement":j=c;break}if(i!==j)return{reset:{placement:j}}}return{}}}};function Vk(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function qk(t){return K7.some(e=>t[e]>=0)}const a9=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...s}=qo(t,e);switch(i){case"referenceHidden":{const a=await r.detectOverflow(e,{...s,elementContext:"reference"}),c=Vk(a,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:qk(c)}}}case"escaped":{const a=await r.detectOverflow(e,{...s,altBoundary:!0}),c=Vk(a,n.floating);return{data:{escapedOffsets:c,escaped:qk(c)}}}default:return{}}}}},Z4=new Set(["left","top"]);async function l9(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=Ko(n),c=Du(n),d=Ys(n)==="y",u=Z4.has(a)?-1:1,f=s&&d?-1:1,m=qo(e,t);let{mainAxis:v,crossAxis:b,alignmentAxis:S}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof S=="number"&&(b=c==="end"?S*-1:S),d?{x:b*f,y:v*u}:{x:v*u,y:b*f}}const c9=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:a,middlewareData:c}=e,d=await l9(e,t);return a===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+d.x,y:s+d.y,data:{...d,placement:a}}}}},u9=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:s}=e,{mainAxis:a=!0,crossAxis:c=!1,limiter:d={fn:k=>{let{x:E,y:R}=k;return{x:E,y:R}}},...u}=qo(t,e),f={x:n,y:r},m=await s.detectOverflow(e,u),v=Ys(Ko(i)),b=Iy(v);let S=f[b],x=f[v];if(a){const k=b==="y"?"top":"left",E=b==="y"?"bottom":"right",R=S+m[k],M=S-m[E];S=A1(R,S,M)}if(c){const k=v==="y"?"top":"left",E=v==="y"?"bottom":"right",R=x+m[k],M=x-m[E];x=A1(R,x,M)}const C=d.fn({...e,[b]:S,[v]:x});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[b]:a,[v]:c}}}}}},d9=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=e,{offset:c=0,mainAxis:d=!0,crossAxis:u=!0}=qo(t,e),f={x:n,y:r},m=Ys(i),v=Iy(m);let b=f[v],S=f[m];const x=qo(c,e),C=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(d){const R=v==="y"?"height":"width",M=s.reference[v]-s.floating[R]+C.mainAxis,O=s.reference[v]+s.reference[R]-C.mainAxis;b<M?b=M:b>O&&(b=O)}if(u){var k,E;const R=v==="y"?"width":"height",M=Z4.has(Ko(i)),O=s.reference[m]-s.floating[R]+(M&&((k=a.offset)==null?void 0:k[m])||0)+(M?0:C.crossAxis),D=s.reference[m]+s.reference[R]+(M?0:((E=a.offset)==null?void 0:E[m])||0)-(M?C.crossAxis:0);S<O?S=O:S>D&&(S=D)}return{[v]:b,[m]:S}}}},h9=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:a,elements:c}=e,{apply:d=()=>{},...u}=qo(t,e),f=await a.detectOverflow(e,u),m=Ko(i),v=Du(i),b=Ys(i)==="y",{width:S,height:x}=s.floating;let C,k;m==="top"||m==="bottom"?(C=m,k=v===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,C=v==="end"?"top":"bottom");const E=x-f.top-f.bottom,R=S-f.left-f.right,M=nl(x-f[C],E),O=nl(S-f[k],R),D=!e.middlewareData.shift;let P=M,z=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(z=R),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(P=E),D&&!v){const L=Mi(f.left,0),W=Mi(f.right,0),V=Mi(f.top,0),F=Mi(f.bottom,0);b?z=S-2*(L!==0||W!==0?L+W:Mi(f.left,f.right)):P=x-2*(V!==0||F!==0?V+F:Mi(f.top,f.bottom))}await d({...e,availableWidth:z,availableHeight:P});const Y=await a.getDimensions(c.floating);return S!==Y.width||x!==Y.height?{reset:{rects:!0}}:{}}}};function mg(){return typeof window<"u"}function Ou(t){return J4(t)?(t.nodeName||"").toLowerCase():"#document"}function Di(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ro(t){var e;return(e=(J4(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function J4(t){return mg()?t instanceof Node||t instanceof Di(t).Node:!1}function ws(t){return mg()?t instanceof Element||t instanceof Di(t).Element:!1}function Qo(t){return mg()?t instanceof HTMLElement||t instanceof Di(t).HTMLElement:!1}function Kk(t){return!mg()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Di(t).ShadowRoot}function Lh(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Cs(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&i!=="inline"&&i!=="contents"}function f9(t){return/^(table|td|th)$/.test(Ou(t))}function pg(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const m9=/transform|translate|scale|rotate|perspective|filter/,p9=/paint|layout|strict|content/,Al=t=>!!t&&t!=="none";let mb;function By(t){const e=ws(t)?Cs(t):t;return Al(e.transform)||Al(e.translate)||Al(e.scale)||Al(e.rotate)||Al(e.perspective)||!Fy()&&(Al(e.backdropFilter)||Al(e.filter))||m9.test(e.willChange||"")||p9.test(e.contain||"")}function g9(t){let e=rl(t);for(;Qo(e)&&!_u(e);){if(By(e))return e;if(pg(e))return null;e=rl(e)}return null}function Fy(){return mb==null&&(mb=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),mb}function _u(t){return/^(html|body|#document)$/.test(Ou(t))}function Cs(t){return Di(t).getComputedStyle(t)}function gg(t){return ws(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function rl(t){if(Ou(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Kk(t)&&t.host||ro(t);return Kk(e)?e.host:e}function eT(t){const e=rl(t);return _u(e)?t.ownerDocument?t.ownerDocument.body:t.body:Qo(e)&&Lh(e)?e:eT(e)}function bh(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=eT(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),a=Di(i);if(s){const c=D1(a);return e.concat(a,a.visualViewport||[],Lh(i)?i:[],c&&n?bh(c):[])}else return e.concat(i,bh(i,[],n))}function D1(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function tT(t){const e=Cs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Qo(t),s=i?t.offsetWidth:n,a=i?t.offsetHeight:r,c=wp(n)!==s||wp(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function Hy(t){return ws(t)?t:t.contextElement}function uu(t){const e=Hy(t);if(!Qo(e))return Js(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=tT(e);let a=(s?wp(n.width):n.width)/r,c=(s?wp(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const v9=Js(0);function nT(t){const e=Di(t);return!Fy()||!e.visualViewport?v9:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function b9(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Di(t)?!1:e}function ql(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=Hy(t);let a=Js(1);e&&(r?ws(r)&&(a=uu(r)):a=uu(t));const c=b9(s,n,r)?nT(s):Js(0);let d=(i.left+c.x)/a.x,u=(i.top+c.y)/a.y,f=i.width/a.x,m=i.height/a.y;if(s){const v=Di(s),b=r&&ws(r)?Di(r):r;let S=v,x=D1(S);for(;x&&r&&b!==S;){const C=uu(x),k=x.getBoundingClientRect(),E=Cs(x),R=k.left+(x.clientLeft+parseFloat(E.paddingLeft))*C.x,M=k.top+(x.clientTop+parseFloat(E.paddingTop))*C.y;d*=C.x,u*=C.y,f*=C.x,m*=C.y,d+=R,u+=M,S=Di(x),x=D1(S)}}return kp({width:f,height:m,x:d,y:u})}function vg(t,e){const n=gg(t).scrollLeft;return e?e.left+n:ql(ro(t)).left+n}function rT(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-vg(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function _9(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",a=ro(r),c=e?pg(e.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},u=Js(1);const f=Js(0),m=Qo(r);if((m||!m&&!s)&&((Ou(r)!=="body"||Lh(a))&&(d=gg(r)),m)){const b=ql(r);u=uu(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const v=a&&!m&&!s?rT(a,d):Js(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-d.scrollLeft*u.x+f.x+v.x,y:n.y*u.y-d.scrollTop*u.y+f.y+v.y}}function y9(t){return Array.from(t.getClientRects())}function x9(t){const e=ro(t),n=gg(t),r=t.ownerDocument.body,i=Mi(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Mi(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+vg(t);const c=-n.scrollTop;return Cs(r).direction==="rtl"&&(a+=Mi(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:c}}const Gk=25;function S9(t,e){const n=Di(t),r=ro(t),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,c=0,d=0;if(i){s=i.width,a=i.height;const f=Fy();(!f||f&&e==="fixed")&&(c=i.offsetLeft,d=i.offsetTop)}const u=vg(r);if(u<=0){const f=r.ownerDocument,m=f.body,v=getComputedStyle(m),b=f.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,S=Math.abs(r.clientWidth-m.clientWidth-b);S<=Gk&&(s-=S)}else u<=Gk&&(s+=u);return{width:s,height:a,x:c,y:d}}function w9(t,e){const n=ql(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Qo(t)?uu(t):Js(1),a=t.clientWidth*s.x,c=t.clientHeight*s.y,d=i*s.x,u=r*s.y;return{width:a,height:c,x:d,y:u}}function Yk(t,e,n){let r;if(e==="viewport")r=S9(t,n);else if(e==="document")r=x9(ro(t));else if(ws(e))r=w9(e,n);else{const i=nT(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return kp(r)}function iT(t,e){const n=rl(t);return n===e||!ws(n)||_u(n)?!1:Cs(n).position==="fixed"||iT(n,e)}function C9(t,e){const n=e.get(t);if(n)return n;let r=bh(t,[],!1).filter(c=>ws(c)&&Ou(c)!=="body"),i=null;const s=Cs(t).position==="fixed";let a=s?rl(t):t;for(;ws(a)&&!_u(a);){const c=Cs(a),d=By(a);!d&&c.position==="fixed"&&(i=null),(s?!d&&!i:!d&&c.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Lh(a)&&!d&&iT(t,a))?r=r.filter(f=>f!==a):i=c,a=rl(a)}return e.set(t,r),r}function k9(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const a=[...n==="clippingAncestors"?pg(e)?[]:C9(e,this._c):[].concat(n),r],c=Yk(e,a[0],i);let d=c.top,u=c.right,f=c.bottom,m=c.left;for(let v=1;v<a.length;v++){const b=Yk(e,a[v],i);d=Mi(b.top,d),u=nl(b.right,u),f=nl(b.bottom,f),m=Mi(b.left,m)}return{width:u-m,height:f-d,x:m,y:d}}function E9(t){const{width:e,height:n}=tT(t);return{width:e,height:n}}function R9(t,e,n){const r=Qo(e),i=ro(e),s=n==="fixed",a=ql(t,!0,s,e);let c={scrollLeft:0,scrollTop:0};const d=Js(0);function u(){d.x=vg(i)}if(r||!r&&!s)if((Ou(e)!=="body"||Lh(i))&&(c=gg(e)),r){const b=ql(e,!0,s,e);d.x=b.x+e.clientLeft,d.y=b.y+e.clientTop}else i&&u();s&&!r&&i&&u();const f=i&&!r&&!s?rT(i,c):Js(0),m=a.left+c.scrollLeft-d.x-f.x,v=a.top+c.scrollTop-d.y-f.y;return{x:m,y:v,width:a.width,height:a.height}}function pb(t){return Cs(t).position==="static"}function Xk(t,e){if(!Qo(t)||Cs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ro(t)===n&&(n=n.ownerDocument.body),n}function sT(t,e){const n=Di(t);if(pg(t))return n;if(!Qo(t)){let i=rl(t);for(;i&&!_u(i);){if(ws(i)&&!pb(i))return i;i=rl(i)}return n}let r=Xk(t,e);for(;r&&f9(r)&&pb(r);)r=Xk(r,e);return r&&_u(r)&&pb(r)&&!By(r)?n:r||g9(t)||n}const T9=async function(t){const e=this.getOffsetParent||sT,n=this.getDimensions,r=await n(t.floating);return{reference:R9(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function M9(t){return Cs(t).direction==="rtl"}const A9={convertOffsetParentRelativeRectToViewportRelativeRect:_9,getDocumentElement:ro,getClippingRect:k9,getOffsetParent:sT,getElementRects:T9,getClientRects:y9,getDimensions:E9,getScale:uu,isElement:ws,isRTL:M9};function oT(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function N9(t,e){let n=null,r;const i=ro(t);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const u=t.getBoundingClientRect(),{left:f,top:m,width:v,height:b}=u;if(c||e(),!v||!b)return;const S=bm(m),x=bm(i.clientWidth-(f+v)),C=bm(i.clientHeight-(m+b)),k=bm(f),R={rootMargin:-S+"px "+-x+"px "+-C+"px "+-k+"px",threshold:Mi(0,nl(1,d))||1};let M=!0;function O(D){const P=D[0].intersectionRatio;if(P!==d){if(!M)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!oT(u,t.getBoundingClientRect())&&a(),M=!1}try{n=new IntersectionObserver(O,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(O,R)}n.observe(t)}return a(!0),s}function D9(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,u=Hy(t),f=i||s?[...u?bh(u):[],...e?bh(e):[]]:[];f.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),s&&k.addEventListener("resize",n)});const m=u&&c?N9(u,n):null;let v=-1,b=null;a&&(b=new ResizeObserver(k=>{let[E]=k;E&&E.target===u&&b&&e&&(b.unobserve(e),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(e)})),n()}),u&&!d&&b.observe(u),e&&b.observe(e));let S,x=d?ql(t):null;d&&C();function C(){const k=ql(t);x&&!oT(x,k)&&n(),x=k,S=requestAnimationFrame(C)}return n(),()=>{var k;f.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,d&&cancelAnimationFrame(S)}}const O9=c9,j9=u9,L9=o9,I9=h9,P9=a9,Qk=s9,z9=d9,B9=(t,e,n)=>{const r=new Map,i={platform:A9,...n},s={...i.platform,_c:r};return i9(t,e,{...i,platform:s})};var F9=typeof document<"u",H9=function(){},Jm=F9?_.useLayoutEffect:H9;function Ep(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Ep(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!Ep(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function aT(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Zk(t,e){const n=aT(t);return Math.round(e*n)/n}function gb(t){const e=_.useRef(t);return Jm(()=>{e.current=t}),e}function $9(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:d,open:u}=t,[f,m]=_.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[v,b]=_.useState(r);Ep(v,r)||b(r);const[S,x]=_.useState(null),[C,k]=_.useState(null),E=_.useCallback(B=>{B!==D.current&&(D.current=B,x(B))},[]),R=_.useCallback(B=>{B!==P.current&&(P.current=B,k(B))},[]),M=s||S,O=a||C,D=_.useRef(null),P=_.useRef(null),z=_.useRef(f),Y=d!=null,L=gb(d),W=gb(i),V=gb(u),F=_.useCallback(()=>{if(!D.current||!P.current)return;const B={placement:e,strategy:n,middleware:v};W.current&&(B.platform=W.current),B9(D.current,P.current,B).then(K=>{const A={...K,isPositioned:V.current!==!1};U.current&&!Ep(z.current,A)&&(z.current=A,es.flushSync(()=>{m(A)}))})},[v,e,n,W,V]);Jm(()=>{u===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,m(B=>({...B,isPositioned:!1})))},[u]);const U=_.useRef(!1);Jm(()=>(U.current=!0,()=>{U.current=!1}),[]),Jm(()=>{if(M&&(D.current=M),O&&(P.current=O),M&&O){if(L.current)return L.current(M,O,F);F()}},[M,O,F,L,Y]);const H=_.useMemo(()=>({reference:D,floating:P,setReference:E,setFloating:R}),[E,R]),j=_.useMemo(()=>({reference:M,floating:O}),[M,O]),G=_.useMemo(()=>{const B={position:n,left:0,top:0};if(!j.floating)return B;const K=Zk(j.floating,f.x),A=Zk(j.floating,f.y);return c?{...B,transform:"translate("+K+"px, "+A+"px)",...aT(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:K,top:A}},[n,c,j.floating,f.x,f.y]);return _.useMemo(()=>({...f,update:F,refs:H,elements:j,floatingStyles:G}),[f,F,H,j,G])}const U9=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Qk({element:r.current,padding:i}).fn(n):{}:r?Qk({element:r,padding:i}).fn(n):{}}}},W9=(t,e)=>{const n=O9(t);return{name:n.name,fn:n.fn,options:[t,e]}},V9=(t,e)=>{const n=j9(t);return{name:n.name,fn:n.fn,options:[t,e]}},q9=(t,e)=>({fn:z9(t).fn,options:[t,e]}),K9=(t,e)=>{const n=L9(t);return{name:n.name,fn:n.fn,options:[t,e]}},G9=(t,e)=>{const n=I9(t);return{name:n.name,fn:n.fn,options:[t,e]}},Y9=(t,e)=>{const n=P9(t);return{name:n.name,fn:n.fn,options:[t,e]}},X9=(t,e)=>{const n=U9(t);return{name:n.name,fn:n.fn,options:[t,e]}};var Q9="Arrow",lT=_.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return g.jsx(Bt.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});lT.displayName=Q9;var Z9=lT;function J9(t){const[e,n]=_.useState(void 0);return Pr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,c;if("borderBoxSize"in s){const d=s.borderBoxSize,u=Array.isArray(d)?d[0]:d;a=u.inlineSize,c=u.blockSize}else a=t.offsetWidth,c=t.offsetHeight;n({width:a,height:c})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var $y="Popper",[cT,sl]=Xo($y),[eF,uT]=cT($y),dT=t=>{const{__scopePopper:e,children:n}=t,[r,i]=_.useState(null);return g.jsx(eF,{scope:e,anchor:r,onAnchorChange:i,children:n})};dT.displayName=$y;var hT="PopperAnchor",fT=_.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=uT(hT,n),a=_.useRef(null),c=Xt(e,a),d=_.useRef(null);return _.useEffect(()=>{const u=d.current;d.current=(r==null?void 0:r.current)||a.current,u!==d.current&&s.onAnchorChange(d.current)}),r?null:g.jsx(Bt.div,{...i,ref:c})});fT.displayName=hT;var Uy="PopperContent",[tF,nF]=cT(Uy),mT=_.forwardRef((t,e)=>{var re,ae,ue,me,se,oe;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:v=!1,updatePositionStrategy:b="optimized",onPlaced:S,...x}=t,C=uT(Uy,n),[k,E]=_.useState(null),R=Xt(e,ee=>E(ee)),[M,O]=_.useState(null),D=J9(M),P=(D==null?void 0:D.width)??0,z=(D==null?void 0:D.height)??0,Y=r+(s!=="center"?"-"+s:""),L=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(u)?u:[u],V=W.length>0,F={padding:L,boundary:W.filter(iF),altBoundary:V},{refs:U,floatingStyles:H,placement:j,isPositioned:G,middlewareData:B}=$9({strategy:"fixed",placement:Y,whileElementsMounted:(...ee)=>D9(...ee,{animationFrame:b==="always"}),elements:{reference:C.anchor},middleware:[W9({mainAxis:i+z,alignmentAxis:a}),d&&V9({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?q9():void 0,...F}),d&&K9({...F}),G9({...F,apply:({elements:ee,rects:Q,availableWidth:te,availableHeight:he})=>{const{width:ie,height:xe}=Q.reference,Ae=ee.floating.style;Ae.setProperty("--radix-popper-available-width",`${te}px`),Ae.setProperty("--radix-popper-available-height",`${he}px`),Ae.setProperty("--radix-popper-anchor-width",`${ie}px`),Ae.setProperty("--radix-popper-anchor-height",`${xe}px`)}}),M&&X9({element:M,padding:c}),sF({arrowWidth:P,arrowHeight:z}),v&&Y9({strategy:"referenceHidden",...F})]}),[K,A]=vT(j),I=Ss(S);Pr(()=>{G&&(I==null||I())},[G,I]);const $=(re=B.arrow)==null?void 0:re.x,T=(ae=B.arrow)==null?void 0:ae.y,X=((ue=B.arrow)==null?void 0:ue.centerOffset)!==0,[Z,J]=_.useState();return Pr(()=>{k&&J(window.getComputedStyle(k).zIndex)},[k]),g.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:G?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(me=B.transformOrigin)==null?void 0:me.x,(se=B.transformOrigin)==null?void 0:se.y].join(" "),...((oe=B.hide)==null?void 0:oe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(tF,{scope:n,placedSide:K,onArrowChange:O,arrowX:$,arrowY:T,shouldHideArrow:X,children:g.jsx(Bt.div,{"data-side":K,"data-align":A,...x,ref:R,style:{...x.style,animation:G?void 0:"none"}})})})});mT.displayName=Uy;var pT="PopperArrow",rF={top:"bottom",right:"left",bottom:"top",left:"right"},gT=_.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=nF(pT,r),a=rF[s.placedSide];return g.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:g.jsx(Z9,{...i,ref:n,style:{...i.style,display:"block"}})})});gT.displayName=pT;function iF(t){return t!==null}var sF=t=>({name:"transformOrigin",options:t,fn(e){var C,k,E;const{placement:n,rects:r,middlewareData:i}=e,a=((C=i.arrow)==null?void 0:C.centerOffset)!==0,c=a?0:t.arrowWidth,d=a?0:t.arrowHeight,[u,f]=vT(n),m={start:"0%",center:"50%",end:"100%"}[f],v=(((k=i.arrow)==null?void 0:k.x)??0)+c/2,b=(((E=i.arrow)==null?void 0:E.y)??0)+d/2;let S="",x="";return u==="bottom"?(S=a?m:`${v}px`,x=`${-d}px`):u==="top"?(S=a?m:`${v}px`,x=`${r.floating.height+d}px`):u==="right"?(S=`${-d}px`,x=a?m:`${b}px`):u==="left"&&(S=`${r.floating.width+d}px`,x=a?m:`${b}px`),{data:{x:S,y:x}}}});function vT(t){const[e,n="center"]=t.split("-");return[e,n]}var bg=dT,Ih=fT,_g=mT,yg=gT,bT=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"}),oF="VisuallyHidden",_T=_.forwardRef((t,e)=>g.jsx(Bt.span,{...t,ref:e,style:{...bT,...t.style}}));_T.displayName=oF;var aF=_T,[xg,Sle]=Xo("Tooltip",[sl]),Sg=sl(),yT="TooltipProvider",lF=700,O1="tooltip.open",[cF,Wy]=xg(yT),xT=t=>{const{__scopeTooltip:e,delayDuration:n=lF,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,a=_.useRef(!0),c=_.useRef(!1),d=_.useRef(0);return _.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),g.jsx(cF,{scope:e,isOpenDelayedRef:a,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:_.useCallback(u=>{c.current=u},[]),disableHoverableContent:i,children:s})};xT.displayName=yT;var _h="Tooltip",[uF,Ph]=xg(_h),ST=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=t,d=Wy(_h,t.__scopeTooltip),u=Sg(e),[f,m]=_.useState(null),v=Wo(),b=_.useRef(0),S=a??d.disableHoverableContent,x=c??d.delayDuration,C=_.useRef(!1),[k,E]=bu({prop:r,defaultProp:i??!1,onChange:P=>{P?(d.onOpen(),document.dispatchEvent(new CustomEvent(O1))):d.onClose(),s==null||s(P)},caller:_h}),R=_.useMemo(()=>k?C.current?"delayed-open":"instant-open":"closed",[k]),M=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C.current=!1,E(!0)},[E]),O=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),D=_.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{C.current=!0,E(!0),b.current=0},x)},[x,E]);return _.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),g.jsx(bg,{...u,children:g.jsx(uF,{scope:e,contentId:v,open:k,stateAttribute:R,trigger:f,onTriggerChange:m,onTriggerEnter:_.useCallback(()=>{d.isOpenDelayedRef.current?D():M()},[d.isOpenDelayedRef,D,M]),onTriggerLeave:_.useCallback(()=>{S?O():(window.clearTimeout(b.current),b.current=0)},[O,S]),onOpen:M,onClose:O,disableHoverableContent:S,children:n})})};ST.displayName=_h;var j1="TooltipTrigger",wT=_.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Ph(j1,n),s=Wy(j1,n),a=Sg(n),c=_.useRef(null),d=Xt(e,c,i.onTriggerChange),u=_.useRef(!1),f=_.useRef(!1),m=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),g.jsx(Ih,{asChild:!0,...a,children:g.jsx(Bt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:d,onPointerMove:nt(t.onPointerMove,v=>{v.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:nt(t.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:nt(t.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:nt(t.onFocus,()=>{u.current||i.onOpen()}),onBlur:nt(t.onBlur,i.onClose),onClick:nt(t.onClick,i.onClose)})})});wT.displayName=j1;var Vy="TooltipPortal",[dF,hF]=xg(Vy,{forceMount:void 0}),CT=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:i}=t,s=Ph(Vy,e);return g.jsx(dF,{scope:e,forceMount:n,children:g.jsx(os,{present:n||s.open,children:g.jsx(Nu,{asChild:!0,container:i,children:r})})})};CT.displayName=Vy;var yu="TooltipContent",kT=_.forwardRef((t,e)=>{const n=hF(yu,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,a=Ph(yu,t.__scopeTooltip);return g.jsx(os,{present:r||a.open,children:a.disableHoverableContent?g.jsx(ET,{side:i,...s,ref:e}):g.jsx(fF,{side:i,...s,ref:e})})}),fF=_.forwardRef((t,e)=>{const n=Ph(yu,t.__scopeTooltip),r=Wy(yu,t.__scopeTooltip),i=_.useRef(null),s=Xt(e,i),[a,c]=_.useState(null),{trigger:d,onClose:u}=n,f=i.current,{onPointerInTransitChange:m}=r,v=_.useCallback(()=>{c(null),m(!1)},[m]),b=_.useCallback((S,x)=>{const C=S.currentTarget,k={x:S.clientX,y:S.clientY},E=bF(k,C.getBoundingClientRect()),R=_F(k,E),M=yF(x.getBoundingClientRect()),O=SF([...R,...M]);c(O),m(!0)},[m]);return _.useEffect(()=>()=>v(),[v]),_.useEffect(()=>{if(d&&f){const S=C=>b(C,f),x=C=>b(C,d);return d.addEventListener("pointerleave",S),f.addEventListener("pointerleave",x),()=>{d.removeEventListener("pointerleave",S),f.removeEventListener("pointerleave",x)}}},[d,f,b,v]),_.useEffect(()=>{if(a){const S=x=>{const C=x.target,k={x:x.clientX,y:x.clientY},E=(d==null?void 0:d.contains(C))||(f==null?void 0:f.contains(C)),R=!xF(k,a);E?v():R&&(v(),u())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[d,f,a,u,v]),g.jsx(ET,{...t,ref:s})}),[mF,pF]=xg(_h,{isInside:!1}),gF=fB("TooltipContent"),ET=_.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=t,d=Ph(yu,n),u=Sg(n),{onClose:f}=d;return _.useEffect(()=>(document.addEventListener(O1,f),()=>document.removeEventListener(O1,f)),[f]),_.useEffect(()=>{if(d.trigger){const m=v=>{const b=v.target;b!=null&&b.contains(d.trigger)&&f()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[d.trigger,f]),g.jsx(Au,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:m=>m.preventDefault(),onDismiss:f,children:g.jsxs(_g,{"data-state":d.stateAttribute,...u,...c,ref:e,style:{...c.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:[g.jsx(gF,{children:r}),g.jsx(mF,{scope:n,isInside:!0,children:g.jsx(aF,{id:d.contentId,role:"tooltip",children:i||r})})]})})});kT.displayName=yu;var RT="TooltipArrow",vF=_.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Sg(n);return pF(RT,n).isInside?null:g.jsx(yg,{...i,...r,ref:e})});vF.displayName=RT;function bF(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function _F(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function yF(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function xF(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,a=e.length-1;s<e.length;a=s++){const c=e[s],d=e[a],u=c.x,f=c.y,m=d.x,v=d.y;f>r!=v>r&&n<(m-u)*(r-f)/(v-f)+u&&(i=!i)}return i}function SF(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),wF(e)}function wF(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],a=e[e.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var CF=xT,TT=ST,MT=wT,AT=CT,qy=kT;function kF(t){const e=ke.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",n),e[3]=n,e[4]=i):i=e[4];let s;return e[5]!==r||e[6]!==i?(s=g.jsx("kbd",{className:i,...r}),e[5]=r,e[6]=i,e[7]=s):s=e[7],s}function EF(t){const e=ke.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("inline-flex items-center gap-0.5",n),e[3]=n,e[4]=i):i=e[4];let s;return e[5]!==r||e[6]!==i?(s=g.jsx("span",{className:i,...r}),e[5]=r,e[6]=i,e[7]=s):s=e[7],s}const RF="z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",TF=CF,zo=TT,Bo=MT,Fo=_.forwardRef((t,e)=>{const n=ke.c(11);let r,i,s;n[0]!==t?({className:r,sideOffset:s,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=s):(r=n[1],i=n[2],s=n[3]);const a=s===void 0?4:s;let c;n[4]!==r?(c=Ce("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border backdrop-blur-md 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",r),n[4]=r,n[5]=c):c=n[5];let d;return n[6]!==i||n[7]!==e||n[8]!==a||n[9]!==c?(d=g.jsx(AT,{children:g.jsx(qy,{ref:e,sideOffset:a,className:c,...i})}),n[6]=i,n[7]=e,n[8]=a,n[9]=c,n[10]=d):d=n[10],d});Fo.displayName=qy.displayName;const Gd=TT,Yd=MT;function NT(t){return t.toUpperCase()}function MF(t){const e=t.split("+");return g.jsx(EF,{children:e.map((n,r)=>g.jsx(kF,{children:NT(n)},`${n}-${r}`))})}const Fl=_.forwardRef((t,e)=>{const n=ke.c(17);let r,i,s,a,c;n[0]!==t?({className:i,sideOffset:c,children:r,shortcut:a,...s}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=s,n[4]=a,n[5]=c):(r=n[1],i=n[2],s=n[3],a=n[4],c=n[5]);const d=c===void 0?4:c,u=a===void 0?null:Array.isArray(a)?a[0]??null:a;let f;n[6]!==i?(f=Ce(RF,i),n[6]=i,n[7]=f):f=n[7];let m;n[8]!==r||n[9]!==u?(m=u?MF(u):g.jsx("span",{children:typeof r=="string"?NT(r):r}),n[8]=r,n[9]=u,n[10]=m):m=n[10];let v;return n[11]!==s||n[12]!==e||n[13]!==d||n[14]!==f||n[15]!==m?(v=g.jsx(AT,{children:g.jsx(qy,{ref:e,sideOffset:d,className:f,...s,children:m})}),n[11]=s,n[12]=e,n[13]=d,n[14]=f,n[15]=m,n[16]=v):v=n[16],v});Fl.displayName="HotkeyTooltipContent";const AF="0.7.1",NF={version:AF},ys="Kaizen",Jk="kaizen",DF=".kaizen",OF=".kaizen-dev",wle=".kaizen",jF="KAIZEN_RUNTIME_PROFILE",LF=`kaizen/${NF.version}`,IF="[kaizen]",Cle=`~/${ys}`,Ky="kaizen:";function ju(){var e;return(e=globalThis.process)==null?void 0:e.env}function PF(t=ju()){const e=t==null?void 0:t[jF];return(e==null?void 0:e.trim().toLowerCase())==="dev"?"dev":"prod"}function zF(t=ju()){return PF(t)==="dev"?OF:DF}function DT(t=ju()){return`~/${zF(t)}`}function kle(t=ju()){return`${DT(t)}/keybindings.json`}function BF(t=ju()){return`${DT(t)}/themes`}function FF(t=ju()){return`${BF(t)}/THEME_README.md`}function Ele(t){return t?`${Jk} ${t}`:Jk}function HF(t){return t==="claude"||t==="codex"||t==="gemini"||t==="cursor"||t==="openrouter"}function $F(t){return HF(t)?t:null}const Rp=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"max",label:"Max"}],L1=[{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"XHigh"}],I1=[{id:"off",label:"Off"},{id:"standard",label:"Standard"},{id:"high",label:"High"}],P1="claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]",OT=[{id:"composer-2[fast=true]",label:"Composer 2",supportsEffort:!1},{id:"composer-1.5[]",label:"Composer 1.5",supportsEffort:!1},{id:"gpt-5.3-codex[reasoning=medium,fast=false]",label:"Codex 5.3",supportsEffort:!1},{id:"gpt-5.4[reasoning=medium,context=272k,fast=false]",label:"GPT-5.4",supportsEffort:!1},{id:"claude-sonnet-4-6[thinking=true,context=200k,effort=medium]",label:"Sonnet 4.6",supportsEffort:!1},{id:"claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]",label:"Opus 4.6",supportsEffort:!1},{id:"claude-opus-4-5[thinking=true]",label:"Opus 4.5",supportsEffort:!1},{id:"gpt-5.2[reasoning=medium,fast=false]",label:"GPT-5.2",supportsEffort:!1},{id:"gemini-3.1-pro[]",label:"Gemini 3.1 Pro",supportsEffort:!1},{id:"gpt-5.4-mini[reasoning=medium]",label:"GPT-5.4 Mini",supportsEffort:!1},{id:"gpt-5.4-nano[reasoning=medium]",label:"GPT-5.4 Nano",supportsEffort:!1},{id:"claude-haiku-4-5[thinking=true]",label:"Haiku 4.5",supportsEffort:!1},{id:"gpt-5.3-codex-spark[reasoning=medium]",label:"Codex 5.3 Spark",supportsEffort:!1},{id:"grok-4-20[thinking=true]",label:"Grok 4.20",supportsEffort:!1},{id:"claude-sonnet-4-5[thinking=true,context=200k]",label:"Sonnet 4.5",supportsEffort:!1},{id:"gpt-5.2-codex[reasoning=medium,fast=false]",label:"Codex 5.2",supportsEffort:!1},{id:"gemini-3-flash[]",label:"Gemini 3 Flash",supportsEffort:!1},{id:"claude-sonnet-4[thinking=false,context=200k]",label:"Sonnet 4",supportsEffort:!1},{id:"kimi-k2.5[]",label:"Kimi K2.5",supportsEffort:!1}],UF={"composer-2-fast":"composer-2[fast=true]","composer-1.5":"composer-1.5[]","gpt-5.3-codex":"gpt-5.3-codex[reasoning=medium,fast=false]","gpt-5.4":"gpt-5.4[reasoning=medium,context=272k,fast=false]","gpt-5.4-medium":"gpt-5.4[reasoning=medium,context=272k,fast=false]","claude-4.6-sonnet-medium-thinking":"claude-sonnet-4-6[thinking=true,context=200k,effort=medium]","claude-4.6-opus-high-thinking":"claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]","claude-4.5-opus-high-thinking":"claude-opus-4-5[thinking=true]","gpt-5.2":"gpt-5.2[reasoning=medium,fast=false]","gemini-3.1-pro":"gemini-3.1-pro[]","gpt-5.4-mini":"gpt-5.4-mini[reasoning=medium]","gpt-5.4-mini-medium":"gpt-5.4-mini[reasoning=medium]","gpt-5.4-nano":"gpt-5.4-nano[reasoning=medium]","gpt-5.4-nano-medium":"gpt-5.4-nano[reasoning=medium]","claude-haiku-4.5":"claude-haiku-4-5[thinking=true]","gpt-5.3-codex-spark-preview":"gpt-5.3-codex-spark[reasoning=medium]","grok-4-20":"grok-4-20[thinking=true]","grok-4-20-thinking":"grok-4-20[thinking=true]","claude-4.5-sonnet-thinking":"claude-sonnet-4-5[thinking=true,context=200k]","gpt-5.2-codex":"gpt-5.2-codex[reasoning=medium,fast=false]","gemini-3-flash":"gemini-3-flash[]","claude-4-sonnet":"claude-sonnet-4[thinking=false,context=200k]","kimi-k2.5":"kimi-k2.5[]"};function WF(t){return t?OT.some(e=>e.id===t)?t:UF[t]??P1:P1}function eE(t){const e=t.indexOf("[");return e>=0?t.slice(0,e):t}function Lu(t){const e=t.match(/\bfast=(true|false)\b/);return e?e[1]==="true"?"fast":"standard":null}function tE(t){return Rp.some(e=>e.id===t)}function nE(t){return L1.some(e=>e.id===t)}const z1=[{id:"200k",label:"200k"},{id:"1m",label:"1M"}];function VF(t){return I1.some(e=>e.id===t)}const qF={image:!0,markdown:!0,document:!0},KF={image:!0,markdown:!0,document:!1},GF={image:!0,markdown:!0,document:!0},YF={image:!0,markdown:!0,document:!0},XF={image:!0,markdown:!0,document:!0},QF={openrouter:"account",providerUsage:"account",handoff:"account",remoteRelay:"paid",browserNotifications:"paid",installMobilePush:"paid",syncedSettings:"paid",syncedKeybindings:"paid",syncedHandoffs:"paid",crossDeviceStorage:"paid"},rc=[{id:"claude",label:"Claude",systemActive:!0,defaultModel:"sonnet",defaultEffort:"high",defaultModelOptions:{reasoningEffort:"high",contextWindow:"200k"},supportsPlanMode:!0,attachmentCapabilities:qF,models:[{id:"opus",label:"Opus",supportsEffort:!0,contextWindowOptions:[...z1]},{id:"sonnet",label:"Sonnet",supportsEffort:!0,contextWindowOptions:[...z1]},{id:"haiku",label:"Haiku",supportsEffort:!0}],efforts:[...Rp]},{id:"codex",label:"Codex",systemActive:!0,defaultModel:"gpt-5.4",defaultModelOptions:{reasoningEffort:"high",fastMode:!1},supportsPlanMode:!0,attachmentCapabilities:KF,models:[{id:"gpt-5.4",label:"GPT-5.4",supportsEffort:!1},{id:"gpt-5.3-codex",label:"GPT-5.3 Codex",supportsEffort:!1},{id:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",supportsEffort:!1}],efforts:[]},{id:"gemini",label:"Gemini",systemActive:!1,defaultModel:"auto-gemini-2.5",defaultModelOptions:{thinkingMode:"standard"},supportsPlanMode:!0,attachmentCapabilities:GF,models:[{id:"auto-gemini-3",label:"Auto (Gemini 3)",supportsEffort:!1},{id:"auto-gemini-2.5",label:"Auto (Gemini 2.5)",supportsEffort:!1},{id:"gemini-3.1-pro-preview",label:"3.1 Pro Preview",supportsEffort:!1},{id:"gemini-3-pro-preview",label:"3 Pro Preview",supportsEffort:!1},{id:"gemini-3-flash-preview",label:"3 Flash Preview",supportsEffort:!1},{id:"gemini-2.5-pro",label:"2.5 Pro",supportsEffort:!1},{id:"gemini-2.5-flash",label:"2.5 Flash",supportsEffort:!1},{id:"gemini-2.5-flash-lite",label:"2.5 Flash Lite",supportsEffort:!1}],efforts:[]},{id:"cursor",label:"Cursor",systemActive:!0,defaultModel:P1,defaultModelOptions:{},supportsPlanMode:!0,attachmentCapabilities:YF,models:[...OT],efforts:[]},{id:"openrouter",label:"OpenRouter",systemActive:!0,defaultModel:"opencode/big-pickle",defaultModelOptions:{},supportsPlanMode:!0,attachmentCapabilities:XF,models:[{id:"opencode/big-pickle",label:"Big Pickle",supportsEffort:!1},{id:"opencode/gpt-5-nano",label:"GPT-5 Nano",supportsEffort:!1},{id:"opencode/mimo-v2-omni-free",label:"MiMo V2 Omni Free",supportsEffort:!1},{id:"opencode/mimo-v2-pro-free",label:"MiMo V2 Pro Free",supportsEffort:!1},{id:"opencode/minimax-m2.5-free",label:"MiniMax M2.5 Free",supportsEffort:!1},{id:"opencode/nemotron-3-super-free",label:"Nemotron 3 Super Free",supportsEffort:!1},{id:"opencode/qwen3.6-plus-free",label:"Qwen3.6 Plus Free",supportsEffort:!1},{id:"openrouter/anthropic/claude-sonnet-4",label:"Claude Sonnet 4",supportsEffort:!1},{id:"openrouter/anthropic/claude-opus-4",label:"Claude Opus 4",supportsEffort:!1},{id:"openrouter/openai/gpt-5.4",label:"GPT-5.4",supportsEffort:!1},{id:"openrouter/google/gemini-2.5-pro",label:"Gemini 2.5 Pro",supportsEffort:!1},{id:"openrouter/deepseek/deepseek-r1",label:"DeepSeek R1",supportsEffort:!1},{id:"openrouter/meta-llama/llama-4-maverick",label:"Llama 4 Maverick",supportsEffort:!1}],efforts:[]}],Tp={claude:{active:!0},codex:{active:!0},gemini:{active:!0},cursor:{active:!0},openrouter:{active:!1}};function Zn(t,e=rc){const n=e.find(r=>r.id===t);if(!n)throw new Error(`Unknown provider: ${t}`);return n}function wg(t,e){const n=e?t.models.find(r=>r.id===e):void 0;return(n==null?void 0:n.attachmentCapabilities)??t.attachmentCapabilities}function Gy(t,e){const n=Tp[e],r=t==null?void 0:t[e];return{active:(r==null?void 0:r.active)??n.active}}function ZF(t,e,n=rc){var s;const r=Zn(t,n),i=Gy(e,t);return r.systemActive&&i.active?null:!r.systemActive&&((s=r.availabilityMessage)!=null&&s.trim())?r.availabilityMessage:`Provider ${r.label} is currently not active.`}function JF(t,e,n=rc){const r=Zn(t,n),i=Gy(e,t);return r.systemActive&&i.active}function eH(t,e){return t.map(n=>{const r=Gy(e,n.id),i=n.systemActive&&r.active;return{...n,active:r.active,isSelectable:i,isUsageEnabled:i,isInactive:!i,inactiveMessage:ZF(n.id,e,t)}})}function tH(t,e){return eH(t,e).filter(n=>n.isSelectable).map(({active:n,isSelectable:r,isUsageEnabled:i,isInactive:s,inactiveMessage:a,...c})=>c)}function jT(t){return tH(rc,t)}function Kr(t){return Zn(t).defaultModelOptions}const LT=Kr("claude");Kr("codex");Kr("gemini");Kr("cursor");Kr("openrouter");function nH(t){return Zn("claude").models.find(e=>e.id===t)}function rH(t){var e;return((e=nH(t))==null?void 0:e.contextWindowOptions)??[]}function iH(t,e){const n=rH(t);if(n.length!==0)return n.some(r=>r.id===e)?e:LT.contextWindow}const sH=["idea","todo","progress","testing","done"],rE={idea:"IDEA",todo:"TODO",progress:"PROGRESS",testing:"TESTING",done:"DONE"},Lo={submitChatMessage:["enter"],toggleQuickPrompts:["cmd+e","ctrl+e"],toggleProjectsSidebar:["ctrl+a"],toggleEmbeddedTerminal:["cmd+j","ctrl+`"],toggleRightSidebar:["cmd+b","ctrl+b"],openInFinder:["cmd+alt+f","ctrl+alt+f"],openInEditor:["cmd+shift+o","ctrl+shift+o"],addSplitTerminal:["cmd+/","ctrl+/"]},Mp=8,IT=10*1024*1024,oH=20*1024*1024,aH=1*1024*1024,Ap=["image/png","image/jpeg","image/webp","image/gif"],PT=["application/pdf"],zT=["text/markdown","text/x-markdown"],lH="/assets/icon-4rSnra9R.svg";function sh(t){const e=ke.c(10);let n,r,i;e[0]!==t?({alt:i,className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const s=i===void 0?"":i;let a;e[4]!==n?(a=Ce("shrink-0 object-contain",n),e[4]=n,e[5]=a):a=e[5];let c;return e[6]!==s||e[7]!==r||e[8]!==a?(c=g.jsx("img",{alt:s,src:lH,className:a,...r}),e[6]=s,e[7]=r,e[8]=a,e[9]=c):c=e[9],c}var Cg="Popover",[BT,Rle]=Xo(Cg,[sl]),zh=sl(),[cH,ol]=BT(Cg),FT=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=t,c=zh(e),d=_.useRef(null),[u,f]=_.useState(!1),[m,v]=bu({prop:r,defaultProp:i??!1,onChange:s,caller:Cg});return g.jsx(bg,{...c,children:g.jsx(cH,{scope:e,contentId:Wo(),triggerRef:d,open:m,onOpenChange:v,onOpenToggle:_.useCallback(()=>v(b=>!b),[v]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>f(!0),[]),onCustomAnchorRemove:_.useCallback(()=>f(!1),[]),modal:a,children:n})})};FT.displayName=Cg;var HT="PopoverAnchor",$T=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=ol(HT,n),s=zh(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:c}=i;return _.useEffect(()=>(a(),()=>c()),[a,c]),g.jsx(Ih,{...s,...r,ref:e})});$T.displayName=HT;var UT="PopoverTrigger",WT=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=ol(UT,n),s=zh(n),a=Xt(e,i.triggerRef),c=g.jsx(Bt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":YT(i.open),...r,ref:a,onClick:nt(t.onClick,i.onOpenToggle)});return i.hasCustomAnchor?c:g.jsx(Ih,{asChild:!0,...s,children:c})});WT.displayName=UT;var Yy="PopoverPortal",[uH,dH]=BT(Yy,{forceMount:void 0}),VT=t=>{const{__scopePopover:e,forceMount:n,children:r,container:i}=t,s=ol(Yy,e);return g.jsx(uH,{scope:e,forceMount:n,children:g.jsx(os,{present:n||s.open,children:g.jsx(Nu,{asChild:!0,container:i,children:r})})})};VT.displayName=Yy;var xu="PopoverContent",qT=_.forwardRef((t,e)=>{const n=dH(xu,t.__scopePopover),{forceMount:r=n.forceMount,...i}=t,s=ol(xu,t.__scopePopover);return g.jsx(os,{present:r||s.open,children:s.modal?g.jsx(fH,{...i,ref:e}):g.jsx(mH,{...i,ref:e})})});qT.displayName=xu;var hH=Wl("PopoverContent.RemoveScroll"),fH=_.forwardRef((t,e)=>{const n=ol(xu,t.__scopePopover),r=_.useRef(null),i=Xt(e,r),s=_.useRef(!1);return _.useEffect(()=>{const a=r.current;if(a)return ug(a)},[]),g.jsx(jh,{as:hH,allowPinchZoom:!0,children:g.jsx(KT,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:nt(t.onCloseAutoFocus,a=>{var c;a.preventDefault(),s.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:nt(t.onPointerDownOutside,a=>{const c=a.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,u=c.button===2||d;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:nt(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),mH=_.forwardRef((t,e)=>{const n=ol(xu,t.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return g.jsx(KT,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,s),s.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),KT=_.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,...m}=t,v=ol(xu,n),b=zh(n);return lg(),g.jsx(Oh,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:g.jsx(Au,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:g.jsx(_g,{"data-state":YT(v.open),role:"dialog",id:v.contentId,...b,...m,ref:e,style:{...m.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)"}})})})}),GT="PopoverClose",pH=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=ol(GT,n);return g.jsx(Bt.button,{type:"button",...r,ref:e,onClick:nt(t.onClick,()=>i.onOpenChange(!1))})});pH.displayName=GT;var gH="PopoverArrow",vH=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=zh(n);return g.jsx(yg,{...i,...r,ref:e})});vH.displayName=gH;function YT(t){return t?"open":"closed"}var XT=FT,bH=$T,_H=WT,QT=VT,Xy=qT;const Qy=XT,Zy=_H,kg=_.forwardRef((t,e)=>{const n=ke.c(17);let r,i,s,a;n[0]!==t?({className:r,align:s,sideOffset:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=s,n[4]=a):(r=n[1],i=n[2],s=n[3],a=n[4]);const c=s===void 0?"center":s,d=a===void 0?4:a;let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u={[vh]:""},n[5]=u):u=n[5];let f;n[6]!==i?(f=b=>{var S;b.preventDefault(),window.dispatchEvent(new Event(xp)),(S=i.onCloseAutoFocus)==null||S.call(i,b)},n[6]=i,n[7]=f):f=n[7];let m;n[8]!==r?(m=Ce("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg backdrop-blur-md 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",r),n[8]=r,n[9]=m):m=n[9];let v;return n[10]!==c||n[11]!==i||n[12]!==e||n[13]!==d||n[14]!==f||n[15]!==m?(v=g.jsx(QT,{children:g.jsx(Xy,{ref:e,align:c,sideOffset:d,...u,onCloseAutoFocus:f,className:m,...i})}),n[10]=c,n[11]=i,n[12]=e,n[13]=d,n[14]=f,n[15]=m,n[16]=v):v=n[16],v});kg.displayName=Xy.displayName;function yH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function xH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 158.7128 157.296",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function SH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M12 0C12 0 12 8 8 12C4 16 0 12 0 12C0 12 4 12 8 12C12 12 12 16 12 24C12 24 12 16 16 12C20 8 24 12 24 12C24 12 16 12 16 12C12 12 12 4 12 0Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function wH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M12 0 2.4 5.5v13L12 24l9.6-5.5v-13Zm0 3.1 6.8 3.9v5.1L15 14.3V9.7L12 8l-3 1.7v4.6l-3.8-2.2V7Zm-6.8 9.8 3.8 2.2v4.5l3 1.8 3-1.8v-4.5l3.8-2.2v3.8L12 20.9l-6.8-3.9Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function CH(t){const e=ke.c(11);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s,a,c;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M12 2.75c2.83 0 5.14 2.28 5.19 5.1l1.72.99A7.25 7.25 0 0 0 5.4 13.45l-1.7.98A9.25 9.25 0 0 1 12 2.75Z",fill:"currentColor"}),a=g.jsx("path",{d:"M19.34 8.2a9.25 9.25 0 0 1-3.4 12.65 9.2 9.2 0 0 1-5.22 1.25v-1.98a7.24 7.24 0 0 0 7.25-12.56l1.37.64Z",fill:"currentColor",opacity:".8"}),c=g.jsx("path",{d:"M8.4 21.02A9.26 9.26 0 0 1 3.3 9.58l1.72.99A7.24 7.24 0 0 0 15.9 18.8l-.02 1.58a9.2 9.2 0 0 1-7.48.64Z",fill:"currentColor",opacity:".6"}),e[5]=s,e[6]=a,e[7]=c):(s=e[5],a=e[6],c=e[7]);let d;return e[8]!==r||e[9]!==i?(d=g.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:i,...r,children:[s,a,c]}),e[8]=r,e[9]=i,e[10]=d):d=e[10],d}function kH(t){return!(t.startsWith("gemini-3")||t==="auto-gemini-3")}const EH=["Composer","GPT","Claude","Gemini","Grok","Kimi"];function RH(t){return t.startsWith("composer-")?"Composer":t.startsWith("gpt-")?"GPT":t.startsWith("claude-")?"Claude":t.startsWith("gemini-")?"Gemini":t.startsWith("grok-")?"Grok":"Kimi"}function iE(t){return{Standard:"Std","Fast Mode":"Fast",Medium:"Med",Minimal:"Min",XHigh:"XHi"}[t]??t}function vb(t,e){const n=Lu(e);return!n||n==="standard"?t:`${t} (${n==="fast"?"Fast":"Standard"})`}const Np={claude:yH,codex:xH,gemini:SH,cursor:wH,openrouter:CH},_m={auto:gn,opus:Gn,sonnet:gn,haiku:qr,"gpt-5.4":Gn,"gpt-5.4[reasoning=medium,context=272k,fast=false]":Gn,"gpt-5.4-mini[reasoning=medium]":gn,"gpt-5.4-nano[reasoning=medium]":qr,"gpt-5.3-codex":gn,"gpt-5.3-codex[reasoning=medium,fast=false]":gn,"gpt-5.3-codex-spark[reasoning=medium]":qr,"gpt-5.2[reasoning=medium,fast=false]":gn,"gpt-5.2-codex[reasoning=medium,fast=false]":gn,"gpt-5.3-codex-spark":qr,"gemini-2.5-pro":Gn,"gemini-2.5-flash":gn,"gemini-2.5-flash-lite":qr,"auto-gemini-3":Gn,"auto-gemini-2.5":gn,"gemini-3.1-pro-preview":Gn,"gemini-3.1-pro[]":Gn,"gemini-3-flash[]":gn,"gemini-3-pro-preview":Gn,"gemini-3-flash-preview":gn,"claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]":Gn,"claude-opus-4-5[thinking=true]":Gn,"claude-sonnet-4-6[thinking=true,context=200k,effort=medium]":gn,"claude-sonnet-4-5[thinking=true,context=200k]":gn,"claude-sonnet-4[thinking=false,context=200k]":gn,"claude-haiku-4-5[thinking=true]":qr,"opencode/big-pickle":Gn,"opencode/gpt-5-nano":qr,"opencode/mimo-v2-omni-free":gn,"opencode/mimo-v2-pro-free":gn,"opencode/minimax-m2.5-free":gn,"opencode/nemotron-3-super-free":Gn,"opencode/qwen3.6-plus-free":Gn,"openrouter/anthropic/claude-sonnet-4":gn,"openrouter/anthropic/claude-opus-4":Gn,"openrouter/openai/gpt-5.4":Gn,"openrouter/google/gemini-2.5-pro":Gn,"openrouter/deepseek/deepseek-r1":Gn,"openrouter/meta-llama/llama-4-maverick":gn,"grok-4-20[thinking=true]":Gn,"kimi-k2.5[]":gn,"composer-2[fast=true]":Gn,"composer-1.5[]":gn};function oi(t){const e=ke.c(16),{onClick:n,selected:r,icon:i,label:s,description:a,disabled:c}=t,d=r?"bg-muted border-border":"hover:opacity-60",u=c&&"opacity-40 cursor-not-allowed";let f;e[0]!==d||e[1]!==u?(f=Ce("w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity",d,u),e[0]=d,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==s?(m=g.jsx("div",{className:"text-sm font-medium",children:s}),e[3]=s,e[4]=m):m=e[4];let v;e[5]!==a?(v=a?g.jsx("div",{className:"text-xs text-muted-foreground",children:a}):null,e[5]=a,e[6]=v):v=e[6];let b;e[7]!==m||e[8]!==v?(b=g.jsxs("div",{children:[m,v]}),e[7]=m,e[8]=v,e[9]=b):b=e[9];let S;return e[10]!==c||e[11]!==i||e[12]!==n||e[13]!==f||e[14]!==b?(S=g.jsxs("button",{onClick:n,disabled:c,className:f,children:[i,b]}),e[10]=c,e[11]=i,e[12]=n,e[13]=f,e[14]=b,e[15]=S):S=e[15],S}function La(t){const e=ke.c(18),{trigger:n,triggerClassName:r,disabled:i,children:s}=t,a=i===void 0?!1:i,[c,d]=_.useState(!1);if(a){let S;e[0]!==r?(S=Ce("flex items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default",r),e[0]=r,e[1]=S):S=e[1];let x;return e[2]!==S||e[3]!==n?(x=g.jsx("button",{disabled:!0,className:S,children:n}),e[2]=S,e[3]=n,e[4]=x):x=e[4],x}let u;e[5]!==r?(u=Ce("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),e[5]=r,e[6]=u):u=e[6];let f;e[7]!==u||e[8]!==n?(f=g.jsx(Zy,{asChild:!0,children:g.jsx("button",{className:u,children:n})}),e[7]=u,e[8]=n,e[9]=f):f=e[9];let m;e[10]!==s?(m=typeof s=="function"?s(()=>d(!1)):s,e[10]=s,e[11]=m):m=e[11];let v;e[12]!==m?(v=g.jsx(kg,{align:"center",className:"w-64 p-1",children:g.jsx("div",{className:"max-h-[min(24rem,60vh)] space-y-1 overflow-y-auto pr-1",children:m})}),e[12]=m,e[13]=v):v=e[13];let b;return e[14]!==c||e[15]!==f||e[16]!==v?(b=g.jsxs(Qy,{open:c,onOpenChange:d,children:[f,v]}),e[14]=c,e[15]=f,e[16]=v,e[17]=b):b=e[17],b}function TH(t){var tt,it,ce,Re,Ue,Je,Ve;const e=ke.c(38),{availableProviders:n,selectedProvider:r,lockedProviders:i,disabled:s,showProviderPicker:a,providerLocked:c,model:d,modelOptions:u,onProviderChange:f,onModelChange:m,onClaudeReasoningEffortChange:v,onClaudeContextWindowChange:b,onCodexReasoningEffortChange:S,onGeminiThinkingModeChange:x,onCodexFastModeChange:C,planMode:k,onPlanModeChange:E,pendingPlanMode:R,includePlanMode:M,className:O}=t,D=s===void 0?!1:s,P=a===void 0?!0:a,z=c===void 0?!1:c,Y=k===void 0?!1:k,L=R===void 0?null:R,W=M===void 0?!0:M,[V,F]=_.useState(null),U=n.find(ze=>ze.id===r)??Zn(r),H=Np[r],j=_m[d]??gn,G=W&&(U==null?void 0:U.supportsPlanMode)&&E,B=L??Y,K=L!==null,A=r==="claude"?u:null,I=r==="codex"?u:null,$=r==="gemini"?u:null,T=((tt=U.models.find(ze=>ze.id===d))==null?void 0:tt.contextWindowOptions)??[],X=(A==null?void 0:A.contextWindow)??z1[0].id,Z=X==="1m"?bk:_k,J=r==="claude"||r==="codex",re=r==="cursor"?Lu(d):null,ae=U.id==="cursor"?U.models.filter(ze=>eE(ze.id)===eE(d)):[],ue=r==="cursor"&&ae.some(OH)&&ae.some(DH),me=U.id==="cursor"?EH.map(ze=>({family:ze,models:U.models.filter(He=>RH(He.id)===ze)})).filter(NH):[];let se;e[0]!==J||e[1]!==u||e[2]!==r?(se=J?r==="claude"?((it=Rp.find(ze=>ze.id===u.reasoningEffort))==null?void 0:it.label)??String(u.reasoningEffort):((ce=L1.find(ze=>ze.id===u.reasoningEffort))==null?void 0:ce.label)??String(u.reasoningEffort):null,e[0]=J,e[1]=u,e[2]=r,e[3]=se):se=e[3];const oe=se;let ee;e[4]!==($==null?void 0:$.thinkingMode)||e[5]!==r?(ee=r==="gemini"?((Re=I1.find(ze=>ze.id===($==null?void 0:$.thinkingMode)))==null?void 0:Re.label)??($==null?void 0:$.thinkingMode)??"Standard":null,e[4]=$==null?void 0:$.thinkingMode,e[5]=r,e[6]=ee):ee=e[6];const Q=ee;let te;e[7]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{F(null)},e[7]=te):te=e[7];let he;e[8]!==r?(he=[r],e[8]=r,e[9]=he):he=e[9],_.useEffect(te,he);const ie=D&&"pointer-events-none opacity-60";let xe;e[10]!==O||e[11]!==ie?(xe=Ce("max-w-full overflow-x-auto scrollbar-hide",ie,O),e[10]=O,e[11]=ie,e[12]=xe):xe=e[12];let Ae;e[13]!==j?(Ae=g.jsx(j,{className:"h-3.5 w-3.5"}),e[13]=j,e[14]=Ae):Ae=e[14];let Ke;e[15]!==oe||e[16]!==J||e[17]!==d||e[18]!==u||e[19]!==v||e[20]!==S||e[21]!==r?(Ke=J?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:oe}),g.jsx("span",{className:"md:hidden",children:oe!==null?iE(oe):null})]}),children:ze=>r==="claude"?Rp.map(He=>g.jsx(oi,{onClick:()=>{v(He.id),ze()},selected:u.reasoningEffort===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,disabled:He.id==="max"&&d!=="opus"},He.id)):L1.map(He=>g.jsx(oi,{onClick:()=>{S(He.id),ze()},selected:u.reasoningEffort===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:He.label},He.id))}):null,e[15]=oe,e[16]=J,e[17]=d,e[18]=u,e[19]=v,e[20]=S,e[21]=r,e[22]=Ke):Ke=e[22];let mt;e[23]!==($==null?void 0:$.thinkingMode)||e[24]!==Q||e[25]!==d||e[26]!==x||e[27]!==r?(mt=r==="gemini"?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:Q}),g.jsx("span",{className:"md:hidden",children:Q!==null?iE(Q):null})]}),children:ze=>I1.map(He=>g.jsx(oi,{onClick:()=>{x(He.id),ze()},selected:($==null?void 0:$.thinkingMode)===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,disabled:He.id==="off"&&!kH(d)},He.id))}):null,e[23]=$==null?void 0:$.thinkingMode,e[24]=Q,e[25]=d,e[26]=x,e[27]=r,e[28]=mt):mt=e[28];let Ye;e[29]!==(I==null?void 0:I.fastMode)||e[30]!==C||e[31]!==r?(Ye=r==="codex"?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[I!=null&&I.fastMode?g.jsx(qr,{className:"h-3.5 w-3.5"}):g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:I!=null&&I.fastMode?"Fast Mode":"Standard"}),g.jsx("span",{className:"md:hidden",children:I!=null&&I.fastMode?"Fast":"Std"})]}),triggerClassName:I!=null&&I.fastMode?"text-emerald-500 dark:text-emerald-400":void 0,children:ze=>g.jsxs(g.Fragment,{children:[g.jsx(oi,{onClick:()=>{C(!1),ze()},selected:!(I!=null&&I.fastMode),icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:"Standard"}),g.jsx(oi,{onClick:()=>{C(!0),ze()},selected:!!(I!=null&&I.fastMode),icon:g.jsx(qr,{className:"h-4 w-4 text-muted-foreground"}),label:"Fast Mode"})]})}):null,e[29]=I==null?void 0:I.fastMode,e[30]=C,e[31]=r,e[32]=Ye):Ye=e[32];let Ze;return e[33]!==B||e[34]!==K||e[35]!==E||e[36]!==G?(Ze=G?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[K?g.jsx(Fn,{className:"h-3.5 w-3.5 animate-spin"}):B?g.jsx(bp,{className:"h-3.5 w-3.5"}):g.jsx(gk,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:K?B?"Planning...":"Implementing...":B?"Plan":"Implement"}),g.jsx("span",{className:"md:hidden",children:K?B?"Plan...":"Impl...":B?"Plan":"Impl"})]}),triggerClassName:B?"text-blue-400 dark:text-blue-300":void 0,children:ze=>g.jsxs(g.Fragment,{children:[g.jsx(oi,{onClick:()=>{E(!1),ze()},selected:!B,icon:g.jsx(gk,{className:"h-4 w-4 text-muted-foreground"}),label:"Implement",description:"Start execution",disabled:K}),g.jsx(oi,{onClick:()=>{E(!0),ze()},selected:B,icon:g.jsx(bp,{className:"h-4 w-4 text-muted-foreground"}),label:"Plan",description:"Review a plan before execution",disabled:K})]})}):null,e[33]=B,e[34]=K,e[35]=E,e[36]=G,e[37]=Ze):Ze=e[37],g.jsx("div",{className:xe,children:g.jsxs("div",{className:"flex w-max items-center justify-center gap-0.5 mx-auto",children:[P?g.jsx(La,{disabled:z||!f,trigger:g.jsxs(g.Fragment,{children:[g.jsx(H,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:(U==null?void 0:U.label)??r})]}),children:ze=>n.map(He=>{const Xe=Np[He.id],ut=i==null?void 0:i[He.id];return g.jsx(oi,{onClick:()=>{ut||(f==null||f(He.id),ze())},selected:r===He.id,icon:g.jsx(Xe,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,description:ut,disabled:!!ut},He.id)})}):null,g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[Ae,g.jsx("span",{children:U.id==="cursor"?vb(((Ue=U.models.find(ze=>ze.id===d))==null?void 0:Ue.label)??d,d):((Je=U.models.find(ze=>ze.id===d))==null?void 0:Je.label)??d})]}),children:ze=>{var He;return U.id==="cursor"?V?g.jsxs(g.Fragment,{children:[g.jsxs("button",{onClick:()=>F(null),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-muted-foreground transition-opacity hover:opacity-70",children:[g.jsx(GR,{className:"h-4 w-4"}),g.jsx("span",{children:V})]}),(He=me.find(Xe=>Xe.family===V))==null?void 0:He.models.map(Xe=>{const ut=_m[Xe.id]??gn;return g.jsx(oi,{onClick:()=>{m(r,Xe.id),F(null),ze()},selected:d===Xe.id,icon:g.jsx(ut,{className:"h-4 w-4 text-muted-foreground"}),label:vb(Xe.label,Xe.id)},Xe.id)})]}):me.map(Xe=>{var rt;const ut=Xe.models.some(Tt=>Tt.id===d),ft=_m[((rt=Xe.models[0])==null?void 0:rt.id)??""]??gn;return g.jsxs("div",{className:"relative",children:[g.jsx(oi,{onClick:()=>F(Xe.family),selected:ut,icon:g.jsx(ft,{className:"h-4 w-4 text-muted-foreground"}),label:Xe.family,description:`${Xe.models.length} model${Xe.models.length===1?"":"s"}`}),g.jsx(Ni,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"})]},Xe.family)}):U.models.map(Xe=>{const ut=_m[Xe.id]??gn;return g.jsx(oi,{onClick:()=>{m(r,Xe.id),ze()},selected:d===Xe.id,icon:g.jsx(ut,{className:"h-4 w-4 text-muted-foreground"}),label:U.id==="cursor"?vb(Xe.label,Xe.id):Xe.label},Xe.id)})}}),ue?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[re==="fast"?g.jsx(qr,{className:"h-3.5 w-3.5"}):g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:re==="fast"?"Fast":"Standard"}),g.jsx("span",{className:"md:hidden",children:re==="fast"?"Fast":"Std"})]}),triggerClassName:re==="fast"?"text-emerald-500 dark:text-emerald-400":void 0,children:ze=>g.jsxs(g.Fragment,{children:[ae.filter(AH).map(He=>g.jsx(oi,{onClick:()=>{m(r,He.id),ze()},selected:d===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:"Standard"},He.id)),ae.filter(MH).map(He=>g.jsx(oi,{onClick:()=>{m(r,He.id),ze()},selected:d===He.id,icon:g.jsx(qr,{className:"h-4 w-4 text-muted-foreground"}),label:"Fast"},He.id))]})}):null,Ke,r==="claude"&&T.length>1?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[g.jsx(Z,{className:"h-3.5 w-3.5"}),g.jsx("span",{children:((Ve=T.find(ze=>ze.id===X))==null?void 0:Ve.label)??X})]}),children:ze=>T.map(He=>g.jsx(oi,{onClick:()=>{b(He.id),ze()},selected:X===He.id,icon:He.id==="1m"?g.jsx(bk,{className:"h-4 w-4 text-muted-foreground"}):g.jsx(_k,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,description:He.id==="1m"?"Expanded context window":"Standard context window"},He.id))}):null,mt,Ye,Ze]})})}function MH(t){return Lu(t.id)==="fast"}function AH(t){return Lu(t.id)==="standard"}function NH(t){return t.models.length>0}function DH(t){return Lu(t.id)==="standard"}function OH(t){return Lu(t.id)==="fast"}const Eg=t=>{const e=ke.c(16);let n,r,i,s,a;e[0]!==t?({children:n,className:r,shimmerWidth:s,animate:a,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=s,e[5]=a):(n=e[1],r=e[2],i=e[3],s=e[4],a=e[5]);const c=s===void 0?100:s,d=a===void 0?!0:a,u=`${Math.min(c,100)}px`;let f;e[6]!==u?(f={"--shiny-width":u},e[6]=u,e[7]=f):f=e[7];const m=f;let v;e[8]!==d||e[9]!==r?(v=Ce("mx-auto max-w-md text-foreground/50",d?["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),e[8]=d,e[9]=r,e[10]=v):v=e[10];let b;return e[11]!==n||e[12]!==i||e[13]!==m||e[14]!==v?(b=g.jsx("span",{style:m,className:v,...i,children:n}),e[11]=n,e[12]=i,e[13]=m,e[14]=v,e[15]=b):b=e[15],b};function B1(t){return t.split(/[\s_-]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}const jH=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function LH(t){const e=t.trim();for(const n of jH){const r=e.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return e}function sE(t){return t.split("/").pop()||t}function IH(t,e){if(t===void 0)return null;const n=Math.max(0,e-t),r=6e4,i=60*r,s=24*i,a=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<a?`${Math.floor(n/s)}d`:`${Math.floor(n/a)}w`}const PH='button, select, input, textarea, [role="combobox"], [role="listbox"], [data-no-touch-drag]';function oE(t){var e;try{(e=navigator.vibrate)==null||e.call(navigator,t)}catch{}}function Jy({enabled:t,visualElementRef:e,onTap:n,onContextMenu:r,onDragStart:i,onDragMove:s,onDragEnd:a,holdDelay:c=300,contextMenuDelay:d=2500,scrollThreshold:u=8,dragMoveThreshold:f=5}){const[m,v]=_.useState(!1),[b,S]=_.useState(!1),[x,C]=_.useState(null),[k,E]=_.useState(null),R=_.useCallback(j=>{E(j)},[]),M=_.useRef("idle"),O=_.useRef({x:0,y:0}),D=_.useRef(null),P=_.useRef(null),z=_.useRef(n),Y=_.useRef(r),L=_.useRef(i),W=_.useRef(s),V=_.useRef(a);z.current=n,Y.current=r,L.current=i,W.current=s,V.current=a;const F=_.useCallback((j,G)=>{const B=(e==null?void 0:e.current)??k;if(!B)return document.elementFromPoint(j,G);const K=B.style.pointerEvents;B.style.pointerEvents="none";const A=document.elementFromPoint(j,G);return B.style.pointerEvents=K,A},[e,k]),U=_.useCallback(()=>{D.current&&(clearTimeout(D.current),D.current=null),P.current&&(clearTimeout(P.current),P.current=null)},[]),H=_.useCallback(()=>{U(),M.current="idle",S(!1),v(!1),C(null)},[U]);return _.useEffect(()=>{if(!k||!t)return;const j=A=>{if(A.target.closest(PH))return;const I=A.touches[0];I&&(O.current={x:I.clientX,y:I.clientY},M.current="holding",D.current=setTimeout(()=>{D.current=null,M.current==="holding"&&(M.current="armed",S(!0),oE(30),P.current=setTimeout(()=>{var T;if(P.current=null,M.current!=="armed")return;oE(100);const $={...O.current};M.current="idle",S(!1),(T=Y.current)==null||T.call(Y,$)},d))},c))},G=A=>{var J,re;const I=M.current;if(I==="idle")return;const $=A.touches[0];if(!$)return;const T=$.clientX-O.current.x,X=$.clientY-O.current.y,Z=Math.sqrt(T*T+X*X);if(I==="holding"){Z>u&&(U(),M.current="idle");return}if(I==="armed"){Z>f&&(P.current&&(clearTimeout(P.current),P.current=null),M.current="dragging",S(!1),v(!0),C({x:$.clientX,y:$.clientY}),A.preventDefault(),(J=L.current)==null||J.call(L,{x:$.clientX,y:$.clientY}));return}if(I==="dragging"){A.preventDefault(),C({x:$.clientX,y:$.clientY});const ae=F($.clientX,$.clientY);(re=W.current)==null||re.call(W,{x:$.clientX,y:$.clientY,elementBelow:ae})}},B=A=>{var $,T;const I=M.current;if(I==="holding"){U(),M.current="idle",S(!1),v(!1),A.preventDefault(),($=z.current)==null||$.call(z);return}if(I==="armed"){H();return}if(I==="dragging"){const X=A.changedTouches[0];if(X){const Z=F(X.clientX,X.clientY);(T=V.current)==null||T.call(V,{x:X.clientX,y:X.clientY,elementBelow:Z})}H()}},K=()=>{var A;M.current==="dragging"&&((A=V.current)==null||A.call(V,{x:0,y:0,elementBelow:null})),H()};return k.addEventListener("touchstart",j,{passive:!1}),k.addEventListener("touchmove",G,{passive:!1}),k.addEventListener("touchend",B),k.addEventListener("touchcancel",K),()=>{k.removeEventListener("touchstart",j),k.removeEventListener("touchmove",G),k.removeEventListener("touchend",B),k.removeEventListener("touchcancel",K),U(),M.current="idle"}},[k,t,c,d,u,f,U,H,F]),{touchRef:R,isDragging:m,isArmed:b,dragPosition:x}}function ZT(t){const e=ke.c(9),{position:n,children:r,className:i}=t;if(!n)return null;let s;e[0]!==n.x||e[1]!==n.y?(s={position:"fixed",left:n.x,top:n.y,transform:"translate(-50%, calc(-100% - 14px))",zIndex:9999,pointerEvents:"none",willChange:"transform"},e[0]=n.x,e[1]=n.y,e[2]=s):s=e[2];let a;e[3]!==i?(a=Ce("flex items-center gap-2 rounded-xl border-2 border-primary/60 bg-card px-3 py-2","shadow-[0_8px_32px_rgba(0,0,0,0.25)] dark:shadow-[0_8px_32px_rgba(0,0,0,0.5)]","min-w-[120px] max-w-[240px]","scale-[1.04]",i),e[3]=i,e[4]=a):a=e[4];let c;return e[5]!==r||e[6]!==s||e[7]!==a?(c=es.createPortal(g.jsx("div",{style:s,className:a,children:r}),document.body),e[5]=r,e[6]=s,e[7]=a,e[8]=c):c=e[8],c}function ex(t){const e=t+"CollectionProvider",[n,r]=Xo(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),a=x=>{const{scope:C,children:k}=x,E=je.useRef(null),R=je.useRef(new Map).current;return g.jsx(i,{scope:C,itemMap:R,collectionRef:E,children:k})};a.displayName=e;const c=t+"CollectionSlot",d=Wl(c),u=je.forwardRef((x,C)=>{const{scope:k,children:E}=x,R=s(c,k),M=Xt(C,R.collectionRef);return g.jsx(d,{ref:M,children:E})});u.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",v=Wl(f),b=je.forwardRef((x,C)=>{const{scope:k,children:E,...R}=x,M=je.useRef(null),O=Xt(C,M),D=s(f,k);return je.useEffect(()=>(D.itemMap.set(M,{ref:M,...R}),()=>void D.itemMap.delete(M))),g.jsx(v,{[m]:"",ref:O,children:E})});b.displayName=f;function S(x){const C=s(t+"CollectionConsumer",x);return je.useCallback(()=>{const E=C.collectionRef.current;if(!E)return[];const R=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(C.itemMap.values()).sort((D,P)=>R.indexOf(D.ref.current)-R.indexOf(P.ref.current))},[C.collectionRef,C.itemMap])}return[{Provider:a,Slot:u,ItemSlot:b},S,r]}var zH=_.createContext(void 0);function tx(t){const e=_.useContext(zH);return t||e||"ltr"}var bb="rovingFocusGroup.onEntryFocus",BH={bubbles:!1,cancelable:!0},Bh="RovingFocusGroup",[F1,JT,FH]=ex(Bh),[HH,eM]=Xo(Bh,[FH]),[$H,UH]=HH(Bh),tM=_.forwardRef((t,e)=>g.jsx(F1.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(F1.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(WH,{...t,ref:e})})}));tM.displayName=Bh;var WH=_.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...m}=t,v=_.useRef(null),b=Xt(e,v),S=tx(s),[x,C]=bu({prop:a,defaultProp:c??null,onChange:d,caller:Bh}),[k,E]=_.useState(!1),R=Ss(u),M=JT(n),O=_.useRef(!1),[D,P]=_.useState(0);return _.useEffect(()=>{const z=v.current;if(z)return z.addEventListener(bb,R),()=>z.removeEventListener(bb,R)},[R]),g.jsx($H,{scope:n,orientation:r,dir:S,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(z=>C(z),[C]),onItemShiftTab:_.useCallback(()=>E(!0),[]),onFocusableItemAdd:_.useCallback(()=>P(z=>z+1),[]),onFocusableItemRemove:_.useCallback(()=>P(z=>z-1),[]),children:g.jsx(Bt.div,{tabIndex:k||D===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:nt(t.onMouseDown,()=>{O.current=!0}),onFocus:nt(t.onFocus,z=>{const Y=!O.current;if(z.target===z.currentTarget&&Y&&!k){const L=new CustomEvent(bb,BH);if(z.currentTarget.dispatchEvent(L),!L.defaultPrevented){const W=M().filter(j=>j.focusable),V=W.find(j=>j.active),F=W.find(j=>j.id===x),H=[V,F,...W].filter(Boolean).map(j=>j.ref.current);iM(H,f)}}O.current=!1}),onBlur:nt(t.onBlur,()=>E(!1))})})}),nM="RovingFocusGroupItem",rM=_.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:a,...c}=t,d=Wo(),u=s||d,f=UH(nM,n),m=f.currentTabStopId===u,v=JT(n),{onFocusableItemAdd:b,onFocusableItemRemove:S,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return b(),()=>S()},[r,b,S]),g.jsx(F1.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:g.jsx(Bt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:nt(t.onMouseDown,C=>{r?f.onItemFocus(u):C.preventDefault()}),onFocus:nt(t.onFocus,()=>f.onItemFocus(u)),onKeyDown:nt(t.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){f.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const k=KH(C,f.orientation,f.dir);if(k!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let R=v().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")R.reverse();else if(k==="prev"||k==="next"){k==="prev"&&R.reverse();const M=R.indexOf(C.currentTarget);R=f.loop?GH(R,M+1):R.slice(M+1)}setTimeout(()=>iM(R))}}),children:typeof a=="function"?a({isCurrentTabStop:m,hasTabStop:x!=null}):a})})});rM.displayName=nM;var VH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qH(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function KH(t,e,n){const r=qH(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return VH[r]}function iM(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function GH(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var YH=tM,XH=rM,H1=["Enter"," "],QH=["ArrowDown","PageUp","Home"],sM=["ArrowUp","PageDown","End"],ZH=[...QH,...sM],JH={ltr:[...H1,"ArrowRight"],rtl:[...H1,"ArrowLeft"]},e$={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Fh="Menu",[yh,t$,n$]=ex(Fh),[ic,oM]=Xo(Fh,[n$,sl,eM]),Rg=sl(),aM=eM(),[r$,sc]=ic(Fh),[i$,Hh]=ic(Fh),lM=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:a=!0}=t,c=Rg(e),[d,u]=_.useState(null),f=_.useRef(!1),m=Ss(s),v=tx(i);return _.useEffect(()=>{const b=()=>{f.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>f.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),g.jsx(bg,{...c,children:g.jsx(r$,{scope:e,open:n,onOpenChange:m,content:d,onContentChange:u,children:g.jsx(i$,{scope:e,onClose:_.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:f,dir:v,modal:a,children:r})})})};lM.displayName=Fh;var s$="MenuAnchor",nx=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Rg(n);return g.jsx(Ih,{...i,...r,ref:e})});nx.displayName=s$;var rx="MenuPortal",[o$,cM]=ic(rx,{forceMount:void 0}),uM=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=sc(rx,e);return g.jsx(o$,{scope:e,forceMount:n,children:g.jsx(os,{present:n||s.open,children:g.jsx(Nu,{asChild:!0,container:i,children:r})})})};uM.displayName=rx;var ts="MenuContent",[a$,ix]=ic(ts),dM=_.forwardRef((t,e)=>{const n=cM(ts,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=sc(ts,t.__scopeMenu),a=Hh(ts,t.__scopeMenu);return g.jsx(yh.Provider,{scope:t.__scopeMenu,children:g.jsx(os,{present:r||s.open,children:g.jsx(yh.Slot,{scope:t.__scopeMenu,children:a.modal?g.jsx(l$,{...i,ref:e}):g.jsx(c$,{...i,ref:e})})})})}),l$=_.forwardRef((t,e)=>{const n=sc(ts,t.__scopeMenu),r=_.useRef(null),i=Xt(e,r);return _.useEffect(()=>{const s=r.current;if(s)return ug(s)},[]),g.jsx(sx,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:nt(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),c$=_.forwardRef((t,e)=>{const n=sc(ts,t.__scopeMenu);return g.jsx(sx,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),u$=Wl("MenuContent.ScrollLock"),sx=_.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:v,onDismiss:b,disableOutsideScroll:S,...x}=t,C=sc(ts,n),k=Hh(ts,n),E=Rg(n),R=aM(n),M=t$(n),[O,D]=_.useState(null),P=_.useRef(null),z=Xt(e,P,C.onContentChange),Y=_.useRef(0),L=_.useRef(""),W=_.useRef(0),V=_.useRef(null),F=_.useRef("right"),U=_.useRef(0),H=S?jh:_.Fragment,j=S?{as:u$,allowPinchZoom:!0}:void 0,G=K=>{var re,ae;const A=L.current+K,I=M().filter(ue=>!ue.disabled),$=document.activeElement,T=(re=I.find(ue=>ue.ref.current===$))==null?void 0:re.textValue,X=I.map(ue=>ue.textValue),Z=S$(X,A,T),J=(ae=I.find(ue=>ue.textValue===Z))==null?void 0:ae.ref.current;(function ue(me){L.current=me,window.clearTimeout(Y.current),me!==""&&(Y.current=window.setTimeout(()=>ue(""),1e3))})(A),J&&setTimeout(()=>J.focus())};_.useEffect(()=>()=>window.clearTimeout(Y.current),[]),lg();const B=_.useCallback(K=>{var I,$;return F.current===((I=V.current)==null?void 0:I.side)&&C$(K,($=V.current)==null?void 0:$.area)},[]);return g.jsx(a$,{scope:n,searchRef:L,onItemEnter:_.useCallback(K=>{B(K)&&K.preventDefault()},[B]),onItemLeave:_.useCallback(K=>{var A;B(K)||((A=P.current)==null||A.focus(),D(null))},[B]),onTriggerLeave:_.useCallback(K=>{B(K)&&K.preventDefault()},[B]),pointerGraceTimerRef:W,onPointerGraceIntentChange:_.useCallback(K=>{V.current=K},[]),children:g.jsx(H,{...j,children:g.jsx(Oh,{asChild:!0,trapped:i,onMountAutoFocus:nt(s,K=>{var A;K.preventDefault(),(A=P.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:g.jsx(Au,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:v,onDismiss:b,children:g.jsx(YH,{asChild:!0,...R,dir:k.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:D,onEntryFocus:nt(d,K=>{k.isUsingKeyboardRef.current||K.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(_g,{role:"menu","aria-orientation":"vertical","data-state":RM(C.open),"data-radix-menu-content":"",dir:k.dir,...E,...x,ref:z,style:{outline:"none",...x.style},onKeyDown:nt(x.onKeyDown,K=>{const I=K.target.closest("[data-radix-menu-content]")===K.currentTarget,$=K.ctrlKey||K.altKey||K.metaKey,T=K.key.length===1;I&&(K.key==="Tab"&&K.preventDefault(),!$&&T&&G(K.key));const X=P.current;if(K.target!==X||!ZH.includes(K.key))return;K.preventDefault();const J=M().filter(re=>!re.disabled).map(re=>re.ref.current);sM.includes(K.key)&&J.reverse(),y$(J)}),onBlur:nt(t.onBlur,K=>{K.currentTarget.contains(K.target)||(window.clearTimeout(Y.current),L.current="")}),onPointerMove:nt(t.onPointerMove,xh(K=>{const A=K.target,I=U.current!==K.clientX;if(K.currentTarget.contains(A)&&I){const $=K.clientX>U.current?"right":"left";F.current=$,U.current=K.clientX}}))})})})})})})});dM.displayName=ts;var d$="MenuGroup",ox=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Bt.div,{role:"group",...r,ref:e})});ox.displayName=d$;var h$="MenuLabel",hM=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Bt.div,{...r,ref:e})});hM.displayName=h$;var Dp="MenuItem",aE="menu.itemSelect",Tg=_.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=_.useRef(null),a=Hh(Dp,t.__scopeMenu),c=ix(Dp,t.__scopeMenu),d=Xt(e,s),u=_.useRef(!1),f=()=>{const m=s.current;if(!n&&m){const v=new CustomEvent(aE,{bubbles:!0,cancelable:!0});m.addEventListener(aE,b=>r==null?void 0:r(b),{once:!0}),_4(m,v),v.defaultPrevented?u.current=!1:a.onClose()}};return g.jsx(fM,{...i,ref:d,disabled:n,onClick:nt(t.onClick,f),onPointerDown:m=>{var v;(v=t.onPointerDown)==null||v.call(t,m),u.current=!0},onPointerUp:nt(t.onPointerUp,m=>{var v;u.current||(v=m.currentTarget)==null||v.click()}),onKeyDown:nt(t.onKeyDown,m=>{const v=c.searchRef.current!=="";n||v&&m.key===" "||H1.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});Tg.displayName=Dp;var fM=_.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,a=ix(Dp,n),c=aM(n),d=_.useRef(null),u=Xt(e,d),[f,m]=_.useState(!1),[v,b]=_.useState("");return _.useEffect(()=>{const S=d.current;S&&b((S.textContent??"").trim())},[s.children]),g.jsx(yh.ItemSlot,{scope:n,disabled:r,textValue:i??v,children:g.jsx(XH,{asChild:!0,...c,focusable:!r,children:g.jsx(Bt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:nt(t.onPointerMove,xh(S=>{r?a.onItemLeave(S):(a.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:nt(t.onPointerLeave,xh(S=>a.onItemLeave(S))),onFocus:nt(t.onFocus,()=>m(!0)),onBlur:nt(t.onBlur,()=>m(!1))})})})}),f$="MenuCheckboxItem",mM=_.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return g.jsx(_M,{scope:t.__scopeMenu,checked:n,children:g.jsx(Tg,{role:"menuitemcheckbox","aria-checked":Op(n)?"mixed":n,...i,ref:e,"data-state":lx(n),onSelect:nt(i.onSelect,()=>r==null?void 0:r(Op(n)?!0:!n),{checkForDefaultPrevented:!1})})})});mM.displayName=f$;var pM="MenuRadioGroup",[m$,p$]=ic(pM,{value:void 0,onValueChange:()=>{}}),gM=_.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Ss(r);return g.jsx(m$,{scope:t.__scopeMenu,value:n,onValueChange:s,children:g.jsx(ox,{...i,ref:e})})});gM.displayName=pM;var vM="MenuRadioItem",bM=_.forwardRef((t,e)=>{const{value:n,...r}=t,i=p$(vM,t.__scopeMenu),s=n===i.value;return g.jsx(_M,{scope:t.__scopeMenu,checked:s,children:g.jsx(Tg,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":lx(s),onSelect:nt(r.onSelect,()=>{var a;return(a=i.onValueChange)==null?void 0:a.call(i,n)},{checkForDefaultPrevented:!1})})})});bM.displayName=vM;var ax="MenuItemIndicator",[_M,g$]=ic(ax,{checked:!1}),yM=_.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=g$(ax,n);return g.jsx(os,{present:r||Op(s.checked)||s.checked===!0,children:g.jsx(Bt.span,{...i,ref:e,"data-state":lx(s.checked)})})});yM.displayName=ax;var v$="MenuSeparator",xM=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Bt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});xM.displayName=v$;var b$="MenuArrow",SM=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Rg(n);return g.jsx(yg,{...i,...r,ref:e})});SM.displayName=b$;var _$="MenuSub",[Tle,wM]=ic(_$),Xd="MenuSubTrigger",CM=_.forwardRef((t,e)=>{const n=sc(Xd,t.__scopeMenu),r=Hh(Xd,t.__scopeMenu),i=wM(Xd,t.__scopeMenu),s=ix(Xd,t.__scopeMenu),a=_.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,u={__scopeMenu:t.__scopeMenu},f=_.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),d(null)}},[c,d]),g.jsx(nx,{asChild:!0,...u,children:g.jsx(fM,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":RM(n.open),...t,ref:Cy(e,i.onTriggerChange),onClick:m=>{var v;(v=t.onClick)==null||v.call(t,m),!(t.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:nt(t.onPointerMove,xh(m=>{s.onItemEnter(m),!m.defaultPrevented&&!t.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:nt(t.onPointerLeave,xh(m=>{var b,S;f();const v=(b=n.content)==null?void 0:b.getBoundingClientRect();if(v){const x=(S=n.content)==null?void 0:S.dataset.side,C=x==="right",k=C?-5:5,E=v[C?"left":"right"],R=v[C?"right":"left"];s.onPointerGraceIntentChange({area:[{x:m.clientX+k,y:m.clientY},{x:E,y:v.top},{x:R,y:v.top},{x:R,y:v.bottom},{x:E,y:v.bottom}],side:x}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(m),m.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:nt(t.onKeyDown,m=>{var b;const v=s.searchRef.current!=="";t.disabled||v&&m.key===" "||JH[r.dir].includes(m.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),m.preventDefault())})})})});CM.displayName=Xd;var kM="MenuSubContent",EM=_.forwardRef((t,e)=>{const n=cM(ts,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=sc(ts,t.__scopeMenu),a=Hh(ts,t.__scopeMenu),c=wM(kM,t.__scopeMenu),d=_.useRef(null),u=Xt(e,d);return g.jsx(yh.Provider,{scope:t.__scopeMenu,children:g.jsx(os,{present:r||s.open,children:g.jsx(yh.Slot,{scope:t.__scopeMenu,children:g.jsx(sx,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:u,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var m;a.isUsingKeyboardRef.current&&((m=d.current)==null||m.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:nt(t.onFocusOutside,f=>{f.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:nt(t.onEscapeKeyDown,f=>{a.onClose(),f.preventDefault()}),onKeyDown:nt(t.onKeyDown,f=>{var b;const m=f.currentTarget.contains(f.target),v=e$[a.dir].includes(f.key);m&&v&&(s.onOpenChange(!1),(b=c.trigger)==null||b.focus(),f.preventDefault())})})})})})});EM.displayName=kM;function RM(t){return t?"open":"closed"}function Op(t){return t==="indeterminate"}function lx(t){return Op(t)?"indeterminate":t?"checked":"unchecked"}function y$(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function x$(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function S$(t,e,n){const i=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let a=x$(t,Math.max(s,0));i.length===1&&(a=a.filter(u=>u!==n));const d=a.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return d!==n?d:void 0}function w$(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,a=e.length-1;s<e.length;a=s++){const c=e[s],d=e[a],u=c.x,f=c.y,m=d.x,v=d.y;f>r!=v>r&&n<(m-u)*(r-f)/(v-f)+u&&(i=!i)}return i}function C$(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return w$(n,e)}function xh(t){return e=>e.pointerType==="mouse"?t(e):void 0}var k$=lM,E$=nx,R$=uM,T$=dM,M$=ox,A$=hM,N$=Tg,D$=mM,O$=gM,j$=bM,L$=yM,I$=xM,P$=SM,z$=CM,B$=EM,cx="ContextMenu",[F$,Mle]=Xo(cx,[oM]),Xr=oM(),[H$,TM]=F$(cx),MM=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:r,dir:i,modal:s=!0}=t,[a,c]=_.useState(!1),d=Xr(e),u=Ss(r),f=_.useCallback(m=>{c(m),u(m)},[u]);return g.jsx(H$,{scope:e,open:a,onOpenChange:f,modal:s,children:g.jsx(k$,{...d,dir:i,open:a,onOpenChange:f,modal:s,children:n})})};MM.displayName=cx;var AM="ContextMenuTrigger",NM=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=t,s=TM(AM,n),a=Xr(n),c=_.useRef({x:0,y:0}),d=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...c.current})}),u=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(u.current),[]),m=v=>{c.current={x:v.clientX,y:v.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),g.jsxs(g.Fragment,{children:[g.jsx(E$,{...a,virtualRef:d}),g.jsx(Bt.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:nt(t.onContextMenu,v=>{f(),m(v),v.preventDefault()}),onPointerDown:r?t.onPointerDown:nt(t.onPointerDown,ym(v=>{f(),u.current=window.setTimeout(()=>m(v),700)})),onPointerMove:r?t.onPointerMove:nt(t.onPointerMove,ym(f)),onPointerCancel:r?t.onPointerCancel:nt(t.onPointerCancel,ym(f)),onPointerUp:r?t.onPointerUp:nt(t.onPointerUp,ym(f))})]})});NM.displayName=AM;var $$="ContextMenuPortal",DM=t=>{const{__scopeContextMenu:e,...n}=t,r=Xr(e);return g.jsx(R$,{...r,...n})};DM.displayName=$$;var OM="ContextMenuContent",jM=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=TM(OM,n),s=Xr(n),a=_.useRef(!1);return g.jsx(T$,{...s,...r,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:c=>{var d;(d=t.onCloseAutoFocus)==null||d.call(t,c),!c.defaultPrevented&&a.current&&c.preventDefault(),a.current=!1},onInteractOutside:c=>{var d;(d=t.onInteractOutside)==null||d.call(t,c),!c.defaultPrevented&&!i.modal&&(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});jM.displayName=OM;var U$="ContextMenuGroup",W$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(M$,{...i,...r,ref:e})});W$.displayName=U$;var V$="ContextMenuLabel",q$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(A$,{...i,...r,ref:e})});q$.displayName=V$;var K$="ContextMenuItem",LM=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(N$,{...i,...r,ref:e})});LM.displayName=K$;var G$="ContextMenuCheckboxItem",Y$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(D$,{...i,...r,ref:e})});Y$.displayName=G$;var X$="ContextMenuRadioGroup",Q$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(O$,{...i,...r,ref:e})});Q$.displayName=X$;var Z$="ContextMenuRadioItem",J$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(j$,{...i,...r,ref:e})});J$.displayName=Z$;var eU="ContextMenuItemIndicator",tU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(L$,{...i,...r,ref:e})});tU.displayName=eU;var nU="ContextMenuSeparator",rU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(I$,{...i,...r,ref:e})});rU.displayName=nU;var iU="ContextMenuArrow",sU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(P$,{...i,...r,ref:e})});sU.displayName=iU;var oU="ContextMenuSubTrigger",aU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(z$,{...i,...r,ref:e})});aU.displayName=oU;var lU="ContextMenuSubContent",cU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(B$,{...i,...r,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cU.displayName=lU;function ym(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var uU=MM,dU=NM,hU=DM,IM=jM,PM=LM;const ux=uU,dx=dU,Mg=_.forwardRef((t,e)=>{const n=ke.c(9);let r,i;n[0]!==t?({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i):(r=n[1],i=n[2]);let s;n[3]!==r?(s=Ce("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg backdrop-blur-md 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",r),n[3]=r,n[4]=s):s=n[4];let a;return n[5]!==i||n[6]!==e||n[7]!==s?(a=g.jsx(hU,{children:g.jsx(IM,{ref:e,className:s,...i})}),n[5]=i,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});Mg.displayName=IM.displayName;const Su=_.forwardRef((t,e)=>{const n=ke.c(9);let r,i;n[0]!==t?({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i):(r=n[1],i=n[2]);let s;n[3]!==r?(s=Ce("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),n[3]=r,n[4]=s):s=n[4];let a;return n[5]!==i||n[6]!==e||n[7]!==s?(a=g.jsx(PM,{ref:e,className:s,...i}),n[5]=i,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});Su.displayName=PM.displayName;function Ag(t){const e=ke.c(12),{open:n,onOpenChange:r,position:i,children:s}=t;let a;e[0]!==i?(a=i?{position:"fixed",left:i.x,top:i.y,width:0,height:0}:void 0,e[0]=i,e[1]=a):a=e[1];let c;e[2]!==a?(c=g.jsx(bH,{style:a}),e[2]=a,e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=Ce("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg backdrop-blur-md","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"),e[4]=d):d=e[4];let u;e[5]!==s?(u=g.jsx(QT,{children:g.jsx(Xy,{side:"bottom",align:"start",sideOffset:4,onOpenAutoFocus:fU,className:d,children:s})}),e[5]=s,e[6]=u):u=e[6];let f;return e[7]!==r||e[8]!==n||e[9]!==c||e[10]!==u?(f=g.jsxs(XT,{open:n,onOpenChange:r,children:[c,u]}),e[7]=r,e[8]=n,e[9]=c,e[10]=u,e[11]=f):f=e[11],f}function fU(t){return t.preventDefault()}function Za(t){const e=ke.c(8),{onSelect:n,className:r,children:i}=t;let s;e[0]!==r?(s=Ce("relative flex w-full cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium outline-hidden transition-colors","hover:bg-accent focus:bg-accent",r),e[0]=r,e[1]=s):s=e[1];let a;e[2]!==n?(a=d=>{d.preventDefault(),n()},e[2]=n,e[3]=a):a=e[3];let c;return e[4]!==i||e[5]!==s||e[6]!==a?(c=g.jsx("button",{type:"button",className:s,onPointerDown:a,children:i}),e[4]=i,e[5]=s,e[6]=a,e[7]=c):c=e[7],c}function mU(t){const e=ke.c(21),{onRemove:n,children:r,mobileMenuPosition:i,onMobileMenuClose:s,skipContextMenu:a}=t;let c;e[0]!==r||e[1]!==n||e[2]!==a?(c=a?r:g.jsxs(ux,{children:[g.jsx(dx,{asChild:!0,children:r}),g.jsx(Mg,{children:g.jsxs(Su,{onSelect:k=>{k.stopPropagation(),n()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[g.jsx(vu,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})})]}),e[0]=r,e[1]=n,e[2]=a,e[3]=c):c=e[3];const d=!!i;let u;e[4]!==s?(u=k=>{k||s==null||s()},e[4]=s,e[5]=u):u=e[5];const f=i??null;let m;e[6]!==s||e[7]!==n?(m=()=>{s==null||s(),n()},e[6]=s,e[7]=n,e[8]=m):m=e[8];let v,b;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=g.jsx(vu,{className:"h-4 w-4"}),b=g.jsx("span",{children:"Hide"}),e[9]=v,e[10]=b):(v=e[9],b=e[10]);let S;e[11]!==m?(S=g.jsxs(Za,{onSelect:m,className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[v,b]}),e[11]=m,e[12]=S):S=e[12];let x;e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==S?(x=g.jsx(Ag,{open:d,onOpenChange:u,position:f,children:S}),e[13]=d,e[14]=u,e[15]=f,e[16]=S,e[17]=x):x=e[17];let C;return e[18]!==c||e[19]!==x?(C=g.jsxs(g.Fragment,{children:[c,x]}),e[18]=c,e[19]=x,e[20]=C):C=e[20],C}function pU(t){const e=ke.c(30),{onRename:n,onDelete:r,children:i,mobileMenuPosition:s,onMobileMenuClose:a,skipContextMenu:c}=t;let d;e[0]!==i||e[1]!==r||e[2]!==n||e[3]!==c?(d=c?i:g.jsxs(ux,{children:[g.jsx(dx,{asChild:!0,children:i}),g.jsxs(Mg,{children:[g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),n()},children:[g.jsx(Ul,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Rename Feature"})]}),g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),r()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[g.jsx(vu,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Delete Feature"})]})]})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=c,e[4]=d):d=e[4];const u=!!s;let f;e[5]!==a?(f=D=>{D||a==null||a()},e[5]=a,e[6]=f):f=e[6];const m=s??null;let v;e[7]!==a||e[8]!==n?(v=()=>{a==null||a(),n()},e[7]=a,e[8]=n,e[9]=v):v=e[9];let b,S;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=g.jsx(Ul,{className:"h-4 w-4"}),S=g.jsx("span",{children:"Rename Feature"}),e[10]=b,e[11]=S):(b=e[10],S=e[11]);let x;e[12]!==v?(x=g.jsxs(Za,{onSelect:v,children:[b,S]}),e[12]=v,e[13]=x):x=e[13];let C;e[14]!==r||e[15]!==a?(C=()=>{a==null||a(),r()},e[14]=r,e[15]=a,e[16]=C):C=e[16];let k,E;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx(vu,{className:"h-4 w-4"}),E=g.jsx("span",{children:"Delete Feature"}),e[17]=k,e[18]=E):(k=e[17],E=e[18]);let R;e[19]!==C?(R=g.jsxs(Za,{onSelect:C,className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[k,E]}),e[19]=C,e[20]=R):R=e[20];let M;e[21]!==R||e[22]!==u||e[23]!==f||e[24]!==m||e[25]!==x?(M=g.jsxs(Ag,{open:u,onOpenChange:f,position:m,children:[x,R]}),e[21]=R,e[22]=u,e[23]=f,e[24]=m,e[25]=x,e[26]=M):M=e[26];let O;return e[27]!==d||e[28]!==M?(O=g.jsxs(g.Fragment,{children:[d,M]}),e[27]=d,e[28]=M,e[29]=O):O=e[29],O}function gU(t){const e=ke.c(30),{onRename:n,onDelete:r,children:i,mobileMenuPosition:s,onMobileMenuClose:a,skipContextMenu:c}=t;let d;e[0]!==i||e[1]!==r||e[2]!==n||e[3]!==c?(d=c?i:g.jsxs(ux,{children:[g.jsx(dx,{asChild:!0,children:i}),g.jsxs(Mg,{children:[g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),n()},children:[g.jsx(Ul,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Rename Chat"})]}),g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),r()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[g.jsx(vu,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Delete Chat"})]})]})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=c,e[4]=d):d=e[4];const u=!!s;let f;e[5]!==a?(f=D=>{D||a==null||a()},e[5]=a,e[6]=f):f=e[6];const m=s??null;let v;e[7]!==a||e[8]!==n?(v=()=>{a==null||a(),n()},e[7]=a,e[8]=n,e[9]=v):v=e[9];let b,S;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=g.jsx(Ul,{className:"h-4 w-4"}),S=g.jsx("span",{children:"Rename Chat"}),e[10]=b,e[11]=S):(b=e[10],S=e[11]);let x;e[12]!==v?(x=g.jsxs(Za,{onSelect:v,children:[b,S]}),e[12]=v,e[13]=x):x=e[13];let C;e[14]!==r||e[15]!==a?(C=()=>{a==null||a(),r()},e[14]=r,e[15]=a,e[16]=C):C=e[16];let k,E;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx(vu,{className:"h-4 w-4"}),E=g.jsx("span",{children:"Delete Chat"}),e[17]=k,e[18]=E):(k=e[17],E=e[18]);let R;e[19]!==C?(R=g.jsxs(Za,{onSelect:C,className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[k,E]}),e[19]=C,e[20]=R):R=e[20];let M;e[21]!==R||e[22]!==u||e[23]!==f||e[24]!==m||e[25]!==x?(M=g.jsxs(Ag,{open:u,onOpenChange:f,position:m,children:[x,R]}),e[21]=R,e[22]=u,e[23]=f,e[24]=m,e[25]=x,e[26]=M):M=e[26];let O;return e[27]!==d||e[28]!==M?(O=g.jsxs(g.Fragment,{children:[d,M]}),e[27]=d,e[28]=M,e[29]=O):O=e[29],O}const vU=new Set(["starting","running"]);function bU(t){const e=ke.c(90),{chat:n,activeChatId:r,nowMs:i,showProviderIcon:s,isCompleted:a,onSelectChat:c,onRenameChat:d,onDeleteChat:u,draggable:f,onDragStart:m,onDragEnd:v,isTouchDevice:b,onTouchDragMove:S,onTouchDragEnd:x}=t,C=s===void 0?!1:s,k=a===void 0?!1:a,E=f===void 0?!1:f,R=b===void 0?!1:b;let M;e[0]!==n.lastMessageAt||e[1]!==i?(M=IH(n.lastMessageAt,i),e[0]=n.lastMessageAt,e[1]=i,e[2]=M):M=e[2];const O=M,D=R,P=n.provider?Np[n.provider]:null,[z,Y]=_.useState(null);let L;e[3]!==n.chatId||e[4]!==c?(L=()=>c(n.chatId),e[3]=n.chatId,e[4]=c,e[5]=L):L=e[5];let W;e[6]===Symbol.for("react.memo_cache_sentinel")?(W=it=>Y(it),e[6]=W):W=e[6];let V;e[7]!==n||e[8]!==E||e[9]!==m?(V=E?()=>m==null?void 0:m(n):void 0,e[7]=n,e[8]=E,e[9]=m,e[10]=V):V=e[10];let F;e[11]!==E||e[12]!==S?(F=E?it=>{const{x:ce,y:Re,elementBelow:Ue}=it;return S==null?void 0:S(ce,Re,Ue)}:void 0,e[11]=E,e[12]=S,e[13]=F):F=e[13];let U;e[14]!==E||e[15]!==v||e[16]!==x?(U=it=>{const{x:ce,y:Re,elementBelow:Ue}=it;E&&(x==null||x(ce,Re,Ue),v==null||v())},e[14]=E,e[15]=v,e[16]=x,e[17]=U):U=e[17];let H;e[18]!==U||e[19]!==L||e[20]!==V||e[21]!==F||e[22]!==D?(H={enabled:D,onTap:L,onContextMenu:W,onDragStart:V,onDragMove:F,onDragEnd:U},e[18]=U,e[19]=L,e[20]=V,e[21]=F,e[22]=D,e[23]=H):H=e[23];const{touchRef:j,isArmed:G,isDragging:B,dragPosition:K}=Jy(H),A=D?j:void 0,I=n._id;let $;e[24]!==n.chatId?($=T1(n.chatId),e[24]=n.chatId,e[25]=$):$=e[25];let T;e[26]!==r||e[27]!==n.chatId?(T=r===T1(n.chatId)?"bg-muted hover:bg-muted border-border":"cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 dark:hover:border-slate-400/10",e[26]=r,e[27]=n.chatId,e[28]=T):T=e[28];const X=G&&"scale-[1.03] shadow-md ring-2 ring-primary/50 bg-card border-primary/40",Z=B&&!G&&"opacity-20 scale-[0.98]";let J;e[29]!==T||e[30]!==X||e[31]!==Z?(J=Ce("group flex items-center gap-2 rounded-lg border px-2.5 py-1.5 transition-all duration-150 select-none",T,X,Z),e[29]=T,e[30]=X,e[31]=Z,e[32]=J):J=e[32];const re=E&&!R;let ae;e[33]!==n||e[34]!==E||e[35]!==R||e[36]!==m?(ae=E&&!R?()=>m==null?void 0:m(n):void 0,e[33]=n,e[34]=E,e[35]=R,e[36]=m,e[37]=ae):ae=e[37];const ue=E&&!R?v:void 0;let me;e[38]!==n.chatId||e[39]!==R||e[40]!==c?(me=R?void 0:()=>c(n.chatId),e[38]=n.chatId,e[39]=R,e[40]=c,e[41]=me):me=e[41];let se;e[42]!==n.status||e[43]!==k?(se=vU.has(n.status)?g.jsx(Fn,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):n.status==="waiting_for_user"?g.jsx("div",{className:"relative",children:g.jsxs("div",{className:"rounded-full z-0 size-3.5 flex items-center justify-center",children:[g.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),g.jsx("div",{className:"rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):k?g.jsx("div",{className:"relative",children:g.jsxs("div",{className:"rounded-full z-0 size-3.5 flex items-center justify-center",children:[g.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping"}),g.jsx("div",{className:"rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,e[42]=n.status,e[43]=k,e[44]=se):se=e[44];let oe;e[45]!==P||e[46]!==n.provider||e[47]!==C?(oe=C&&P?g.jsx(P,{className:"size-3.5 flex-shrink-0 text-muted-foreground/80","aria-label":`${n.provider} provider`}):null,e[45]=P,e[46]=n.provider,e[47]=C,e[48]=oe):oe=e[48];let ee;e[49]!==n.status||e[50]!==n.title?(ee=n.status!=="idle"&&n.status!=="waiting_for_user"?g.jsx(Eg,{animate:n.status==="running",shimmerWidth:Math.max(20,n.title.length*3),children:n.title}):n.title,e[49]=n.status,e[50]=n.title,e[51]=ee):ee=e[51];let Q;e[52]!==ee?(Q=g.jsx("span",{className:"min-w-0 flex-1 translate-y-[-0.5px] truncate text-sm",children:ee}),e[52]=ee,e[53]=Q):Q=e[53];let te;e[54]!==O?(te=O?g.jsx("span",{className:"hidden shrink-0 text-[11px] text-muted-foreground opacity-60 md:inline",children:O}):null,e[54]=O,e[55]=te):te=e[55];let he;e[56]!==n._id||e[57]!==A||e[58]!==$||e[59]!==J||e[60]!==re||e[61]!==ae||e[62]!==ue||e[63]!==me||e[64]!==se||e[65]!==oe||e[66]!==Q||e[67]!==te?(he=g.jsxs("div",{ref:A,"data-chat-id":$,className:J,draggable:re,onDragStart:ae,onDragEnd:ue,onContextMenu:_U,onClick:me,children:[se,oe,Q,te]},I),e[56]=n._id,e[57]=A,e[58]=$,e[59]=J,e[60]=re,e[61]=ae,e[62]=ue,e[63]=me,e[64]=se,e[65]=oe,e[66]=Q,e[67]=te,e[68]=he):he=e[68];const ie=he;let xe;e[69]!==n.chatId||e[70]!==d?(xe=()=>d(n.chatId),e[69]=n.chatId,e[70]=d,e[71]=xe):xe=e[71];let Ae;e[72]!==n.chatId||e[73]!==u?(Ae=()=>u(n.chatId),e[72]=n.chatId,e[73]=u,e[74]=Ae):Ae=e[74];let Ke;e[75]===Symbol.for("react.memo_cache_sentinel")?(Ke=()=>Y(null),e[75]=Ke):Ke=e[75];let mt;e[76]!==R||e[77]!==z||e[78]!==ie||e[79]!==xe||e[80]!==Ae?(mt=g.jsx(gU,{onRename:xe,onDelete:Ae,mobileMenuPosition:z,onMobileMenuClose:Ke,skipContextMenu:R,children:ie}),e[76]=R,e[77]=z,e[78]=ie,e[79]=xe,e[80]=Ae,e[81]=mt):mt=e[81];let Ye;e[82]!==n.title?(Ye=g.jsx("span",{className:"text-sm font-medium truncate",children:n.title}),e[82]=n.title,e[83]=Ye):Ye=e[83];let Ze;e[84]!==K||e[85]!==Ye?(Ze=g.jsx(ZT,{position:K,children:Ye}),e[84]=K,e[85]=Ye,e[86]=Ze):Ze=e[86];let tt;return e[87]!==mt||e[88]!==Ze?(tt=g.jsxs(g.Fragment,{children:[mt,Ze]}),e[87]=mt,e[88]=Ze,e[89]=tt):tt=e[89],tt}function _U(t){t.stopPropagation()}function yU(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const Ng=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Iu(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function hx(t){return"nodeType"in t}function hi(t){var e,n;return t?Iu(t)?t:hx(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function fx(t){const{Document:e}=hi(t);return t instanceof e}function $h(t){return Iu(t)?!1:t instanceof hi(t).HTMLElement}function zM(t){return t instanceof hi(t).SVGElement}function Pu(t){return t?Iu(t)?t.document:hx(t)?fx(t)?t:$h(t)||zM(t)?t.ownerDocument:document:document:document}const to=Ng?_.useLayoutEffect:_.useEffect;function mx(t){const e=_.useRef(t);return to(()=>{e.current=t}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function xU(){const t=_.useRef(null),e=_.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=_.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Sh(t,e){e===void 0&&(e=[t]);const n=_.useRef(t);return to(()=>{n.current!==t&&(n.current=t)},e),n}function Uh(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function jp(t){const e=mx(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,r]}function $1(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let _b={};function Wh(t,e){return _.useMemo(()=>{if(e)return e;const n=_b[t]==null?0:_b[t]+1;return _b[t]=n,t+"-"+n},[t,e])}function BM(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const c=Object.entries(a);for(const[d,u]of c){const f=s[d];f!=null&&(s[d]=f+t*u)}return s},{...e})}}const du=BM(1),Lp=BM(-1);function SU(t){return"clientX"in t&&"clientY"in t}function px(t){if(!t)return!1;const{KeyboardEvent:e}=hi(t.target);return e&&t instanceof e}function wU(t){if(!t)return!1;const{TouchEvent:e}=hi(t.target);return e&&t instanceof e}function U1(t){if(wU(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return SU(t)?{x:t.clientX,y:t.clientY}:null}const wu=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[wu.Translate.toString(t),wu.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),lE="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function CU(t){return t.matches(lE)?t:t.querySelector(lE)}const kU={display:"none"};function EU(t){let{id:e,value:n}=t;return je.createElement("div",{id:e,style:kU},n)}function RU(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return je.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function TU(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const FM=_.createContext(null);function MU(t){const e=_.useContext(FM);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function AU(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.useCallback(r=>{let{type:i,event:s}=r;t.forEach(a=>{var c;return(c=a[i])==null?void 0:c.call(a,s)})},[t]),e]}const NU={draggable:`
468
+ 6. Paste it here.`;function q7(t){const e=ke.c(44),{open:n,onOpenChange:r,onSubmit:i}=t,s=_.useRef(null),[a,c]=_.useState(""),[d,u]=_.useState(!1);let f,m;e[0]!==n?(f=()=>{n&&(c(""),setTimeout(()=>{var I;return(I=s.current)==null?void 0:I.focus()},0))},m=[n],e[0]=n,e[1]=f,e[2]=m):(f=e[1],m=e[2]),_.useEffect(f,m);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=async function(){const $=await navigator.clipboard.readText();c($)},e[3]=v):v=e[3];const b=v;let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=async function(){await navigator.clipboard.writeText(Hk),u(!0),setTimeout(()=>u(!1),2e3)},e[4]=S):S=e[4];const x=S;let C;e[5]!==a?(C=a.trim(),e[5]=a,e[6]=C):C=e[6];const k=C.length>0;let E;e[7]!==k||e[8]!==a||e[9]!==i?(E=I=>{I.preventDefault(),k&&i(a.trim())},e[7]=k,e[8]=a,e[9]=i,e[10]=E):E=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=g.jsx(Ay,{children:"Import Cursor Session"}),e[11]=R):R=e[11];let M,O;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=g.jsxs(Ny,{children:["Paste the copied ",g.jsx("code",{children:"get-current-period-usage"})," curl command and Kaizen will import the session for you."]}),O=g.jsx("div",{className:"rounded-xl border border-border bg-card px-3 py-3 text-sm text-muted-foreground whitespace-pre-line",children:Hk}),e[12]=M,e[13]=O):(M=e[12],O=e[13]);let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=g.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>void b(),children:"Paste Clipboard"}),e[14]=D):D=e[14];let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=()=>void x(),e[15]=P):P=e[15];let z;e[16]!==d?(z=d?g.jsx(di,{className:"h-4 w-4"}):g.jsx(lu,{className:"h-4 w-4"}),e[16]=d,e[17]=z):z=e[17];const Y=d?"Copied":"Copy Steps";let L;e[18]!==Y?(L=g.jsx("span",{className:"ml-1",children:Y}),e[18]=Y,e[19]=L):L=e[19];let W;e[20]!==z||e[21]!==L?(W=g.jsxs("div",{className:"flex gap-2",children:[D,g.jsxs(vt,{type:"button",variant:"ghost",size:"sm",onClick:P,children:[z,L]})]}),e[20]=z,e[21]=L,e[22]=W):W=e[22];let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=I=>c(I.target.value),e[23]=V):V=e[23];let F;e[24]!==a?(F=g.jsx(fg,{ref:s,value:a,onChange:V,rows:10,placeholder:"Paste the copied curl command here",className:"font-mono text-xs"}),e[24]=a,e[25]=F):F=e[25];let U;e[26]!==W||e[27]!==F?(U=g.jsxs(Dy,{className:"space-y-4",children:[R,M,O,W,F]}),e[26]=W,e[27]=F,e[28]=U):U=e[28];let H;e[29]!==r?(H=g.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"}),e[29]=r,e[30]=H):H=e[30];const j=!k;let G;e[31]!==j?(G=g.jsx(vt,{type:"submit",variant:"secondary",size:"sm",disabled:j,children:"Import Session"}),e[31]=j,e[32]=G):G=e[32];let B;e[33]!==H||e[34]!==G?(B=g.jsxs(Oy,{children:[H,G]}),e[33]=H,e[34]=G,e[35]=B):B=e[35];let K;e[36]!==U||e[37]!==B||e[38]!==E?(K=g.jsx(hg,{size:"lg",children:g.jsxs("form",{onSubmit:E,children:[U,B]})}),e[36]=U,e[37]=B,e[38]=E,e[39]=K):K=e[39];let A;return e[40]!==r||e[41]!==n||e[42]!==K?(A=g.jsx(My,{open:n,onOpenChange:r,children:K}),e[40]=r,e[41]=n,e[42]=K,e[43]=A):A=e[43],A}const K7=["top","right","bottom","left"],nl=Math.min,Mi=Math.max,wp=Math.round,bm=Math.floor,Js=t=>({x:t,y:t}),G7={left:"right",right:"left",bottom:"top",top:"bottom"};function A1(t,e,n){return Mi(t,nl(e,n))}function qo(t,e){return typeof t=="function"?t(e):t}function Ko(t){return t.split("-")[0]}function Du(t){return t.split("-")[1]}function Iy(t){return t==="x"?"y":"x"}function Py(t){return t==="y"?"height":"width"}function Ys(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function zy(t){return Iy(Ys(t))}function Y7(t,e,n){n===void 0&&(n=!1);const r=Du(t),i=zy(t),s=Py(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(a=Cp(a)),[a,Cp(a)]}function X7(t){const e=Cp(t);return[N1(t),e,N1(e)]}function N1(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const $k=["left","right"],Uk=["right","left"],Q7=["top","bottom"],Z7=["bottom","top"];function J7(t,e,n){switch(t){case"top":case"bottom":return n?e?Uk:$k:e?$k:Uk;case"left":case"right":return e?Q7:Z7;default:return[]}}function e9(t,e,n,r){const i=Du(t);let s=J7(Ko(t),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),e&&(s=s.concat(s.map(N1)))),s}function Cp(t){const e=Ko(t);return G7[e]+t.slice(e.length)}function t9(t){return{top:0,right:0,bottom:0,left:0,...t}}function Q4(t){return typeof t!="number"?t9(t):{top:t,right:t,bottom:t,left:t}}function kp(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Wk(t,e,n){let{reference:r,floating:i}=t;const s=Ys(e),a=zy(e),c=Py(a),d=Ko(e),u=s==="y",f=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,v=r[c]/2-i[c]/2;let b;switch(d){case"top":b={x:f,y:r.y-i.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-i.width,y:m};break;default:b={x:r.x,y:r.y}}switch(Du(e)){case"start":b[a]-=v*(n&&u?-1:1);break;case"end":b[a]+=v*(n&&u?-1:1);break}return b}async function n9(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:a,elements:c,strategy:d}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:v=!1,padding:b=0}=qo(e,t),S=Q4(b),C=c[v?m==="floating"?"reference":"floating":m],k=kp(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(C)))==null||n?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:u,rootBoundary:f,strategy:d})),E=m==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),M=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},O=kp(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:R,strategy:d}):E);return{top:(k.top-O.top+S.top)/M.y,bottom:(O.bottom-k.bottom+S.bottom)/M.y,left:(k.left-O.left+S.left)/M.x,right:(O.right-k.right+S.right)/M.x}}const r9=50,i9=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,c=a.detectOverflow?a:{...a,detectOverflow:n9},d=await(a.isRTL==null?void 0:a.isRTL(e));let u=await a.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:m}=Wk(u,r,d),v=r,b=0;const S={};for(let x=0;x<s.length;x++){const C=s[x];if(!C)continue;const{name:k,fn:E}=C,{x:R,y:M,data:O,reset:D}=await E({x:f,y:m,initialPlacement:r,placement:v,strategy:i,middlewareData:S,rects:u,platform:c,elements:{reference:t,floating:e}});f=R??f,m=M??m,S[k]={...S[k],...O},D&&b<r9&&(b++,typeof D=="object"&&(D.placement&&(v=D.placement),D.rects&&(u=D.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:i}):D.rects),{x:f,y:m}=Wk(u,v,d)),x=-1)}return{x:f,y:m,placement:v,strategy:i,middlewareData:S}},s9=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:a,elements:c,middlewareData:d}=e,{element:u,padding:f=0}=qo(t,e)||{};if(u==null)return{};const m=Q4(f),v={x:n,y:r},b=zy(i),S=Py(b),x=await a.getDimensions(u),C=b==="y",k=C?"top":"left",E=C?"bottom":"right",R=C?"clientHeight":"clientWidth",M=s.reference[S]+s.reference[b]-v[b]-s.floating[S],O=v[b]-s.reference[b],D=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let P=D?D[R]:0;(!P||!await(a.isElement==null?void 0:a.isElement(D)))&&(P=c.floating[R]||s.floating[S]);const z=M/2-O/2,Y=P/2-x[S]/2-1,L=nl(m[k],Y),W=nl(m[E],Y),V=L,F=P-x[S]-W,U=P/2-x[S]/2+z,H=A1(V,U,F),j=!d.arrow&&Du(i)!=null&&U!==H&&s.reference[S]/2-(U<V?L:W)-x[S]/2<0,G=j?U<V?U-V:U-F:0;return{[b]:v[b]+G,data:{[b]:H,centerOffset:U-H-G,...j&&{alignmentOffset:G}},reset:j}}}),o9=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:c,platform:d,elements:u}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:x=!0,...C}=qo(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const k=Ko(i),E=Ys(c),R=Ko(c)===c,M=await(d.isRTL==null?void 0:d.isRTL(u.floating)),O=v||(R||!x?[Cp(c)]:X7(c)),D=S!=="none";!v&&D&&O.push(...e9(c,x,S,M));const P=[c,...O],z=await d.detectOverflow(e,C),Y=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&Y.push(z[k]),m){const U=Y7(i,a,M);Y.push(z[U[0]],z[U[1]])}if(L=[...L,{placement:i,overflows:Y}],!Y.every(U=>U<=0)){var W,V;const U=(((W=s.flip)==null?void 0:W.index)||0)+1,H=P[U];if(H&&(!(m==="alignment"?E!==Ys(H):!1)||L.every(B=>Ys(B.placement)===E?B.overflows[0]>0:!0)))return{data:{index:U,overflows:L},reset:{placement:H}};let j=(V=L.filter(G=>G.overflows[0]<=0).sort((G,B)=>G.overflows[1]-B.overflows[1])[0])==null?void 0:V.placement;if(!j)switch(b){case"bestFit":{var F;const G=(F=L.filter(B=>{if(D){const K=Ys(B.placement);return K===E||K==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(K=>K>0).reduce((K,A)=>K+A,0)]).sort((B,K)=>B[1]-K[1])[0])==null?void 0:F[0];G&&(j=G);break}case"initialPlacement":j=c;break}if(i!==j)return{reset:{placement:j}}}return{}}}};function Vk(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function qk(t){return K7.some(e=>t[e]>=0)}const a9=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...s}=qo(t,e);switch(i){case"referenceHidden":{const a=await r.detectOverflow(e,{...s,elementContext:"reference"}),c=Vk(a,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:qk(c)}}}case"escaped":{const a=await r.detectOverflow(e,{...s,altBoundary:!0}),c=Vk(a,n.floating);return{data:{escapedOffsets:c,escaped:qk(c)}}}default:return{}}}}},Z4=new Set(["left","top"]);async function l9(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=Ko(n),c=Du(n),d=Ys(n)==="y",u=Z4.has(a)?-1:1,f=s&&d?-1:1,m=qo(e,t);let{mainAxis:v,crossAxis:b,alignmentAxis:S}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof S=="number"&&(b=c==="end"?S*-1:S),d?{x:b*f,y:v*u}:{x:v*u,y:b*f}}const c9=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:a,middlewareData:c}=e,d=await l9(e,t);return a===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+d.x,y:s+d.y,data:{...d,placement:a}}}}},u9=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:s}=e,{mainAxis:a=!0,crossAxis:c=!1,limiter:d={fn:k=>{let{x:E,y:R}=k;return{x:E,y:R}}},...u}=qo(t,e),f={x:n,y:r},m=await s.detectOverflow(e,u),v=Ys(Ko(i)),b=Iy(v);let S=f[b],x=f[v];if(a){const k=b==="y"?"top":"left",E=b==="y"?"bottom":"right",R=S+m[k],M=S-m[E];S=A1(R,S,M)}if(c){const k=v==="y"?"top":"left",E=v==="y"?"bottom":"right",R=x+m[k],M=x-m[E];x=A1(R,x,M)}const C=d.fn({...e,[b]:S,[v]:x});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[b]:a,[v]:c}}}}}},d9=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=e,{offset:c=0,mainAxis:d=!0,crossAxis:u=!0}=qo(t,e),f={x:n,y:r},m=Ys(i),v=Iy(m);let b=f[v],S=f[m];const x=qo(c,e),C=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(d){const R=v==="y"?"height":"width",M=s.reference[v]-s.floating[R]+C.mainAxis,O=s.reference[v]+s.reference[R]-C.mainAxis;b<M?b=M:b>O&&(b=O)}if(u){var k,E;const R=v==="y"?"width":"height",M=Z4.has(Ko(i)),O=s.reference[m]-s.floating[R]+(M&&((k=a.offset)==null?void 0:k[m])||0)+(M?0:C.crossAxis),D=s.reference[m]+s.reference[R]+(M?0:((E=a.offset)==null?void 0:E[m])||0)-(M?C.crossAxis:0);S<O?S=O:S>D&&(S=D)}return{[v]:b,[m]:S}}}},h9=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:a,elements:c}=e,{apply:d=()=>{},...u}=qo(t,e),f=await a.detectOverflow(e,u),m=Ko(i),v=Du(i),b=Ys(i)==="y",{width:S,height:x}=s.floating;let C,k;m==="top"||m==="bottom"?(C=m,k=v===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,C=v==="end"?"top":"bottom");const E=x-f.top-f.bottom,R=S-f.left-f.right,M=nl(x-f[C],E),O=nl(S-f[k],R),D=!e.middlewareData.shift;let P=M,z=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(z=R),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(P=E),D&&!v){const L=Mi(f.left,0),W=Mi(f.right,0),V=Mi(f.top,0),F=Mi(f.bottom,0);b?z=S-2*(L!==0||W!==0?L+W:Mi(f.left,f.right)):P=x-2*(V!==0||F!==0?V+F:Mi(f.top,f.bottom))}await d({...e,availableWidth:z,availableHeight:P});const Y=await a.getDimensions(c.floating);return S!==Y.width||x!==Y.height?{reset:{rects:!0}}:{}}}};function mg(){return typeof window<"u"}function Ou(t){return J4(t)?(t.nodeName||"").toLowerCase():"#document"}function Di(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ro(t){var e;return(e=(J4(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function J4(t){return mg()?t instanceof Node||t instanceof Di(t).Node:!1}function ws(t){return mg()?t instanceof Element||t instanceof Di(t).Element:!1}function Qo(t){return mg()?t instanceof HTMLElement||t instanceof Di(t).HTMLElement:!1}function Kk(t){return!mg()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Di(t).ShadowRoot}function Lh(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Cs(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&i!=="inline"&&i!=="contents"}function f9(t){return/^(table|td|th)$/.test(Ou(t))}function pg(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const m9=/transform|translate|scale|rotate|perspective|filter/,p9=/paint|layout|strict|content/,Al=t=>!!t&&t!=="none";let mb;function By(t){const e=ws(t)?Cs(t):t;return Al(e.transform)||Al(e.translate)||Al(e.scale)||Al(e.rotate)||Al(e.perspective)||!Fy()&&(Al(e.backdropFilter)||Al(e.filter))||m9.test(e.willChange||"")||p9.test(e.contain||"")}function g9(t){let e=rl(t);for(;Qo(e)&&!_u(e);){if(By(e))return e;if(pg(e))return null;e=rl(e)}return null}function Fy(){return mb==null&&(mb=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),mb}function _u(t){return/^(html|body|#document)$/.test(Ou(t))}function Cs(t){return Di(t).getComputedStyle(t)}function gg(t){return ws(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function rl(t){if(Ou(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Kk(t)&&t.host||ro(t);return Kk(e)?e.host:e}function eT(t){const e=rl(t);return _u(e)?t.ownerDocument?t.ownerDocument.body:t.body:Qo(e)&&Lh(e)?e:eT(e)}function bh(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=eT(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),a=Di(i);if(s){const c=D1(a);return e.concat(a,a.visualViewport||[],Lh(i)?i:[],c&&n?bh(c):[])}else return e.concat(i,bh(i,[],n))}function D1(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function tT(t){const e=Cs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Qo(t),s=i?t.offsetWidth:n,a=i?t.offsetHeight:r,c=wp(n)!==s||wp(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function Hy(t){return ws(t)?t:t.contextElement}function uu(t){const e=Hy(t);if(!Qo(e))return Js(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=tT(e);let a=(s?wp(n.width):n.width)/r,c=(s?wp(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const v9=Js(0);function nT(t){const e=Di(t);return!Fy()||!e.visualViewport?v9:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function b9(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Di(t)?!1:e}function ql(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=Hy(t);let a=Js(1);e&&(r?ws(r)&&(a=uu(r)):a=uu(t));const c=b9(s,n,r)?nT(s):Js(0);let d=(i.left+c.x)/a.x,u=(i.top+c.y)/a.y,f=i.width/a.x,m=i.height/a.y;if(s){const v=Di(s),b=r&&ws(r)?Di(r):r;let S=v,x=D1(S);for(;x&&r&&b!==S;){const C=uu(x),k=x.getBoundingClientRect(),E=Cs(x),R=k.left+(x.clientLeft+parseFloat(E.paddingLeft))*C.x,M=k.top+(x.clientTop+parseFloat(E.paddingTop))*C.y;d*=C.x,u*=C.y,f*=C.x,m*=C.y,d+=R,u+=M,S=Di(x),x=D1(S)}}return kp({width:f,height:m,x:d,y:u})}function vg(t,e){const n=gg(t).scrollLeft;return e?e.left+n:ql(ro(t)).left+n}function rT(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-vg(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function _9(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",a=ro(r),c=e?pg(e.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},u=Js(1);const f=Js(0),m=Qo(r);if((m||!m&&!s)&&((Ou(r)!=="body"||Lh(a))&&(d=gg(r)),m)){const b=ql(r);u=uu(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const v=a&&!m&&!s?rT(a,d):Js(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-d.scrollLeft*u.x+f.x+v.x,y:n.y*u.y-d.scrollTop*u.y+f.y+v.y}}function y9(t){return Array.from(t.getClientRects())}function x9(t){const e=ro(t),n=gg(t),r=t.ownerDocument.body,i=Mi(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Mi(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+vg(t);const c=-n.scrollTop;return Cs(r).direction==="rtl"&&(a+=Mi(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:c}}const Gk=25;function S9(t,e){const n=Di(t),r=ro(t),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,c=0,d=0;if(i){s=i.width,a=i.height;const f=Fy();(!f||f&&e==="fixed")&&(c=i.offsetLeft,d=i.offsetTop)}const u=vg(r);if(u<=0){const f=r.ownerDocument,m=f.body,v=getComputedStyle(m),b=f.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,S=Math.abs(r.clientWidth-m.clientWidth-b);S<=Gk&&(s-=S)}else u<=Gk&&(s+=u);return{width:s,height:a,x:c,y:d}}function w9(t,e){const n=ql(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Qo(t)?uu(t):Js(1),a=t.clientWidth*s.x,c=t.clientHeight*s.y,d=i*s.x,u=r*s.y;return{width:a,height:c,x:d,y:u}}function Yk(t,e,n){let r;if(e==="viewport")r=S9(t,n);else if(e==="document")r=x9(ro(t));else if(ws(e))r=w9(e,n);else{const i=nT(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return kp(r)}function iT(t,e){const n=rl(t);return n===e||!ws(n)||_u(n)?!1:Cs(n).position==="fixed"||iT(n,e)}function C9(t,e){const n=e.get(t);if(n)return n;let r=bh(t,[],!1).filter(c=>ws(c)&&Ou(c)!=="body"),i=null;const s=Cs(t).position==="fixed";let a=s?rl(t):t;for(;ws(a)&&!_u(a);){const c=Cs(a),d=By(a);!d&&c.position==="fixed"&&(i=null),(s?!d&&!i:!d&&c.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Lh(a)&&!d&&iT(t,a))?r=r.filter(f=>f!==a):i=c,a=rl(a)}return e.set(t,r),r}function k9(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const a=[...n==="clippingAncestors"?pg(e)?[]:C9(e,this._c):[].concat(n),r],c=Yk(e,a[0],i);let d=c.top,u=c.right,f=c.bottom,m=c.left;for(let v=1;v<a.length;v++){const b=Yk(e,a[v],i);d=Mi(b.top,d),u=nl(b.right,u),f=nl(b.bottom,f),m=Mi(b.left,m)}return{width:u-m,height:f-d,x:m,y:d}}function E9(t){const{width:e,height:n}=tT(t);return{width:e,height:n}}function R9(t,e,n){const r=Qo(e),i=ro(e),s=n==="fixed",a=ql(t,!0,s,e);let c={scrollLeft:0,scrollTop:0};const d=Js(0);function u(){d.x=vg(i)}if(r||!r&&!s)if((Ou(e)!=="body"||Lh(i))&&(c=gg(e)),r){const b=ql(e,!0,s,e);d.x=b.x+e.clientLeft,d.y=b.y+e.clientTop}else i&&u();s&&!r&&i&&u();const f=i&&!r&&!s?rT(i,c):Js(0),m=a.left+c.scrollLeft-d.x-f.x,v=a.top+c.scrollTop-d.y-f.y;return{x:m,y:v,width:a.width,height:a.height}}function pb(t){return Cs(t).position==="static"}function Xk(t,e){if(!Qo(t)||Cs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ro(t)===n&&(n=n.ownerDocument.body),n}function sT(t,e){const n=Di(t);if(pg(t))return n;if(!Qo(t)){let i=rl(t);for(;i&&!_u(i);){if(ws(i)&&!pb(i))return i;i=rl(i)}return n}let r=Xk(t,e);for(;r&&f9(r)&&pb(r);)r=Xk(r,e);return r&&_u(r)&&pb(r)&&!By(r)?n:r||g9(t)||n}const T9=async function(t){const e=this.getOffsetParent||sT,n=this.getDimensions,r=await n(t.floating);return{reference:R9(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function M9(t){return Cs(t).direction==="rtl"}const A9={convertOffsetParentRelativeRectToViewportRelativeRect:_9,getDocumentElement:ro,getClippingRect:k9,getOffsetParent:sT,getElementRects:T9,getClientRects:y9,getDimensions:E9,getScale:uu,isElement:ws,isRTL:M9};function oT(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function N9(t,e){let n=null,r;const i=ro(t);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const u=t.getBoundingClientRect(),{left:f,top:m,width:v,height:b}=u;if(c||e(),!v||!b)return;const S=bm(m),x=bm(i.clientWidth-(f+v)),C=bm(i.clientHeight-(m+b)),k=bm(f),R={rootMargin:-S+"px "+-x+"px "+-C+"px "+-k+"px",threshold:Mi(0,nl(1,d))||1};let M=!0;function O(D){const P=D[0].intersectionRatio;if(P!==d){if(!M)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!oT(u,t.getBoundingClientRect())&&a(),M=!1}try{n=new IntersectionObserver(O,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(O,R)}n.observe(t)}return a(!0),s}function D9(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,u=Hy(t),f=i||s?[...u?bh(u):[],...e?bh(e):[]]:[];f.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),s&&k.addEventListener("resize",n)});const m=u&&c?N9(u,n):null;let v=-1,b=null;a&&(b=new ResizeObserver(k=>{let[E]=k;E&&E.target===u&&b&&e&&(b.unobserve(e),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(e)})),n()}),u&&!d&&b.observe(u),e&&b.observe(e));let S,x=d?ql(t):null;d&&C();function C(){const k=ql(t);x&&!oT(x,k)&&n(),x=k,S=requestAnimationFrame(C)}return n(),()=>{var k;f.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),m==null||m(),(k=b)==null||k.disconnect(),b=null,d&&cancelAnimationFrame(S)}}const O9=c9,j9=u9,L9=o9,I9=h9,P9=a9,Qk=s9,z9=d9,B9=(t,e,n)=>{const r=new Map,i={platform:A9,...n},s={...i.platform,_c:r};return i9(t,e,{...i,platform:s})};var F9=typeof document<"u",H9=function(){},Jm=F9?_.useLayoutEffect:H9;function Ep(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Ep(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!Ep(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function aT(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Zk(t,e){const n=aT(t);return Math.round(e*n)/n}function gb(t){const e=_.useRef(t);return Jm(()=>{e.current=t}),e}function $9(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:d,open:u}=t,[f,m]=_.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[v,b]=_.useState(r);Ep(v,r)||b(r);const[S,x]=_.useState(null),[C,k]=_.useState(null),E=_.useCallback(B=>{B!==D.current&&(D.current=B,x(B))},[]),R=_.useCallback(B=>{B!==P.current&&(P.current=B,k(B))},[]),M=s||S,O=a||C,D=_.useRef(null),P=_.useRef(null),z=_.useRef(f),Y=d!=null,L=gb(d),W=gb(i),V=gb(u),F=_.useCallback(()=>{if(!D.current||!P.current)return;const B={placement:e,strategy:n,middleware:v};W.current&&(B.platform=W.current),B9(D.current,P.current,B).then(K=>{const A={...K,isPositioned:V.current!==!1};U.current&&!Ep(z.current,A)&&(z.current=A,es.flushSync(()=>{m(A)}))})},[v,e,n,W,V]);Jm(()=>{u===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,m(B=>({...B,isPositioned:!1})))},[u]);const U=_.useRef(!1);Jm(()=>(U.current=!0,()=>{U.current=!1}),[]),Jm(()=>{if(M&&(D.current=M),O&&(P.current=O),M&&O){if(L.current)return L.current(M,O,F);F()}},[M,O,F,L,Y]);const H=_.useMemo(()=>({reference:D,floating:P,setReference:E,setFloating:R}),[E,R]),j=_.useMemo(()=>({reference:M,floating:O}),[M,O]),G=_.useMemo(()=>{const B={position:n,left:0,top:0};if(!j.floating)return B;const K=Zk(j.floating,f.x),A=Zk(j.floating,f.y);return c?{...B,transform:"translate("+K+"px, "+A+"px)",...aT(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:K,top:A}},[n,c,j.floating,f.x,f.y]);return _.useMemo(()=>({...f,update:F,refs:H,elements:j,floatingStyles:G}),[f,F,H,j,G])}const U9=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Qk({element:r.current,padding:i}).fn(n):{}:r?Qk({element:r,padding:i}).fn(n):{}}}},W9=(t,e)=>{const n=O9(t);return{name:n.name,fn:n.fn,options:[t,e]}},V9=(t,e)=>{const n=j9(t);return{name:n.name,fn:n.fn,options:[t,e]}},q9=(t,e)=>({fn:z9(t).fn,options:[t,e]}),K9=(t,e)=>{const n=L9(t);return{name:n.name,fn:n.fn,options:[t,e]}},G9=(t,e)=>{const n=I9(t);return{name:n.name,fn:n.fn,options:[t,e]}},Y9=(t,e)=>{const n=P9(t);return{name:n.name,fn:n.fn,options:[t,e]}},X9=(t,e)=>{const n=U9(t);return{name:n.name,fn:n.fn,options:[t,e]}};var Q9="Arrow",lT=_.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return g.jsx(Bt.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});lT.displayName=Q9;var Z9=lT;function J9(t){const[e,n]=_.useState(void 0);return Pr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,c;if("borderBoxSize"in s){const d=s.borderBoxSize,u=Array.isArray(d)?d[0]:d;a=u.inlineSize,c=u.blockSize}else a=t.offsetWidth,c=t.offsetHeight;n({width:a,height:c})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var $y="Popper",[cT,sl]=Xo($y),[eF,uT]=cT($y),dT=t=>{const{__scopePopper:e,children:n}=t,[r,i]=_.useState(null);return g.jsx(eF,{scope:e,anchor:r,onAnchorChange:i,children:n})};dT.displayName=$y;var hT="PopperAnchor",fT=_.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=uT(hT,n),a=_.useRef(null),c=Xt(e,a),d=_.useRef(null);return _.useEffect(()=>{const u=d.current;d.current=(r==null?void 0:r.current)||a.current,u!==d.current&&s.onAnchorChange(d.current)}),r?null:g.jsx(Bt.div,{...i,ref:c})});fT.displayName=hT;var Uy="PopperContent",[tF,nF]=cT(Uy),mT=_.forwardRef((t,e)=>{var re,ae,ue,me,se,oe;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:v=!1,updatePositionStrategy:b="optimized",onPlaced:S,...x}=t,C=uT(Uy,n),[k,E]=_.useState(null),R=Xt(e,ee=>E(ee)),[M,O]=_.useState(null),D=J9(M),P=(D==null?void 0:D.width)??0,z=(D==null?void 0:D.height)??0,Y=r+(s!=="center"?"-"+s:""),L=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(u)?u:[u],V=W.length>0,F={padding:L,boundary:W.filter(iF),altBoundary:V},{refs:U,floatingStyles:H,placement:j,isPositioned:G,middlewareData:B}=$9({strategy:"fixed",placement:Y,whileElementsMounted:(...ee)=>D9(...ee,{animationFrame:b==="always"}),elements:{reference:C.anchor},middleware:[W9({mainAxis:i+z,alignmentAxis:a}),d&&V9({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?q9():void 0,...F}),d&&K9({...F}),G9({...F,apply:({elements:ee,rects:Q,availableWidth:te,availableHeight:he})=>{const{width:ie,height:xe}=Q.reference,Ae=ee.floating.style;Ae.setProperty("--radix-popper-available-width",`${te}px`),Ae.setProperty("--radix-popper-available-height",`${he}px`),Ae.setProperty("--radix-popper-anchor-width",`${ie}px`),Ae.setProperty("--radix-popper-anchor-height",`${xe}px`)}}),M&&X9({element:M,padding:c}),sF({arrowWidth:P,arrowHeight:z}),v&&Y9({strategy:"referenceHidden",...F})]}),[K,A]=vT(j),I=Ss(S);Pr(()=>{G&&(I==null||I())},[G,I]);const $=(re=B.arrow)==null?void 0:re.x,T=(ae=B.arrow)==null?void 0:ae.y,X=((ue=B.arrow)==null?void 0:ue.centerOffset)!==0,[Z,J]=_.useState();return Pr(()=>{k&&J(window.getComputedStyle(k).zIndex)},[k]),g.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:G?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(me=B.transformOrigin)==null?void 0:me.x,(se=B.transformOrigin)==null?void 0:se.y].join(" "),...((oe=B.hide)==null?void 0:oe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(tF,{scope:n,placedSide:K,onArrowChange:O,arrowX:$,arrowY:T,shouldHideArrow:X,children:g.jsx(Bt.div,{"data-side":K,"data-align":A,...x,ref:R,style:{...x.style,animation:G?void 0:"none"}})})})});mT.displayName=Uy;var pT="PopperArrow",rF={top:"bottom",right:"left",bottom:"top",left:"right"},gT=_.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=nF(pT,r),a=rF[s.placedSide];return g.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:g.jsx(Z9,{...i,ref:n,style:{...i.style,display:"block"}})})});gT.displayName=pT;function iF(t){return t!==null}var sF=t=>({name:"transformOrigin",options:t,fn(e){var C,k,E;const{placement:n,rects:r,middlewareData:i}=e,a=((C=i.arrow)==null?void 0:C.centerOffset)!==0,c=a?0:t.arrowWidth,d=a?0:t.arrowHeight,[u,f]=vT(n),m={start:"0%",center:"50%",end:"100%"}[f],v=(((k=i.arrow)==null?void 0:k.x)??0)+c/2,b=(((E=i.arrow)==null?void 0:E.y)??0)+d/2;let S="",x="";return u==="bottom"?(S=a?m:`${v}px`,x=`${-d}px`):u==="top"?(S=a?m:`${v}px`,x=`${r.floating.height+d}px`):u==="right"?(S=`${-d}px`,x=a?m:`${b}px`):u==="left"&&(S=`${r.floating.width+d}px`,x=a?m:`${b}px`),{data:{x:S,y:x}}}});function vT(t){const[e,n="center"]=t.split("-");return[e,n]}var bg=dT,Ih=fT,_g=mT,yg=gT,bT=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"}),oF="VisuallyHidden",_T=_.forwardRef((t,e)=>g.jsx(Bt.span,{...t,ref:e,style:{...bT,...t.style}}));_T.displayName=oF;var aF=_T,[xg,Sle]=Xo("Tooltip",[sl]),Sg=sl(),yT="TooltipProvider",lF=700,O1="tooltip.open",[cF,Wy]=xg(yT),xT=t=>{const{__scopeTooltip:e,delayDuration:n=lF,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,a=_.useRef(!0),c=_.useRef(!1),d=_.useRef(0);return _.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),g.jsx(cF,{scope:e,isOpenDelayedRef:a,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:_.useCallback(u=>{c.current=u},[]),disableHoverableContent:i,children:s})};xT.displayName=yT;var _h="Tooltip",[uF,Ph]=xg(_h),ST=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=t,d=Wy(_h,t.__scopeTooltip),u=Sg(e),[f,m]=_.useState(null),v=Wo(),b=_.useRef(0),S=a??d.disableHoverableContent,x=c??d.delayDuration,C=_.useRef(!1),[k,E]=bu({prop:r,defaultProp:i??!1,onChange:P=>{P?(d.onOpen(),document.dispatchEvent(new CustomEvent(O1))):d.onClose(),s==null||s(P)},caller:_h}),R=_.useMemo(()=>k?C.current?"delayed-open":"instant-open":"closed",[k]),M=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C.current=!1,E(!0)},[E]),O=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),D=_.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{C.current=!0,E(!0),b.current=0},x)},[x,E]);return _.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),g.jsx(bg,{...u,children:g.jsx(uF,{scope:e,contentId:v,open:k,stateAttribute:R,trigger:f,onTriggerChange:m,onTriggerEnter:_.useCallback(()=>{d.isOpenDelayedRef.current?D():M()},[d.isOpenDelayedRef,D,M]),onTriggerLeave:_.useCallback(()=>{S?O():(window.clearTimeout(b.current),b.current=0)},[O,S]),onOpen:M,onClose:O,disableHoverableContent:S,children:n})})};ST.displayName=_h;var j1="TooltipTrigger",wT=_.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Ph(j1,n),s=Wy(j1,n),a=Sg(n),c=_.useRef(null),d=Xt(e,c,i.onTriggerChange),u=_.useRef(!1),f=_.useRef(!1),m=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),g.jsx(Ih,{asChild:!0,...a,children:g.jsx(Bt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:d,onPointerMove:nt(t.onPointerMove,v=>{v.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:nt(t.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:nt(t.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:nt(t.onFocus,()=>{u.current||i.onOpen()}),onBlur:nt(t.onBlur,i.onClose),onClick:nt(t.onClick,i.onClose)})})});wT.displayName=j1;var Vy="TooltipPortal",[dF,hF]=xg(Vy,{forceMount:void 0}),CT=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:i}=t,s=Ph(Vy,e);return g.jsx(dF,{scope:e,forceMount:n,children:g.jsx(os,{present:n||s.open,children:g.jsx(Nu,{asChild:!0,container:i,children:r})})})};CT.displayName=Vy;var yu="TooltipContent",kT=_.forwardRef((t,e)=>{const n=hF(yu,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,a=Ph(yu,t.__scopeTooltip);return g.jsx(os,{present:r||a.open,children:a.disableHoverableContent?g.jsx(ET,{side:i,...s,ref:e}):g.jsx(fF,{side:i,...s,ref:e})})}),fF=_.forwardRef((t,e)=>{const n=Ph(yu,t.__scopeTooltip),r=Wy(yu,t.__scopeTooltip),i=_.useRef(null),s=Xt(e,i),[a,c]=_.useState(null),{trigger:d,onClose:u}=n,f=i.current,{onPointerInTransitChange:m}=r,v=_.useCallback(()=>{c(null),m(!1)},[m]),b=_.useCallback((S,x)=>{const C=S.currentTarget,k={x:S.clientX,y:S.clientY},E=bF(k,C.getBoundingClientRect()),R=_F(k,E),M=yF(x.getBoundingClientRect()),O=SF([...R,...M]);c(O),m(!0)},[m]);return _.useEffect(()=>()=>v(),[v]),_.useEffect(()=>{if(d&&f){const S=C=>b(C,f),x=C=>b(C,d);return d.addEventListener("pointerleave",S),f.addEventListener("pointerleave",x),()=>{d.removeEventListener("pointerleave",S),f.removeEventListener("pointerleave",x)}}},[d,f,b,v]),_.useEffect(()=>{if(a){const S=x=>{const C=x.target,k={x:x.clientX,y:x.clientY},E=(d==null?void 0:d.contains(C))||(f==null?void 0:f.contains(C)),R=!xF(k,a);E?v():R&&(v(),u())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[d,f,a,u,v]),g.jsx(ET,{...t,ref:s})}),[mF,pF]=xg(_h,{isInside:!1}),gF=fB("TooltipContent"),ET=_.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=t,d=Ph(yu,n),u=Sg(n),{onClose:f}=d;return _.useEffect(()=>(document.addEventListener(O1,f),()=>document.removeEventListener(O1,f)),[f]),_.useEffect(()=>{if(d.trigger){const m=v=>{const b=v.target;b!=null&&b.contains(d.trigger)&&f()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[d.trigger,f]),g.jsx(Au,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:m=>m.preventDefault(),onDismiss:f,children:g.jsxs(_g,{"data-state":d.stateAttribute,...u,...c,ref:e,style:{...c.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:[g.jsx(gF,{children:r}),g.jsx(mF,{scope:n,isInside:!0,children:g.jsx(aF,{id:d.contentId,role:"tooltip",children:i||r})})]})})});kT.displayName=yu;var RT="TooltipArrow",vF=_.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Sg(n);return pF(RT,n).isInside?null:g.jsx(yg,{...i,...r,ref:e})});vF.displayName=RT;function bF(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function _F(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function yF(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function xF(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,a=e.length-1;s<e.length;a=s++){const c=e[s],d=e[a],u=c.x,f=c.y,m=d.x,v=d.y;f>r!=v>r&&n<(m-u)*(r-f)/(v-f)+u&&(i=!i)}return i}function SF(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),wF(e)}function wF(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],a=e[e.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var CF=xT,TT=ST,MT=wT,AT=CT,qy=kT;function kF(t){const e=ke.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",n),e[3]=n,e[4]=i):i=e[4];let s;return e[5]!==r||e[6]!==i?(s=g.jsx("kbd",{className:i,...r}),e[5]=r,e[6]=i,e[7]=s):s=e[7],s}function EF(t){const e=ke.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("inline-flex items-center gap-0.5",n),e[3]=n,e[4]=i):i=e[4];let s;return e[5]!==r||e[6]!==i?(s=g.jsx("span",{className:i,...r}),e[5]=r,e[6]=i,e[7]=s):s=e[7],s}const RF="z-50 overflow-hidden rounded-md border border-border backdrop-blur-md p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",TF=CF,zo=TT,Bo=MT,Fo=_.forwardRef((t,e)=>{const n=ke.c(11);let r,i,s;n[0]!==t?({className:r,sideOffset:s,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=s):(r=n[1],i=n[2],s=n[3]);const a=s===void 0?4:s;let c;n[4]!==r?(c=Ce("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border backdrop-blur-md 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",r),n[4]=r,n[5]=c):c=n[5];let d;return n[6]!==i||n[7]!==e||n[8]!==a||n[9]!==c?(d=g.jsx(AT,{children:g.jsx(qy,{ref:e,sideOffset:a,className:c,...i})}),n[6]=i,n[7]=e,n[8]=a,n[9]=c,n[10]=d):d=n[10],d});Fo.displayName=qy.displayName;const Gd=TT,Yd=MT;function NT(t){return t.toUpperCase()}function MF(t){const e=t.split("+");return g.jsx(EF,{children:e.map((n,r)=>g.jsx(kF,{children:NT(n)},`${n}-${r}`))})}const Fl=_.forwardRef((t,e)=>{const n=ke.c(17);let r,i,s,a,c;n[0]!==t?({className:i,sideOffset:c,children:r,shortcut:a,...s}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=s,n[4]=a,n[5]=c):(r=n[1],i=n[2],s=n[3],a=n[4],c=n[5]);const d=c===void 0?4:c,u=a===void 0?null:Array.isArray(a)?a[0]??null:a;let f;n[6]!==i?(f=Ce(RF,i),n[6]=i,n[7]=f):f=n[7];let m;n[8]!==r||n[9]!==u?(m=u?MF(u):g.jsx("span",{children:typeof r=="string"?NT(r):r}),n[8]=r,n[9]=u,n[10]=m):m=n[10];let v;return n[11]!==s||n[12]!==e||n[13]!==d||n[14]!==f||n[15]!==m?(v=g.jsx(AT,{children:g.jsx(qy,{ref:e,sideOffset:d,className:f,...s,children:m})}),n[11]=s,n[12]=e,n[13]=d,n[14]=f,n[15]=m,n[16]=v):v=n[16],v});Fl.displayName="HotkeyTooltipContent";const AF="0.7.2",NF={version:AF},ys="Kaizen",Jk="kaizen",DF=".kaizen",OF=".kaizen-dev",wle=".kaizen",jF="KAIZEN_RUNTIME_PROFILE",LF=`kaizen/${NF.version}`,IF="[kaizen]",Cle=`~/${ys}`,Ky="kaizen:";function ju(){var e;return(e=globalThis.process)==null?void 0:e.env}function PF(t=ju()){const e=t==null?void 0:t[jF];return(e==null?void 0:e.trim().toLowerCase())==="dev"?"dev":"prod"}function zF(t=ju()){return PF(t)==="dev"?OF:DF}function DT(t=ju()){return`~/${zF(t)}`}function kle(t=ju()){return`${DT(t)}/keybindings.json`}function BF(t=ju()){return`${DT(t)}/themes`}function FF(t=ju()){return`${BF(t)}/THEME_README.md`}function Ele(t){return t?`${Jk} ${t}`:Jk}function HF(t){return t==="claude"||t==="codex"||t==="gemini"||t==="cursor"||t==="openrouter"}function $F(t){return HF(t)?t:null}const Rp=[{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"max",label:"Max"}],L1=[{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"XHigh"}],I1=[{id:"off",label:"Off"},{id:"standard",label:"Standard"},{id:"high",label:"High"}],P1="claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]",OT=[{id:"composer-2[fast=true]",label:"Composer 2",supportsEffort:!1},{id:"composer-1.5[]",label:"Composer 1.5",supportsEffort:!1},{id:"gpt-5.3-codex[reasoning=medium,fast=false]",label:"Codex 5.3",supportsEffort:!1},{id:"gpt-5.4[reasoning=medium,context=272k,fast=false]",label:"GPT-5.4",supportsEffort:!1},{id:"claude-sonnet-4-6[thinking=true,context=200k,effort=medium]",label:"Sonnet 4.6",supportsEffort:!1},{id:"claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]",label:"Opus 4.6",supportsEffort:!1},{id:"claude-opus-4-5[thinking=true]",label:"Opus 4.5",supportsEffort:!1},{id:"gpt-5.2[reasoning=medium,fast=false]",label:"GPT-5.2",supportsEffort:!1},{id:"gemini-3.1-pro[]",label:"Gemini 3.1 Pro",supportsEffort:!1},{id:"gpt-5.4-mini[reasoning=medium]",label:"GPT-5.4 Mini",supportsEffort:!1},{id:"gpt-5.4-nano[reasoning=medium]",label:"GPT-5.4 Nano",supportsEffort:!1},{id:"claude-haiku-4-5[thinking=true]",label:"Haiku 4.5",supportsEffort:!1},{id:"gpt-5.3-codex-spark[reasoning=medium]",label:"Codex 5.3 Spark",supportsEffort:!1},{id:"grok-4-20[thinking=true]",label:"Grok 4.20",supportsEffort:!1},{id:"claude-sonnet-4-5[thinking=true,context=200k]",label:"Sonnet 4.5",supportsEffort:!1},{id:"gpt-5.2-codex[reasoning=medium,fast=false]",label:"Codex 5.2",supportsEffort:!1},{id:"gemini-3-flash[]",label:"Gemini 3 Flash",supportsEffort:!1},{id:"claude-sonnet-4[thinking=false,context=200k]",label:"Sonnet 4",supportsEffort:!1},{id:"kimi-k2.5[]",label:"Kimi K2.5",supportsEffort:!1}],UF={"composer-2-fast":"composer-2[fast=true]","composer-1.5":"composer-1.5[]","gpt-5.3-codex":"gpt-5.3-codex[reasoning=medium,fast=false]","gpt-5.4":"gpt-5.4[reasoning=medium,context=272k,fast=false]","gpt-5.4-medium":"gpt-5.4[reasoning=medium,context=272k,fast=false]","claude-4.6-sonnet-medium-thinking":"claude-sonnet-4-6[thinking=true,context=200k,effort=medium]","claude-4.6-opus-high-thinking":"claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]","claude-4.5-opus-high-thinking":"claude-opus-4-5[thinking=true]","gpt-5.2":"gpt-5.2[reasoning=medium,fast=false]","gemini-3.1-pro":"gemini-3.1-pro[]","gpt-5.4-mini":"gpt-5.4-mini[reasoning=medium]","gpt-5.4-mini-medium":"gpt-5.4-mini[reasoning=medium]","gpt-5.4-nano":"gpt-5.4-nano[reasoning=medium]","gpt-5.4-nano-medium":"gpt-5.4-nano[reasoning=medium]","claude-haiku-4.5":"claude-haiku-4-5[thinking=true]","gpt-5.3-codex-spark-preview":"gpt-5.3-codex-spark[reasoning=medium]","grok-4-20":"grok-4-20[thinking=true]","grok-4-20-thinking":"grok-4-20[thinking=true]","claude-4.5-sonnet-thinking":"claude-sonnet-4-5[thinking=true,context=200k]","gpt-5.2-codex":"gpt-5.2-codex[reasoning=medium,fast=false]","gemini-3-flash":"gemini-3-flash[]","claude-4-sonnet":"claude-sonnet-4[thinking=false,context=200k]","kimi-k2.5":"kimi-k2.5[]"};function WF(t){return t?OT.some(e=>e.id===t)?t:UF[t]??P1:P1}function eE(t){const e=t.indexOf("[");return e>=0?t.slice(0,e):t}function Lu(t){const e=t.match(/\bfast=(true|false)\b/);return e?e[1]==="true"?"fast":"standard":null}function tE(t){return Rp.some(e=>e.id===t)}function nE(t){return L1.some(e=>e.id===t)}const z1=[{id:"200k",label:"200k"},{id:"1m",label:"1M"}];function VF(t){return I1.some(e=>e.id===t)}const qF={image:!0,markdown:!0,document:!0},KF={image:!0,markdown:!0,document:!1},GF={image:!0,markdown:!0,document:!0},YF={image:!0,markdown:!0,document:!0},XF={image:!0,markdown:!0,document:!0},QF={openrouter:"account",providerUsage:"account",handoff:"account",remoteRelay:"paid",browserNotifications:"paid",installMobilePush:"paid",syncedSettings:"paid",syncedKeybindings:"paid",syncedHandoffs:"paid",crossDeviceStorage:"paid"},rc=[{id:"claude",label:"Claude",systemActive:!0,defaultModel:"sonnet",defaultEffort:"high",defaultModelOptions:{reasoningEffort:"high",contextWindow:"200k"},supportsPlanMode:!0,attachmentCapabilities:qF,models:[{id:"opus",label:"Opus",supportsEffort:!0,contextWindowOptions:[...z1]},{id:"sonnet",label:"Sonnet",supportsEffort:!0,contextWindowOptions:[...z1]},{id:"haiku",label:"Haiku",supportsEffort:!0}],efforts:[...Rp]},{id:"codex",label:"Codex",systemActive:!0,defaultModel:"gpt-5.4",defaultModelOptions:{reasoningEffort:"high",fastMode:!1},supportsPlanMode:!0,attachmentCapabilities:KF,models:[{id:"gpt-5.4",label:"GPT-5.4",supportsEffort:!1},{id:"gpt-5.3-codex",label:"GPT-5.3 Codex",supportsEffort:!1},{id:"gpt-5.3-codex-spark",label:"GPT-5.3 Codex Spark",supportsEffort:!1}],efforts:[]},{id:"gemini",label:"Gemini",systemActive:!1,defaultModel:"auto-gemini-2.5",defaultModelOptions:{thinkingMode:"standard"},supportsPlanMode:!0,attachmentCapabilities:GF,models:[{id:"auto-gemini-3",label:"Auto (Gemini 3)",supportsEffort:!1},{id:"auto-gemini-2.5",label:"Auto (Gemini 2.5)",supportsEffort:!1},{id:"gemini-3.1-pro-preview",label:"3.1 Pro Preview",supportsEffort:!1},{id:"gemini-3-pro-preview",label:"3 Pro Preview",supportsEffort:!1},{id:"gemini-3-flash-preview",label:"3 Flash Preview",supportsEffort:!1},{id:"gemini-2.5-pro",label:"2.5 Pro",supportsEffort:!1},{id:"gemini-2.5-flash",label:"2.5 Flash",supportsEffort:!1},{id:"gemini-2.5-flash-lite",label:"2.5 Flash Lite",supportsEffort:!1}],efforts:[]},{id:"cursor",label:"Cursor",systemActive:!0,defaultModel:P1,defaultModelOptions:{},supportsPlanMode:!0,attachmentCapabilities:YF,models:[...OT],efforts:[]},{id:"openrouter",label:"OpenRouter",systemActive:!0,defaultModel:"opencode/big-pickle",defaultModelOptions:{},supportsPlanMode:!0,attachmentCapabilities:XF,models:[{id:"opencode/big-pickle",label:"Big Pickle",supportsEffort:!1},{id:"opencode/gpt-5-nano",label:"GPT-5 Nano",supportsEffort:!1},{id:"opencode/mimo-v2-omni-free",label:"MiMo V2 Omni Free",supportsEffort:!1},{id:"opencode/mimo-v2-pro-free",label:"MiMo V2 Pro Free",supportsEffort:!1},{id:"opencode/minimax-m2.5-free",label:"MiniMax M2.5 Free",supportsEffort:!1},{id:"opencode/nemotron-3-super-free",label:"Nemotron 3 Super Free",supportsEffort:!1},{id:"opencode/qwen3.6-plus-free",label:"Qwen3.6 Plus Free",supportsEffort:!1},{id:"openrouter/anthropic/claude-sonnet-4",label:"Claude Sonnet 4",supportsEffort:!1},{id:"openrouter/anthropic/claude-opus-4",label:"Claude Opus 4",supportsEffort:!1},{id:"openrouter/openai/gpt-5.4",label:"GPT-5.4",supportsEffort:!1},{id:"openrouter/google/gemini-2.5-pro",label:"Gemini 2.5 Pro",supportsEffort:!1},{id:"openrouter/deepseek/deepseek-r1",label:"DeepSeek R1",supportsEffort:!1},{id:"openrouter/meta-llama/llama-4-maverick",label:"Llama 4 Maverick",supportsEffort:!1}],efforts:[]}],Tp={claude:{active:!0},codex:{active:!0},gemini:{active:!0},cursor:{active:!0},openrouter:{active:!1}};function Zn(t,e=rc){const n=e.find(r=>r.id===t);if(!n)throw new Error(`Unknown provider: ${t}`);return n}function wg(t,e){const n=e?t.models.find(r=>r.id===e):void 0;return(n==null?void 0:n.attachmentCapabilities)??t.attachmentCapabilities}function Gy(t,e){const n=Tp[e],r=t==null?void 0:t[e];return{active:(r==null?void 0:r.active)??n.active}}function ZF(t,e,n=rc){var s;const r=Zn(t,n),i=Gy(e,t);return r.systemActive&&i.active?null:!r.systemActive&&((s=r.availabilityMessage)!=null&&s.trim())?r.availabilityMessage:`Provider ${r.label} is currently not active.`}function JF(t,e,n=rc){const r=Zn(t,n),i=Gy(e,t);return r.systemActive&&i.active}function eH(t,e){return t.map(n=>{const r=Gy(e,n.id),i=n.systemActive&&r.active;return{...n,active:r.active,isSelectable:i,isUsageEnabled:i,isInactive:!i,inactiveMessage:ZF(n.id,e,t)}})}function tH(t,e){return eH(t,e).filter(n=>n.isSelectable).map(({active:n,isSelectable:r,isUsageEnabled:i,isInactive:s,inactiveMessage:a,...c})=>c)}function jT(t){return tH(rc,t)}function Kr(t){return Zn(t).defaultModelOptions}const LT=Kr("claude");Kr("codex");Kr("gemini");Kr("cursor");Kr("openrouter");function nH(t){return Zn("claude").models.find(e=>e.id===t)}function rH(t){var e;return((e=nH(t))==null?void 0:e.contextWindowOptions)??[]}function iH(t,e){const n=rH(t);if(n.length!==0)return n.some(r=>r.id===e)?e:LT.contextWindow}const sH=["idea","todo","progress","testing","done"],rE={idea:"IDEA",todo:"TODO",progress:"PROGRESS",testing:"TESTING",done:"DONE"},Lo={submitChatMessage:["enter"],toggleQuickPrompts:["cmd+e","ctrl+e"],toggleProjectsSidebar:["ctrl+a"],toggleEmbeddedTerminal:["cmd+j","ctrl+`"],toggleRightSidebar:["cmd+b","ctrl+b"],openInFinder:["cmd+alt+f","ctrl+alt+f"],openInEditor:["cmd+shift+o","ctrl+shift+o"],addSplitTerminal:["cmd+/","ctrl+/"]},Mp=8,IT=10*1024*1024,oH=20*1024*1024,aH=1*1024*1024,Ap=["image/png","image/jpeg","image/webp","image/gif"],PT=["application/pdf"],zT=["text/markdown","text/x-markdown"],lH="/assets/icon-4rSnra9R.svg";function sh(t){const e=ke.c(10);let n,r,i;e[0]!==t?({alt:i,className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const s=i===void 0?"":i;let a;e[4]!==n?(a=Ce("shrink-0 object-contain",n),e[4]=n,e[5]=a):a=e[5];let c;return e[6]!==s||e[7]!==r||e[8]!==a?(c=g.jsx("img",{alt:s,src:lH,className:a,...r}),e[6]=s,e[7]=r,e[8]=a,e[9]=c):c=e[9],c}var Cg="Popover",[BT,Rle]=Xo(Cg,[sl]),zh=sl(),[cH,ol]=BT(Cg),FT=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=t,c=zh(e),d=_.useRef(null),[u,f]=_.useState(!1),[m,v]=bu({prop:r,defaultProp:i??!1,onChange:s,caller:Cg});return g.jsx(bg,{...c,children:g.jsx(cH,{scope:e,contentId:Wo(),triggerRef:d,open:m,onOpenChange:v,onOpenToggle:_.useCallback(()=>v(b=>!b),[v]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>f(!0),[]),onCustomAnchorRemove:_.useCallback(()=>f(!1),[]),modal:a,children:n})})};FT.displayName=Cg;var HT="PopoverAnchor",$T=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=ol(HT,n),s=zh(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:c}=i;return _.useEffect(()=>(a(),()=>c()),[a,c]),g.jsx(Ih,{...s,...r,ref:e})});$T.displayName=HT;var UT="PopoverTrigger",WT=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=ol(UT,n),s=zh(n),a=Xt(e,i.triggerRef),c=g.jsx(Bt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":YT(i.open),...r,ref:a,onClick:nt(t.onClick,i.onOpenToggle)});return i.hasCustomAnchor?c:g.jsx(Ih,{asChild:!0,...s,children:c})});WT.displayName=UT;var Yy="PopoverPortal",[uH,dH]=BT(Yy,{forceMount:void 0}),VT=t=>{const{__scopePopover:e,forceMount:n,children:r,container:i}=t,s=ol(Yy,e);return g.jsx(uH,{scope:e,forceMount:n,children:g.jsx(os,{present:n||s.open,children:g.jsx(Nu,{asChild:!0,container:i,children:r})})})};VT.displayName=Yy;var xu="PopoverContent",qT=_.forwardRef((t,e)=>{const n=dH(xu,t.__scopePopover),{forceMount:r=n.forceMount,...i}=t,s=ol(xu,t.__scopePopover);return g.jsx(os,{present:r||s.open,children:s.modal?g.jsx(fH,{...i,ref:e}):g.jsx(mH,{...i,ref:e})})});qT.displayName=xu;var hH=Wl("PopoverContent.RemoveScroll"),fH=_.forwardRef((t,e)=>{const n=ol(xu,t.__scopePopover),r=_.useRef(null),i=Xt(e,r),s=_.useRef(!1);return _.useEffect(()=>{const a=r.current;if(a)return ug(a)},[]),g.jsx(jh,{as:hH,allowPinchZoom:!0,children:g.jsx(KT,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:nt(t.onCloseAutoFocus,a=>{var c;a.preventDefault(),s.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:nt(t.onPointerDownOutside,a=>{const c=a.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,u=c.button===2||d;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:nt(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),mH=_.forwardRef((t,e)=>{const n=ol(xu,t.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return g.jsx(KT,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,s),s.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var d,u;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),KT=_.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,...m}=t,v=ol(xu,n),b=zh(n);return lg(),g.jsx(Oh,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:g.jsx(Au,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>v.onOpenChange(!1),children:g.jsx(_g,{"data-state":YT(v.open),role:"dialog",id:v.contentId,...b,...m,ref:e,style:{...m.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)"}})})})}),GT="PopoverClose",pH=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=ol(GT,n);return g.jsx(Bt.button,{type:"button",...r,ref:e,onClick:nt(t.onClick,()=>i.onOpenChange(!1))})});pH.displayName=GT;var gH="PopoverArrow",vH=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=zh(n);return g.jsx(yg,{...i,...r,ref:e})});vH.displayName=gH;function YT(t){return t?"open":"closed"}var XT=FT,bH=$T,_H=WT,QT=VT,Xy=qT;const Qy=XT,Zy=_H,kg=_.forwardRef((t,e)=>{const n=ke.c(17);let r,i,s,a;n[0]!==t?({className:r,align:s,sideOffset:a,...i}=t,n[0]=t,n[1]=r,n[2]=i,n[3]=s,n[4]=a):(r=n[1],i=n[2],s=n[3],a=n[4]);const c=s===void 0?"center":s,d=a===void 0?4:a;let u;n[5]===Symbol.for("react.memo_cache_sentinel")?(u={[vh]:""},n[5]=u):u=n[5];let f;n[6]!==i?(f=b=>{var S;b.preventDefault(),window.dispatchEvent(new Event(xp)),(S=i.onCloseAutoFocus)==null||S.call(i,b)},n[6]=i,n[7]=f):f=n[7];let m;n[8]!==r?(m=Ce("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg backdrop-blur-md 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",r),n[8]=r,n[9]=m):m=n[9];let v;return n[10]!==c||n[11]!==i||n[12]!==e||n[13]!==d||n[14]!==f||n[15]!==m?(v=g.jsx(QT,{children:g.jsx(Xy,{ref:e,align:c,sideOffset:d,...u,onCloseAutoFocus:f,className:m,...i})}),n[10]=c,n[11]=i,n[12]=e,n[13]=d,n[14]=f,n[15]=m,n[16]=v):v=n[16],v});kg.displayName=Xy.displayName;function yH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function xH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 158.7128 157.296",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function SH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M12 0C12 0 12 8 8 12C4 16 0 12 0 12C0 12 4 12 8 12C12 12 12 16 12 24C12 24 12 16 16 12C20 8 24 12 24 12C24 12 16 12 16 12C12 12 12 4 12 0Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function wH(t){const e=ke.c(9);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M12 0 2.4 5.5v13L12 24l9.6-5.5v-13Zm0 3.1 6.8 3.9v5.1L15 14.3V9.7L12 8l-3 1.7v4.6l-3.8-2.2V7Zm-6.8 9.8 3.8 2.2v4.5l3 1.8 3-1.8v-4.5l3.8-2.2v3.8L12 20.9l-6.8-3.9Z"}),e[5]=s):s=e[5];let a;return e[6]!==r||e[7]!==i?(a=g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:i,...r,children:s}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function CH(t){const e=ke.c(11);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=Ce("shrink-0",n),e[3]=n,e[4]=i):i=e[4];let s,a,c;e[5]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("path",{d:"M12 2.75c2.83 0 5.14 2.28 5.19 5.1l1.72.99A7.25 7.25 0 0 0 5.4 13.45l-1.7.98A9.25 9.25 0 0 1 12 2.75Z",fill:"currentColor"}),a=g.jsx("path",{d:"M19.34 8.2a9.25 9.25 0 0 1-3.4 12.65 9.2 9.2 0 0 1-5.22 1.25v-1.98a7.24 7.24 0 0 0 7.25-12.56l1.37.64Z",fill:"currentColor",opacity:".8"}),c=g.jsx("path",{d:"M8.4 21.02A9.26 9.26 0 0 1 3.3 9.58l1.72.99A7.24 7.24 0 0 0 15.9 18.8l-.02 1.58a9.2 9.2 0 0 1-7.48.64Z",fill:"currentColor",opacity:".6"}),e[5]=s,e[6]=a,e[7]=c):(s=e[5],a=e[6],c=e[7]);let d;return e[8]!==r||e[9]!==i?(d=g.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:i,...r,children:[s,a,c]}),e[8]=r,e[9]=i,e[10]=d):d=e[10],d}function kH(t){return!(t.startsWith("gemini-3")||t==="auto-gemini-3")}const EH=["Composer","GPT","Claude","Gemini","Grok","Kimi"];function RH(t){return t.startsWith("composer-")?"Composer":t.startsWith("gpt-")?"GPT":t.startsWith("claude-")?"Claude":t.startsWith("gemini-")?"Gemini":t.startsWith("grok-")?"Grok":"Kimi"}function iE(t){return{Standard:"Std","Fast Mode":"Fast",Medium:"Med",Minimal:"Min",XHigh:"XHi"}[t]??t}function vb(t,e){const n=Lu(e);return!n||n==="standard"?t:`${t} (${n==="fast"?"Fast":"Standard"})`}const Np={claude:yH,codex:xH,gemini:SH,cursor:wH,openrouter:CH},_m={auto:gn,opus:Gn,sonnet:gn,haiku:qr,"gpt-5.4":Gn,"gpt-5.4[reasoning=medium,context=272k,fast=false]":Gn,"gpt-5.4-mini[reasoning=medium]":gn,"gpt-5.4-nano[reasoning=medium]":qr,"gpt-5.3-codex":gn,"gpt-5.3-codex[reasoning=medium,fast=false]":gn,"gpt-5.3-codex-spark[reasoning=medium]":qr,"gpt-5.2[reasoning=medium,fast=false]":gn,"gpt-5.2-codex[reasoning=medium,fast=false]":gn,"gpt-5.3-codex-spark":qr,"gemini-2.5-pro":Gn,"gemini-2.5-flash":gn,"gemini-2.5-flash-lite":qr,"auto-gemini-3":Gn,"auto-gemini-2.5":gn,"gemini-3.1-pro-preview":Gn,"gemini-3.1-pro[]":Gn,"gemini-3-flash[]":gn,"gemini-3-pro-preview":Gn,"gemini-3-flash-preview":gn,"claude-opus-4-6[thinking=true,context=200k,effort=high,fast=false]":Gn,"claude-opus-4-5[thinking=true]":Gn,"claude-sonnet-4-6[thinking=true,context=200k,effort=medium]":gn,"claude-sonnet-4-5[thinking=true,context=200k]":gn,"claude-sonnet-4[thinking=false,context=200k]":gn,"claude-haiku-4-5[thinking=true]":qr,"opencode/big-pickle":Gn,"opencode/gpt-5-nano":qr,"opencode/mimo-v2-omni-free":gn,"opencode/mimo-v2-pro-free":gn,"opencode/minimax-m2.5-free":gn,"opencode/nemotron-3-super-free":Gn,"opencode/qwen3.6-plus-free":Gn,"openrouter/anthropic/claude-sonnet-4":gn,"openrouter/anthropic/claude-opus-4":Gn,"openrouter/openai/gpt-5.4":Gn,"openrouter/google/gemini-2.5-pro":Gn,"openrouter/deepseek/deepseek-r1":Gn,"openrouter/meta-llama/llama-4-maverick":gn,"grok-4-20[thinking=true]":Gn,"kimi-k2.5[]":gn,"composer-2[fast=true]":Gn,"composer-1.5[]":gn};function oi(t){const e=ke.c(16),{onClick:n,selected:r,icon:i,label:s,description:a,disabled:c}=t,d=r?"bg-muted border-border":"hover:opacity-60",u=c&&"opacity-40 cursor-not-allowed";let f;e[0]!==d||e[1]!==u?(f=Ce("w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity",d,u),e[0]=d,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==s?(m=g.jsx("div",{className:"text-sm font-medium",children:s}),e[3]=s,e[4]=m):m=e[4];let v;e[5]!==a?(v=a?g.jsx("div",{className:"text-xs text-muted-foreground",children:a}):null,e[5]=a,e[6]=v):v=e[6];let b;e[7]!==m||e[8]!==v?(b=g.jsxs("div",{children:[m,v]}),e[7]=m,e[8]=v,e[9]=b):b=e[9];let S;return e[10]!==c||e[11]!==i||e[12]!==n||e[13]!==f||e[14]!==b?(S=g.jsxs("button",{onClick:n,disabled:c,className:f,children:[i,b]}),e[10]=c,e[11]=i,e[12]=n,e[13]=f,e[14]=b,e[15]=S):S=e[15],S}function La(t){const e=ke.c(18),{trigger:n,triggerClassName:r,disabled:i,children:s}=t,a=i===void 0?!1:i,[c,d]=_.useState(!1);if(a){let S;e[0]!==r?(S=Ce("flex items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default",r),e[0]=r,e[1]=S):S=e[1];let x;return e[2]!==S||e[3]!==n?(x=g.jsx("button",{disabled:!0,className:S,children:n}),e[2]=S,e[3]=n,e[4]=x):x=e[4],x}let u;e[5]!==r?(u=Ce("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),e[5]=r,e[6]=u):u=e[6];let f;e[7]!==u||e[8]!==n?(f=g.jsx(Zy,{asChild:!0,children:g.jsx("button",{className:u,children:n})}),e[7]=u,e[8]=n,e[9]=f):f=e[9];let m;e[10]!==s?(m=typeof s=="function"?s(()=>d(!1)):s,e[10]=s,e[11]=m):m=e[11];let v;e[12]!==m?(v=g.jsx(kg,{align:"center",className:"w-64 p-1",children:g.jsx("div",{className:"max-h-[min(24rem,60vh)] space-y-1 overflow-y-auto pr-1",children:m})}),e[12]=m,e[13]=v):v=e[13];let b;return e[14]!==c||e[15]!==f||e[16]!==v?(b=g.jsxs(Qy,{open:c,onOpenChange:d,children:[f,v]}),e[14]=c,e[15]=f,e[16]=v,e[17]=b):b=e[17],b}function TH(t){var tt,it,ce,Re,Ue,Je,Ve;const e=ke.c(38),{availableProviders:n,selectedProvider:r,lockedProviders:i,disabled:s,showProviderPicker:a,providerLocked:c,model:d,modelOptions:u,onProviderChange:f,onModelChange:m,onClaudeReasoningEffortChange:v,onClaudeContextWindowChange:b,onCodexReasoningEffortChange:S,onGeminiThinkingModeChange:x,onCodexFastModeChange:C,planMode:k,onPlanModeChange:E,pendingPlanMode:R,includePlanMode:M,className:O}=t,D=s===void 0?!1:s,P=a===void 0?!0:a,z=c===void 0?!1:c,Y=k===void 0?!1:k,L=R===void 0?null:R,W=M===void 0?!0:M,[V,F]=_.useState(null),U=n.find(ze=>ze.id===r)??Zn(r),H=Np[r],j=_m[d]??gn,G=W&&(U==null?void 0:U.supportsPlanMode)&&E,B=L??Y,K=L!==null,A=r==="claude"?u:null,I=r==="codex"?u:null,$=r==="gemini"?u:null,T=((tt=U.models.find(ze=>ze.id===d))==null?void 0:tt.contextWindowOptions)??[],X=(A==null?void 0:A.contextWindow)??z1[0].id,Z=X==="1m"?bk:_k,J=r==="claude"||r==="codex",re=r==="cursor"?Lu(d):null,ae=U.id==="cursor"?U.models.filter(ze=>eE(ze.id)===eE(d)):[],ue=r==="cursor"&&ae.some(OH)&&ae.some(DH),me=U.id==="cursor"?EH.map(ze=>({family:ze,models:U.models.filter(He=>RH(He.id)===ze)})).filter(NH):[];let se;e[0]!==J||e[1]!==u||e[2]!==r?(se=J?r==="claude"?((it=Rp.find(ze=>ze.id===u.reasoningEffort))==null?void 0:it.label)??String(u.reasoningEffort):((ce=L1.find(ze=>ze.id===u.reasoningEffort))==null?void 0:ce.label)??String(u.reasoningEffort):null,e[0]=J,e[1]=u,e[2]=r,e[3]=se):se=e[3];const oe=se;let ee;e[4]!==($==null?void 0:$.thinkingMode)||e[5]!==r?(ee=r==="gemini"?((Re=I1.find(ze=>ze.id===($==null?void 0:$.thinkingMode)))==null?void 0:Re.label)??($==null?void 0:$.thinkingMode)??"Standard":null,e[4]=$==null?void 0:$.thinkingMode,e[5]=r,e[6]=ee):ee=e[6];const Q=ee;let te;e[7]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{F(null)},e[7]=te):te=e[7];let he;e[8]!==r?(he=[r],e[8]=r,e[9]=he):he=e[9],_.useEffect(te,he);const ie=D&&"pointer-events-none opacity-60";let xe;e[10]!==O||e[11]!==ie?(xe=Ce("max-w-full overflow-x-auto scrollbar-hide",ie,O),e[10]=O,e[11]=ie,e[12]=xe):xe=e[12];let Ae;e[13]!==j?(Ae=g.jsx(j,{className:"h-3.5 w-3.5"}),e[13]=j,e[14]=Ae):Ae=e[14];let Ke;e[15]!==oe||e[16]!==J||e[17]!==d||e[18]!==u||e[19]!==v||e[20]!==S||e[21]!==r?(Ke=J?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:oe}),g.jsx("span",{className:"md:hidden",children:oe!==null?iE(oe):null})]}),children:ze=>r==="claude"?Rp.map(He=>g.jsx(oi,{onClick:()=>{v(He.id),ze()},selected:u.reasoningEffort===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,disabled:He.id==="max"&&d!=="opus"},He.id)):L1.map(He=>g.jsx(oi,{onClick:()=>{S(He.id),ze()},selected:u.reasoningEffort===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:He.label},He.id))}):null,e[15]=oe,e[16]=J,e[17]=d,e[18]=u,e[19]=v,e[20]=S,e[21]=r,e[22]=Ke):Ke=e[22];let mt;e[23]!==($==null?void 0:$.thinkingMode)||e[24]!==Q||e[25]!==d||e[26]!==x||e[27]!==r?(mt=r==="gemini"?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:Q}),g.jsx("span",{className:"md:hidden",children:Q!==null?iE(Q):null})]}),children:ze=>I1.map(He=>g.jsx(oi,{onClick:()=>{x(He.id),ze()},selected:($==null?void 0:$.thinkingMode)===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,disabled:He.id==="off"&&!kH(d)},He.id))}):null,e[23]=$==null?void 0:$.thinkingMode,e[24]=Q,e[25]=d,e[26]=x,e[27]=r,e[28]=mt):mt=e[28];let Ye;e[29]!==(I==null?void 0:I.fastMode)||e[30]!==C||e[31]!==r?(Ye=r==="codex"?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[I!=null&&I.fastMode?g.jsx(qr,{className:"h-3.5 w-3.5"}):g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:I!=null&&I.fastMode?"Fast Mode":"Standard"}),g.jsx("span",{className:"md:hidden",children:I!=null&&I.fastMode?"Fast":"Std"})]}),triggerClassName:I!=null&&I.fastMode?"text-emerald-500 dark:text-emerald-400":void 0,children:ze=>g.jsxs(g.Fragment,{children:[g.jsx(oi,{onClick:()=>{C(!1),ze()},selected:!(I!=null&&I.fastMode),icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:"Standard"}),g.jsx(oi,{onClick:()=>{C(!0),ze()},selected:!!(I!=null&&I.fastMode),icon:g.jsx(qr,{className:"h-4 w-4 text-muted-foreground"}),label:"Fast Mode"})]})}):null,e[29]=I==null?void 0:I.fastMode,e[30]=C,e[31]=r,e[32]=Ye):Ye=e[32];let Ze;return e[33]!==B||e[34]!==K||e[35]!==E||e[36]!==G?(Ze=G?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[K?g.jsx(Fn,{className:"h-3.5 w-3.5 animate-spin"}):B?g.jsx(bp,{className:"h-3.5 w-3.5"}):g.jsx(gk,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:K?B?"Planning...":"Implementing...":B?"Plan":"Implement"}),g.jsx("span",{className:"md:hidden",children:K?B?"Plan...":"Impl...":B?"Plan":"Impl"})]}),triggerClassName:B?"text-blue-400 dark:text-blue-300":void 0,children:ze=>g.jsxs(g.Fragment,{children:[g.jsx(oi,{onClick:()=>{E(!1),ze()},selected:!B,icon:g.jsx(gk,{className:"h-4 w-4 text-muted-foreground"}),label:"Implement",description:"Start execution",disabled:K}),g.jsx(oi,{onClick:()=>{E(!0),ze()},selected:B,icon:g.jsx(bp,{className:"h-4 w-4 text-muted-foreground"}),label:"Plan",description:"Review a plan before execution",disabled:K})]})}):null,e[33]=B,e[34]=K,e[35]=E,e[36]=G,e[37]=Ze):Ze=e[37],g.jsx("div",{className:xe,children:g.jsxs("div",{className:"flex w-max items-center justify-center gap-0.5 mx-auto",children:[P?g.jsx(La,{disabled:z||!f,trigger:g.jsxs(g.Fragment,{children:[g.jsx(H,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:(U==null?void 0:U.label)??r})]}),children:ze=>n.map(He=>{const Xe=Np[He.id],ut=i==null?void 0:i[He.id];return g.jsx(oi,{onClick:()=>{ut||(f==null||f(He.id),ze())},selected:r===He.id,icon:g.jsx(Xe,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,description:ut,disabled:!!ut},He.id)})}):null,g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[Ae,g.jsx("span",{children:U.id==="cursor"?vb(((Ue=U.models.find(ze=>ze.id===d))==null?void 0:Ue.label)??d,d):((Je=U.models.find(ze=>ze.id===d))==null?void 0:Je.label)??d})]}),children:ze=>{var He;return U.id==="cursor"?V?g.jsxs(g.Fragment,{children:[g.jsxs("button",{onClick:()=>F(null),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-muted-foreground transition-opacity hover:opacity-70",children:[g.jsx(GR,{className:"h-4 w-4"}),g.jsx("span",{children:V})]}),(He=me.find(Xe=>Xe.family===V))==null?void 0:He.models.map(Xe=>{const ut=_m[Xe.id]??gn;return g.jsx(oi,{onClick:()=>{m(r,Xe.id),F(null),ze()},selected:d===Xe.id,icon:g.jsx(ut,{className:"h-4 w-4 text-muted-foreground"}),label:vb(Xe.label,Xe.id)},Xe.id)})]}):me.map(Xe=>{var rt;const ut=Xe.models.some(Tt=>Tt.id===d),ft=_m[((rt=Xe.models[0])==null?void 0:rt.id)??""]??gn;return g.jsxs("div",{className:"relative",children:[g.jsx(oi,{onClick:()=>F(Xe.family),selected:ut,icon:g.jsx(ft,{className:"h-4 w-4 text-muted-foreground"}),label:Xe.family,description:`${Xe.models.length} model${Xe.models.length===1?"":"s"}`}),g.jsx(Ni,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"})]},Xe.family)}):U.models.map(Xe=>{const ut=_m[Xe.id]??gn;return g.jsx(oi,{onClick:()=>{m(r,Xe.id),ze()},selected:d===Xe.id,icon:g.jsx(ut,{className:"h-4 w-4 text-muted-foreground"}),label:U.id==="cursor"?vb(Xe.label,Xe.id):Xe.label},Xe.id)})}}),ue?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[re==="fast"?g.jsx(qr,{className:"h-3.5 w-3.5"}):g.jsx(Ao,{className:"h-3.5 w-3.5"}),g.jsx("span",{className:"hidden md:inline",children:re==="fast"?"Fast":"Standard"}),g.jsx("span",{className:"md:hidden",children:re==="fast"?"Fast":"Std"})]}),triggerClassName:re==="fast"?"text-emerald-500 dark:text-emerald-400":void 0,children:ze=>g.jsxs(g.Fragment,{children:[ae.filter(AH).map(He=>g.jsx(oi,{onClick:()=>{m(r,He.id),ze()},selected:d===He.id,icon:g.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"}),label:"Standard"},He.id)),ae.filter(MH).map(He=>g.jsx(oi,{onClick:()=>{m(r,He.id),ze()},selected:d===He.id,icon:g.jsx(qr,{className:"h-4 w-4 text-muted-foreground"}),label:"Fast"},He.id))]})}):null,Ke,r==="claude"&&T.length>1?g.jsx(La,{trigger:g.jsxs(g.Fragment,{children:[g.jsx(Z,{className:"h-3.5 w-3.5"}),g.jsx("span",{children:((Ve=T.find(ze=>ze.id===X))==null?void 0:Ve.label)??X})]}),children:ze=>T.map(He=>g.jsx(oi,{onClick:()=>{b(He.id),ze()},selected:X===He.id,icon:He.id==="1m"?g.jsx(bk,{className:"h-4 w-4 text-muted-foreground"}):g.jsx(_k,{className:"h-4 w-4 text-muted-foreground"}),label:He.label,description:He.id==="1m"?"Expanded context window":"Standard context window"},He.id))}):null,mt,Ye,Ze]})})}function MH(t){return Lu(t.id)==="fast"}function AH(t){return Lu(t.id)==="standard"}function NH(t){return t.models.length>0}function DH(t){return Lu(t.id)==="standard"}function OH(t){return Lu(t.id)==="fast"}const Eg=t=>{const e=ke.c(16);let n,r,i,s,a;e[0]!==t?({children:n,className:r,shimmerWidth:s,animate:a,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=s,e[5]=a):(n=e[1],r=e[2],i=e[3],s=e[4],a=e[5]);const c=s===void 0?100:s,d=a===void 0?!0:a,u=`${Math.min(c,100)}px`;let f;e[6]!==u?(f={"--shiny-width":u},e[6]=u,e[7]=f):f=e[7];const m=f;let v;e[8]!==d||e[9]!==r?(v=Ce("mx-auto max-w-md text-foreground/50",d?["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),e[8]=d,e[9]=r,e[10]=v):v=e[10];let b;return e[11]!==n||e[12]!==i||e[13]!==m||e[14]!==v?(b=g.jsx("span",{style:m,className:v,...i,children:n}),e[11]=n,e[12]=i,e[13]=m,e[14]=v,e[15]=b):b=e[15],b};function B1(t){return t.split(/[\s_-]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}const jH=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function LH(t){const e=t.trim();for(const n of jH){const r=e.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return e}function sE(t){return t.split("/").pop()||t}function IH(t,e){if(t===void 0)return null;const n=Math.max(0,e-t),r=6e4,i=60*r,s=24*i,a=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<a?`${Math.floor(n/s)}d`:`${Math.floor(n/a)}w`}const PH='button, select, input, textarea, [role="combobox"], [role="listbox"], [data-no-touch-drag]';function oE(t){var e;try{(e=navigator.vibrate)==null||e.call(navigator,t)}catch{}}function Jy({enabled:t,visualElementRef:e,onTap:n,onContextMenu:r,onDragStart:i,onDragMove:s,onDragEnd:a,holdDelay:c=300,contextMenuDelay:d=2500,scrollThreshold:u=8,dragMoveThreshold:f=5}){const[m,v]=_.useState(!1),[b,S]=_.useState(!1),[x,C]=_.useState(null),[k,E]=_.useState(null),R=_.useCallback(j=>{E(j)},[]),M=_.useRef("idle"),O=_.useRef({x:0,y:0}),D=_.useRef(null),P=_.useRef(null),z=_.useRef(n),Y=_.useRef(r),L=_.useRef(i),W=_.useRef(s),V=_.useRef(a);z.current=n,Y.current=r,L.current=i,W.current=s,V.current=a;const F=_.useCallback((j,G)=>{const B=(e==null?void 0:e.current)??k;if(!B)return document.elementFromPoint(j,G);const K=B.style.pointerEvents;B.style.pointerEvents="none";const A=document.elementFromPoint(j,G);return B.style.pointerEvents=K,A},[e,k]),U=_.useCallback(()=>{D.current&&(clearTimeout(D.current),D.current=null),P.current&&(clearTimeout(P.current),P.current=null)},[]),H=_.useCallback(()=>{U(),M.current="idle",S(!1),v(!1),C(null)},[U]);return _.useEffect(()=>{if(!k||!t)return;const j=A=>{if(A.target.closest(PH))return;const I=A.touches[0];I&&(O.current={x:I.clientX,y:I.clientY},M.current="holding",D.current=setTimeout(()=>{D.current=null,M.current==="holding"&&(M.current="armed",S(!0),oE(30),P.current=setTimeout(()=>{var T;if(P.current=null,M.current!=="armed")return;oE(100);const $={...O.current};M.current="idle",S(!1),(T=Y.current)==null||T.call(Y,$)},d))},c))},G=A=>{var J,re;const I=M.current;if(I==="idle")return;const $=A.touches[0];if(!$)return;const T=$.clientX-O.current.x,X=$.clientY-O.current.y,Z=Math.sqrt(T*T+X*X);if(I==="holding"){Z>u&&(U(),M.current="idle");return}if(I==="armed"){Z>f&&(P.current&&(clearTimeout(P.current),P.current=null),M.current="dragging",S(!1),v(!0),C({x:$.clientX,y:$.clientY}),A.preventDefault(),(J=L.current)==null||J.call(L,{x:$.clientX,y:$.clientY}));return}if(I==="dragging"){A.preventDefault(),C({x:$.clientX,y:$.clientY});const ae=F($.clientX,$.clientY);(re=W.current)==null||re.call(W,{x:$.clientX,y:$.clientY,elementBelow:ae})}},B=A=>{var $,T;const I=M.current;if(I==="holding"){U(),M.current="idle",S(!1),v(!1),A.preventDefault(),($=z.current)==null||$.call(z);return}if(I==="armed"){H();return}if(I==="dragging"){const X=A.changedTouches[0];if(X){const Z=F(X.clientX,X.clientY);(T=V.current)==null||T.call(V,{x:X.clientX,y:X.clientY,elementBelow:Z})}H()}},K=()=>{var A;M.current==="dragging"&&((A=V.current)==null||A.call(V,{x:0,y:0,elementBelow:null})),H()};return k.addEventListener("touchstart",j,{passive:!1}),k.addEventListener("touchmove",G,{passive:!1}),k.addEventListener("touchend",B),k.addEventListener("touchcancel",K),()=>{k.removeEventListener("touchstart",j),k.removeEventListener("touchmove",G),k.removeEventListener("touchend",B),k.removeEventListener("touchcancel",K),U(),M.current="idle"}},[k,t,c,d,u,f,U,H,F]),{touchRef:R,isDragging:m,isArmed:b,dragPosition:x}}function ZT(t){const e=ke.c(9),{position:n,children:r,className:i}=t;if(!n)return null;let s;e[0]!==n.x||e[1]!==n.y?(s={position:"fixed",left:n.x,top:n.y,transform:"translate(-50%, calc(-100% - 14px))",zIndex:9999,pointerEvents:"none",willChange:"transform"},e[0]=n.x,e[1]=n.y,e[2]=s):s=e[2];let a;e[3]!==i?(a=Ce("flex items-center gap-2 rounded-xl border-2 border-primary/60 bg-card px-3 py-2","shadow-[0_8px_32px_rgba(0,0,0,0.25)] dark:shadow-[0_8px_32px_rgba(0,0,0,0.5)]","min-w-[120px] max-w-[240px]","scale-[1.04]",i),e[3]=i,e[4]=a):a=e[4];let c;return e[5]!==r||e[6]!==s||e[7]!==a?(c=es.createPortal(g.jsx("div",{style:s,className:a,children:r}),document.body),e[5]=r,e[6]=s,e[7]=a,e[8]=c):c=e[8],c}function ex(t){const e=t+"CollectionProvider",[n,r]=Xo(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),a=x=>{const{scope:C,children:k}=x,E=je.useRef(null),R=je.useRef(new Map).current;return g.jsx(i,{scope:C,itemMap:R,collectionRef:E,children:k})};a.displayName=e;const c=t+"CollectionSlot",d=Wl(c),u=je.forwardRef((x,C)=>{const{scope:k,children:E}=x,R=s(c,k),M=Xt(C,R.collectionRef);return g.jsx(d,{ref:M,children:E})});u.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",v=Wl(f),b=je.forwardRef((x,C)=>{const{scope:k,children:E,...R}=x,M=je.useRef(null),O=Xt(C,M),D=s(f,k);return je.useEffect(()=>(D.itemMap.set(M,{ref:M,...R}),()=>void D.itemMap.delete(M))),g.jsx(v,{[m]:"",ref:O,children:E})});b.displayName=f;function S(x){const C=s(t+"CollectionConsumer",x);return je.useCallback(()=>{const E=C.collectionRef.current;if(!E)return[];const R=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(C.itemMap.values()).sort((D,P)=>R.indexOf(D.ref.current)-R.indexOf(P.ref.current))},[C.collectionRef,C.itemMap])}return[{Provider:a,Slot:u,ItemSlot:b},S,r]}var zH=_.createContext(void 0);function tx(t){const e=_.useContext(zH);return t||e||"ltr"}var bb="rovingFocusGroup.onEntryFocus",BH={bubbles:!1,cancelable:!0},Bh="RovingFocusGroup",[F1,JT,FH]=ex(Bh),[HH,eM]=Xo(Bh,[FH]),[$H,UH]=HH(Bh),tM=_.forwardRef((t,e)=>g.jsx(F1.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(F1.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(WH,{...t,ref:e})})}));tM.displayName=Bh;var WH=_.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...m}=t,v=_.useRef(null),b=Xt(e,v),S=tx(s),[x,C]=bu({prop:a,defaultProp:c??null,onChange:d,caller:Bh}),[k,E]=_.useState(!1),R=Ss(u),M=JT(n),O=_.useRef(!1),[D,P]=_.useState(0);return _.useEffect(()=>{const z=v.current;if(z)return z.addEventListener(bb,R),()=>z.removeEventListener(bb,R)},[R]),g.jsx($H,{scope:n,orientation:r,dir:S,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(z=>C(z),[C]),onItemShiftTab:_.useCallback(()=>E(!0),[]),onFocusableItemAdd:_.useCallback(()=>P(z=>z+1),[]),onFocusableItemRemove:_.useCallback(()=>P(z=>z-1),[]),children:g.jsx(Bt.div,{tabIndex:k||D===0?-1:0,"data-orientation":r,...m,ref:b,style:{outline:"none",...t.style},onMouseDown:nt(t.onMouseDown,()=>{O.current=!0}),onFocus:nt(t.onFocus,z=>{const Y=!O.current;if(z.target===z.currentTarget&&Y&&!k){const L=new CustomEvent(bb,BH);if(z.currentTarget.dispatchEvent(L),!L.defaultPrevented){const W=M().filter(j=>j.focusable),V=W.find(j=>j.active),F=W.find(j=>j.id===x),H=[V,F,...W].filter(Boolean).map(j=>j.ref.current);iM(H,f)}}O.current=!1}),onBlur:nt(t.onBlur,()=>E(!1))})})}),nM="RovingFocusGroupItem",rM=_.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:a,...c}=t,d=Wo(),u=s||d,f=UH(nM,n),m=f.currentTabStopId===u,v=JT(n),{onFocusableItemAdd:b,onFocusableItemRemove:S,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return b(),()=>S()},[r,b,S]),g.jsx(F1.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:g.jsx(Bt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:nt(t.onMouseDown,C=>{r?f.onItemFocus(u):C.preventDefault()}),onFocus:nt(t.onFocus,()=>f.onItemFocus(u)),onKeyDown:nt(t.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){f.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const k=KH(C,f.orientation,f.dir);if(k!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let R=v().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")R.reverse();else if(k==="prev"||k==="next"){k==="prev"&&R.reverse();const M=R.indexOf(C.currentTarget);R=f.loop?GH(R,M+1):R.slice(M+1)}setTimeout(()=>iM(R))}}),children:typeof a=="function"?a({isCurrentTabStop:m,hasTabStop:x!=null}):a})})});rM.displayName=nM;var VH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qH(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function KH(t,e,n){const r=qH(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return VH[r]}function iM(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function GH(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var YH=tM,XH=rM,H1=["Enter"," "],QH=["ArrowDown","PageUp","Home"],sM=["ArrowUp","PageDown","End"],ZH=[...QH,...sM],JH={ltr:[...H1,"ArrowRight"],rtl:[...H1,"ArrowLeft"]},e$={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Fh="Menu",[yh,t$,n$]=ex(Fh),[ic,oM]=Xo(Fh,[n$,sl,eM]),Rg=sl(),aM=eM(),[r$,sc]=ic(Fh),[i$,Hh]=ic(Fh),lM=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:a=!0}=t,c=Rg(e),[d,u]=_.useState(null),f=_.useRef(!1),m=Ss(s),v=tx(i);return _.useEffect(()=>{const b=()=>{f.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>f.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),g.jsx(bg,{...c,children:g.jsx(r$,{scope:e,open:n,onOpenChange:m,content:d,onContentChange:u,children:g.jsx(i$,{scope:e,onClose:_.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:f,dir:v,modal:a,children:r})})})};lM.displayName=Fh;var s$="MenuAnchor",nx=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Rg(n);return g.jsx(Ih,{...i,...r,ref:e})});nx.displayName=s$;var rx="MenuPortal",[o$,cM]=ic(rx,{forceMount:void 0}),uM=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=sc(rx,e);return g.jsx(o$,{scope:e,forceMount:n,children:g.jsx(os,{present:n||s.open,children:g.jsx(Nu,{asChild:!0,container:i,children:r})})})};uM.displayName=rx;var ts="MenuContent",[a$,ix]=ic(ts),dM=_.forwardRef((t,e)=>{const n=cM(ts,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=sc(ts,t.__scopeMenu),a=Hh(ts,t.__scopeMenu);return g.jsx(yh.Provider,{scope:t.__scopeMenu,children:g.jsx(os,{present:r||s.open,children:g.jsx(yh.Slot,{scope:t.__scopeMenu,children:a.modal?g.jsx(l$,{...i,ref:e}):g.jsx(c$,{...i,ref:e})})})})}),l$=_.forwardRef((t,e)=>{const n=sc(ts,t.__scopeMenu),r=_.useRef(null),i=Xt(e,r);return _.useEffect(()=>{const s=r.current;if(s)return ug(s)},[]),g.jsx(sx,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:nt(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),c$=_.forwardRef((t,e)=>{const n=sc(ts,t.__scopeMenu);return g.jsx(sx,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),u$=Wl("MenuContent.ScrollLock"),sx=_.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:v,onDismiss:b,disableOutsideScroll:S,...x}=t,C=sc(ts,n),k=Hh(ts,n),E=Rg(n),R=aM(n),M=t$(n),[O,D]=_.useState(null),P=_.useRef(null),z=Xt(e,P,C.onContentChange),Y=_.useRef(0),L=_.useRef(""),W=_.useRef(0),V=_.useRef(null),F=_.useRef("right"),U=_.useRef(0),H=S?jh:_.Fragment,j=S?{as:u$,allowPinchZoom:!0}:void 0,G=K=>{var re,ae;const A=L.current+K,I=M().filter(ue=>!ue.disabled),$=document.activeElement,T=(re=I.find(ue=>ue.ref.current===$))==null?void 0:re.textValue,X=I.map(ue=>ue.textValue),Z=S$(X,A,T),J=(ae=I.find(ue=>ue.textValue===Z))==null?void 0:ae.ref.current;(function ue(me){L.current=me,window.clearTimeout(Y.current),me!==""&&(Y.current=window.setTimeout(()=>ue(""),1e3))})(A),J&&setTimeout(()=>J.focus())};_.useEffect(()=>()=>window.clearTimeout(Y.current),[]),lg();const B=_.useCallback(K=>{var I,$;return F.current===((I=V.current)==null?void 0:I.side)&&C$(K,($=V.current)==null?void 0:$.area)},[]);return g.jsx(a$,{scope:n,searchRef:L,onItemEnter:_.useCallback(K=>{B(K)&&K.preventDefault()},[B]),onItemLeave:_.useCallback(K=>{var A;B(K)||((A=P.current)==null||A.focus(),D(null))},[B]),onTriggerLeave:_.useCallback(K=>{B(K)&&K.preventDefault()},[B]),pointerGraceTimerRef:W,onPointerGraceIntentChange:_.useCallback(K=>{V.current=K},[]),children:g.jsx(H,{...j,children:g.jsx(Oh,{asChild:!0,trapped:i,onMountAutoFocus:nt(s,K=>{var A;K.preventDefault(),(A=P.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:g.jsx(Au,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:v,onDismiss:b,children:g.jsx(YH,{asChild:!0,...R,dir:k.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:D,onEntryFocus:nt(d,K=>{k.isUsingKeyboardRef.current||K.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(_g,{role:"menu","aria-orientation":"vertical","data-state":RM(C.open),"data-radix-menu-content":"",dir:k.dir,...E,...x,ref:z,style:{outline:"none",...x.style},onKeyDown:nt(x.onKeyDown,K=>{const I=K.target.closest("[data-radix-menu-content]")===K.currentTarget,$=K.ctrlKey||K.altKey||K.metaKey,T=K.key.length===1;I&&(K.key==="Tab"&&K.preventDefault(),!$&&T&&G(K.key));const X=P.current;if(K.target!==X||!ZH.includes(K.key))return;K.preventDefault();const J=M().filter(re=>!re.disabled).map(re=>re.ref.current);sM.includes(K.key)&&J.reverse(),y$(J)}),onBlur:nt(t.onBlur,K=>{K.currentTarget.contains(K.target)||(window.clearTimeout(Y.current),L.current="")}),onPointerMove:nt(t.onPointerMove,xh(K=>{const A=K.target,I=U.current!==K.clientX;if(K.currentTarget.contains(A)&&I){const $=K.clientX>U.current?"right":"left";F.current=$,U.current=K.clientX}}))})})})})})})});dM.displayName=ts;var d$="MenuGroup",ox=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Bt.div,{role:"group",...r,ref:e})});ox.displayName=d$;var h$="MenuLabel",hM=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Bt.div,{...r,ref:e})});hM.displayName=h$;var Dp="MenuItem",aE="menu.itemSelect",Tg=_.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=_.useRef(null),a=Hh(Dp,t.__scopeMenu),c=ix(Dp,t.__scopeMenu),d=Xt(e,s),u=_.useRef(!1),f=()=>{const m=s.current;if(!n&&m){const v=new CustomEvent(aE,{bubbles:!0,cancelable:!0});m.addEventListener(aE,b=>r==null?void 0:r(b),{once:!0}),_4(m,v),v.defaultPrevented?u.current=!1:a.onClose()}};return g.jsx(fM,{...i,ref:d,disabled:n,onClick:nt(t.onClick,f),onPointerDown:m=>{var v;(v=t.onPointerDown)==null||v.call(t,m),u.current=!0},onPointerUp:nt(t.onPointerUp,m=>{var v;u.current||(v=m.currentTarget)==null||v.click()}),onKeyDown:nt(t.onKeyDown,m=>{const v=c.searchRef.current!=="";n||v&&m.key===" "||H1.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});Tg.displayName=Dp;var fM=_.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,a=ix(Dp,n),c=aM(n),d=_.useRef(null),u=Xt(e,d),[f,m]=_.useState(!1),[v,b]=_.useState("");return _.useEffect(()=>{const S=d.current;S&&b((S.textContent??"").trim())},[s.children]),g.jsx(yh.ItemSlot,{scope:n,disabled:r,textValue:i??v,children:g.jsx(XH,{asChild:!0,...c,focusable:!r,children:g.jsx(Bt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:nt(t.onPointerMove,xh(S=>{r?a.onItemLeave(S):(a.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:nt(t.onPointerLeave,xh(S=>a.onItemLeave(S))),onFocus:nt(t.onFocus,()=>m(!0)),onBlur:nt(t.onBlur,()=>m(!1))})})})}),f$="MenuCheckboxItem",mM=_.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return g.jsx(_M,{scope:t.__scopeMenu,checked:n,children:g.jsx(Tg,{role:"menuitemcheckbox","aria-checked":Op(n)?"mixed":n,...i,ref:e,"data-state":lx(n),onSelect:nt(i.onSelect,()=>r==null?void 0:r(Op(n)?!0:!n),{checkForDefaultPrevented:!1})})})});mM.displayName=f$;var pM="MenuRadioGroup",[m$,p$]=ic(pM,{value:void 0,onValueChange:()=>{}}),gM=_.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Ss(r);return g.jsx(m$,{scope:t.__scopeMenu,value:n,onValueChange:s,children:g.jsx(ox,{...i,ref:e})})});gM.displayName=pM;var vM="MenuRadioItem",bM=_.forwardRef((t,e)=>{const{value:n,...r}=t,i=p$(vM,t.__scopeMenu),s=n===i.value;return g.jsx(_M,{scope:t.__scopeMenu,checked:s,children:g.jsx(Tg,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":lx(s),onSelect:nt(r.onSelect,()=>{var a;return(a=i.onValueChange)==null?void 0:a.call(i,n)},{checkForDefaultPrevented:!1})})})});bM.displayName=vM;var ax="MenuItemIndicator",[_M,g$]=ic(ax,{checked:!1}),yM=_.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=g$(ax,n);return g.jsx(os,{present:r||Op(s.checked)||s.checked===!0,children:g.jsx(Bt.span,{...i,ref:e,"data-state":lx(s.checked)})})});yM.displayName=ax;var v$="MenuSeparator",xM=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Bt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});xM.displayName=v$;var b$="MenuArrow",SM=_.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=Rg(n);return g.jsx(yg,{...i,...r,ref:e})});SM.displayName=b$;var _$="MenuSub",[Tle,wM]=ic(_$),Xd="MenuSubTrigger",CM=_.forwardRef((t,e)=>{const n=sc(Xd,t.__scopeMenu),r=Hh(Xd,t.__scopeMenu),i=wM(Xd,t.__scopeMenu),s=ix(Xd,t.__scopeMenu),a=_.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,u={__scopeMenu:t.__scopeMenu},f=_.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),d(null)}},[c,d]),g.jsx(nx,{asChild:!0,...u,children:g.jsx(fM,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":RM(n.open),...t,ref:Cy(e,i.onTriggerChange),onClick:m=>{var v;(v=t.onClick)==null||v.call(t,m),!(t.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:nt(t.onPointerMove,xh(m=>{s.onItemEnter(m),!m.defaultPrevented&&!t.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:nt(t.onPointerLeave,xh(m=>{var b,S;f();const v=(b=n.content)==null?void 0:b.getBoundingClientRect();if(v){const x=(S=n.content)==null?void 0:S.dataset.side,C=x==="right",k=C?-5:5,E=v[C?"left":"right"],R=v[C?"right":"left"];s.onPointerGraceIntentChange({area:[{x:m.clientX+k,y:m.clientY},{x:E,y:v.top},{x:R,y:v.top},{x:R,y:v.bottom},{x:E,y:v.bottom}],side:x}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(m),m.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:nt(t.onKeyDown,m=>{var b;const v=s.searchRef.current!=="";t.disabled||v&&m.key===" "||JH[r.dir].includes(m.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),m.preventDefault())})})})});CM.displayName=Xd;var kM="MenuSubContent",EM=_.forwardRef((t,e)=>{const n=cM(ts,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=sc(ts,t.__scopeMenu),a=Hh(ts,t.__scopeMenu),c=wM(kM,t.__scopeMenu),d=_.useRef(null),u=Xt(e,d);return g.jsx(yh.Provider,{scope:t.__scopeMenu,children:g.jsx(os,{present:r||s.open,children:g.jsx(yh.Slot,{scope:t.__scopeMenu,children:g.jsx(sx,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:u,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var m;a.isUsingKeyboardRef.current&&((m=d.current)==null||m.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:nt(t.onFocusOutside,f=>{f.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:nt(t.onEscapeKeyDown,f=>{a.onClose(),f.preventDefault()}),onKeyDown:nt(t.onKeyDown,f=>{var b;const m=f.currentTarget.contains(f.target),v=e$[a.dir].includes(f.key);m&&v&&(s.onOpenChange(!1),(b=c.trigger)==null||b.focus(),f.preventDefault())})})})})})});EM.displayName=kM;function RM(t){return t?"open":"closed"}function Op(t){return t==="indeterminate"}function lx(t){return Op(t)?"indeterminate":t?"checked":"unchecked"}function y$(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function x$(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function S$(t,e,n){const i=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let a=x$(t,Math.max(s,0));i.length===1&&(a=a.filter(u=>u!==n));const d=a.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return d!==n?d:void 0}function w$(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,a=e.length-1;s<e.length;a=s++){const c=e[s],d=e[a],u=c.x,f=c.y,m=d.x,v=d.y;f>r!=v>r&&n<(m-u)*(r-f)/(v-f)+u&&(i=!i)}return i}function C$(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return w$(n,e)}function xh(t){return e=>e.pointerType==="mouse"?t(e):void 0}var k$=lM,E$=nx,R$=uM,T$=dM,M$=ox,A$=hM,N$=Tg,D$=mM,O$=gM,j$=bM,L$=yM,I$=xM,P$=SM,z$=CM,B$=EM,cx="ContextMenu",[F$,Mle]=Xo(cx,[oM]),Xr=oM(),[H$,TM]=F$(cx),MM=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:r,dir:i,modal:s=!0}=t,[a,c]=_.useState(!1),d=Xr(e),u=Ss(r),f=_.useCallback(m=>{c(m),u(m)},[u]);return g.jsx(H$,{scope:e,open:a,onOpenChange:f,modal:s,children:g.jsx(k$,{...d,dir:i,open:a,onOpenChange:f,modal:s,children:n})})};MM.displayName=cx;var AM="ContextMenuTrigger",NM=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=t,s=TM(AM,n),a=Xr(n),c=_.useRef({x:0,y:0}),d=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...c.current})}),u=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(u.current),[]),m=v=>{c.current={x:v.clientX,y:v.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),g.jsxs(g.Fragment,{children:[g.jsx(E$,{...a,virtualRef:d}),g.jsx(Bt.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:nt(t.onContextMenu,v=>{f(),m(v),v.preventDefault()}),onPointerDown:r?t.onPointerDown:nt(t.onPointerDown,ym(v=>{f(),u.current=window.setTimeout(()=>m(v),700)})),onPointerMove:r?t.onPointerMove:nt(t.onPointerMove,ym(f)),onPointerCancel:r?t.onPointerCancel:nt(t.onPointerCancel,ym(f)),onPointerUp:r?t.onPointerUp:nt(t.onPointerUp,ym(f))})]})});NM.displayName=AM;var $$="ContextMenuPortal",DM=t=>{const{__scopeContextMenu:e,...n}=t,r=Xr(e);return g.jsx(R$,{...r,...n})};DM.displayName=$$;var OM="ContextMenuContent",jM=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=TM(OM,n),s=Xr(n),a=_.useRef(!1);return g.jsx(T$,{...s,...r,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:c=>{var d;(d=t.onCloseAutoFocus)==null||d.call(t,c),!c.defaultPrevented&&a.current&&c.preventDefault(),a.current=!1},onInteractOutside:c=>{var d;(d=t.onInteractOutside)==null||d.call(t,c),!c.defaultPrevented&&!i.modal&&(a.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});jM.displayName=OM;var U$="ContextMenuGroup",W$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(M$,{...i,...r,ref:e})});W$.displayName=U$;var V$="ContextMenuLabel",q$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(A$,{...i,...r,ref:e})});q$.displayName=V$;var K$="ContextMenuItem",LM=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(N$,{...i,...r,ref:e})});LM.displayName=K$;var G$="ContextMenuCheckboxItem",Y$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(D$,{...i,...r,ref:e})});Y$.displayName=G$;var X$="ContextMenuRadioGroup",Q$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(O$,{...i,...r,ref:e})});Q$.displayName=X$;var Z$="ContextMenuRadioItem",J$=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(j$,{...i,...r,ref:e})});J$.displayName=Z$;var eU="ContextMenuItemIndicator",tU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(L$,{...i,...r,ref:e})});tU.displayName=eU;var nU="ContextMenuSeparator",rU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(I$,{...i,...r,ref:e})});rU.displayName=nU;var iU="ContextMenuArrow",sU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(P$,{...i,...r,ref:e})});sU.displayName=iU;var oU="ContextMenuSubTrigger",aU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(z$,{...i,...r,ref:e})});aU.displayName=oU;var lU="ContextMenuSubContent",cU=_.forwardRef((t,e)=>{const{__scopeContextMenu:n,...r}=t,i=Xr(n);return g.jsx(B$,{...i,...r,ref:e,style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cU.displayName=lU;function ym(t){return e=>e.pointerType!=="mouse"?t(e):void 0}var uU=MM,dU=NM,hU=DM,IM=jM,PM=LM;const ux=uU,dx=dU,Mg=_.forwardRef((t,e)=>{const n=ke.c(9);let r,i;n[0]!==t?({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i):(r=n[1],i=n[2]);let s;n[3]!==r?(s=Ce("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg backdrop-blur-md 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",r),n[3]=r,n[4]=s):s=n[4];let a;return n[5]!==i||n[6]!==e||n[7]!==s?(a=g.jsx(hU,{children:g.jsx(IM,{ref:e,className:s,...i})}),n[5]=i,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});Mg.displayName=IM.displayName;const Su=_.forwardRef((t,e)=>{const n=ke.c(9);let r,i;n[0]!==t?({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i):(r=n[1],i=n[2]);let s;n[3]!==r?(s=Ce("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),n[3]=r,n[4]=s):s=n[4];let a;return n[5]!==i||n[6]!==e||n[7]!==s?(a=g.jsx(PM,{ref:e,className:s,...i}),n[5]=i,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});Su.displayName=PM.displayName;function Ag(t){const e=ke.c(12),{open:n,onOpenChange:r,position:i,children:s}=t;let a;e[0]!==i?(a=i?{position:"fixed",left:i.x,top:i.y,width:0,height:0}:void 0,e[0]=i,e[1]=a):a=e[1];let c;e[2]!==a?(c=g.jsx(bH,{style:a}),e[2]=a,e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=Ce("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg backdrop-blur-md","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"),e[4]=d):d=e[4];let u;e[5]!==s?(u=g.jsx(QT,{children:g.jsx(Xy,{side:"bottom",align:"start",sideOffset:4,onOpenAutoFocus:fU,className:d,children:s})}),e[5]=s,e[6]=u):u=e[6];let f;return e[7]!==r||e[8]!==n||e[9]!==c||e[10]!==u?(f=g.jsxs(XT,{open:n,onOpenChange:r,children:[c,u]}),e[7]=r,e[8]=n,e[9]=c,e[10]=u,e[11]=f):f=e[11],f}function fU(t){return t.preventDefault()}function Za(t){const e=ke.c(8),{onSelect:n,className:r,children:i}=t;let s;e[0]!==r?(s=Ce("relative flex w-full cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium outline-hidden transition-colors","hover:bg-accent focus:bg-accent",r),e[0]=r,e[1]=s):s=e[1];let a;e[2]!==n?(a=d=>{d.preventDefault(),n()},e[2]=n,e[3]=a):a=e[3];let c;return e[4]!==i||e[5]!==s||e[6]!==a?(c=g.jsx("button",{type:"button",className:s,onPointerDown:a,children:i}),e[4]=i,e[5]=s,e[6]=a,e[7]=c):c=e[7],c}function mU(t){const e=ke.c(21),{onRemove:n,children:r,mobileMenuPosition:i,onMobileMenuClose:s,skipContextMenu:a}=t;let c;e[0]!==r||e[1]!==n||e[2]!==a?(c=a?r:g.jsxs(ux,{children:[g.jsx(dx,{asChild:!0,children:r}),g.jsx(Mg,{children:g.jsxs(Su,{onSelect:k=>{k.stopPropagation(),n()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[g.jsx(vu,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})})]}),e[0]=r,e[1]=n,e[2]=a,e[3]=c):c=e[3];const d=!!i;let u;e[4]!==s?(u=k=>{k||s==null||s()},e[4]=s,e[5]=u):u=e[5];const f=i??null;let m;e[6]!==s||e[7]!==n?(m=()=>{s==null||s(),n()},e[6]=s,e[7]=n,e[8]=m):m=e[8];let v,b;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=g.jsx(vu,{className:"h-4 w-4"}),b=g.jsx("span",{children:"Hide"}),e[9]=v,e[10]=b):(v=e[9],b=e[10]);let S;e[11]!==m?(S=g.jsxs(Za,{onSelect:m,className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[v,b]}),e[11]=m,e[12]=S):S=e[12];let x;e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==S?(x=g.jsx(Ag,{open:d,onOpenChange:u,position:f,children:S}),e[13]=d,e[14]=u,e[15]=f,e[16]=S,e[17]=x):x=e[17];let C;return e[18]!==c||e[19]!==x?(C=g.jsxs(g.Fragment,{children:[c,x]}),e[18]=c,e[19]=x,e[20]=C):C=e[20],C}function pU(t){const e=ke.c(30),{onRename:n,onDelete:r,children:i,mobileMenuPosition:s,onMobileMenuClose:a,skipContextMenu:c}=t;let d;e[0]!==i||e[1]!==r||e[2]!==n||e[3]!==c?(d=c?i:g.jsxs(ux,{children:[g.jsx(dx,{asChild:!0,children:i}),g.jsxs(Mg,{children:[g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),n()},children:[g.jsx(Ul,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Rename Feature"})]}),g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),r()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[g.jsx(vu,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Delete Feature"})]})]})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=c,e[4]=d):d=e[4];const u=!!s;let f;e[5]!==a?(f=D=>{D||a==null||a()},e[5]=a,e[6]=f):f=e[6];const m=s??null;let v;e[7]!==a||e[8]!==n?(v=()=>{a==null||a(),n()},e[7]=a,e[8]=n,e[9]=v):v=e[9];let b,S;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=g.jsx(Ul,{className:"h-4 w-4"}),S=g.jsx("span",{children:"Rename Feature"}),e[10]=b,e[11]=S):(b=e[10],S=e[11]);let x;e[12]!==v?(x=g.jsxs(Za,{onSelect:v,children:[b,S]}),e[12]=v,e[13]=x):x=e[13];let C;e[14]!==r||e[15]!==a?(C=()=>{a==null||a(),r()},e[14]=r,e[15]=a,e[16]=C):C=e[16];let k,E;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx(vu,{className:"h-4 w-4"}),E=g.jsx("span",{children:"Delete Feature"}),e[17]=k,e[18]=E):(k=e[17],E=e[18]);let R;e[19]!==C?(R=g.jsxs(Za,{onSelect:C,className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[k,E]}),e[19]=C,e[20]=R):R=e[20];let M;e[21]!==R||e[22]!==u||e[23]!==f||e[24]!==m||e[25]!==x?(M=g.jsxs(Ag,{open:u,onOpenChange:f,position:m,children:[x,R]}),e[21]=R,e[22]=u,e[23]=f,e[24]=m,e[25]=x,e[26]=M):M=e[26];let O;return e[27]!==d||e[28]!==M?(O=g.jsxs(g.Fragment,{children:[d,M]}),e[27]=d,e[28]=M,e[29]=O):O=e[29],O}function gU(t){const e=ke.c(30),{onRename:n,onDelete:r,children:i,mobileMenuPosition:s,onMobileMenuClose:a,skipContextMenu:c}=t;let d;e[0]!==i||e[1]!==r||e[2]!==n||e[3]!==c?(d=c?i:g.jsxs(ux,{children:[g.jsx(dx,{asChild:!0,children:i}),g.jsxs(Mg,{children:[g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),n()},children:[g.jsx(Ul,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Rename Chat"})]}),g.jsxs(Su,{onSelect:D=>{D.stopPropagation(),r()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[g.jsx(vu,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs font-medium",children:"Delete Chat"})]})]})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=c,e[4]=d):d=e[4];const u=!!s;let f;e[5]!==a?(f=D=>{D||a==null||a()},e[5]=a,e[6]=f):f=e[6];const m=s??null;let v;e[7]!==a||e[8]!==n?(v=()=>{a==null||a(),n()},e[7]=a,e[8]=n,e[9]=v):v=e[9];let b,S;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=g.jsx(Ul,{className:"h-4 w-4"}),S=g.jsx("span",{children:"Rename Chat"}),e[10]=b,e[11]=S):(b=e[10],S=e[11]);let x;e[12]!==v?(x=g.jsxs(Za,{onSelect:v,children:[b,S]}),e[12]=v,e[13]=x):x=e[13];let C;e[14]!==r||e[15]!==a?(C=()=>{a==null||a(),r()},e[14]=r,e[15]=a,e[16]=C):C=e[16];let k,E;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx(vu,{className:"h-4 w-4"}),E=g.jsx("span",{children:"Delete Chat"}),e[17]=k,e[18]=E):(k=e[17],E=e[18]);let R;e[19]!==C?(R=g.jsxs(Za,{onSelect:C,className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[k,E]}),e[19]=C,e[20]=R):R=e[20];let M;e[21]!==R||e[22]!==u||e[23]!==f||e[24]!==m||e[25]!==x?(M=g.jsxs(Ag,{open:u,onOpenChange:f,position:m,children:[x,R]}),e[21]=R,e[22]=u,e[23]=f,e[24]=m,e[25]=x,e[26]=M):M=e[26];let O;return e[27]!==d||e[28]!==M?(O=g.jsxs(g.Fragment,{children:[d,M]}),e[27]=d,e[28]=M,e[29]=O):O=e[29],O}const vU=new Set(["starting","running"]);function bU(t){const e=ke.c(90),{chat:n,activeChatId:r,nowMs:i,showProviderIcon:s,isCompleted:a,onSelectChat:c,onRenameChat:d,onDeleteChat:u,draggable:f,onDragStart:m,onDragEnd:v,isTouchDevice:b,onTouchDragMove:S,onTouchDragEnd:x}=t,C=s===void 0?!1:s,k=a===void 0?!1:a,E=f===void 0?!1:f,R=b===void 0?!1:b;let M;e[0]!==n.lastMessageAt||e[1]!==i?(M=IH(n.lastMessageAt,i),e[0]=n.lastMessageAt,e[1]=i,e[2]=M):M=e[2];const O=M,D=R,P=n.provider?Np[n.provider]:null,[z,Y]=_.useState(null);let L;e[3]!==n.chatId||e[4]!==c?(L=()=>c(n.chatId),e[3]=n.chatId,e[4]=c,e[5]=L):L=e[5];let W;e[6]===Symbol.for("react.memo_cache_sentinel")?(W=it=>Y(it),e[6]=W):W=e[6];let V;e[7]!==n||e[8]!==E||e[9]!==m?(V=E?()=>m==null?void 0:m(n):void 0,e[7]=n,e[8]=E,e[9]=m,e[10]=V):V=e[10];let F;e[11]!==E||e[12]!==S?(F=E?it=>{const{x:ce,y:Re,elementBelow:Ue}=it;return S==null?void 0:S(ce,Re,Ue)}:void 0,e[11]=E,e[12]=S,e[13]=F):F=e[13];let U;e[14]!==E||e[15]!==v||e[16]!==x?(U=it=>{const{x:ce,y:Re,elementBelow:Ue}=it;E&&(x==null||x(ce,Re,Ue),v==null||v())},e[14]=E,e[15]=v,e[16]=x,e[17]=U):U=e[17];let H;e[18]!==U||e[19]!==L||e[20]!==V||e[21]!==F||e[22]!==D?(H={enabled:D,onTap:L,onContextMenu:W,onDragStart:V,onDragMove:F,onDragEnd:U},e[18]=U,e[19]=L,e[20]=V,e[21]=F,e[22]=D,e[23]=H):H=e[23];const{touchRef:j,isArmed:G,isDragging:B,dragPosition:K}=Jy(H),A=D?j:void 0,I=n._id;let $;e[24]!==n.chatId?($=T1(n.chatId),e[24]=n.chatId,e[25]=$):$=e[25];let T;e[26]!==r||e[27]!==n.chatId?(T=r===T1(n.chatId)?"bg-muted hover:bg-muted border-border":"cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 dark:hover:border-slate-400/10",e[26]=r,e[27]=n.chatId,e[28]=T):T=e[28];const X=G&&"scale-[1.03] shadow-md ring-2 ring-primary/50 bg-card border-primary/40",Z=B&&!G&&"opacity-20 scale-[0.98]";let J;e[29]!==T||e[30]!==X||e[31]!==Z?(J=Ce("group flex items-center gap-2 rounded-lg border px-2.5 py-1.5 transition-all duration-150 select-none",T,X,Z),e[29]=T,e[30]=X,e[31]=Z,e[32]=J):J=e[32];const re=E&&!R;let ae;e[33]!==n||e[34]!==E||e[35]!==R||e[36]!==m?(ae=E&&!R?()=>m==null?void 0:m(n):void 0,e[33]=n,e[34]=E,e[35]=R,e[36]=m,e[37]=ae):ae=e[37];const ue=E&&!R?v:void 0;let me;e[38]!==n.chatId||e[39]!==R||e[40]!==c?(me=R?void 0:()=>c(n.chatId),e[38]=n.chatId,e[39]=R,e[40]=c,e[41]=me):me=e[41];let se;e[42]!==n.status||e[43]!==k?(se=vU.has(n.status)?g.jsx(Fn,{className:"size-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):n.status==="waiting_for_user"?g.jsx("div",{className:"relative",children:g.jsxs("div",{className:"rounded-full z-0 size-3.5 flex items-center justify-center",children:[g.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-blue-400/80 animate-ping"}),g.jsx("div",{className:"rounded-full z-0 size-2.5 bg-blue-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):k?g.jsx("div",{className:"relative",children:g.jsxs("div",{className:"rounded-full z-0 size-3.5 flex items-center justify-center",children:[g.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-emerald-400/80 animate-ping"}),g.jsx("div",{className:"rounded-full z-0 size-2.5 bg-emerald-400 ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,e[42]=n.status,e[43]=k,e[44]=se):se=e[44];let oe;e[45]!==P||e[46]!==n.provider||e[47]!==C?(oe=C&&P?g.jsx(P,{className:"size-3.5 flex-shrink-0 text-muted-foreground/80","aria-label":`${n.provider} provider`}):null,e[45]=P,e[46]=n.provider,e[47]=C,e[48]=oe):oe=e[48];let ee;e[49]!==n.status||e[50]!==n.title?(ee=n.status!=="idle"&&n.status!=="waiting_for_user"?g.jsx(Eg,{animate:n.status==="running",shimmerWidth:Math.max(20,n.title.length*3),children:n.title}):n.title,e[49]=n.status,e[50]=n.title,e[51]=ee):ee=e[51];let Q;e[52]!==ee?(Q=g.jsx("span",{className:"min-w-0 flex-1 translate-y-[-0.5px] truncate text-sm",children:ee}),e[52]=ee,e[53]=Q):Q=e[53];let te;e[54]!==O?(te=O?g.jsx("span",{className:"hidden shrink-0 text-[11px] text-muted-foreground opacity-60 md:inline",children:O}):null,e[54]=O,e[55]=te):te=e[55];let he;e[56]!==n._id||e[57]!==A||e[58]!==$||e[59]!==J||e[60]!==re||e[61]!==ae||e[62]!==ue||e[63]!==me||e[64]!==se||e[65]!==oe||e[66]!==Q||e[67]!==te?(he=g.jsxs("div",{ref:A,"data-chat-id":$,className:J,draggable:re,onDragStart:ae,onDragEnd:ue,onContextMenu:_U,onClick:me,children:[se,oe,Q,te]},I),e[56]=n._id,e[57]=A,e[58]=$,e[59]=J,e[60]=re,e[61]=ae,e[62]=ue,e[63]=me,e[64]=se,e[65]=oe,e[66]=Q,e[67]=te,e[68]=he):he=e[68];const ie=he;let xe;e[69]!==n.chatId||e[70]!==d?(xe=()=>d(n.chatId),e[69]=n.chatId,e[70]=d,e[71]=xe):xe=e[71];let Ae;e[72]!==n.chatId||e[73]!==u?(Ae=()=>u(n.chatId),e[72]=n.chatId,e[73]=u,e[74]=Ae):Ae=e[74];let Ke;e[75]===Symbol.for("react.memo_cache_sentinel")?(Ke=()=>Y(null),e[75]=Ke):Ke=e[75];let mt;e[76]!==R||e[77]!==z||e[78]!==ie||e[79]!==xe||e[80]!==Ae?(mt=g.jsx(gU,{onRename:xe,onDelete:Ae,mobileMenuPosition:z,onMobileMenuClose:Ke,skipContextMenu:R,children:ie}),e[76]=R,e[77]=z,e[78]=ie,e[79]=xe,e[80]=Ae,e[81]=mt):mt=e[81];let Ye;e[82]!==n.title?(Ye=g.jsx("span",{className:"text-sm font-medium truncate",children:n.title}),e[82]=n.title,e[83]=Ye):Ye=e[83];let Ze;e[84]!==K||e[85]!==Ye?(Ze=g.jsx(ZT,{position:K,children:Ye}),e[84]=K,e[85]=Ye,e[86]=Ze):Ze=e[86];let tt;return e[87]!==mt||e[88]!==Ze?(tt=g.jsxs(g.Fragment,{children:[mt,Ze]}),e[87]=mt,e[88]=Ze,e[89]=tt):tt=e[89],tt}function _U(t){t.stopPropagation()}function yU(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const Ng=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Iu(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function hx(t){return"nodeType"in t}function hi(t){var e,n;return t?Iu(t)?t:hx(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function fx(t){const{Document:e}=hi(t);return t instanceof e}function $h(t){return Iu(t)?!1:t instanceof hi(t).HTMLElement}function zM(t){return t instanceof hi(t).SVGElement}function Pu(t){return t?Iu(t)?t.document:hx(t)?fx(t)?t:$h(t)||zM(t)?t.ownerDocument:document:document:document}const to=Ng?_.useLayoutEffect:_.useEffect;function mx(t){const e=_.useRef(t);return to(()=>{e.current=t}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function xU(){const t=_.useRef(null),e=_.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=_.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Sh(t,e){e===void 0&&(e=[t]);const n=_.useRef(t);return to(()=>{n.current!==t&&(n.current=t)},e),n}function Uh(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function jp(t){const e=mx(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,r]}function $1(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let _b={};function Wh(t,e){return _.useMemo(()=>{if(e)return e;const n=_b[t]==null?0:_b[t]+1;return _b[t]=n,t+"-"+n},[t,e])}function BM(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const c=Object.entries(a);for(const[d,u]of c){const f=s[d];f!=null&&(s[d]=f+t*u)}return s},{...e})}}const du=BM(1),Lp=BM(-1);function SU(t){return"clientX"in t&&"clientY"in t}function px(t){if(!t)return!1;const{KeyboardEvent:e}=hi(t.target);return e&&t instanceof e}function wU(t){if(!t)return!1;const{TouchEvent:e}=hi(t.target);return e&&t instanceof e}function U1(t){if(wU(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return SU(t)?{x:t.clientX,y:t.clientY}:null}const wu=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[wu.Translate.toString(t),wu.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),lE="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function CU(t){return t.matches(lE)?t:t.querySelector(lE)}const kU={display:"none"};function EU(t){let{id:e,value:n}=t;return je.createElement("div",{id:e,style:kU},n)}function RU(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return je.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function TU(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const FM=_.createContext(null);function MU(t){const e=_.useContext(FM);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function AU(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.useCallback(r=>{let{type:i,event:s}=r;t.forEach(a=>{var c;return(c=a[i])==null?void 0:c.call(a,s)})},[t]),e]}const NU={draggable:`
469
469
  To pick up a draggable item, press the space bar.
470
470
  While dragging, use the arrow keys to move the item.
471
471
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -605,4 +605,4 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
605
605
  `))}function d(b,S,x,C){const k=x.enter("tableCell"),E=x.enter("phrasing"),R=x.containerPhrasing(b,{...C,before:s,after:s});return E(),k(),R}function u(b,S){return Kre(b,{align:S,alignDelimiters:r,padding:n,stringLength:i})}function f(b,S,x){const C=b.children;let k=-1;const E=[],R=S.enter("table");for(;++k<C.length;)E[k]=m(C[k],S,x);return R(),E}function m(b,S,x){const C=b.children;let k=-1;const E=[],R=S.enter("tableRow");for(;++k<C.length;)E[k]=d(C[k],b,S,x);return R(),E}function v(b,S,x){let C=z6.inlineCode(b,S,x);return x.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function jie(){return{exit:{taskListCheckValueChecked:tR,taskListCheckValueUnchecked:tR,paragraph:Iie}}}function Lie(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Pie}}}function tR(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Iie(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,a;for(;++s<i.length;){const c=i[s];if(c.type==="paragraph"){a=c;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function Pie(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",c=n.createTracker(r);s&&c.move(a);let d=z6.listItem(t,e,n,{...r,...c.current()});return s&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),d;function u(f){return f+a}}function zie(){return[gre(),Pre(),Hre(),Rie(),jie()]}function Bie(t){return{extensions:[vre(),zre(t),$re(),Oie(t),Lie()]}}const Fie={tokenize:qie,partial:!0},B6={tokenize:Kie,partial:!0},F6={tokenize:Gie,partial:!0},H6={tokenize:Yie,partial:!0},Hie={tokenize:Xie,partial:!0},$6={name:"wwwAutolink",tokenize:Wie,previous:W6},U6={name:"protocolAutolink",tokenize:Vie,previous:V6},ta={name:"emailAutolink",tokenize:Uie,previous:q6},io={};function $ie(){return{text:io}}let jl=48;for(;jl<123;)io[jl]=ta,jl++,jl===58?jl=65:jl===91&&(jl=97);io[43]=ta;io[45]=ta;io[46]=ta;io[95]=ta;io[72]=[ta,U6];io[104]=[ta,U6];io[87]=[ta,$6];io[119]=[ta,$6];function Uie(t,e,n){const r=this;let i,s;return a;function a(m){return!ly(m)||!q6.call(r,r.previous)||dS(r.events)?n(m):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),c(m))}function c(m){return ly(m)?(t.consume(m),c):m===64?(t.consume(m),d):n(m)}function d(m){return m===46?t.check(Hie,f,u)(m):m===45||m===95||Ir(m)?(s=!0,t.consume(m),d):f(m)}function u(m){return t.consume(m),i=!0,d}function f(m){return s&&i&&Gr(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(m)):n(m)}}function Wie(t,e,n){const r=this;return i;function i(a){return a!==87&&a!==119||!W6.call(r,r.previous)||dS(r.events)?n(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Fie,t.attempt(B6,t.attempt(F6,s),n),n)(a))}function s(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function Vie(t,e,n){const r=this;let i="",s=!1;return a;function a(m){return(m===72||m===104)&&V6.call(r,r.previous)&&!dS(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(m),t.consume(m),c):n(m)}function c(m){if(Gr(m)&&i.length<5)return i+=String.fromCodePoint(m),t.consume(m),c;if(m===58){const v=i.toLowerCase();if(v==="http"||v==="https")return t.consume(m),d}return n(m)}function d(m){return m===47?(t.consume(m),s?u:(s=!0,d)):n(m)}function u(m){return m===null||Xp(m)||un(m)||ec(m)||Kg(m)?n(m):t.attempt(B6,t.attempt(F6,f),n)(m)}function f(m){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(m)}}function qie(t,e,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,t.consume(a),i):a===46&&r===3?(t.consume(a),s):n(a)}function s(a){return a===null?n(a):e(a)}}function Kie(t,e,n){let r,i,s;return a;function a(u){return u===46||u===95?t.check(H6,d,c)(u):u===null||un(u)||ec(u)||u!==45&&Kg(u)?d(u):(s=!0,t.consume(u),a)}function c(u){return u===95?r=!0:(i=r,r=void 0),t.consume(u),a}function d(u){return i||r||!s?n(u):e(u)}}function Gie(t,e){let n=0,r=0;return i;function i(a){return a===40?(n++,t.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(H6,e,s)(a):a===null||un(a)||ec(a)?e(a):(t.consume(a),i)}function s(a){return a===41&&r++,t.consume(a),i}}function Yie(t,e,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(t.consume(c),r):c===38?(t.consume(c),s):c===93?(t.consume(c),i):c===60||c===null||un(c)||ec(c)?e(c):n(c)}function i(c){return c===null||c===40||c===91||un(c)||ec(c)?e(c):r(c)}function s(c){return Gr(c)?a(c):n(c)}function a(c){return c===59?(t.consume(c),r):Gr(c)?(t.consume(c),a):n(c)}}function Xie(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Ir(s)?n(s):e(s)}}function W6(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||un(t)}function V6(t){return!Gr(t)}function q6(t){return!(t===47||ly(t))}function ly(t){return t===43||t===45||t===46||t===95||Ir(t)}function dS(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Qie={tokenize:sse,partial:!0};function Zie(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:nse,continuation:{tokenize:rse},exit:ise}},text:{91:{name:"gfmFootnoteCall",tokenize:tse},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Jie,resolveTo:ese}}}}function Jie(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const d=r.events[i][1];if(d.type==="labelImage"){a=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!a||!a._balanced)return n(d);const u=xs(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(d):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),e(d))}}function ese(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",a,e],["exit",a,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...c),t}function tse(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return c;function c(m){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(t.enter("gfmFootnoteCallMarker"),t.consume(m),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(m){if(s>999||m===93&&!a||m===null||m===91||un(m))return n(m);if(m===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return i.includes(xs(r.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(m)}return un(m)||(a=!0),s++,t.consume(m),m===92?f:u}function f(m){return m===91||m===92||m===93?(t.consume(m),s++,u):u(m)}}function nse(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,c;return d;function d(S){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(S){return S===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",f):n(S)}function f(S){if(a>999||S===93&&!c||S===null||S===91||un(S))return n(S);if(S===93){t.exit("chunkString");const x=t.exit("gfmFootnoteDefinitionLabelString");return s=xs(r.sliceSerialize(x)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(S),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return un(S)||(c=!0),a++,t.consume(S),S===92?m:f}function m(S){return S===91||S===92||S===93?(t.consume(S),a++,f):f(S)}function v(S){return S===58?(t.enter("definitionMarker"),t.consume(S),t.exit("definitionMarker"),i.includes(s)||i.push(s),Vt(t,b,"gfmFootnoteDefinitionWhitespace")):n(S)}function b(S){return e(S)}}function rse(t,e,n){return t.check(ef,e,t.attempt(Qie,e,n))}function ise(t){t.exit("gfmFootnoteDefinition")}function sse(t,e,n){const r=this;return Vt(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(s):n(s)}}function ose(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,c){let d=-1;for(;++d<a.length;)if(a[d][0]==="enter"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._close){let u=d;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[d][1].end.offset-a[d][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[d][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[d][1].end)},m={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[d][1].start)},v=[["enter",f,c],["enter",a[u][1],c],["exit",a[u][1],c],["enter",m,c]],b=c.parser.constructs.insideSpan.null;b&&Oi(v,v.length,0,Gg(b,a.slice(u+1,d),c)),Oi(v,v.length,0,[["exit",m,c],["enter",a[d][1],c],["exit",a[d][1],c],["exit",f,c]]),Oi(a,u-1,d-u+3,v),d=u+v.length-2;break}}for(d=-1;++d<a.length;)a[d][1].type==="strikethroughSequenceTemporary"&&(a[d][1].type="data");return a}function s(a,c,d){const u=this.previous,f=this.events;let m=0;return v;function v(S){return u===126&&f[f.length-1][1].type!=="characterEscape"?d(S):(a.enter("strikethroughSequenceTemporary"),b(S))}function b(S){const x=Eu(u);if(S===126)return m>1?d(S):(a.consume(S),m++,b);if(m<2&&!n)return d(S);const C=a.exit("strikethroughSequenceTemporary"),k=Eu(S);return C._open=!k||k===2&&!!x,C._close=!x||x===2&&!!k,c(S)}}}class ase{constructor(){this.map=[]}add(e,n,r){lse(this,e,n,r)}consume(e){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function lse(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function cse(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function use(){return{flow:{null:{name:"table",tokenize:dse,resolveAll:hse}}}}function dse(t,e,n){const r=this;let i=0,s=0,a;return c;function c(L){let W=r.events.length-1;for(;W>-1;){const U=r.events[W][1].type;if(U==="lineEnding"||U==="linePrefix")W--;else break}const V=W>-1?r.events[W][1].type:null,F=V==="tableHead"||V==="tableRow"?D:d;return F===D&&r.parser.lazy[r.now().line]?n(L):F(L)}function d(L){return t.enter("tableHead"),t.enter("tableRow"),u(L)}function u(L){return L===124||(a=!0,s+=1),f(L)}function f(L){return L===null?n(L):bt(L)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(L),t.exit("lineEnding"),b):n(L):zt(L)?Vt(t,f,"whitespace")(L):(s+=1,a&&(a=!1,i+=1),L===124?(t.enter("tableCellDivider"),t.consume(L),t.exit("tableCellDivider"),a=!0,f):(t.enter("data"),m(L)))}function m(L){return L===null||L===124||un(L)?(t.exit("data"),f(L)):(t.consume(L),L===92?v:m)}function v(L){return L===92||L===124?(t.consume(L),m):m(L)}function b(L){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(L):(t.enter("tableDelimiterRow"),a=!1,zt(L)?Vt(t,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):S(L))}function S(L){return L===45||L===58?C(L):L===124?(a=!0,t.enter("tableCellDivider"),t.consume(L),t.exit("tableCellDivider"),x):O(L)}function x(L){return zt(L)?Vt(t,C,"whitespace")(L):C(L)}function C(L){return L===58?(s+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(L),t.exit("tableDelimiterMarker"),k):L===45?(s+=1,k(L)):L===null||bt(L)?M(L):O(L)}function k(L){return L===45?(t.enter("tableDelimiterFiller"),E(L)):O(L)}function E(L){return L===45?(t.consume(L),E):L===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(L),t.exit("tableDelimiterMarker"),R):(t.exit("tableDelimiterFiller"),R(L))}function R(L){return zt(L)?Vt(t,M,"whitespace")(L):M(L)}function M(L){return L===124?S(L):L===null||bt(L)?!a||i!==s?O(L):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(L)):O(L)}function O(L){return n(L)}function D(L){return t.enter("tableRow"),P(L)}function P(L){return L===124?(t.enter("tableCellDivider"),t.consume(L),t.exit("tableCellDivider"),P):L===null||bt(L)?(t.exit("tableRow"),e(L)):zt(L)?Vt(t,P,"whitespace")(L):(t.enter("data"),z(L))}function z(L){return L===null||L===124||un(L)?(t.exit("data"),P(L)):(t.consume(L),L===92?Y:z)}function Y(L){return L===92||L===124?(t.consume(L),z):z(L)}}function hse(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],c=!1,d=0,u,f,m;const v=new ase;for(;++n<t.length;){const b=t[n],S=b[1];b[0]==="enter"?S.type==="tableHead"?(c=!1,d!==0&&(nR(v,e,d,u,f),f=void 0,d=0),u={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},v.add(n,0,[["enter",u,e]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(r=!0,m=void 0,s=[0,0,0,0],a=[0,n+1,0,0],c&&(c=!1,f={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},v.add(n,0,[["enter",f,e]])),i=S.type==="tableDelimiterRow"?2:f?3:1):i&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],m=Bm(v,e,s,i,void 0,m),s=[0,0,0,0]),a[2]=n)):S.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],m=Bm(v,e,s,i,void 0,m)),s=a,a=[s[1],n,0,0])):S.type==="tableHead"?(c=!0,d=n):S.type==="tableRow"||S.type==="tableDelimiterRow"?(d=n,s[1]!==0?(a[0]=a[1],m=Bm(v,e,s,i,n,m)):a[1]!==0&&(m=Bm(v,e,a,i,n,m)),i=0):i&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(a[3]=n)}for(d!==0&&nR(v,e,d,u,f),v.consume(e.events),n=-1;++n<e.events.length;){const b=e.events[n];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=cse(e.events,n))}return t}function Bm(t,e,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(s.end=Object.assign({},nu(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const d=nu(e.events,n[1]);if(s={type:a,start:Object.assign({},d),end:Object.assign({},d)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const u=nu(e.events,n[2]),f=nu(e.events,n[3]),m={type:c,start:Object.assign({},u),end:Object.assign({},f)};if(t.add(n[2],0,[["enter",m,e]]),r!==2){const v=e.events[n[2]],b=e.events[n[3]];if(v[1].end=Object.assign({},b[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const S=n[2]+1,x=n[3]-n[2]-1;t.add(S,x,[])}}t.add(n[3]+1,0,[["exit",m,e]])}return i!==void 0&&(s.end=Object.assign({},nu(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function nR(t,e,n,r,i){const s=[],a=nu(e.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,e])),r.end=Object.assign({},a),s.push(["exit",r,e]),t.add(n+1,0,s)}function nu(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const fse={name:"tasklistCheck",tokenize:pse};function mse(){return{text:{91:fse}}}function pse(t,e,n){const r=this;return i;function i(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(d),t.exit("taskListCheckMarker"),s)}function s(d){return un(d)?(t.enter("taskListCheckValueUnchecked"),t.consume(d),t.exit("taskListCheckValueUnchecked"),a):d===88||d===120?(t.enter("taskListCheckValueChecked"),t.consume(d),t.exit("taskListCheckValueChecked"),a):n(d)}function a(d){return d===93?(t.enter("taskListCheckMarker"),t.consume(d),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),c):n(d)}function c(d){return bt(d)?e(d):zt(d)?t.check({tokenize:gse},e,n)(d):n(d)}}function gse(t,e,n){return Vt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function vse(t){return r6([$ie(),Zie(),ose(t),use(),mse()])}const bse={};function rf(t){const e=this,n=t||bse,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(vse(n)),s.push(zie()),a.push(Bie(n))}function _se(t){const e=ke.c(11),{content:n,attachments:r}=t,[i,s]=_.useState(null),a=(r==null?void 0:r.filter(Sse))??[],c=(r==null?void 0:r.filter(xse))??[],d=a.find(k=>k.id===i)??null;_.useEffect(()=>{d||s(null)},[d]);const u="flex gap-2 justify-end",f="max-w-[85%] sm:max-w-[80%] min-w-0 rounded-[20px] py-1.5 px-3.5 bg-muted text-primary border border-border prose prose-sm prose-invert break-words [overflow-wrap:anywhere] [&_p]:whitespace-pre-line",m=c.length?g.jsx("div",{className:"mb-2 flex flex-col gap-2 max-w-[420px]",children:c.map(yse)}):null,v=a.length?g.jsx("div",{className:"mb-2 grid max-w-[420px] grid-cols-2 gap-2",children:a.map(k=>g.jsxs("button",{type:"button",className:"overflow-hidden rounded-lg border border-border/80 bg-background/70 text-left cursor-zoom-in",onClick:()=>s(k.id),children:[g.jsx("img",{src:k.previewUrl,alt:k.name,className:"h-full max-h-[220px] w-full object-cover"}),g.jsx("div",{className:"border-t border-border/60 px-2 py-1 text-[11px] text-muted-foreground",children:k.name})]},k.id))}):null;let b;e[0]!==n?(b=n.trim()?g.jsx(nf,{remarkPlugins:[rf],components:Zh(),children:n}):null,e[0]=n,e[1]=b):b=e[1];let S;e[2]!==m||e[3]!==v||e[4]!==b?(S=g.jsx("div",{className:u,children:g.jsxs("div",{className:f,children:[m,v,b]})}),e[2]=m,e[3]=v,e[4]=b,e[5]=S):S=e[5];let x;e[6]!==d?(x=d?g.jsx("button",{type:"button",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4 cursor-zoom-out",onClick:()=>s(null),children:g.jsx("img",{src:d.previewUrl,alt:d.name,className:"max-h-full max-w-full rounded-xl shadow-2xl"})}):null,e[6]=d,e[7]=x):x=e[7];let C;return e[8]!==S||e[9]!==x?(C=g.jsxs(g.Fragment,{children:[S,x]}),e[8]=S,e[9]=x,e[10]=C):C=e[10],C}function yse(t){return g.jsxs("a",{href:t.previewUrl,target:"_blank",rel:"noreferrer",className:"flex items-center gap-3 rounded-lg border border-border/80 bg-background/70 px-3 py-2 no-underline transition-colors hover:bg-background",children:[g.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-muted text-muted-foreground",children:g.jsx(ag,{className:"h-5 w-5"})}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{className:"truncate text-sm text-foreground",children:t.name}),g.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[Math.max(1,Math.round(t.sizeBytes/1024))," KB"]})]})]},t.id)}function xse(t){return t.type==="document"||t.type==="text"}function Sse(t){return t.type==="image"}function wse(t){const e=ke.c(2),{json:n}=t;let r;return e[0]!==n?(r=g.jsx("div",{className:"flex gap-3 justify-start",children:g.jsx("div",{className:"flex-1 max-w-[90%]",children:g.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted rounded-lg p-3 overflow-auto max-h-96",children:n})})}),e[0]=n,e[1]=r):r=e[1],r}function K6(t){const e=ke.c(22),{title:n,count:r,children:i,badge:s}=t,[a,c]=_.useState(!1);if(r===0)return null;let d;e[0]!==a?(d=()=>c(!a),e[0]=a,e[1]=d):d=e[1];const u=a&&"rotate-90";let f;e[2]!==u?(f=Ce("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",u),e[2]=u,e[3]=f):f=e[3];let m;e[4]!==f?(m=g.jsx(Ni,{className:f}),e[4]=f,e[5]=m):m=e[5];let v;e[6]!==n?(v=g.jsx("span",{className:"text-muted-foreground font-medium",children:n}),e[6]=n,e[7]=v):v=e[7];let b;e[8]!==r?(b=g.jsx("span",{className:"text-muted-foreground/60",children:r}),e[8]=r,e[9]=b):b=e[9];let S;e[10]!==s||e[11]!==d||e[12]!==m||e[13]!==v||e[14]!==b?(S=g.jsxs("button",{onClick:d,className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[m,v,b,s]}),e[10]=s,e[11]=d,e[12]=m,e[13]=v,e[14]=b,e[15]=S):S=e[15];let x;e[16]!==i||e[17]!==a?(x=a&&g.jsx("div",{className:"ml-5",children:i}),e[16]=i,e[17]=a,e[18]=x):x=e[18];let C;return e[19]!==S||e[20]!==x?(C=g.jsxs("div",{className:"flex flex-col gap-1.5",children:[S,x]}),e[19]=S,e[20]=x,e[21]=C):C=e[21],C}function d1(t){const e=ke.c(13),{title:n,items:r,icon:i,getIcon:s}=t;if(r.length===0)return null;const a=r.length;let c;if(e[0]!==s||e[1]!==i||e[2]!==r){let f;e[4]!==s||e[5]!==i?(f=m=>g.jsx(zD,{icon:s?s(m):i,children:m},m),e[4]=s,e[5]=i,e[6]=f):f=e[6],c=r.map(f),e[0]=s,e[1]=i,e[2]=r,e[3]=c}else c=e[3];let d;e[7]!==c?(d=g.jsx("div",{className:"flex flex-wrap gap-1.5",children:c}),e[7]=c,e[8]=d):d=e[8];let u;return e[9]!==r.length||e[10]!==d||e[11]!==n?(u=g.jsx(K6,{title:n,count:a,children:d}),e[9]=r.length,e[10]=d,e[11]=n,e[12]=u):u=e[12],u}function Cse(t){const e=t.match(/^mcp__([^_]+)__(.+)$/);return e?{server:e[1],tool:e[2]}:null}function G6(t){const e=ke.c(4),{status:n}=t,r=n==="connected"?"bg-emerald-500":n==="pending"?"bg-yellow-500":"bg-red-500";let i;e[0]!==r?(i=Ce("inline-block h-2 w-2 rounded-full shrink-0",r),e[0]=r,e[1]=i):i=e[1];let s;return e[2]!==i?(s=g.jsx("span",{className:i}),e[2]=i,e[3]=s):s=e[3],s}function kse(t){switch(t){case"connected":return"Connected";case"failed":return"Failed";case"needs-auth":return"Needs auth";case"pending":return"Connecting...";case"disabled":return"Disabled";default:return t}}function Y6(t){const e=ke.c(38),{server:n}=t,[r,i]=_.useState(!1),s=n.status==="connected";let a;e[0]!==s||e[1]!==r||e[2]!==n.tools?(a=()=>s&&n.tools.length>0&&i(!r),e[0]=s,e[1]=r,e[2]=n.tools,e[3]=a):a=e[3];const c=s&&n.tools.length>0&&"cursor-pointer hover:opacity-60 transition-opacity";let d;e[4]!==c?(d=Ce("flex items-center gap-1.5",c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==s||e[7]!==r||e[8]!==n.tools?(u=s&&n.tools.length>0&&g.jsx(Ni,{className:Ce("h-3 w-3 text-muted-foreground transition-transform duration-200",r&&"rotate-90")}),e[6]=s,e[7]=r,e[8]=n.tools,e[9]=u):u=e[9];let f;e[10]!==n.status?(f=g.jsx(G6,{status:n.status}),e[10]=n.status,e[11]=f):f=e[11];let m;e[12]!==n.name?(m=B1(n.name),e[12]=n.name,e[13]=m):m=e[13];let v;e[14]!==m?(v=g.jsx("span",{className:"text-muted-foreground font-medium",children:m}),e[14]=m,e[15]=v):v=e[15];let b;e[16]!==s||e[17]!==n.status||e[18]!==n.tools?(b=s?g.jsxs("span",{className:"text-muted-foreground/50",children:[n.tools.length," tools"]}):g.jsx("span",{className:"text-muted-foreground/50",children:kse(n.status)}),e[16]=s,e[17]=n.status,e[18]=n.tools,e[19]=b):b=e[19];let S;e[20]!==a||e[21]!==d||e[22]!==u||e[23]!==f||e[24]!==v||e[25]!==b?(S=g.jsxs("button",{onClick:a,className:d,children:[u,f,v,b]}),e[20]=a,e[21]=d,e[22]=u,e[23]=f,e[24]=v,e[25]=b,e[26]=S):S=e[26];let x;e[27]!==s||e[28]!==n.error?(x=!s&&n.error&&g.jsx("span",{className:"text-destructive ml-5",children:n.error}),e[27]=s,e[28]=n.error,e[29]=x):x=e[29];let C;e[30]!==r||e[31]!==n.name||e[32]!==n.tools?(C=r&&n.tools.length>0&&g.jsx("div",{className:"flex flex-wrap gap-1.5 ml-5",children:n.tools.map(E=>g.jsx(zD,{icon:PD(`mcp__${n.name}__${E}`),children:E},E))}),e[30]=r,e[31]=n.name,e[32]=n.tools,e[33]=C):C=e[33];let k;return e[34]!==x||e[35]!==C||e[36]!==S?(k=g.jsxs("div",{className:"flex flex-col gap-1.5",children:[S,x,C]}),e[34]=x,e[35]=C,e[36]=S,e[37]=k):k=e[37],k}function Ese(t){const e=ke.c(18),{servers:n}=t;if(n.length===0)return null;let r,i,s,a,c,d,u;if(e[0]!==n){const v=n.filter(Ase),b=n.filter(Mse),S=b.length>0?g.jsxs("span",{className:"flex items-center gap-1 ml-1",children:[g.jsx(G6,{status:"failed"}),g.jsxs("span",{className:"text-muted-foreground/60",children:[b.length," disconnected"]})]}):null;r=K6,c="MCP Servers",d=n.length,u=S,i="flex flex-col gap-2",s=v.map(Tse),a=b.map(Rse),e[0]=n,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=c,e[6]=d,e[7]=u}else r=e[1],i=e[2],s=e[3],a=e[4],c=e[5],d=e[6],u=e[7];let f;e[8]!==i||e[9]!==s||e[10]!==a?(f=g.jsxs("div",{className:i,children:[s,a]}),e[8]=i,e[9]=s,e[10]=a,e[11]=f):f=e[11];let m;return e[12]!==r||e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==f?(m=g.jsx(r,{title:c,count:d,badge:u,children:f}),e[12]=r,e[13]=c,e[14]=d,e[15]=u,e[16]=f,e[17]=m):m=e[17],m}function Rse(t){return g.jsx(Y6,{server:t},t.name)}function Tse(t){return g.jsx(Y6,{server:t},t.name)}function Mse(t){return t.status!=="connected"}function Ase(t){return t.status==="connected"}function Nse(t){const e=ke.c(16),{rawJson:n}=t,[r,i]=_.useState(!1);let s;e[0]!==r?(s=()=>i(!r),e[0]=r,e[1]=s):s=e[1];const a=r&&"rotate-90";let c;e[2]!==a?(c=Ce("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",a),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c?(d=g.jsx(Ni,{className:c}),e[4]=c,e[5]=d):d=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=g.jsx("span",{className:"text-muted-foreground font-medium",children:"Raw Message"}),e[6]=u):u=e[6];let f;e[7]!==s||e[8]!==d?(f=g.jsxs("button",{onClick:s,className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[d,u]}),e[7]=s,e[8]=d,e[9]=f):f=e[9];let m;e[10]!==r||e[11]!==n?(m=r&&g.jsx("pre",{className:"ml-5 text-xs whitespace-pre-wrap break-all border border-border rounded-md p-3 overflow-x-auto max-h-96 overflow-y-auto",children:n}),e[10]=r,e[11]=n,e[12]=m):m=e[12];let v;return e[13]!==f||e[14]!==m?(v=g.jsxs("div",{className:"flex flex-col gap-1.5",children:[f,m]}),e[13]=f,e[14]=m,e[15]=v):v=e[15],v}function Dse(t){const e=ke.c(30),{message:n,rawJson:r}=t;let i,s;if(e[0]!==n.mcpServers||e[1]!==n.tools){const M=new Map;i=[];for(const O of n.tools){const D=Cse(O);if(D){const P=M.get(D.server)||[];P.push(D.tool),M.set(D.server,P)}else i.push(O)}s=n.mcpServers.map(O=>({name:O.name,status:O.status,error:O.error,tools:M.get(O.name)||[]})),e[0]=n.mcpServers,e[1]=n.tools,e[2]=i,e[3]=s}else i=e[2],s=e[3];const a=s;let c;e[4]!==i||e[5]!==a?(c={coreTools:i,mcpServersWithTools:a},e[4]=i,e[5]=a,e[6]=c):c=e[6];const{coreTools:d,mcpServersWithTools:u}=c;let f;e[7]!==n.model?(f=g.jsx(wZ,{children:n.model}),e[7]=n.model,e[8]=f):f=e[8];let m;e[9]!==d?(m=g.jsx(d1,{title:"Tools",items:d,getIcon:Ose}),e[9]=d,e[10]=m):m=e[10];let v;e[11]!==n.agents?(v=g.jsx(d1,{title:"Agents",items:n.agents,icon:xy}),e[11]=n.agents,e[12]=v):v=e[12];let b;e[13]!==n.slashCommands?(b=g.jsx(d1,{title:"Commands",items:n.slashCommands,icon:e4}),e[13]=n.slashCommands,e[14]=b):b=e[14];let S;e[15]!==u?(S=g.jsx(Ese,{servers:u}),e[15]=u,e[16]=S):S=e[16];let x;e[17]!==r?(x=r&&g.jsx(Nse,{rawJson:r}),e[17]=r,e[18]=x):x=e[18];let C;e[19]!==f||e[20]!==m||e[21]!==v||e[22]!==b||e[23]!==S||e[24]!==x?(C=g.jsx(Qh,{className:"my-4 text-xs",children:g.jsxs("div",{className:"flex flex-col gap-3",children:[f,m,v,b,S,x]})}),e[19]=f,e[20]=m,e[21]=v,e[22]=b,e[23]=S,e[24]=x,e[25]=C):C=e[25];let k,E;e[26]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx(jP,{className:"h-5 w-5 text-logo"}),E=g.jsx(Yo,{children:"Session Started"}),e[26]=k,e[27]=E):(k=e[26],E=e[27]);let R;return e[28]!==C?(R=g.jsx(ea,{children:g.jsxs(Xh,{expandedContent:C,children:[k,E]})}),e[28]=C,e[29]=R):R=e[29],R}function Ose(t){return X_[t]??ID}function jse(t){const e=ke.c(8),{message:n}=t;let r;e[0]!==n.accountInfo?(r=JSON.stringify(n.accountInfo,null,2),e[0]=n.accountInfo,e[1]=r):r=e[1];let i;e[2]!==r?(i=g.jsx(Qh,{className:"my-4 text-xs",children:g.jsx("pre",{className:"font-mono whitespace-pre-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto",children:r})}),e[2]=r,e[3]=i):i=e[3];let s,a;e[4]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("div",{className:"size-5 flex justify-center items-center ",children:g.jsx(xy,{className:"h-4 w-4 text-muted-foreground"})}),a=g.jsx(Yo,{children:"Account"}),e[4]=s,e[5]=a):(s=e[4],a=e[5]);let c;return e[6]!==i?(c=g.jsx(ea,{className:"hidden",children:g.jsxs(Xh,{expandedContent:i,children:[s,a]})}),e[6]=i,e[7]=c):c=e[7],c}function Lse(t){const e=ke.c(4),{message:n,isStreaming:r}=t;let i,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[rf],s=Zh(),e[0]=i,e[1]=s):(i=e[0],s=e[1]);let a;return e[2]!==n.text?(a=g.jsx("div",{className:"text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-full min-w-0 break-words [overflow-wrap:anywhere] space-y-4",children:g.jsx(nf,{remarkPlugins:i,components:s,children:n.text})}),e[2]=n.text,e[3]=a):a=e[3],a}function Ise(t){const e=ke.c(8),{message:n}=t;let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[rf],i=Zh(),e[0]=r,e[1]=i):(r=e[0],i=e[1]);let s;e[2]!==n.text?(s=g.jsx(Qh,{className:"my-4 text-sm text-muted-foreground/90",children:g.jsx("div",{className:"text-pretty prose prose-sm max-w-full px-0.5 opacity-90 dark:prose-invert",children:g.jsx(nf,{remarkPlugins:r,components:i,children:n.text})})}),e[2]=n.text,e[3]=s):s=e[3];let a,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsx(Gn,{className:"h-4 w-4 text-muted-icon"}),c=g.jsx(Yo,{className:"text-left text-muted-foreground",children:"Thinking"}),e[4]=a,e[5]=c):(a=e[4],c=e[5]);let d;return e[6]!==s?(d=g.jsx(ea,{className:"w-full",children:g.jsxs(Xh,{expandedContent:s,children:[a,c]})}),e[6]=s,e[7]=d):d=e[7],d}function Pse(t,e){return e<=0?0:Math.max(0,Math.min(100,(t+1)/e*100))}function zse(t){const e=ke.c(17),{question:n,currentIndex:r,totalQuestions:i,onBack:s,children:a}=t,c=s&&r>0;let d;e[0]!==r||e[1]!==s||e[2]!==c||e[3]!==i?(d=c?g.jsx("button",{onClick:s,className:" text-muted-foreground hover:opacity-60 transition-all flex items-center",children:g.jsx(GR,{className:"h-4 w-4 -ml-0.5",strokeWidth:3})}):i>1?g.jsxs("span",{className:"font-bold text-muted-foreground whitespace-nowrap",children:[r+1," of ",i]}):null,e[0]=r,e[1]=s,e[2]=c,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==n||e[6]!==d?(u=g.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border text-foreground flex flex-row items-center gap-2",children:[d,n]}),e[5]=n,e[6]=d,e[7]=u):u=e[7];let f;e[8]!==r||e[9]!==i?(f=i>1&&g.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-border",children:g.jsx("div",{className:"h-full bg-muted-foreground/40 transition-all duration-300",style:{width:`${Pse(r,i)}%`}})}),e[8]=r,e[9]=i,e[10]=f):f=e[10];let m;e[11]!==u||e[12]!==f?(m=g.jsxs("div",{className:"relative",children:[u,f]}),e[11]=u,e[12]=f,e[13]=m):m=e[13];let v;return e[14]!==a||e[15]!==m?(v=g.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[m,a]}),e[14]=a,e[15]=m,e[16]=v):v=e[16],v}function rR(t){const e=ke.c(7),{label:n,description:r}=t;let i;e[0]!==n?(i=g.jsx("span",{className:"text-foreground text-sm",children:n}),e[0]=n,e[1]=i):i=e[1];let s;e[2]!==r?(s=r&&g.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r}),e[2]=r,e[3]=s):s=e[3];let a;return e[4]!==i||e[5]!==s?(a=g.jsxs(g.Fragment,{children:[i,s]}),e[4]=i,e[5]=s,e[6]=a):a=e[6],a}function X6(t){const e=ke.c(10),{selected:n,multiSelect:r,onClick:i}=t,s=r?"rounded":"rounded-full",a=n?"border-slate-500/0 bg-foreground":"border-muted-foreground/50 bg-background",c=i&&n&&"cursor-pointer";let d;e[0]!==s||e[1]!==a||e[2]!==c?(d=Ce("flex-shrink-0 w-5 h-5 border-1 flex items-center justify-center",s,a,c),e[0]=s,e[1]=a,e[2]=c,e[3]=d):d=e[3];let u;e[4]!==n?(u=n&&g.jsx(di,{strokeWidth:3,className:"translate-y-[0.5px] h-3 w-3 text-white dark:text-background"}),e[4]=n,e[5]=u):u=e[5];let f;return e[6]!==i||e[7]!==d||e[8]!==u?(f=g.jsx("button",{type:"button",onClick:i,className:d,children:u}),e[6]=i,e[7]=d,e[8]=u,e[9]=f):f=e[9],f}function Bse(t){const e=ke.c(23),{option:n,selected:r,multiSelect:i,onClick:s,isLast:a}=t,c=a?"":"border-b border-border";if(s){let m;e[0]!==c?(m=Ce("w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background",c,"transition-all cursor-pointer"),e[0]=c,e[1]=m):m=e[1];let v;e[2]!==n.description||e[3]!==n.label?(v=g.jsx("div",{className:"flex-1 min-w-0",children:g.jsx(rR,{label:n.label,description:n.description})}),e[2]=n.description,e[3]=n.label,e[4]=v):v=e[4];let b;e[5]!==i||e[6]!==r?(b=g.jsx(X6,{selected:r,multiSelect:i}),e[5]=i,e[6]=r,e[7]=b):b=e[7];let S;e[8]!==v||e[9]!==b?(S=g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[v,b]}),e[8]=v,e[9]=b,e[10]=S):S=e[10];let x;return e[11]!==s||e[12]!==m||e[13]!==S?(x=g.jsx("button",{onClick:s,className:m,children:S}),e[11]=s,e[12]=m,e[13]=S,e[14]=x):x=e[14],x}let d;e[15]!==c?(d=Ce("w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background",c),e[15]=c,e[16]=d):d=e[16];let u;e[17]!==n.description||e[18]!==n.label?(u=g.jsx(rR,{label:n.label,description:n.description}),e[17]=n.description,e[18]=n.label,e[19]=u):u=e[19];let f;return e[20]!==d||e[21]!==u?(f=g.jsx("div",{className:d,children:u}),e[20]=d,e[21]=u,e[22]=f):f=e[22],f}function Fse(t){return t==null?void 0:t.answers}function ph(t){return t?Object.values(t).some(e=>e.length>0):!1}function Hse(t,e){return ph(t)?t:ph(e)?e:t??e??{}}function gs(t){return t.id||t.question}function $se({message:t,onSubmit:e,isLatest:n}){var B,K;const r=t.input.questions,i=!!t.result,s=Fse(t.result),a=((B=t.result)==null?void 0:B.discarded)===!0,[c,d]=_.useState(0),[u,f]=_.useState({}),[m,v]=_.useState({}),[b,S]=_.useState(s??null),[x,C]=_.useState(i),[k,E]=_.useState(!1);_.useEffect(()=>{if(!t.result){S(null),C(!1);return}if(!ph(s)||a){S(null),C(!1);return}ph(s)&&(S(s),C(!0))},[a,t.result,s]);const R=(A,I)=>{var J;const $=(J=m[A])==null?void 0:J.trim(),T=u[A]||"",X=I||r.find(re=>gs(re)===A);if(X!=null&&X.multiSelect)return[T,$].filter(Boolean).flatMap(re=>re.split(", ").filter(Boolean));const Z=$||T;return Z?[Z]:[]},M=A=>{const I=u[gs(A)]||"";return A.multiSelect?I.split(", ").filter(Boolean):[I]},O=(A,I)=>{const $=gs(A);if(A.multiSelect){const T=u[$]?u[$].split(", ").filter(Boolean):[],X=T.includes(I)?T.filter(Z=>Z!==I):[...T,I];f({...u,[$]:X.join(", ")})}else f({...u,[$]:I}),v({...m,[$]:""}),c<r.length-1&&setTimeout(()=>d(c+1),150)},D=(A,I)=>{const $=gs(A);v({...m,[$]:I}),I&&!A.multiSelect&&f({...u,[$]:""})},P=A=>{const I=gs(A);A.multiSelect&&m[I]&&v({...m,[I]:""})},z=r.every(A=>R(gs(A),A).length>0),Y=r[c],L=c===r.length-1,W=Y&&R(gs(Y),Y).length>0,V=()=>{c<r.length-1&&d(c+1)},F=()=>{c>0&&d(c-1)},U=async()=>{if(!z||k)return;const A={};for(const I of r){const $=gs(I);A[$]=R($,I)}E(!0);try{await e(t.toolId,r,A),S(A),C(!0)}catch{S(null),C(!1)}finally{E(!1)}},H=A=>{if(A.key==="Enter"&&!(!Y||!W||k)){if(A.preventDefault(),L){U();return}V()}};if(x||i){const A=a||!ph(s)?{}:Hse(s,b);return g.jsx("div",{className:"w-full",children:g.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[g.jsxs("div",{className:"font-medium text-sm p-3 px-4 pr-5 bg-muted border-b border-border flex flex-row items-center justify-between",children:[g.jsxs("p",{children:["Question",r.length!==1?"s":""]}),g.jsx("p",{className:"",children:a?"Discarded":"Answers"})]}),r.map((I,$)=>{const T=A[gs(I)]||A[I.question]||[],X=$===r.length-1;return g.jsxs("div",{className:Ce("w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-center justify-between gap-3",!X&&"border-b border-border"),children:[g.jsx("div",{className:"text-sm text-pretty",children:I.question}),T.length>0&&g.jsx("div",{className:"text-sm font-medium text-right max-w-[50%] text-pretty",children:T.join(", ")}),T.length===0&&g.jsx("div",{className:"text-sm font-medium text-right italic",children:a?"Discarded":"No Response"})]},gs(I))})]})})}if(!n)return g.jsx("div",{className:"w-full py-2",children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(XR,{className:"h-4 w-4 text-muted-foreground"}),g.jsx("span",{className:"text-sm text-muted-foreground",children:"Questions pending (newer question active)"})]})});if(!Y)return null;const j=M(Y),G=m[gs(Y)]||"";return g.jsxs("div",{className:"w-full space-y-3",children:[g.jsxs(zse,{question:Y.question,currentIndex:c,totalQuestions:r.length,onBack:c>0?F:void 0,children:[(K=Y.options)==null?void 0:K.map(A=>g.jsx(Bse,{option:A,selected:j.includes(A.label),multiSelect:Y.multiSelect,onClick:()=>O(Y,A.label)},A.label)),g.jsx("div",{className:"transition-all bg-background",children:g.jsxs("div",{className:"flex pr-5 items-center justify-between gap-3",children:[g.jsx("input",{type:"text",value:G,onChange:A=>D(Y,A.target.value),onKeyDown:H,placeholder:"Other...",className:"flex-1 px-3 !py-1 pl-4 min-h-[55px] min-w-0 text-base md:text-sm bg-transparent outline-none text-foreground placeholder:text-muted-foreground"}),g.jsx(X6,{selected:!!G,multiSelect:Y.multiSelect,onClick:Y.multiSelect&&G?()=>P(Y):void 0})]})})]}),g.jsxs("div",{className:"flex justify-end gap-2 mx-2",children:[!L&&W&&(Y.multiSelect||!!G)&&g.jsx(vt,{size:"sm",onClick:V,children:"Next"}),L&&g.jsx(vt,{size:"sm",onClick:()=>void U(),disabled:!z||k,className:Ce((!z||k)&&"opacity-50 cursor-not-allowed","rounded-full"),children:"Submit"})]})]})}function Use(t){const e=ke.c(27);let n,r,i,s,a,c,d,u,f;e[0]!==t?({to:u,onNavigate:s,replace:c,children:n,className:r,disabled:d,variant:f,size:a,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=s,e[5]=a,e[6]=c,e[7]=d,e[8]=u,e[9]=f):(n=e[1],r=e[2],i=e[3],s=e[4],a=e[5],c=e[6],d=e[7],u=e[8],f=e[9]);const m=c===void 0?!1:c,v=d===void 0?!1:d;let b;e[10]!==v||e[11]!==s?(b=function(M){if(v){M.preventDefault(),M.stopPropagation();return}s==null||s()},e[10]=v,e[11]=s,e[12]=b):b=e[12];const S=b,x=v||void 0,C=v?-1:void 0;let k;e[13]!==r||e[14]!==v||e[15]!==a||e[16]!==f?(k=Ce(v4({variant:f,size:a}),v&&"cursor-not-allowed opacity-50",r),e[13]=r,e[14]=v,e[15]=a,e[16]=f,e[17]=k):k=e[17];let E;return e[18]!==n||e[19]!==S||e[20]!==i||e[21]!==m||e[22]!==x||e[23]!==C||e[24]!==k||e[25]!==u?(E=g.jsx(Dh,{...i,to:u,replace:m,onClick:S,"aria-disabled":x,tabIndex:C,className:k,children:n}),e[18]=n,e[19]=S,e[20]=i,e[21]=m,e[22]=x,e[23]=C,e[24]=k,e[25]=u,e[26]=E):E=e[26],E}function Wse(t){const e=ke.c(8),{level:n,className:r}=t,i=n==="paid"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300";let s;e[0]!==r||e[1]!==i?(s=Ce("inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium",i,r),e[0]=r,e[1]=i,e[2]=s):s=e[2];let a;e[3]!==n?(a=kx(n),e[3]=n,e[4]=a):a=e[4];let c;return e[5]!==s||e[6]!==a?(c=g.jsx("span",{className:s,children:a}),e[5]=s,e[6]=a,e[7]=c):c=e[7],c}async function Vse(t){const e=await new Promise((n,r)=>{const i=new FileReader;i.onload=()=>{if(typeof i.result=="string"){n(i.result);return}r(new Error("Failed to read image attachment"))},i.onerror=()=>r(i.error??new Error("Failed to read image attachment")),i.readAsDataURL(t)});return{type:"image",name:t.name,mimeType:t.type,sizeBytes:t.size,dataUrl:e}}function Fm(t){return String(t).padStart(2,"0")}function qse(t,e=new Date){const n=t?new Date(t):null,r=n&&!Number.isNaN(n.getTime())?n:e;return["kaizen-plan",`${r.getFullYear()}-${Fm(r.getMonth()+1)}-${Fm(r.getDate())}`,`${Fm(r.getHours())}-${Fm(r.getMinutes())}.md`].join("-")}function Kse(t){const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e.focus(),e.select();const n=document.execCommand("copy");return document.body.removeChild(e),n}function iR(){const t=ke.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsx("div",{className:"my-1 h-px bg-border","aria-hidden":"true"}),t[0]=e):e=t[0],e}function sR(t){const e=ke.c(2),{children:n}=t;let r;return e[0]!==n?(r=g.jsx("div",{className:"px-3 py-1 text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:n}),e[0]=n,e[1]=r):r=e[1],r}function Hm(t){const e=ke.c(13),{icon:n,label:r,onSelect:i,disabled:s}=t,a=s===void 0?!1:s,c=a?"cursor-not-allowed text-muted-foreground/60":"text-foreground hover:bg-accent";let d;e[0]!==c?(d=Ce("flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]!==a||e[3]!==i?(u=v=>{v.preventDefault(),v.stopPropagation(),a||i==null||i()},e[2]=a,e[3]=i,e[4]=u):u=e[4];let f;e[5]!==r?(f=g.jsx("span",{children:r}),e[5]=r,e[6]=f):f=e[6];let m;return e[7]!==a||e[8]!==n||e[9]!==d||e[10]!==u||e[11]!==f?(m=g.jsxs("button",{type:"button",className:d,onClick:u,disabled:a,children:[n,f]}),e[7]=a,e[8]=n,e[9]=d,e[10]=u,e[11]=f,e[12]=m):m=e[12],m}function Gse(t){const e=ke.c(5),{onNavigate:n}=t,r=Yr();let i;e[0]!==r.pathname?(i=r.pathname.startsWith("/settings"),e[0]=r.pathname,e[1]=i):i=e[1];let s;return e[2]!==n||e[3]!==i?(s=g.jsx(Use,{variant:"outline",size:"sm",className:"w-full",to:aq,replace:i,onNavigate:n,children:"Open Account"}),e[2]=n,e[3]=i,e[4]=s):s=e[4],s}function oR(t){const e=ke.c(5),{renderAccountAction:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx(Wse,{level:"account"}),e[0]=r):r=e[0];let i;e[1]!==n?(i=n(Yse),e[1]=n,e[2]=i):i=e[2];let s;return e[3]!==i?(s=g.jsxs(g.Fragment,{children:[r,i]}),e[3]=i,e[4]=s):s=e[4],s}function Yse(){}function Xse(t){const e=ke.c(7);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];const{remoteAuth:r}=Hu();let i;e[2]!==r?(i=Bg(r),e[2]=r,e[3]=i):i=e[3];const s=i;let a;return e[4]!==s.features.handoff.enabled||e[5]!==n?(a=g.jsx(Zse,{...n,handoffEnabled:s.features.handoff.enabled,renderAccountAction:Qse}),e[4]=s.features.handoff.enabled,e[5]=n,e[6]=a):a=e[6],a}function Qse(t){return g.jsx(Gse,{onNavigate:t})}function Zse({message:t,onConfirm:e,onHandoff:n,isLatest:r,isActionable:i=r,availableProviders:s,handoffPendingStatus:a=null,handoffEnabled:c,renderAccountAction:d}){const u=!!t.result,[f,m]=_.useState(!1),[v,b]=_.useState(!1),[S,x]=_.useState(!1),[C,k]=_.useState(""),[E,R]=_.useState([]),[M,O]=_.useState(null),[D,P]=_.useState(!1),[z,Y]=_.useState(null),[L,W]=_.useState(null),[V,F]=_.useState(!1),[U,H]=_.useState(null),j=_.useRef(null),G=_.useRef(null),B=_.useRef(null),K=t.input,A=hr.planHandoff(t.toolId,"idle"),I=QV(L??A),$=a??I,T=$!==null,X=z==="suggest_edits",Z=z!==null,J=pK(ie=>ie.entries),re=new Set(s.map(ie=>ie.id)),ae=J.filter(ie=>re.has(ie.provider));_.useEffect(()=>{S&&j.current&&j.current.focus()},[S]),_.useEffect(()=>()=>{for(const ie of E)URL.revokeObjectURL(ie.previewUrl);B.current&&clearTimeout(B.current)},[E]);const ue=async()=>{var ie;if(K!=null&&K.plan)try{if((ie=navigator.clipboard)!=null&&ie.writeText)await navigator.clipboard.writeText(K.plan);else if(!Kse(K.plan))throw new Error("Clipboard copy failed");b(!0),ru("Plan copied to clipboard."),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>b(!1),2e3)}catch{ru("Failed to copy plan.")}},me=_.useCallback(()=>{if(!(K!=null&&K.plan))return;const ie=new Blob([K.plan],{type:"text/markdown;charset=utf-8"}),xe=URL.createObjectURL(ie),Ae=document.createElement("a");Ae.href=xe,Ae.download=qse(t.timestamp),Ae.click(),URL.revokeObjectURL(xe)},[K==null?void 0:K.plan,t.timestamp]),se=_.useCallback(async ie=>{if(!(K!=null&&K.plan)||L!==null)return;const xe=hr.planHandoff(t.toolId,ie.id);W(xe);try{await Ho(xe,()=>n(t.toolId,K.plan,ie),{statusLabel:"Starting new chat..."}),F(!1),H(null)}catch(Ae){throw F(!1),H(null),Ae}finally{W(Ae=>Ae===xe?null:Ae)}},[L,K==null?void 0:K.plan,t.toolId,n]),oe=_.useCallback(ie=>{const xe=ie.filter(Ae=>Ae.type.startsWith("image/"));if(xe.length===0){O("Only PNG, JPEG, WEBP, and GIF images are supported.");return}R(Ae=>{const Ke=[...Ae];let mt=null;for(const Ye of xe){if(!Ap.includes(Ye.type)){mt=`Unsupported image type: ${Ye.type||"unknown"}`;continue}if(Ye.size<=0||Ye.size>IT){mt=`${Ye.name} is empty or larger than 10 MB.`;continue}if(Ke.length>=Mp){mt=`You can attach up to ${Mp} images per message.`;break}Ke.push({id:Ai(),file:Ye,name:Ye.name||"image",mimeType:Ye.type,sizeBytes:Ye.size,previewUrl:URL.createObjectURL(Ye)})}return O(mt),Ke})},[]),ee=_.useCallback(ie=>{R(xe=>{const Ae=xe.find(Ke=>Ke.id===ie);return Ae&&URL.revokeObjectURL(Ae.previewUrl),xe.filter(Ke=>Ke.id!==ie)}),O(null)},[]),Q=async()=>{if(!C.trim()&&E.length===0)return;const ie=hr.planRespond(t.toolId,"suggest_edits");Y("suggest_edits");try{const xe=E.length?await Promise.all(E.map(Ae=>Vse(Ae.file))):void 0;await Ho(ie,()=>e(t.toolId,!1,void 0,C.trim(),xe),{statusLabel:"Sending edits..."})}finally{Y(xe=>xe==="suggest_edits"?null:xe)}},te=u?t.result:null,he=(te==null?void 0:te.discarded)===!0;return g.jsxs("div",{className:"flex flex-col gap-3",children:[g.jsxs("div",{className:"relative rounded-2xl border border-border overflow-hidden group/plan",children:[(K==null?void 0:K.plan)&&g.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:Ce("absolute top-2 right-2 z-10 h-8 w-8 rounded-md text-muted-foreground opacity-100 transition-opacity",!v&&"md:opacity-0 md:group-hover/plan:opacity-100",!v&&"hover:text-foreground",v&&"hover:!bg-transparent hover:!border-transparent"),onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),ue()},"aria-label":v?"Plan copied":"Copy plan",title:v?"Plan copied":"Copy plan",children:v?g.jsx(di,{className:"h-4 w-4 text-green-400"}):g.jsx(lu,{className:"h-4 w-4"})}),g.jsxs("div",{className:Ce("!pt-5 !pb-0 px-4 md:py-4.5 md:px-5.5 bg-muted dark:bg-card overflow-scroll no-pre-highlight transition-all",u&&!f?"max-h-[min(400px,40vh)] ":"",u?"hover:!pb-[32px]":""),children:[u&&g.jsxs(vt,{type:"button",variant:"ghost",className:"absolute z-10 bottom-2 pr-2.5 !pl-3.5 h-[34px] inline-flex gap-1 text-sm left-[50%] -translate-x-[50%] text-muted-foreground backdrop-blur-sm hover:text-foreground opacity-0 group-hover/plan:opacity-100 transition-all rounded-full border border-border",onClick:ie=>{ie.preventDefault(),ie.stopPropagation(),m(!f)},children:[f?"Show Less":"Show More",g.jsx(og,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`})]}),K!=null&&K.plan?g.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:[g.jsx(nf,{remarkPlugins:[rf],components:Zh(),children:K.plan}),g.jsx("div",{className:"mt-5"})]}):g.jsx("p",{className:"text-sm text-muted-foreground",children:"No plan provided"})]})]}),u?g.jsx("div",{className:"flex justify-end mx-2",children:g.jsxs("span",{className:"pl-4 inline text-sm font-medium bg-background text-foreground/60 border border-border py-1.5 px-3 rounded-[20px] leading-relaxed max-w-[85%] sm:max-w-[80%]",children:[g.jsx("em",{children:he?"Discarded":te!=null&&te.clearContext?"Approved & Cleared Context":te!=null&&te.confirmed?"Approved":te!=null&&te.message?`Adjusted: "${te.message}"`:"Adjusted Plan"}),g.jsx(n8,{className:"inline h-4 w-4 ml-1.5 -mt-0.5"})]})}):r?i?g.jsxs("div",{className:"flex flex-col gap-3",children:[!S&&g.jsx("div",{className:"flex flex-col gap-2 mx-2 md:flex-row md:items-center md:justify-between",children:T?g.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-muted px-3 py-2 text-sm text-muted-foreground dark:bg-card",children:[g.jsx(Fn,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),g.jsx("span",{children:$})]}):g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex items-center gap-2",children:K!=null&&K.plan?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"hidden items-center gap-2 md:flex",children:g.jsxs(Qy,{open:V,onOpenChange:F,children:[g.jsx(Zy,{asChild:!0,children:g.jsx(vt,{type:"button",size:"icon",variant:"outline",className:"rounded-full","aria-label":"More plan actions",title:"More plan actions",disabled:T,children:g.jsx(pk,{className:"h-4 w-4"})})}),g.jsxs(kg,{align:"start",className:"w-64 p-1.5",children:[g.jsx(Hm,{icon:v?g.jsx(di,{className:"h-4 w-4 text-green-400"}):g.jsx(lu,{className:"h-4 w-4"}),label:v?"Copied":"Copy",onSelect:()=>void ue(),disabled:T}),g.jsx(Hm,{icon:g.jsx(mk,{className:"h-4 w-4"}),label:"Download .md",onSelect:me,disabled:T}),g.jsx(iR,{}),g.jsx(sR,{children:"Hand Off to..."}),c?ae.length>0?ae.map(ie=>g.jsx(Hm,{icon:L===hr.planHandoff(t.toolId,ie.id)?g.jsx(Fn,{className:"h-4 w-4 animate-spin"}):g.jsx(qr,{className:"h-4 w-4"}),label:L===hr.planHandoff(t.toolId,ie.id)?"Starting new chat...":ie.label,onSelect:()=>{se(ie)},disabled:L!==null},ie.id)):g.jsx(Hm,{icon:g.jsx(qr,{className:"h-4 w-4"}),label:"No Hand Off entries configured",disabled:!0}):g.jsx("div",{className:"rounded-lg border border-border px-3 py-2",children:g.jsx(oR,{renderAccountAction:ie=>d(()=>{ie(),F(!1)})})})]})]})}),g.jsxs("div",{className:"md:hidden",children:[g.jsx(vt,{type:"button",size:"icon",variant:"outline",className:"rounded-full","aria-label":"More plan actions",title:"More plan actions",disabled:T,onClick:ie=>{const xe=ie.currentTarget.getBoundingClientRect();H({x:xe.left,y:xe.bottom+4})},children:g.jsx(pk,{className:"h-4 w-4"})}),g.jsxs(Ag,{open:U!==null,onOpenChange:ie=>{ie||H(null)},position:U,children:[g.jsxs(Za,{onSelect:()=>{H(null),ue()},children:[g.jsx(lu,{className:"h-4 w-4"}),g.jsx("span",{children:"Copy"})]}),g.jsxs(Za,{onSelect:()=>{H(null),me()},children:[g.jsx(mk,{className:"h-4 w-4"}),g.jsx("span",{children:"Download .md"})]}),g.jsx(iR,{}),g.jsx(sR,{children:"Hand Off to..."}),c?ae.length>0?ae.map(ie=>g.jsxs(Za,{onSelect:()=>{se(ie)},children:[L===hr.planHandoff(t.toolId,ie.id)?g.jsx(Fn,{className:"h-4 w-4 animate-spin"}):g.jsx(qr,{className:"h-4 w-4"}),g.jsx("span",{children:L===hr.planHandoff(t.toolId,ie.id)?"Starting new chat...":ie.label})]},ie.id)):g.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground/60",children:"No Hand Off entries configured"}):g.jsx("div",{className:"px-3 py-2",children:g.jsx(oR,{renderAccountAction:ie=>d(()=>{ie(),H(null)})})})]})]})]}):null}),g.jsxs("div",{className:"flex flex-col md:flex-row items-stretch md:items-center justify-end gap-2",children:[g.jsxs(vt,{type:"button",size:"sm",onClick:()=>{const ie=hr.planRespond(t.toolId,"approve_clear");Y("approve_clear"),Ho(ie,()=>e(t.toolId,!0,!0),{statusLabel:"Approving and clearing context..."}).finally(()=>{Y(xe=>xe==="approve_clear"?null:xe)})},className:"rounded-full bg-primary text-primary-foreground pr-4 md:order-last",disabled:Z,children:[z==="approve_clear"?g.jsx(Fn,{className:"h-4 w-4 mr-1.5 animate-spin"}):g.jsx(PP,{className:"h-4 w-4 mr-1.5"}),z==="approve_clear"?"Clearing...":"Approve & Clear"]}),g.jsxs("div",{className:"flex items-stretch md:items-center gap-2 md:contents",children:[g.jsxs(vt,{type:"button",size:"sm",variant:"outline",onClick:()=>x(!0),className:"rounded-full border-border flex-1 md:flex-initial md:order-first",disabled:Z,children:[X?g.jsx(Fn,{className:"h-4 w-4 mr-1.5 animate-spin"}):g.jsx(Ul,{className:"h-4 w-4 mr-1.5"}),"Suggest Edits"]}),g.jsxs(vt,{type:"button",size:"sm",variant:"outline",onClick:()=>{const ie=hr.planRespond(t.toolId,"approve");Y("approve"),Ho(ie,()=>e(t.toolId,!0),{statusLabel:"Approving plan..."}).finally(()=>{Y(xe=>xe==="approve"?null:xe)})},className:"rounded-full border-border flex-1 md:flex-initial",disabled:Z,children:[z==="approve"?g.jsx(Fn,{className:"h-4 w-4 mr-1.5 animate-spin"}):g.jsx(di,{className:"h-4 w-4 mr-1.5"}),z==="approve"?"Approving...":"Approve"]})]})]})]})}),S&&g.jsxs("div",{className:Ce("flex flex-col gap-2 rounded-2xl border bg-muted dark:bg-card px-4 py-3 transition-colors",D?"border-foreground/40 bg-muted/80":"border-border"),onDragEnter:ie=>{ie.dataTransfer.types.includes("Files")&&(ie.preventDefault(),P(!0))},onDragOver:ie=>{ie.dataTransfer.types.includes("Files")&&(ie.preventDefault(),ie.dataTransfer.dropEffect="copy",P(!0))},onDragLeave:ie=>{if(!ie.dataTransfer.types.includes("Files"))return;ie.preventDefault();const xe=ie.relatedTarget;xe instanceof Node&&ie.currentTarget.contains(xe)||P(!1)},onDrop:ie=>{var xe;ie.dataTransfer.types.includes("Files")&&(ie.preventDefault(),P(!1),oe(Array.from(ie.dataTransfer.files)),(xe=j.current)==null||xe.focus())},children:[g.jsx("input",{ref:G,type:"file",accept:Ap.join(","),multiple:!0,className:"hidden",onChange:ie=>{oe(Array.from(ie.target.files??[])),ie.target.value=""}}),E.length?g.jsx("div",{className:"grid grid-cols-2 gap-2 pt-1 pb-2 sm:grid-cols-3",children:E.map(ie=>g.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/80 bg-background/80",children:[g.jsx("img",{src:ie.previewUrl,alt:ie.name,className:"h-28 w-full object-cover"}),g.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 px-2 py-1.5",children:[g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{className:"truncate text-xs text-foreground",children:ie.name}),g.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[Math.max(1,Math.round(ie.sizeBytes/1024))," KB"]})]}),g.jsx(vt,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",onClick:()=>ee(ie.id),disabled:X,children:g.jsx(is,{className:"h-3.5 w-3.5"})})]})]},ie.id))}):null,g.jsx("textarea",{ref:j,value:C,onChange:ie=>k(ie.target.value),onPaste:ie=>{const xe=Array.from(ie.clipboardData.files);xe.some(Ae=>Ae.type.startsWith("image/"))&&(ie.preventDefault(),oe(xe))},onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(C.trim()||E.length>0)&&(ie.preventDefault(),Q()),ie.key==="Escape"&&(x(!1),k(""),R([]),O(null))},placeholder:"Describe what you'd like to change...",rows:3,className:"w-full bg-transparent text-[16px] md:text-sm text-foreground placeholder:text-muted-foreground resize-none outline-none"}),M?g.jsx("div",{className:"text-xs text-destructive",children:M}):null,g.jsxs("div",{className:"flex items-center justify-between mt-1",children:[g.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>{var ie;return(ie=G.current)==null?void 0:ie.click()},disabled:X,children:g.jsx(ZR,{className:"h-4 w-4"})}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(vt,{type:"button",size:"sm",variant:"ghost",onClick:()=>{x(!1),k(""),R([]),O(null)},className:"rounded-full text-muted-foreground",disabled:X,children:"Cancel"}),g.jsxs(vt,{type:"button",size:"sm",disabled:!C.trim()&&E.length===0||X,onClick:()=>void Q(),className:"rounded-full bg-primary text-primary-foreground disabled:opacity-50 disabled:pointer-events-none",children:[g.jsx(Y8,{className:"h-4 w-4 mr-1.5"}),X?"Adjusting...":"Adjust Plan"]})]})]})]})]}):g.jsx("div",{className:"flex justify-end mx-2",children:g.jsx("span",{className:"inline text-sm text-muted-foreground italic",children:"Plan pending"})}):g.jsx("div",{className:"flex justify-end mx-2",children:g.jsx("span",{className:"inline text-sm text-muted-foreground italic",children:"Plan pending (newer prompt active)"})})]})}const Jse={completed:{Icon:di,iconClass:"text-emerald-500",textClass:"text-muted-foreground"},in_progress:{Icon:Fn,iconClass:"text-foreground animate-spin",textClass:"text-foreground font-medium"},pending:{Icon:QP,iconClass:"text-muted-foreground",textClass:"text-muted-foreground"}};function eoe(t){const e=ke.c(7),{message:n}=t,r=n.input.todos;if(!r.length)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsxs("h3",{className:"font-medium text-foreground text-sm p-3 px-4 bg-card border-b border-border flex items-center gap-2",children:[g.jsx(T8,{className:"h-4 w-4 text-muted-foreground"}),"Progress"]}),e[0]=i):i=e[0];let s;if(e[1]!==r){let c;e[3]!==r.length?(c=(d,u)=>{const f=u===r.length-1,{Icon:m,iconClass:v,textClass:b}=Jse[d.status];return g.jsxs("div",{className:Ce("flex items-center gap-3 px-4 py-2.5 bg-background",!f&&"border-b border-border"),children:[g.jsx(m,{className:Ce("h-4 w-4 flex-shrink-0",v)}),g.jsx("span",{className:Ce("text-sm",b),children:d.status==="in_progress"?d.activeForm:d.content})]},u)},e[3]=r.length,e[4]=c):c=e[4],s=r.map(c),e[1]=r,e[2]=s}else s=e[2];let a;return e[5]!==s?(a=g.jsx("div",{className:"w-full",children:g.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[i,g.jsx("div",{children:s})]})}),e[5]=s,e[6]=a):a=e[6],a}function toe(t){const e=t.split(`
606
606
  `),n=/^\s*(\d+)→(.*)$/;return e.map(r=>{const i=r.match(n);return i?{lineNumber:parseInt(i[1],10),content:i[2]}:{lineNumber:null,content:r}})}function noe(t){return t.replace(/<[^>]+>/g,"")}function roe(t,e){const n=t.split(`
607
607
  `),r=e.split(`
608
- `),i=ioe(n,r),s=soe(n,r,i);return ooe(s)}function ioe(t,e){const n=t.length,r=e.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let s=1;s<=n;s++)for(let a=1;a<=r;a++)i[s][a]=t[s-1]===e[a-1]?i[s-1][a-1]+1:Math.max(i[s-1][a],i[s][a-1]);return i}function soe(t,e,n){const r=[];let i=t.length,s=e.length;for(;i>0||s>0;)i>0&&s>0&&t[i-1]===e[s-1]?(r.push({type:"context",text:t[i-1],oldIdx:i,newIdx:s}),i--,s--):s>0&&(i===0||n[i][s-1]>=n[i-1][s])?(r.push({type:"added",text:e[s-1],oldIdx:i,newIdx:s}),s--):(r.push({type:"removed",text:t[i-1],oldIdx:i,newIdx:s}),i--);return r.reverse()}function ooe(t){return t.map(e=>{const n=e.type==="removed"?"-":e.type==="added"?"+":" ";return{type:e.type,content:`${n}${e.text}`}})}function h1(t){const e=ke.c(20),{content:n,isDiff:r,oldString:i,newString:s}=t,a=r===void 0?!1:r;let c;e:{if(a&&i!==void 0&&s!==void 0){let C;e[0]!==s||e[1]!==i?(C=roe(i,s),e[0]=s,e[1]=i,e[2]=C):C=e[2],c=C;break e}let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[3]=x):x=e[3],c=x}const d=c;let u;e:{if(!a){let C;e[4]!==n?(C=toe(n),e[4]=n,e[5]=C):C=e[5],u=C;break e}let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[6]=x):x=e[6],u=x}const f=u;let m;e[7]!==f?(m=f.some(loe),e[7]=f,e[8]=m):m=e[8];const v=m;if(a&&d.length>0){let x;e[9]!==d?(x=d.map(aoe),e[9]=d,e[10]=x):x=e[10];let C;return e[11]!==x?(C=g.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:g.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:g.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:g.jsx("tbody",{children:x})})})}),e[11]=x,e[12]=C):C=e[12],C}let b;if(e[13]!==v||e[14]!==f){let x;e[16]!==v?(x=(C,k)=>g.jsxs("tr",{children:[v&&g.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:C.lineNumber!==null?C.lineNumber:""}),g.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:noe(C.content)})]},k),e[16]=v,e[17]=x):x=e[17],b=f.map(x),e[13]=v,e[14]=f,e[15]=b}else b=e[15];let S;return e[18]!==b?(S=g.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:g.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:g.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:g.jsx("tbody",{children:b})})})}),e[18]=b,e[19]=S):S=e[19],S}function aoe(t,e){const n=t.type==="removed"?"bg-red-500/10 dark:bg-red-500/15":t.type==="added"?"bg-green-500/10 dark:bg-green-500/15":"",r=t.type==="removed"?"text-red-700 dark:text-red-400":t.type==="added"?"text-green-700 dark:text-green-400":"text-foreground";return g.jsxs("tr",{className:n,children:[g.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${t.type==="removed"?"text-red-500/50":t.type==="added"?"text-green-500/50":"text-muted-foreground/50"}`,children:t.type==="removed"?"-":t.type==="added"?"+":" "}),g.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${r}`,children:t.content.slice(1)})]},e)}function loe(t){return t.lineNumber!==null}function Q6(t){var $;const e=ke.c(78),{message:n,isLoading:r,localPath:i}=t,s=r===void 0?!1:r,a=n.result!==void 0,c=!a&&s;let d;e:{if(typeof n.result=="string"){d=n.result;break e}if(!n.result){d="";break e}if(typeof n.result=="object"&&n.result!==null&&"content"in n.result){const X=n.result.content;if(typeof X=="string"){d=X;break e}}let T;e[0]!==n.result?(T=JSON.stringify(n.result,null,2),e[0]=n.result,e[1]=T):T=e[1],d=T}const u=d;let f;if(e[2]!==n.input||e[3]!==n.toolKind||e[4]!==u){e:{if((n.toolKind==="read_file"||n.toolKind==="write_file"||n.toolKind==="edit_file")&&n.input.filePath){f=n.input.filePath;break e}if(n.toolKind==="edit_file"){const T=u.match(/^Updated\s+(.+)$/m);if(T!=null&&T[1]){f=T[1].trim();break e}}f=""}e[2]=n.input,e[3]=n.toolKind,e[4]=u,e[5]=f}else f=e[5];const m=f;let v;e:{if(n.toolKind==="skill"){v=n.input.skill;break e}if(n.toolKind==="glob"){v=`Search files ${n.input.pattern==="**/*"?"in all directories":`matching ${n.input.pattern}`}`;break e}if(n.toolKind==="grep"){const T=n.input.pattern,X=n.input.outputMode;if(X==="count"){v=`Count \`${T}\` occurrences`;break e}if(X==="content"){v=`Find \`${T}\` in text`;break e}v=`Find \`${T}\` in files`;break e}if(n.toolKind==="bash"){let T;e[6]!==n.input.command||e[7]!==n.input.description?(T=n.input.description||(n.input.command?LH(n.input.command):"Bash"),e[6]=n.input.command,e[7]=n.input.description,e[8]=T):T=e[8],v=T;break e}if(n.toolKind==="web_search"){v=n.input.query||"Web Search";break e}if(n.toolKind==="read_file"){let T;e[9]!==m||e[10]!==i?(T=m?`Read ${Vb(m,i)}`:"Read file",e[9]=m,e[10]=i,e[11]=T):T=e[11],v=T;break e}if(n.toolKind==="write_file"){let T;e[12]!==m||e[13]!==i?(T=m?`Write ${Vb(m,i)}`:"Write file",e[12]=m,e[13]=i,e[14]=T):T=e[14],v=T;break e}if(n.toolKind==="edit_file"){let T;e[15]!==m||e[16]!==i?(T=m?`Edit ${Vb(m,i)}`:"Edit file",e[15]=m,e[16]=i,e[17]=T):T=e[17],v=T;break e}if(n.toolKind==="mcp_generic"){let T;e[18]!==n.input.tool?(T=B1(n.input.tool),e[18]=n.input.tool,e[19]=T):T=e[19];let X;e[20]!==n.input.server?(X=B1(n.input.server),e[20]=n.input.server,e[21]=X):X=e[21],v=`${T} from ${X}`;break e}if(n.toolKind==="subagent_task"){v=n.input.subagentType||n.toolName;break e}v=n.toolName}const b=v,S=n.toolKind==="subagent_task";let x;e:{if(n.toolKind==="skill"){x=n.input.skill;break e}x=void 0}const C=x,k=n.toolKind==="bash",E=n.toolKind==="write_file",R=n.toolKind==="edit_file",M=n.toolKind==="read_file";let O;e[22]!==M||e[23]!==u?(O=M&&!!u.trim(),e[22]=M,e[23]=u,e[24]=O):O=e[24];const D=O;let P;e[25]!==R||e[26]!==n.input?(P=R&&(!!n.input.oldString.trim()||!!n.input.newString.trim()),e[25]=R,e[26]=n.input,e[27]=P):P=e[27];const z=P;let Y;e:switch(n.toolKind){case"bash":{Y=n.input.command;break e}case"write_file":{Y=n.input.content;break e}default:{let T;e[28]!==n.input?(T=JSON.stringify(n.input,null,2),e[28]=n.input,e[29]=T):T=e[29],Y=T}}const L=Y;let W;e[30]!==z||e[31]!==L||e[32]!==k||e[33]!==R||e[34]!==M||e[35]!==E||e[36]!==n.input||e[37]!==n.isError||e[38]!==u?(W=R?z?g.jsx(h1,{content:"",isDiff:!0,oldString:n.input.oldString,newString:n.input.newString}):u.trim()?g.jsx(qb,{label:n.isError?"Error":"Result",copyText:u,children:u}):g.jsx("div",{className:"text-muted-foreground text-xs",children:"Cursor completed this edit, but ACP did not include the file diff details."}):!M&&!E&&g.jsx(qb,{label:k?g.jsxs("span",{className:"flex items-center gap-2 w-full",children:[g.jsx("span",{children:"Command"}),!!n.input.timeoutMs&&g.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(n.input.timeoutMs),"ms"]}),!!n.input.runInBackground&&g.jsx("span",{className:"text-muted-foreground",children:"background"})]}):E?"Contents":"Input",copyText:L,children:L}),e[30]=z,e[31]=L,e[32]=k,e[33]=R,e[34]=M,e[35]=E,e[36]=n.input,e[37]=n.isError,e[38]=u,e[39]=W):W=e[39];let V;e[40]!==D||e[41]!==a||e[42]!==M||e[43]!==n.isError||e[44]!==u?(V=a&&M&&!n.isError&&(D?g.jsx(h1,{content:u}):g.jsx("div",{className:"text-muted-foreground text-xs",children:"Cursor completed this read, but ACP did not include the file contents."})),e[40]=D,e[41]=a,e[42]=M,e[43]=n.isError,e[44]=u,e[45]=V):V=e[45];let F;e[46]!==E||e[47]!==n.input||e[48]!==n.isError?(F=E&&!n.isError&&g.jsx(h1,{content:n.input.content}),e[46]=E,e[47]=n.input,e[48]=n.isError,e[49]=F):F=e[49];let U;e[50]!==a||e[51]!==R||e[52]!==M||e[53]!==E||e[54]!==n.isError||e[55]!==u?(U=a&&!M&&!(E&&!n.isError)&&!(R&&!n.isError)&&g.jsx(qb,{label:n.isError?"Error":"Result",copyText:u,children:u}),e[50]=a,e[51]=R,e[52]=M,e[53]=E,e[54]=n.isError,e[55]=u,e[56]=U):U=e[56];let H;e[57]!==V||e[58]!==F||e[59]!==U||e[60]!==W?(H=g.jsx(Qh,{className:"my-4 text-sm",children:g.jsxs("div",{className:"flex flex-col gap-2",children:[W,V,F,U]})}),e[57]=V,e[58]=F,e[59]=U,e[60]=W,e[61]=H):H=e[61];let j;e:{if(n.isError){let J;e[62]===Symbol.for("react.memo_cache_sentinel")?(J=g.jsx(is,{className:"size-4 text-destructive"}),e[62]=J):J=e[62],j=J;break e}if(S){let J;e[63]===Symbol.for("react.memo_cache_sentinel")?(J=g.jsx(xy,{className:"size-4 text-muted-icon"}),e[63]=J):J=e[63],j=J;break e}let T;e[64]!==n.toolName?(T=PD(n.toolName),e[64]=n.toolName,e[65]=T):T=e[65];const X=T;let Z;e[66]!==X?(Z=g.jsx(X,{className:"size-4 text-muted-icon"}),e[66]=X,e[67]=Z):Z=e[67],j=Z}let G;e[68]!==j?(G=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:j}),e[68]=j,e[69]=G):G=e[69];const B=Math.max(20,((($=C||b)==null?void 0:$.length)??33)*3),K=C||b;let A;e[70]!==c||e[71]!==B||e[72]!==K?(A=g.jsx(Yo,{className:"text-left transition-opacity duration-200 truncate",children:g.jsx(Eg,{animate:c,shimmerWidth:B,children:K})}),e[70]=c,e[71]=B,e[72]=K,e[73]=A):A=e[73];let I;return e[74]!==H||e[75]!==G||e[76]!==A?(I=g.jsx(ea,{className:"w-full",children:g.jsxs(Xh,{expandedContent:H,children:[G,A]})}),e[74]=H,e[75]=G,e[76]=A,e[77]=I):I=e[77],I}function coe(t){const e=ke.c(9),{message:n}=t,r=uoe;if(!n.success){const f=n.result||"An unknown error occurred.";let m;return e[0]!==f?(m=g.jsx("div",{className:"px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:f}),e[0]=f,e[1]=m):m=e[1],m}const i=`px-0.5 text-xs tracking-wide ${n.durationMs>6e4?"":"hidden"}`;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("div",{className:"w-full h-[1px] bg-border"}),e[2]=s):s=e[2];const a=r(n.durationMs);let c;e[3]!==a?(c=g.jsxs(Yo,{className:"whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0",children:["Worked for ",a]}),e[3]=a,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=g.jsx("div",{className:"w-full h-[1px] bg-border"}),e[5]=d):d=e[5];let u;return e[6]!==i||e[7]!==c?(u=g.jsxs(ea,{className:i,children:[s,c,d]}),e[6]=i,e[7]=c,e[8]=u):u=e[8],u}function uoe(t){if(t<1e3)return`${t}ms`;const e=Math.floor(t/1e3),n=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return n>0?`${n}h${r>0?` ${r}m`:""}`:r>0?`${r}m${i>0?` ${i}s`:""}`:`${i}s`}function doe(t){const e=ke.c(1);let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=g.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground my-3",children:g.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:[g.jsx(YP,{className:"h-4 w-4 ml-1.5"}),g.jsx("em",{children:"Interrupted"})]})}),e[0]=n):n=e[0],n}function eg(t){const e=ke.c(15),{size:n}=t,r=n===void 0?4:n,i=`0 0 100 ${r}`,s=`${r}px`;let a;e[0]!==s?(a={height:s},e[0]=s,e[1]=a):a=e[1];const c=`M0 ${r} L${r/2} 0 L${r} ${r}`;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={stroke:"currentColor"},e[2]=d):d=e[2];let u;e[3]!==c?(u=g.jsx("path",{d:c,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:d}),e[3]=c,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==u?(f=g.jsx("pattern",{id:"zigzag",width:r,height:r,patternUnits:"userSpaceOnUse",children:u}),e[5]=r,e[6]=u,e[7]=f):f=e[7];let m;e[8]!==r?(m=g.jsx("rect",{width:"100%",height:r,fill:"url(#zigzag)",className:"text-muted-foreground/30"}),e[8]=r,e[9]=m):m=e[9];let v;return e[10]!==i||e[11]!==a||e[12]!==f||e[13]!==m?(v=g.jsxs("svg",{className:"flex-1",viewBox:i,preserveAspectRatio:"none",style:a,children:[f,m]}),e[10]=i,e[11]=a,e[12]=f,e[13]=m,e[14]=v):v=e[14],v}function hoe(){const t=ke.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(eg,{}),g.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),g.jsx(eg,{})]}),t[0]=e):e=t[0],e}function foe(){const t=ke.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(eg,{}),g.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),g.jsx(eg,{})]}),t[0]=e):e=t[0],e}function moe(t){const e=ke.c(8),{message:n}=t;let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[rf],i=Zh(),e[0]=r,e[1]=i):(r=e[0],i=e[1]);let s;e[2]!==n.summary?(s=g.jsx(Qh,{className:"my-4 text-xs",children:g.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:g.jsx(nf,{remarkPlugins:r,components:i,children:n.summary})})}),e[2]=n.summary,e[3]=s):s=e[3];let a,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(QR,{className:"h-4.5 w-4.5 text-muted-foreground"})}),c=g.jsx(Yo,{children:"Summarized"}),e[4]=a,e[5]=c):(a=e[4],c=e[5]);let d;return e[6]!==s?(d=g.jsx(ea,{children:g.jsxs(Xh,{expandedContent:s,children:[a,c]})}),e[6]=s,e[7]=d):d=e[7],d}const poe={compacting:"Compacting..."};function goe(t){const e=ke.c(3),{message:n}=t,r=poe[n.status]||n.status;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(QR,{className:"h-4.5 w-4.5 text-muted-foreground"})}),e[0]=i):i=e[0];let s;return e[1]!==r?(s=g.jsxs(ea,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[i,g.jsx(Yo,{className:"text-left transition-opacity duration-200 truncate",children:r})]}),e[1]=r,e[2]=s):s=e[2],s}const voe={read_file:{key:"read",singular:"read",plural:"reads"},edit_file:{key:"edit",singular:"edit",plural:"edits"},write_file:{key:"write",singular:"write",plural:"writes"},bash:{key:"bash",singular:"command",plural:"commands"},grep:{key:"grep",singular:"search",plural:"searches"},glob:{key:"glob",singular:"glob",plural:"globs"},subagent_task:{key:"task",singular:"agent",plural:"agents"},web_search:{key:"websearch",singular:"web search",plural:"web searches"},skill:{key:"skill",singular:"skill",plural:"skills"},todo_write:{key:"todo",singular:"todo update",plural:"todo updates"}},boe={key:"other",singular:"tool call",plural:"tool calls"};function _oe(t){return voe[t]??boe}function yoe(t){const e=new Map,n=[];for(const r of t){const i=r.toolKind,s=_oe(i),a=e.get(s.key);a?a.count++:(e.set(s.key,{category:s,count:1}),n.push(s.key))}return n.map(r=>{const{category:i,count:s}=e.get(r);return`${s} ${s===1?i.singular:i.plural}`}).join(", ")}function xoe(t){const e=ke.c(26),{messages:n,isLoading:r,localPath:i}=t,[s,a]=_.useState(!1);let c;e[0]!==n?(c=yoe(n),e[0]=n,e[1]=c):c=e[1];const d=c;let u;e[2]!==n?(u=n.some(Soe),e[2]=n,e[3]=u):u=e[3];const m=u&&r;let v;e[4]!==s?(v=()=>a(!s),e[4]=s,e[5]=v):v=e[5];const b=`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!s&&!m?"hover:opacity-60 transition-opacity":""}`,S=`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${s?"rotate-90":""}`;let x;e[6]!==S?(x=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(Ni,{className:S})}),e[6]=S,e[7]=x):x=e[7];let C;e[8]!==d||e[9]!==m?(C=g.jsx(Yo,{className:"text-left",children:g.jsx(Eg,{animate:m,children:d})}),e[8]=d,e[9]=m,e[10]=C):C=e[10];let k;e[11]!==x||e[12]!==C?(k=g.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x,C]}),e[11]=x,e[12]=C,e[13]=k):k=e[13];let E;e[14]!==v||e[15]!==b||e[16]!==k?(E=g.jsx("button",{onClick:v,className:b,children:k}),e[14]=v,e[15]=b,e[16]=k,e[17]=E):E=e[17];let R;e[18]!==s||e[19]!==r||e[20]!==i||e[21]!==n?(R=s&&g.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[n.map(O=>g.jsx(Q6,{message:O,isLoading:r,localPath:i},O.id)),n.length>5&&g.jsx("button",{onClick:()=>a(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:g.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(Ni,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),g.jsx(Yo,{className:"text-left",children:"Collapse"})]})})]}),e[18]=s,e[19]=r,e[20]=i,e[21]=n,e[22]=R):R=e[22];let M;return e[23]!==R||e[24]!==E?(M=g.jsx(ea,{className:"w-full",children:g.jsxs("div",{className:"flex flex-col w-full",children:[E,R]})}),e[23]=R,e[24]=E,e[25]=M):M=e[25],M}function Soe(t){return t.result===void 0}const woe=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite"]);function aR(t){if(t.kind!=="tool")return!1;const e=t.toolName;return!woe.has(e)}function Coe(t,e,n){return t?t.kind==="status"&&e<n.length-1:!1}function koe(t,e={}){var s;const n=[];let r=0;const i=a=>(a==null?void 0:a.kind)==="tool"&&a.toolName==="TodoWrite"&&a.id!==e.TodoWrite;for(;r<t.length;){const a=t[r];if(aR(a)){const c=[a],d=r;for(r+=1;r<t.length;){const u=t[r];if(aR(u)){c.push(u),r+=1;continue}if(Coe(u,r,t)){r+=1;continue}if(i(u)){r+=1;continue}break}c.length>=2?n.push({type:"tool-group",key:`group-${((s=c[0])==null?void 0:s.id)??d}`,messages:c,startIndex:d}):n.push({type:"single",key:a.id,message:a,index:d});continue}n.push({type:"single",key:a.id,message:a,index:r}),r+=1}return n}function Eoe(t,e){var r;if(!e)return null;let n=-1;for(let i=t.length-1;i>=0;i-=1)if(((r=t[i])==null?void 0:r.kind)==="user_prompt"){n=i;break}if(n<0)return null;for(let i=t.length-1;i>n;i-=1){const s=t[i];if((s==null?void 0:s.kind)==="assistant_text")return s.id}return null}function Roe(t,e){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect().top-n.top+t.scrollTop;return{viewportHeight:t.clientHeight,viewportWidth:t.clientWidth,viewportStart:Math.max(0,t.scrollTop-i)}}function Toe(t){const e=ke.c(67),{messages:n,isLoading:r,hasOlderMessages:i,oldestLoadedEntryId:s,isLoadingOlderMessages:a,isAtBottom:c,localPath:d,latestToolIds:u,onOpenLocalLink:f,onAskUserQuestionSubmit:m,onExitPlanModeConfirm:v,onHandoff:b,onLoadOlder:S,pendingTool:x,availableProviders:C,scrollContainerRef:k}=t,E=_.useRef(null),R=_.useRef(null);let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={viewportHeight:0,viewportWidth:0,viewportStart:0},e[0]=M):M=e[0];const[O,D]=_.useState(M);let P;e[1]!==n?(P=n.filter(Noe),e[1]=n,e[2]=P):P=e[2];const z=P;let Y;e[3]!==u||e[4]!==z?(Y=koe(z,u),e[3]=u,e[4]=z,e[5]=Y):Y=e[5];const L=Y;let W;e[6]!==z?(W=z.findIndex(Aoe),e[6]=z,e[7]=W):W=e[7];const V=W;let F;e[8]!==z?(F=z.findIndex(Moe),e[8]=z,e[9]=F):F=e[9];const U=F;let H;e[10]!==r||e[11]!==z?(H=Eoe(z,r),e[10]=r,e[11]=z,e[12]=H):H=e[12];const j=H;let G;e[13]!==k?(G=()=>{const me=k.current,se=E.current;if(!me||!se)return;const oe=()=>{const Q=Roe(me,se);D(te=>te.viewportHeight===Q.viewportHeight&&te.viewportWidth===Q.viewportWidth&&te.viewportStart===Q.viewportStart?te:Q)};oe();const ee=new ResizeObserver(oe);return ee.observe(me),ee.observe(se),me.addEventListener("scroll",oe,{passive:!0}),()=>{ee.disconnect(),me.removeEventListener("scroll",oe)}},e[13]=k,e[14]=G):G=e[14];let B;e[15]!==n.length||e[16]!==k?(B=[n.length,k],e[15]=n.length,e[16]=k,e[17]=B):B=e[17],_.useEffect(G,B);let K,A;e[18]!==c||e[19]!==s||e[20]!==O.viewportStart?(A=()=>{if(c||O.viewportStart>480){R.current=null;return}s&&R.current!==s&&(R.current=null)},K=[c,s,O.viewportStart],e[18]=c,e[19]=s,e[20]=O.viewportStart,e[21]=K,e[22]=A):(K=e[21],A=e[22]),_.useEffect(A,K);let I;e[23]!==i||e[24]!==c||e[25]!==a||e[26]!==s||e[27]!==S||e[28]!==k||e[29]!==O.viewportStart?(I=()=>{if(!i||!s||a||c||O.viewportStart>480)return;const me=k.current;if(me){const se=me.scrollHeight-me.scrollTop-me.clientHeight;if(dN(se))return}R.current!==s&&(R.current=s,S())},e[23]=i,e[24]=c,e[25]=a,e[26]=s,e[27]=S,e[28]=k,e[29]=O.viewportStart,e[30]=I):I=e[30];let $;e[31]!==i||e[32]!==c||e[33]!==a||e[34]!==n.length||e[35]!==s||e[36]!==S||e[37]!==O.viewportStart?($=[i,c,s,a,n.length,S,O.viewportStart],e[31]=i,e[32]=c,e[33]=a,e[34]=n.length,e[35]=s,e[36]=S,e[37]=O.viewportStart,e[38]=$):$=e[38],_.useEffect(I,$);let T;e[39]!==C||e[40]!==U||e[41]!==V||e[42]!==r||e[43]!==j||e[44]!==u||e[45]!==d||e[46]!==m||e[47]!==v||e[48]!==b||e[49]!==x||e[50]!==z?(T=function(se,oe){if(se.kind==="user_prompt")return g.jsx(_se,{content:se.content,attachments:se.attachments},se.id);switch(se.kind){case"unknown":return g.jsx(wse,{json:se.json},se.id);case"system_init":return oe===V?g.jsx(Dse,{message:se,rawJson:se.debugRaw},se.id):null;case"account_info":return oe===U?g.jsx(jse,{message:se},se.id):null;case"assistant_text":return g.jsx(Lse,{message:se,isStreaming:r&&se.id===j},se.id);case"assistant_thought":return g.jsx(Ise,{message:se},se.id);case"tool":return se.toolKind==="ask_user_question"?g.jsx($se,{message:se,onSubmit:m,isLatest:se.id===u.AskUserQuestion},se.id):se.toolKind==="exit_plan_mode"?g.jsx(Xse,{message:se,onConfirm:v,onHandoff:b,isLatest:se.id===u.ExitPlanMode,isActionable:(x==null?void 0:x.toolKind)==="exit_plan_mode"&&x.toolUseId===se.toolId,availableProviders:C},se.id):se.toolKind==="todo_write"?se.id!==u.TodoWrite?null:g.jsx(eoe,{message:se},se.id):g.jsx(Q6,{message:se,isLoading:r,localPath:d},se.id);case"result":{const ee=z[oe+1],Q=z[oe-1];return(ee==null?void 0:ee.kind)==="context_cleared"||(Q==null?void 0:Q.kind)==="context_cleared"?null:g.jsx(coe,{message:se},se.id)}case"interrupted":return g.jsx(doe,{message:se},se.id);case"compact_boundary":return g.jsx(hoe,{},se.id);case"context_cleared":return g.jsx(foe,{},se.id);case"compact_summary":return g.jsx(moe,{message:se},se.id);case"status":return oe===z.length-1?g.jsx(goe,{message:se},se.id):null}},e[39]=C,e[40]=U,e[41]=V,e[42]=r,e[43]=j,e[44]=u,e[45]=d,e[46]=m,e[47]=v,e[48]=b,e[49]=x,e[50]=z,e[51]=T):T=e[51];const X=T;let Z;e[52]!==r||e[53]!==d||e[54]!==X?(Z=function(se,oe){if(se.type==="tool-group")return g.jsx("div",{className:oe?void 0:"pb-5",children:g.jsx("div",{className:"group relative",[Sp]:"",children:g.jsx(xoe,{messages:se.messages,isLoading:r,localPath:d})})},se.key);const ee=X(se.message,se.index);return ee?g.jsx("div",{className:oe?void 0:"pb-5",children:g.jsx("div",{id:`msg-${se.message.id}`,className:"group relative",[Sp]:"",children:ee})},se.key):null},e[52]=r,e[53]=d,e[54]=X,e[55]=Z):Z=e[55];const J=Z;let re;if(e[56]!==J||e[57]!==L){let me;e[59]!==J||e[60]!==L.length?(me=(se,oe)=>J(se,oe===L.length-1),e[59]=J,e[60]=L.length,e[61]=me):me=e[61],re=L.map(me),e[56]=J,e[57]=L,e[58]=re}else re=e[58];let ae;e[62]!==re?(ae=g.jsx("div",{ref:E,children:re}),e[62]=re,e[63]=ae):ae=e[63];let ue;return e[64]!==f||e[65]!==ae?(ue=g.jsx(xZ,{onOpenLocalLink:f,children:ae}),e[64]=f,e[65]=ae,e[66]=ue):ue=e[66],ue}function Moe(t){return t.kind==="account_info"}function Aoe(t){return t.kind==="system_init"}function Noe(t){return!t.hidden}function Doe(t){const e=ke.c(6),{rootRef:n,fallbackRef:r,enabled:i,canCancel:s}=t;let a,c;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==n?(a=()=>{if(!i)return;let d=0,u=null;const f=x=>{const C=x instanceof Element?x:null,k=n.current,E=r.current;if(Fk({trigger:"pointer",activeElement:document.activeElement,pointerStartTarget:u,pointerEndTarget:C,root:k,fallback:E,hasActiveOverlay:Bk(document),hasActiveSelection:z7(window.getSelection())})!=="restore"){u=null;return}E==null||E.focus({preventScroll:!0}),u=null},m=x=>{cancelAnimationFrame(d),u=x.target instanceof Element?x.target:null},v=x=>{cancelAnimationFrame(d),d=window.requestAnimationFrame(()=>{f(x.target)})},b=()=>{u=null;const x=r.current;!x||x.disabled||x.focus({preventScroll:!0})},S=x=>{if(x.key!=="Escape")return;const C=r.current;Fk({trigger:"escape",activeElement:document.activeElement,fallback:C,hasActiveOverlay:Bk(document),canCancel:s,defaultPrevented:x.defaultPrevented})==="escape-focus"&&(x.preventDefault(),C==null||C.focus({preventScroll:!0}))};return window.addEventListener("pointerdown",m,!0),window.addEventListener("pointerup",v,!0),window.addEventListener("keydown",S,!0),window.addEventListener(xp,b),()=>{cancelAnimationFrame(d),window.removeEventListener("pointerdown",m,!0),window.removeEventListener("pointerup",v,!0),window.removeEventListener("keydown",S,!0),window.removeEventListener(xp,b)}},c=[s,i,r,n],e[0]=s,e[1]=i,e[2]=r,e[3]=n,e[4]=a,e[5]=c):(a=e[4],c=e[5]),_.useEffect(a,c)}const $m="Use any pull-request skills to create a new pull request for these local changes. Write a clear, concise title, description, and testing summary.",Um="Use any pull-request skills to update the existing pull request for these local changes. Commit the local changes with a clear, concise message and summarize what changed.",au=["codex"],Ooe=new Set(rc.map(t=>t.id));function lR(t){if(!Array.isArray(t))return[...au];const e=t.filter(n=>typeof n=="string"&&Ooe.has(n));return e.length>0?Array.from(new Set(e)):[...au]}const f1=fi()(Li(t=>({pullRequestPrompt:$m,pullRequestUpdatePrompt:Um,pullRequestProviders:[...au],setPullRequestPrompt:e=>t({pullRequestPrompt:e}),setPullRequestUpdatePrompt:e=>t({pullRequestUpdatePrompt:e}),setPullRequestProviders:e=>t({pullRequestProviders:lR(e)}),togglePullRequestProvider:e=>t(n=>{const r=n.pullRequestProviders.includes(e)?n.pullRequestProviders.filter(i=>i!==e):[...n.pullRequestProviders,e];return{pullRequestProviders:r.length>0?r:[...au]}}),resetToDefaults:()=>t({pullRequestPrompt:$m,pullRequestUpdatePrompt:Um,pullRequestProviders:[...au]})}),{name:"slash-command-settings",version:1,migrate:t=>{if(!t||typeof t!="object")return{pullRequestPrompt:$m,pullRequestUpdatePrompt:Um,pullRequestProviders:[...au]};const e=t;return{...e,pullRequestPrompt:typeof e.pullRequestPrompt=="string"?e.pullRequestPrompt:$m,pullRequestUpdatePrompt:typeof e.pullRequestUpdatePrompt=="string"?e.pullRequestUpdatePrompt:Um,pullRequestProviders:lR(e.pullRequestProviders)}}}));function Wm(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function joe(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}function Loe(t,e){const n=joe(e);switch(t.toolKind){case"ask_user_question":{const i=Wm(n),s=Wm(i==null?void 0:i.answers)??(i||{});return{answers:Object.fromEntries(Object.entries(s).map(([a,c])=>Array.isArray(c)?[a,c.map(d=>String(d))]:c&&typeof c=="object"&&Array.isArray(c.answers)?[a,c.answers.map(d=>String(d))]:c==null||c===""?[a,[]]:[a,[String(c)]])),...(i==null?void 0:i.discarded)===!0?{discarded:!0}:{}}}case"exit_plan_mode":{const i=Wm(n);return{confirmed:typeof(i==null?void 0:i.confirmed)=="boolean"?i.confirmed:void 0,clearContext:typeof(i==null?void 0:i.clearContext)=="boolean"?i.clearContext:void 0,suppressFollowUp:typeof(i==null?void 0:i.suppressFollowUp)=="boolean"?i.suppressFollowUp:void 0,message:typeof(i==null?void 0:i.message)=="string"?i.message:void 0,...(i==null?void 0:i.discarded)===!0?{discarded:!0}:{}}}case"read_file":if(typeof n=="string")return n;const r=Wm(n);return{content:typeof(r==null?void 0:r.content)=="string"?r.content:JSON.stringify(n,null,2)};default:return n}}function Z6(t){return new Date(t).toISOString()}function Yi(t){return{id:t._id,messageId:t.messageId,timestamp:Z6(t.createdAt),hidden:t.hidden}}function Ioe(t){return{id:t._id,messageId:t.messageId,hidden:t.hidden,kind:"tool",toolKind:t.tool.toolKind,toolName:t.tool.toolName,toolId:t.tool.toolId,input:t.tool.input,timestamp:Z6(t.createdAt)}}function Poe(t){if(t.debugRaw)try{return JSON.parse(t.debugRaw).tool_use_result}catch{return}}function zoe(t){if(t!=null&&t.length)return t.map(e=>({...e,previewUrl:`/attachments/${e.relativePath.split("/").map(encodeURIComponent).join("/")}`}))}function cR(t,e){const n=t.at(-1);if((n==null?void 0:n.kind)===e.kind&&n.hidden===e.hidden&&n.messageId===e.messageId){n.text+=e.text;return}t.push(e)}function uR(t){if(!t||typeof t!="object"||!("answers"in t))return!1;const e=t.answers;return Object.values(e).some(n=>Array.isArray(n)&&n.length>0)}function Boe(t){const e=new Map,n=[];for(const r of t)switch(r.kind){case"user_prompt":n.push({...Yi(r),kind:"user_prompt",content:r.content,attachments:zoe(r.attachments)});break;case"system_init":n.push({...Yi(r),kind:"system_init",provider:r.provider,model:r.model,tools:r.tools,agents:r.agents,slashCommands:r.slashCommands,mcpServers:r.mcpServers,debugRaw:r.debugRaw});break;case"account_info":n.push({...Yi(r),kind:"account_info",accountInfo:r.accountInfo});break;case"assistant_text":cR(n,{...Yi(r),kind:"assistant_text",text:r.text});break;case"assistant_thought":cR(n,{...Yi(r),kind:"assistant_thought",text:r.text});break;case"tool_call":{const i=n.at(-1);(i==null?void 0:i.kind)==="assistant_text"&&r.tool.toolKind==="ask_user_question"&&(i.hidden=!0);const s=Ioe(r);e.set(r.tool.toolId,{hydrated:s,normalized:r.tool,precedingAssistantText:(i==null?void 0:i.kind)==="assistant_text"?i:void 0}),n.push(s);break}case"tool_result":{const i=e.get(r.toolId);if(i){const s=i.normalized.toolKind==="ask_user_question"||i.normalized.toolKind==="exit_plan_mode"?Poe(r)??r.content:r.content,a=Loe(i.normalized,s);(i.normalized.toolKind!=="ask_user_question"||!uR(i.hydrated.result)||uR(a))&&(i.hydrated.result=a,i.hydrated.rawResult=s),i.hydrated.isError=r.isError,i.normalized.toolKind==="exit_plan_mode"&&i.precedingAssistantText&&i.hydrated.result&&(i.precedingAssistantText.hidden=!0)}break}case"result":n.push({...Yi(r),kind:"result",success:!r.isError,cancelled:r.subtype==="cancelled",result:r.result,durationMs:r.durationMs,costUsd:r.costUsd});break;case"status":n.push({...Yi(r),kind:"status",status:r.status});break;case"compact_boundary":n.push({...Yi(r),kind:"compact_boundary"});break;case"compact_summary":n.push({...Yi(r),kind:"compact_summary",summary:r.summary});break;case"context_cleared":n.push({...Yi(r),kind:"context_cleared"});break;case"interrupted":n.push({...Yi(r),kind:"interrupted"});break;default:n.push({...Yi(r),kind:"unknown",json:JSON.stringify(r,null,2)});break}return n}const Foe=["AskUserQuestion","ExitPlanMode","TodoWrite"],Hoe=new Set(["TodoWrite"]);function $oe(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r.kind!=="tool")continue;const i=r;if(i.toolName===e&&!i.result)return i.id}return null}function Uoe(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r.kind!=="tool")continue;const i=r;if(i.toolName===e)return i.id}return null}function Woe(t){const e={};for(const n of Foe)e[n]=Hoe.has(n)?Uoe(t,n):$oe(t,n);return e}function Voe(t){return t==="starting"||t==="running"||t==="waiting_for_user"}function cy(t){return t==="starting"||t==="running"||t==="waiting_for_user"}function J6(){return typeof window>"u"?null:(window.__KAIZEN_PERF__??(window.__KAIZEN_PERF__={timings:{},counters:{}}),window.__KAIZEN_PERF__)}function eO(){return typeof window>"u"?!1:window.localStorage.getItem("kaizen.debug.perf")==="1"}function tO(t,e,n){const r=J6();r&&(r.timings[t]={value:e,meta:n,recordedAt:Date.now()},eO()&&console.debug(`[kaizen][perf] timing ${t}=${e}`,n??{}))}function dR(t,e=1,n){var s;const r=J6();if(!r)return;const i=(((s=r.counters[t])==null?void 0:s.value)??0)+e;r.counters[t]={value:i,meta:n,recordedAt:Date.now()},eO()&&console.debug(`[kaizen][perf] counter ${t}=${i}`,n??{})}function qoe(t){const e=new Set;return t.filter(n=>{const r=n.localPath??n.projectId;return!r||e.has(r)?!1:(e.add(r),!0)})}function Koe(t,e,n){return{...t,projectGroups:t.projectGroups.map(r=>{if(r.groupKey!==e)return r;const i=new Map(r.features.map(a=>[a.featureId,a])),s=n.map(a=>i.get(a)).filter(a=>!!a);return s.length!==r.features.length?r:{...r,features:s}})}}function Goe(t,e){const n=t.stage==="done"?1:0,r=e.stage==="done"?1:0;return n!==r?n-r:t.sortOrder!==e.sortOrder?t.sortOrder-e.sortOrder:e.updatedAt-t.updatedAt}function Yoe(t,e,n){const r=t.filter(s=>s.featureId!==e);if(n==="done"){const s=r.filter(c=>c.stage==="done").map(c=>c.sortOrder),a=r.map(c=>c.sortOrder);return s.length>0?Math.max(...s)+1:a.length>0?Math.max(...a)+1:0}const i=r.filter(s=>s.stage!=="done").map(s=>s.sortOrder);return i.length===0?0:Math.max(...i)+1}function Xoe(t,e,n,r=Date.now()){return{...t,projectGroups:t.projectGroups.map(i=>{const s=i.features.find(d=>d.featureId===e);if(!s||s.stage===n)return i;const a=s.stage==="done"||n==="done",c=i.features.map(d=>d.featureId===e?{...d,stage:n,updatedAt:r,sortOrder:a?Yoe(i.features,e,n):d.sortOrder}:d).sort(Goe);return{...i,features:c}})}}function Qoe(){return{projectBrowserStateById:{},projectGeneralChatsBrowserStateById:{},featureBrowserStateById:{},featureStageById:{},featureOrderByProjectId:{}}}function Zoe(t,e){let n={...t,projectGroups:t.projectGroups.map(r=>{var i,s;return{...r,browserState:((i=e.projectBrowserStateById[r.groupKey])==null?void 0:i.value)??r.browserState,generalChatsBrowserState:((s=e.projectGeneralChatsBrowserStateById[r.groupKey])==null?void 0:s.value)??r.generalChatsBrowserState,features:r.features.map(a=>{var c;return{...a,browserState:((c=e.featureBrowserStateById[a.featureId])==null?void 0:c.value)??a.browserState}})}})};for(const[r,i]of Object.entries(e.featureOrderByProjectId))n=Koe(n,r,i.value);for(const[r,i]of Object.entries(e.featureStageById))n=Xoe(n,r,i.value);return n}function nO(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(t[n]!==e[n])return!1;return!0}function Vm(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>{var s,a,c,d;return((s=t[i])==null?void 0:s.value)===((a=e[i])==null?void 0:a.value)&&((c=t[i])==null?void 0:c.opId)===((d=e[i])==null?void 0:d.opId)})}function Joe(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>{var s,a;return e[i]?((s=t[i])==null?void 0:s.opId)===((a=e[i])==null?void 0:a.opId)&&nO(t[i].value,e[i].value):!1})}function m1(t,e){return t.projectGroups.find(n=>n.groupKey===e)}function hR(t,e){return t.projectGroups.flatMap(n=>n.features).find(n=>n.featureId===e)}function eae(t,e){const n=Object.fromEntries(Object.entries(e.projectBrowserStateById).filter(([c,d])=>{var u;return((u=m1(t,c))==null?void 0:u.browserState)!==d.value})),r=Object.fromEntries(Object.entries(e.projectGeneralChatsBrowserStateById).filter(([c,d])=>{var u;return((u=m1(t,c))==null?void 0:u.generalChatsBrowserState)!==d.value})),i=Object.fromEntries(Object.entries(e.featureBrowserStateById).filter(([c,d])=>{var u;return((u=hR(t,c))==null?void 0:u.browserState)!==d.value})),s=Object.fromEntries(Object.entries(e.featureStageById).filter(([c,d])=>{var u;return((u=hR(t,c))==null?void 0:u.stage)!==d.value})),a=Object.fromEntries(Object.entries(e.featureOrderByProjectId).filter(([c,d])=>{const u=m1(t,c);return u?!nO(u.features.map(f=>f.featureId),d.value):!1}));return{projectBrowserStateById:n,projectGeneralChatsBrowserStateById:r,featureBrowserStateById:i,featureStageById:s,featureOrderByProjectId:a}}function tae(t,e){return Vm(t.projectBrowserStateById,e.projectBrowserStateById)&&Vm(t.projectGeneralChatsBrowserStateById,e.projectGeneralChatsBrowserStateById)&&Vm(t.featureBrowserStateById,e.featureBrowserStateById)&&Vm(t.featureStageById,e.featureStageById)&&Joe(t.featureOrderByProjectId,e.featureOrderByProjectId)}function qd(t,e,n){var s;if(!(e in t)||((s=t[e])==null?void 0:s.opId)!==n)return t;const{[e]:r,...i}=t;return i}const rO=_.createContext(void 0);function nae(t){const e=new Map;for(const n of t.projectGroups)for(const r of[...n.generalChats,...n.features.flatMap(i=>i.chats)])e.set(r.chatId,r.status);return e}function uy(t,e){switch(e.type){case"sidebar.project-added":{const n=[...t.projectGroups];return n.splice(e.index,0,{...e.project,features:[],generalChats:[]}),{...t,projectGroups:n}}case"sidebar.project-removed":return{...t,projectGroups:t.projectGroups.filter(n=>n.groupKey!==e.projectId)};case"sidebar.project-moved":{const n=t.projectGroups.findIndex(s=>s.groupKey===e.projectId);if(n===-1)return t;const r=[...t.projectGroups],[i]=r.splice(n,1);return r.splice(e.index,0,i),{...t,projectGroups:r}}case"sidebar.project-fields-set":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey===e.projectId?{...n,...e.patch}:n)};case"sidebar.feature-added":return{...t,projectGroups:t.projectGroups.map(n=>{if(n.groupKey!==e.projectId)return n;const r=[...n.features];return r.splice(e.index,0,e.feature),{...n,features:r}})};case"sidebar.feature-removed":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:{...n,features:n.features.filter(r=>r.featureId!==e.featureId)})};case"sidebar.feature-moved":return{...t,projectGroups:t.projectGroups.map(n=>{if(n.groupKey!==e.projectId)return n;const r=n.features.findIndex(a=>a.featureId===e.featureId);if(r===-1)return n;const i=[...n.features],[s]=i.splice(r,1);return i.splice(e.index,0,s),{...n,features:i}})};case"sidebar.feature-fields-set":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:{...n,features:n.features.map(r=>r.featureId===e.featureId?{...r,...e.patch}:r)})};case"sidebar.chat-added":return{...t,projectGroups:t.projectGroups.map(n=>{if(n.groupKey!==e.projectId)return n;if(e.featureId)return{...n,features:n.features.map(i=>{if(i.featureId!==e.featureId)return i;const s=[...i.chats];return s.splice(e.index,0,e.chat),{...i,chats:s}})};const r=[...n.generalChats];return r.splice(e.index,0,e.chat),{...n,generalChats:r}})};case"sidebar.chat-removed":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:e.featureId?{...n,features:n.features.map(r=>r.featureId!==e.featureId?r:{...r,chats:r.chats.filter(i=>i.chatId!==e.chatId)})}:{...n,generalChats:n.generalChats.filter(r=>r.chatId!==e.chatId)})};case"sidebar.chat-moved":{const n=uy(t,{type:"sidebar.chat-removed",projectId:e.projectId,featureId:e.fromFeatureId,chatId:e.chatId}),r=t.projectGroups.flatMap(i=>[...i.generalChats,...i.features.flatMap(s=>s.chats)]).find(i=>i.chatId===e.chatId);return r?uy(n,{type:"sidebar.chat-added",projectId:e.projectId,featureId:e.toFeatureId,chat:{...r,featureId:e.toFeatureId},index:e.index}):n}case"sidebar.chat-fields-set":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:e.featureId?{...n,features:n.features.map(r=>r.featureId!==e.featureId?r:{...r,chats:r.chats.map(i=>i.chatId===e.chatId?{...i,...e.patch}:i)})}:{...n,generalChats:n.generalChats.map(r=>r.chatId===e.chatId?{...r,...e.patch}:r)})};case"sidebar.provider-usage-set":return{...t,providerUsage:e.providerUsage}}}function rae({children:t,activeChatId:e,activeOverviewFeatureId:n}){const r=tc(),i=Ly(),{socket:s}=Vh(),{setCommandError:a,handleOpenCreateFeatureModal:c}=Fu(),[d,u]=_.useState({projectGroups:[]}),[f,m]=_.useState(Qoe),[v,b]=_.useState(null),[S,x]=_.useState(null),[C,k]=_.useState(!1),[E,R]=_.useState(!1),[M,O]=_.useState(!1),[D,P]=_.useState(!1),[z,Y]=_.useState(new Set),L=_.useRef(1),W=_.useRef(d),V=_.useRef(new Map),F=_.useRef(typeof document>"u"?!0:document.visibilityState==="visible"),U=dh(ee=>ee.setVisibility),H=_.useMemo(()=>Zoe(d,f),[d,f]),j=_.useCallback(ee=>{W.current=ee,u(ee),m(Q=>{const te=eae(ee,Q);return tae(Q,te)?Q:te})},[]);function G(){const ee=L.current;return L.current+=1,ee}_.useEffect(()=>{function ee(){const Q=document.visibilityState==="visible";F.current=Q,!(!Q||!e)&&Y(te=>{if(!te.has(e))return te;const he=new Set(te);return he.delete(e),he})}return document.addEventListener("visibilitychange",ee),()=>document.removeEventListener("visibilitychange",ee)},[e]),_.useEffect(()=>s.subscribe({type:"sidebar"},ee=>{j(ee),k(!0),a(null)},ee=>{const Q=performance.now(),te=uy(W.current,ee);j(te),tO("sidebar_event_apply_ms",Math.round(performance.now()-Q),{type:ee.type}),k(!0),a(null)}),[j,a,s]),_.useEffect(()=>{const ee=nae(H),Q=V.current,te=F.current;Y(he=>{let ie=he;for(const[xe,Ae]of ee){const Ke=Q.get(xe);cy(Ae)&&ie.has(xe)&&(ie===he&&(ie=new Set(he)),ie.delete(xe)),Ke&&cy(Ke)&&Ae==="idle"&&(xe!==e||!te)&&(ie===he&&(ie=new Set(he)),ie.add(xe))}return ie}),V.current=ee},[e,H]),_.useEffect(()=>s.subscribe({type:"local-projects"},ee=>{b(ee),R(!0),a(null)}),[a,s]),_.useEffect(()=>{if(!n){x(null);return}return x(null),s.subscribe({type:"feature-overview",featureId:n},ee=>{x(ee),a(null)})},[n,a,s]),_.useEffect(()=>{if(!e)return;const ee=u_(H.projectGroups,e);ee&&U(ee,!1)},[e,U,H.projectGroups]);function B(ee){Y(Q=>{if(!Q.has(ee))return Q;const te=new Set(Q);return te.delete(ee),te})}async function K(ee){const Q=ee.split("/").filter(Boolean).pop()??ee;if(await i.confirm({title:"Hide Project",description:`Hide "${Q}" from ${ys}? This only removes it from ${ys} until you re-add it or reset local state.`,confirmLabel:"Hide",confirmVariant:"destructive"}))try{await s.command({type:"project.hide",localPath:ee}),a(null)}catch(he){a(he instanceof Error?he.message:String(he))}}async function A(ee){const Q=new URL(Hg("/api/directories"),window.location.origin);ee&&Q.searchParams.set("path",ee);const te=await fetch(Q.toString());if(!te.ok){let ie="Failed to load directories";try{const xe=await te.json();xe.error&&(ie=xe.error)}catch{}throw new Error(ie)}const he=await te.json();return a(null),he}async function I(ee){const Q=H.projectGroups.flatMap(he=>he.features).find(he=>he.featureId===ee);if(!Q)return;const te=await i.prompt({title:"Rename Feature",placeholder:"Feature name",initialValue:Q.title,confirmLabel:"Rename"});if(!(!te||te===Q.title))try{await s.command({type:"feature.rename",featureId:ee,title:te}),a(null)}catch(he){a(he instanceof Error?he.message:String(he))}}async function $(ee){const Q=H.projectGroups.flatMap(he=>he.features).find(he=>he.featureId===ee);if(!(!Q||!await i.confirm({title:"Delete Feature",description:`Delete "${Q.title}"? Its chats will move to General and the feature folder will be removed.`,confirmLabel:"Delete",confirmVariant:"destructive"})))try{await s.command({type:"feature.delete",featureId:ee}),n===ee&&r("/"),a(null)}catch(he){a(he instanceof Error?he.message:String(he))}}async function T(ee,Q){const te=G();m(he=>({...he,featureBrowserStateById:{...he.featureBrowserStateById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"feature.setBrowserState",featureId:ee,browserState:Q}),a(null)}catch(he){m(ie=>({...ie,featureBrowserStateById:qd(ie.featureBrowserStateById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function X(ee,Q){const te=G();m(he=>({...he,projectBrowserStateById:{...he.projectBrowserStateById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"project.setBrowserState",projectId:ee,browserState:Q}),a(null)}catch(he){m(ie=>({...ie,projectBrowserStateById:qd(ie.projectBrowserStateById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function Z(ee,Q){const te=G();m(he=>({...he,projectGeneralChatsBrowserStateById:{...he.projectGeneralChatsBrowserStateById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"project.setGeneralChatsBrowserState",projectId:ee,browserState:Q}),a(null)}catch(he){m(ie=>({...ie,projectGeneralChatsBrowserStateById:qd(ie.projectGeneralChatsBrowserStateById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function J(ee,Q){const te=G();m(he=>({...he,featureStageById:{...he.featureStageById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"feature.setStage",featureId:ee,stage:Q}),a(null)}catch(he){m(ie=>({...ie,featureStageById:qd(ie.featureStageById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function re(ee,Q){try{const te=await s.command({type:"feature.updateOverview",featureId:ee,content:Q});return a(null),te}catch(te){const he=te instanceof Error?te.message:String(te);throw a(he),te}}async function ae(ee,Q){const te=G();m(he=>({...he,featureOrderByProjectId:{...he.featureOrderByProjectId,[ee]:{value:Q,opId:te}}}));try{const he=await s.command({type:"feature.reorder",projectId:ee,orderedFeatureIds:Q});j(he.sidebar),a(null)}catch(he){m(ie=>({...ie,featureOrderByProjectId:qd(ie.featureOrderByProjectId,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function ue(ee,Q){await s.command({type:"project.setProjectMetadataDirectoryCommitMode",projectId:ee.projectId,localPath:ee.localPath,commitProjectMetadata:Q})}async function me(ee){try{await Promise.all(qoe((v==null?void 0:v.projects.map(Q=>({localPath:Q.localPath})))??H.projectGroups.map(Q=>({projectId:Q.groupKey,localPath:Q.localPath}))).map(Q=>ue(Q,ee))),a(null)}catch(Q){throw a(Q instanceof Error?Q.message:String(Q)),Q}}async function se(ee){const Q=H.projectGroups.find(ie=>ie.groupKey===ee);if(!Q)return;const te=Q.localPath.split("/").filter(Boolean).pop()??Q.localPath;if(await i.confirm({title:"Hide Project",description:`Hide "${te}" from ${ys}? Existing chats for this project will be removed from ${ys}, but the project itself is not deleted.`,confirmLabel:"Hide",confirmVariant:"destructive"}))try{await s.command({type:"project.remove",projectId:ee}),Ha.getState().clearProject(ee),dh.getState().clearProject(ee),(e&&u_(H.projectGroups,e)===ee||(S==null?void 0:S.projectId)===ee)&&r("/"),a(null)}catch(ie){a(ie instanceof Error?ie.message:String(ie))}}const oe=_.useMemo(()=>({sidebarData:H,completedChatIds:z,localProjects:v,featureOverviewSnapshot:S,sidebarReady:C,localProjectsReady:E,sidebarOpen:M,sidebarCollapsed:D,openSidebar:()=>O(!0),closeSidebar:()=>O(!1),collapseSidebar:()=>P(!0),expandSidebar:()=>P(!1),toggleProjectsSidebar:ee=>{if(ee){O(!1),P(Q=>!Q);return}O(Q=>!Q)},clearCompletedChatId:B,handleCreateFeature:ee=>c(ee),handleOpenFeatureOverview:ee=>{r(`/overview/${ee}`),O(!1),a(null)},handleRenameFeature:I,handleDeleteFeature:$,handleSetProjectBrowserState:X,handleSetProjectGeneralChatsBrowserState:Z,handleSetFeatureBrowserState:T,handleSetFeatureStage:J,handleReorderFeatures:ae,handleHideLocalProject:K,handleListDirectories:A,handleRemoveProject:se,handleUpdateFeatureOverview:re,handleSetCommitProjectMetadataDirectory:me}),[z,S,B,$,K,c,A,se,I,ae,me,T,J,X,Z,re,v,E,r,a,D,H,M,C,s]);return g.jsx(rO.Provider,{value:oe,children:t})}function hS(){const t=_.useContext(rO);if(!t)throw new Error("useSidebarContext must be used within SidebarProvider");return t}const iae=1e3,sae=4,oae=40*1024*1024,iO=_.createContext(void 0);function Kd(t,e){return!!(t&&e&&t.runtime.chatId===e)}function qm(t,e){return(t?JSON.stringify(t).length:0)+JSON.stringify(e).length+256}function aae(t){return!!(t.activeChatId&&t.restoredFromCache&&!t.restoredFromFreshCache)}function lae(t){var n;if(!(t!=null&&t.length))return null;let e=((n=t[0])==null?void 0:n.createdAt)??null;for(const r of t)(e===null||r.createdAt>e)&&(e=r.createdAt);return e}function p1(t,e){const n=t.filter(r=>r._id!==e);return n.length===t.length?t:n}const dy="optimistic:";function fR(t){return t.startsWith(dy)}function cae(t){const e=tl(t.loadedTranscriptEntries,[t.entry]);return{snapshot:t.snapshot&&t.snapshot.runtime.chatId===t.chatId?{...t.snapshot,messages:tl(t.snapshot.messages,[t.entry]),transcript:{...t.snapshot.transcript,entries:tl(t.snapshot.transcript.entries,[t.entry])}}:t.snapshot,loadedTranscriptEntries:e}}function uae(t){return{snapshot:t.snapshot===null?null:{...t.snapshot,messages:p1(t.snapshot.messages,t.entryId),transcript:{...t.snapshot.transcript,entries:p1(t.snapshot.transcript.entries,t.entryId)}},loadedTranscriptEntries:p1(t.loadedTranscriptEntries,t.entryId)}}function dae(t){return t.map(e=>JSON.stringify({_id:e._id,messageId:e.messageId??null,createdAt:e.createdAt,hidden:e.hidden??!1,kind:e.kind,payload:hae(e)})).join("")}function hae(t){switch(t.kind){case"user_prompt":return{content:t.content,attachments:t.attachments??[]};case"system_init":return{provider:t.provider,model:t.model,tools:t.tools,agents:t.agents,slashCommands:t.slashCommands,mcpServers:t.mcpServers,debugRaw:t.debugRaw??null};case"account_info":return t.accountInfo;case"assistant_text":case"assistant_thought":return t.text;case"tool_call":return t.tool;case"tool_result":return{toolId:t.toolId,content:t.content,isError:t.isError??!1,debugRaw:t.debugRaw??null};case"result":return{subtype:t.subtype,isError:t.isError,durationMs:t.durationMs,result:t.result,costUsd:t.costUsd??null};case"status":return t.status;case"compact_boundary":case"context_cleared":case"interrupted":return null;case"compact_summary":return t.summary;default:return t}}function fae(t){var n,r,i;const e=lae(t.loadedTranscriptEntries.length>0?t.loadedTranscriptEntries:(n=t.snapshot)==null?void 0:n.transcript.entries);return{cachedStatus:((r=t.snapshot)==null?void 0:r.runtime.status)??null,cachedUpdatedAt:((i=t.snapshot)==null?void 0:i.runtime.updatedAt)??e}}function mae(t){return t?t.updatedAt??t.lastMessageAt??null:null}function pae(t){return t.queuedReason===t.nextReason&&t.isQueued}function gae(t){return t.currentChat?t.cachedStatus===t.currentChat.status&&t.cachedUpdatedAt===mae(t.currentChat):!1}function tl(t,e){if(e.length===0)return t;if(t.length===0)return e===t?t:[...e];const n=new Set(t.map(f=>f._id)),r=new Set(t.flatMap(f=>f.kind==="tool_result"&&f.toolId&&fR(f._id)?[f.toolId]:[]));let i=!0,s=t[t.length-1];for(const f of e){if(n.has(f._id)){i=!1;break}if(f.createdAt<s.createdAt||f.createdAt===s.createdAt&&f._id.localeCompare(s._id)<=0){i=!1;break}if(f.kind==="tool_result"&&f.toolId&&r.has(f.toolId)){i=!1;break}s=f}if(i)return[...t,...e];const a=new Map;for(const f of t)a.set(f._id,f);for(const f of e)a.set(f._id,f);const c=new Set,d=new Map;for(const f of a.values()){if(f.kind!=="tool_result"||!f.toolId)continue;const m=d.get(f.toolId)??[];m.push(f._id),d.set(f.toolId,m),fR(f._id)&&c.add(f._id)}for(const f of d.values()){if(f.length<2)continue;const m=f.some(b=>c.has(b)),v=f.filter(b=>!c.has(b));if(!(!m||v.length!==1))for(const b of f)c.has(b)&&a.delete(b)}const u=[...a.values()].sort((f,m)=>f.createdAt!==m.createdAt?f.createdAt-m.createdAt:f._id.localeCompare(m._id));if(t.length===u.length){let f=!1;for(let m=0;m<t.length;m+=1){const v=t[m],b=u[m];if((v==null?void 0:v._id)!==(b==null?void 0:b._id)||!vae(v,b)){f=!0;break}}if(!f)return t}return u}function vae(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const i of n)if(!(i in e)||!Object.is(t[i],e[i]))return!1;return!0}function sO(t){return t.flatMap(e=>[...e.generalChats,...e.features.flatMap(n=>n.chats)])}function mR(t){return sO(t).some(e=>e.status==="starting"||e.status==="running")}function pR(t){return t.chat.chatId===t.activeChatId||t.chat.provider!=="claude"&&t.chat.provider!=="codex"&&t.chat.provider!=="cursor"||t.chat.status==="starting"||t.chat.status==="running"?null:t.chat.status==="waiting_for_user"?"waiting_for_user":t.completedChatIds.has(t.chat.chatId)?"completed":null}function bae(t){const e=[];for(const n of t.cachedChatIdsNewestFirst){if(e.length>=t.limit)break;if(n===t.activeChatId)continue;const r=tu(t.projectGroups,n);r&&(r.status!=="starting"&&r.status!=="running"||e.push(n))}return e}function gR(t,e){if(!t||t.runtime.chatId!==e.chatId)return t;switch(e.type){case"chat.message-appended":{const n=tl(t.transcript.entries,[e.entry]),r=Math.max(t.runtime.updatedAt??0,e.entry.createdAt);return{...t,messages:n,runtime:{...t.runtime,updatedAt:r},transcript:{...t.transcript,entries:n}}}case"chat.messages-appended":{const n=tl(t.transcript.entries,e.entries),r=e.entries.reduce((i,s)=>Math.max(i,s.createdAt),t.runtime.updatedAt??0);return{...t,messages:n,runtime:{...t.runtime,updatedAt:r},transcript:{...t.transcript,entries:n}}}case"chat.status-set":return{...t,runtime:{...t.runtime,status:e.status}};case"chat.title-set":return{...t,runtime:{...t.runtime,title:e.title}};case"chat.provider-set":return{...t,runtime:{...t.runtime,provider:e.provider}};case"chat.plan-mode-set":return{...t,runtime:{...t.runtime,planMode:e.planMode}};case"chat.pending-tool-set":return{...t,runtime:{...t.runtime,pendingTool:e.pendingTool}};case"chat.session-token-set":return{...t,runtime:{...t.runtime,sessionToken:e.sessionToken,hydrationState:e.hydrationState}};case"chat.usage-set":return{...t,usage:e.usage};case"chat.available-providers-set":return{...t,availableProviders:e.availableProviders,providerSettings:e.providerSettings??t.providerSettings};case"chat.transcript-window-meta-set":return{...t,transcript:{...t.transcript,hasOlder:e.hasOlder,oldestEntryId:e.oldestEntryId,hydrationState:e.hydrationState??t.transcript.hydrationState}};case"chat.deleted":return null}}function _ae({children:t,activeChatId:e}){var so,oo,na;const n=tc(),r=Ly(),{socket:i}=Vh(),{providerSettings:s}=Hu(),{sidebarData:a,sidebarReady:c,localProjects:d,featureOverviewSnapshot:u,closeSidebar:f,completedChatIds:m,clearCompletedChatId:v}=hS(),{createFeatureModalProjectId:b,handleCloseCreateFeatureModal:S,setCommandError:x}=Fu(),[C,k]=_.useState(null),[E,R]=_.useState(!1),[M,O]=_.useState(null),[D,P]=_.useState(null),[z,Y]=_.useState([]),L=_.useRef([]),[W,V]=_.useState(!1),[F,U]=_.useState(null),[H,j]=_.useState(!1),[G,B]=_.useState(null),[K,A]=_.useState(!1),[I,$]=_.useState(!1),[T,X]=_.useState(148),[Z,J]=_.useState(!0),re=_.useRef(null),ae=_.useRef(!1),ue=_.useRef(null),me=_.useRef(!0),se=_.useRef(null),oe=_.useRef(null),ee=_.useRef(!1),Q=_.useRef(null),te=_.useRef(null),he=_.useRef(null),ie=_.useRef(null),xe=_.useRef(!1),Ae=_.useRef(null),Ke=_.useRef(null),mt=_.useRef(new Map),Ye=_.useRef(null),Ze=_.useRef(new Map),tt=_.useRef(0),it=_.useRef(new Map),ce=_.useRef([]),Re=_.useRef(new Map),Ue=_.useRef(null),[Je,Ve]=_.useState(0),[ze,He]=_.useState(0);function Xe(){Ke.current=null,oe.current=null,L.current=[],k(null),Y([]),V(!1),U(null),j(!1)}function ut(be){const we=Ae.current;if(!we)return()=>{};const Te=cae({snapshot:oe.current,chatId:we,loadedTranscriptEntries:L.current,entry:be}),Pe=Te.snapshot;return Pe&&(oe.current=Pe,k(Pe)),L.current=Te.loadedTranscriptEntries,Y(Te.loadedTranscriptEntries),()=>{var Ft;if(Ae.current!==we)return;const Ge=uae({snapshot:((Ft=oe.current)==null?void 0:Ft.runtime.chatId)===we?oe.current:null,loadedTranscriptEntries:L.current,entryId:be._id});oe.current=Ge.snapshot,L.current=Ge.loadedTranscriptEntries,k(Ge.snapshot),Y(Ge.loadedTranscriptEntries)}}function ft(be){const we=Ze.current.get(be);we&&(tt.current-=we.estimatedBytes,Ze.current.delete(be),Ve(Te=>Te+1))}function rt(be,we){const Te=Ze.current.get(be);Te&&(tt.current-=Te.estimatedBytes,Ze.current.delete(be));const Pe={...we,...fae({snapshot:we.snapshot,loadedTranscriptEntries:we.loadedTranscriptEntries})};for(Ze.current.set(be,Pe),tt.current+=Pe.estimatedBytes,Ve(Ge=>Ge+1);tt.current>oae&&Ze.current.size>1;){const Ge=Ze.current.keys().next().value;if(!Ge||Ge===e)break;const Ft=Ze.current.get(Ge);Ft&&(tt.current-=Ft.estimatedBytes),Ze.current.delete(Ge),Ve(hn=>hn+1)}}function Tt(be){const we=Ze.current.get(be);if(!we)return null;if(!Kd(we.snapshot,be))return tt.current-=we.estimatedBytes,Ze.current.delete(be),null;const Te={...we,isFresh:gae({cachedStatus:we.cachedStatus,cachedUpdatedAt:we.cachedUpdatedAt,currentChat:tu(a.projectGroups,be)})};return Ze.current.delete(be),Ze.current.set(be,Te),oe.current=Te.snapshot,k(Te.snapshot),Y(Te.loadedTranscriptEntries),Ke.current=Te.oldestLoadedEntryId,V(Te.hasOlderMessages),U(Te.oldestLoadedEntryId),j(!1),R(!0),Te}_.useLayoutEffect(()=>{L.current=z},[z]),_.useLayoutEffect(()=>{me.current=Z}),_.useEffect(()=>{if(!e){Ae.current=null,te.current=null,Ke.current=null,ie.current=null,oe.current=null,k(null),Y([]),V(!1),U(null),j(!1),A(!1),R(!0);return}const we=Ae.current!==e;if(Ae.current=e,we){Ye.current={chatId:e,startedAt:performance.now()},te.current=null,he.current=null,ie.current=null,Xe(),R(!1);const Te=Tt(e),Pe=!!Te;A(aae({activeChatId:e,restoredFromCache:Pe,restoredFromFreshCache:Te==null?void 0:Te.isFresh})),Pe?dR("chat_cache_hit_count",1,{chatId:e}):(dR("chat_cache_miss_count",1,{chatId:e}),Xe())}return i.subscribe({type:"chat",chatId:e},Te=>{Ae.current===e&&(oe.current=Te,k(Te),A(!1),R(!0),x(null))},Te=>{if(Ae.current!==e)return;A(!1);const Pe=gR(oe.current,Te);Pe===null?(ft(e),Xe()):(oe.current=Pe,k(Pe)),R(!0),x(null)})},[e,x,i]),_.useEffect(()=>{e&&v(e)},[e,v]),_.useEffect(()=>{const be=new Set(bae({cachedChatIdsNewestFirst:[...Ze.current.keys()].reverse(),projectGroups:a.projectGroups,activeChatId:e,limit:sae}));for(const[we,Te]of it.current)be.has(we)||(Te(),it.current.delete(we));for(const we of be){if(it.current.has(we))continue;const Te=i.subscribe({type:"chat",chatId:we},Pe=>{if(Ae.current!==we){if(!Kd(Pe,we)){ft(we);return}rt(we,{snapshot:Pe,loadedTranscriptEntries:[...Pe.transcript.entries],hasOlderMessages:Pe.transcript.hasOlder,oldestLoadedEntryId:Pe.transcript.oldestEntryId,estimatedBytes:qm(Pe,Pe.transcript.entries),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})}},Pe=>{if(Ae.current===we)return;const Ge=Ze.current.get(we),Ft=gR((Ge==null?void 0:Ge.snapshot)??null,Pe);if(Ft===null){ft(we);return}const hn=tl((Ge==null?void 0:Ge.loadedTranscriptEntries)??[],Ft.transcript.entries);rt(we,{snapshot:Ft,loadedTranscriptEntries:hn,hasOlderMessages:(Ge==null?void 0:Ge.hasOlderMessages)??Ft.transcript.hasOlder,oldestLoadedEntryId:(Ge==null?void 0:Ge.oldestLoadedEntryId)??Ft.transcript.oldestEntryId,estimatedBytes:qm(Ft,hn),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})});it.current.set(we,Te)}},[e,Je,a.projectGroups,i]),_.useEffect(()=>{const be=new Set,we=ce.current.filter(Pe=>{const Ge=tu(a.projectGroups,Pe);return!!(Ge&&Ge.chatId!==e)});let Te=we.length!==ce.current.length;for(const Pe of sO(a.projectGroups)){be.add(Pe.chatId);const Ge=pR({chat:Pe,activeChatId:e,completedChatIds:m});if(!Ge){Re.current.delete(Pe.chatId);continue}const Ft=we.includes(Pe.chatId);pae({queuedReason:Re.current.get(Pe.chatId),nextReason:Ge,isQueued:Ft})||(Re.current.set(Pe.chatId,Ge),Ft||(we.push(Pe.chatId),Te=!0))}for(const Pe of[...Re.current.keys()])be.has(Pe)||Re.current.delete(Pe);Te&&(ce.current=we,He(Pe=>Pe+1))},[e,m,a.projectGroups]),_.useEffect(()=>{u&&O(u.projectId)},[u]),_.useEffect(()=>()=>{for(const be of it.current.values())be();it.current.clear()},[]),_.useEffect(()=>{if(Ue.current||mR(a.projectGroups))return;const be=ce.current.find(Te=>Te!==e);if(!be)return;const we=window.setTimeout(()=>{const Te=tu(a.projectGroups,be),Pe=Te?pR({chat:Te,activeChatId:e,completedChatIds:m}):null;if(!Te||!Pe||mR(a.projectGroups)){ce.current=ce.current.filter(Ge=>Ge!==be),He(Ge=>Ge+1);return}Ue.current=be,i.command({type:"chat.prefetch",chatId:be}).then(Ge=>{if(!Kd(Ge,be)){ft(be);return}rt(be,{snapshot:Ge,loadedTranscriptEntries:[...Ge.transcript.entries],hasOlderMessages:Ge.transcript.hasOlder,oldestLoadedEntryId:Ge.transcript.oldestEntryId,estimatedBytes:qm(Ge,Ge.transcript.entries),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})}).catch(Ge=>{}).finally(()=>{Ue.current===be&&(Ue.current=null),ce.current=ce.current.filter(Ge=>Ge!==be),He(Ge=>Ge+1)})},iae);return()=>window.clearTimeout(we)},[e,ze,m,a.projectGroups,i]),_.useEffect(()=>{if(M)return;const be=a.projectGroups[0];be&&O(be.groupKey)},[M,a.projectGroups]),_.useEffect(()=>{if(!e||!c||!E)return;if(a.projectGroups.some(we=>[...we.generalChats,...we.features.flatMap(Te=>Te.chats)].some(Te=>Te.chatId===e))){D===e&&P(null);return}D!==e&&n("/")},[e,E,n,D,a.projectGroups,c]),_.useEffect(()=>{e&&Kd(C,e)&&rt(e,{snapshot:C,loadedTranscriptEntries:z,hasOlderMessages:W,oldestLoadedEntryId:F,estimatedBytes:qm(C,z),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})},[e,C,W,z,F]),_.useEffect(()=>{if(!C)return;O(C.runtime.projectId),C.transcript.hydrationState==="provider"?ie.current=C.runtime.chatId:ie.current===C.runtime.chatId&&(ie.current=null),!!Ke.current&&Ke.current!==C.transcript.oldestEntryId?(Y(we=>{var Pe;const Te=tl(we,C.transcript.entries);return Ke.current=((Pe=Te[0])==null?void 0:Pe._id)??null,Te}),V(we=>we&&C.transcript.hasOlder)):(Ke.current=C.transcript.oldestEntryId,Y([...C.transcript.entries]),V(C.transcript.hasOlder),U(C.transcript.oldestEntryId))},[C]),_.useEffect(()=>{ee.current=!1,Q.current!==null&&(window.cancelAnimationFrame(Q.current),Q.current=null),ie.current=null,ae.current=!1,ue.current=null,J(!0)},[e]),_.useEffect(()=>()=>{Q.current!==null&&window.cancelAnimationFrame(Q.current)},[]),_.useLayoutEffect(()=>{if(!ee.current)return;const be=re.current;be&&me.current&&(be.scrollTop=be.scrollHeight)},[e,z]),_.useLayoutEffect(()=>{const be=se.current;if(!be)return;const we=new ResizeObserver(()=>{X(be.getBoundingClientRect().height)});return we.observe(be),X(be.getBoundingClientRect().height),()=>we.disconnect()},[]);const lt=e?(()=>{const be=Ze.current.get(e)??null;return Kd((be==null?void 0:be.snapshot)??null,e)?be:null})():null,ht=_.useMemo(()=>{const be=xK(C,e);return be||((lt==null?void 0:lt.snapshot)??null)},[lt,e,C]),Be=z.length>0?z:(lt==null?void 0:lt.loadedTranscriptEntries)??[],$e=_.useMemo(()=>{const be=ht;if(!be)return[];const we=Be,Te=be.runtime.chatId,Pe=dae(we),Ge=mt.current.get(Te);if((Ge==null?void 0:Ge.signature)===Pe)return Ge.messages;const Ft=Boe(we);return mt.current.set(Te,{signature:Pe,messages:Ft}),Ft},[ht,Be]),Le=_.useMemo(()=>Woe($e),[$e]),Fe=(ht==null?void 0:ht.runtime)??null,ye=(ht==null?void 0:ht.usage)??null,Ie=e&&D===e&&!Fe?"starting":Fe==null?void 0:Fe.status,Qe=!!(e&&!ht),gt=(ht==null?void 0:ht.availableProviders)??jT((s==null?void 0:s.settings)??Tp),Wt=cy(Ie),wt=Voe(Ie),xt=vK(T),Qt=!Z&&$e.length>0,kt=((so=d==null?void 0:d.projects[0])==null?void 0:so.localPath)??null,Dt=(u==null?void 0:u.localPath)??(Fe==null?void 0:Fe.localPath)??kt??((oo=a.projectGroups[0])==null?void 0:oo.localPath),wn=!!(M??(u==null?void 0:u.projectId)??(Fe==null?void 0:Fe.projectId)??((na=a.projectGroups[0])==null?void 0:na.groupKey)??kt);_.useEffect(()=>{!e||!ht||H||z.length>0||ht.transcript.hydrationState==="provider"&&he.current!==e&&(he.current=e,dn())},[e,ht,H,z.length]),_.useEffect(()=>{const be=Ye.current;!e||!be||be.chatId!==e||!E||($e.length>0||Fe)&&(tO("chat_switch_ready_ms",Math.round(performance.now()-be.startedAt),{chatId:e,cached:!!lt}),Ye.current=null)},[lt,e,E,$e.length,Fe==null?void 0:Fe.status]),_.useLayoutEffect(()=>{if(ee.current)return;const be=re.current;be&&(e&&!Fe||(be.scrollTo({top:be.scrollHeight,behavior:"auto"}),Q.current!==null&&window.cancelAnimationFrame(Q.current),Q.current=window.requestAnimationFrame(()=>{const we=re.current;we&&(we.scrollTo({top:we.scrollHeight,behavior:"auto"}),Q.current=null)}),ee.current=!0))},[e,T,$e.length,Fe]),_.useEffect(()=>{if(!ee.current||!Z)return;const be=window.requestAnimationFrame(()=>{const we=re.current;!we||!Z||(we.scrollTop=we.scrollHeight)});return()=>window.cancelAnimationFrame(be)},[e,T,Z]);function Zt(){const be=re.current;if(!be)return;const we=be.scrollTop,Te=be.scrollHeight-we-be.clientHeight,Pe=dN(Te);ue.current!==null&&we<ue.current&&(ae.current=!1),ue.current=we,Pe&&(ae.current=!1),ae.current||J(Pe)}function bn(){const be=re.current;J(!0),be&&(be.scrollTop=be.scrollHeight,ue.current=be.scrollTop,ae.current=!1)}function Hn(){bn()}async function dn(){var Ft,hn;const be=F??"",we=te.current;if(we&&we.chatId===e&&we.beforeEntryId===be)return;const Te=(ht==null?void 0:ht.transcript.hydrationState)==="provider"&&z.length===0;if(!e||H||!Te&&!F)return;const Pe=e,Ge=be;try{te.current={chatId:Pe,beforeEntryId:Ge},j(!0);const fn=await i.command({type:"chat.loadMore",chatId:Pe,beforeEntryId:Te?void 0:Ge||void 0});if(Ae.current!==Pe)return;Y(as=>tl(as,fn.entries)),fn.hydrationState==="provider"?ie.current=Pe:ie.current===Pe&&(ie.current=null),Ke.current=fn.oldestEntryId,V(fn.hasOlder),U(fn.oldestEntryId),x(null)}catch(fn){Ae.current===Pe&&x(fn instanceof Error?fn.message:String(fn))}finally{((Ft=te.current)==null?void 0:Ft.chatId)===Pe&&((hn=te.current)==null?void 0:hn.beforeEntryId)===Ge&&(te.current=null),Ae.current===Pe&&j(!1)}}async function pe(be,we){$o.getState().initializeComposerForNewChat();const Te=await i.command({type:"chat.create",projectId:be,featureId:we});O(be),P(Te.chatId),n(`/chat/${Te.chatId}`),f(),x(null)}async function de(be,we=fu.getState().commitProjectMetadataDirectory){await i.command({type:"project.setProjectMetadataDirectoryCommitMode",projectId:be.projectId,localPath:be.localPath,commitProjectMetadata:we})}async function Oe(be){return be.kind==="project_id"?{projectId:be.projectId}:be.kind==="local_path"?{projectId:(await i.command({type:"project.open",localPath:be.localPath})).projectId,localPath:be.localPath}:{projectId:(await i.command(be.project.mode==="new"?{type:"project.create",localPath:be.project.localPath,title:be.project.title}:{type:"project.open",localPath:be.project.localPath})).projectId,localPath:be.project.localPath}}async function Et(be){try{const we=be.kind==="project_id"?null:be.kind==="local_path"?be.localPath:be.project.localPath;we&&B(we);const{projectId:Te}=await Oe(be);await de({projectId:Te}),await pe(Te)}catch(we){x(we instanceof Error?we.message:String(we))}finally{B(null)}}async function _n(be,we){try{await pe(be,we)}catch(Te){x(Te instanceof Error?Te.message:String(Te))}}async function An(be){const we=b;if(we&&!(I||xe.current))try{xe.current=!0,$(!0);const Te=await i.command({type:"feature.create",projectId:we,title:be.title,description:be.description,generateOverview:fu.getState().showFeatureOverviewInSidebar});S(),await pe(we,Te.featureId)}catch(Te){x(Te instanceof Error?Te.message:String(Te))}finally{xe.current=!1,$(!1)}}async function Jn(be){await Et({kind:"local_path",localPath:be})}async function $n(be){await Et({kind:"project_request",project:be})}async function tn(be,we){var Te;try{let Pe=M??((Te=a.projectGroups[0])==null?void 0:Te.groupKey)??null;if(!e&&!Pe&&kt&&(Pe=(await i.command({type:"project.open",localPath:kt})).projectId,O(Pe)),!e&&!Pe)throw new Error("Open a project first");if(we!=null&&we.provider&&!JF(we.provider,(s==null?void 0:s.settings)??Tp))throw new Error(`${we.provider} is inactive.`);bn();const Ge=await i.command({type:"chat.send",chatId:e??void 0,projectId:e?void 0:Pe??void 0,provider:we==null?void 0:we.provider,message:be,model:we==null?void 0:we.model,modelOptions:we==null?void 0:we.modelOptions,planMode:we==null?void 0:we.planMode});!e&&Ge.chatId&&(P(Ge.chatId),n(`/chat/${Ge.chatId}`)),x(null)}catch(Pe){throw x(Pe instanceof Error?Pe.message:String(Pe)),Pe}}async function er(){if(e)try{await i.command({type:"chat.cancel",chatId:e})}catch(be){x(be instanceof Error?be.message:String(be))}}async function lr(be){if(await r.confirm({title:"Delete Chat",description:`Delete "${be.title}"? This cannot be undone.`,confirmLabel:"Delete",confirmVariant:"destructive"}))try{if(await i.command({type:"chat.delete",chatId:be.chatId}),be.chatId===e){const Te=gK(a.projectGroups,be.chatId);n(Te?`/chat/${Te}`:"/")}}catch(Te){x(Te instanceof Error?Te.message:String(Te))}}async function Br(be){const we=await r.prompt({title:"Rename Chat",placeholder:"Chat name",initialValue:be.title,confirmLabel:"Rename"}),Te=we==null?void 0:we.trim();if(!(!Te||Te===be.title))try{await i.command({type:"chat.rename",chatId:be.chatId,title:Te}),x(null)}catch(Pe){x(Pe instanceof Error?Pe.message:String(Pe))}}async function Rn(be,we){try{await i.command({type:"chat.setFeature",chatId:be,featureId:we}),x(null)}catch(Te){x(Te instanceof Error?Te.message:String(Te))}}async function nn(be){var Te,Pe;const we=(Fe==null?void 0:Fe.localPath)??((Te=d==null?void 0:d.projects[0])==null?void 0:Te.localPath)??((Pe=a.projectGroups[0])==null?void 0:Pe.localPath);if(we)try{x(null),await a_({socket:i,action:be,localPath:we})}catch(Ge){x(Ge instanceof Error?Ge.message:String(Ge))}}function Fr(){var Pe;const be=e?tu(a.projectGroups,e):null,we=e?u_(a.projectGroups,e):null;if(be&&we){x(null),_n(we,be.featureId??void 0);return}const Te=yK({selectedProjectId:M,sidebarProjectId:(Pe=a.projectGroups[0])==null?void 0:Pe.groupKey,fallbackLocalProjectPath:kt});if(Te){x(null),Et(Te);return}x("Open a project first")}async function xr(be,we,Te){if(!e)return;const Pe=ut({_id:`${dy}${Ai()}`,createdAt:Date.now(),kind:"tool_result",toolId:be,content:{answers:Te},isError:!1});try{await i.command({type:"chat.respondTool",chatId:e,toolUseId:be,result:{questions:we,answers:Te}})}catch(Ge){Pe(),x(Ge instanceof Error?Ge.message:String(Ge))}}async function Jr(be,we,Te,Pe,Ge){if(!e)return;const Ft={confirmed:we,...Te?{clearContext:!0}:{},...Pe?{message:Pe}:{},...Ge?{attachments:Ge}:{}},hn=ut({_id:`${dy}${Ai()}`,createdAt:Date.now(),kind:"tool_result",toolId:be,content:Ft,isError:!1});try{await i.command({type:"chat.respondTool",chatId:e,toolUseId:be,result:Ft}),we&&$o.getState().setComposerPlanMode(!1)}catch(fn){hn(),we&&$o.getState().setComposerPlanMode(!0),x(fn instanceof Error?fn.message:String(fn))}}async function Un(be,we,Te){if(!e||!(Fe!=null&&Fe.projectId))return;const Pe=Fe.projectId,Ge=tu(a.projectGroups,e),Ft=(Ge==null?void 0:Ge.featureId)??void 0;try{const hn=await CK({socket:i,sourceChatId:e,toolUseId:be,projectId:Pe,featureId:Ft,entry:Te,planText:we});$o.getState().setComposerPlanMode(!1),O(Pe),P(hn.chatId),n(`/chat/${hn.chatId}`),f(),x(null)}catch(hn){throw x(hn instanceof Error?hn.message:String(hn)),hn}}const ul=_.useMemo(()=>({activeChatId:e,chatSnapshot:C,runtime:Fe,usage:ye,messages:$e,latestToolIds:Le,availableProviders:gt,processingStatus:Ie,isChatLoading:Qe,isRefreshingActiveChat:K,isProcessing:Wt,canCancel:wt,chatReady:E,pendingChatId:D,selectedProjectId:M,startingLocalPath:G,hasSelectedProject:wn,navbarLocalPath:Dt,scrollRef:re,inputRef:se,transcriptPaddingBottom:xt,showScrollButton:Qt,hasOlderMessages:W,oldestLoadedEntryId:F,isLoadingOlderMessages:H,updateScrollState:Zt,scrollToBottom:Hn,loadOlderMessages:dn,createChatForProject:pe,handleCreateChat:_n,handleConfirmCreateFeature:An,handleOpenLocalProject:Jn,handleCreateProject:$n,handleSend:tn,handleCancel:er,handleRenameChat:Br,handleDeleteChat:lr,handleSetChatFeature:Rn,handleOpenExternal:nn,handleCompose:Fr,handleAskUserQuestion:xr,handleExitPlanMode:Jr,handleHandoff:Un,isCreatingFeature:I}),[e,gt,wt,E,C,pe,b,r,bn,kt,xr,er,Fr,An,_n,$n,lr,Jr,Un,nn,Jn,tn,Rn,Br,wn,W,Qe,I,H,Wt,K,Le,dn,$e,Dt,n,F,D,Ie,s,Fe,M,x,Qt,a.projectGroups,G,Hn,i,xt,Zt,ye]);return g.jsx(iO.Provider,{value:ul,children:t})}function oO(){const t=_.useContext(iO);if(!t)throw new Error("useChatContext must be used within ChatProvider");return t}const Km="How can I help you?",yae=19,vR=72,xae=48,Gm="max-w-[800px] md:max-w-[920px]";function Sae(t){return t.isRefreshingActiveChat&&t.messageCount>0}function wae(t){return t.messageCount>0?null:t.isChatLoading?"loading":t.isProviderRecovering?"recovering":t.isProviderUnavailable?"unavailable":t.isProcessing?null:"empty"}function Cae(){var Fe,ye,Ie,Qe,gt,Wt,wt,xt,Qt,kt,Dt,wn,Zt,bn,Hn,dn,pe;const t=Vh(),e=Hu(),n=hS(),r=oO(),i=Fu(),s={...t,...e,...n,...r,...i},a=oN(de=>de.isOpen),c=_.useRef(null),d=_.useRef(null),u=_.useRef(null),[f,m]=_.useState(""),[v,b]=_.useState(!1),[S,x]=_.useState(0),[C,k]=_.useState(!1),[E,R]=_.useState(null),[M,O]=_.useState(0),D=_.useRef(((Fe=s.runtime)==null?void 0:Fe.planMode)??!1),P=_.useRef(null),z=zg("(min-width: 768px)"),Y=typeof window>"u"?!0:RZ(window.location.hostname),L=((ye=s.runtime)==null?void 0:ye.projectId)??null,W=_.useMemo(()=>hr.chatPlanMode(s.activeChatId??L??"composer"),[L,s.activeChatId]),F=Ha(de=>L?de.projects[L]:void 0)??LZ,H=dh(de=>L?de.projects[L]:void 0)??AZ,j=Ha(de=>de.addTerminal),G=Ha(de=>de.removeTerminal),B=Ha(de=>de.toggleVisibility),K=Ha(de=>de.resetMainSizes),A=Ha(de=>de.setMainSizes),I=Ha(de=>de.setTerminalSizes),$=dh(de=>de.toggleVisibility),T=dh(de=>de.setSize),X=Fp(de=>de.scrollbackLines),Z=Fp(de=>de.minColumnWidth),J=s.keybindings,re=$o(de=>de.composerState.provider),ae=f1(de=>de.pullRequestPrompt),ue=f1(de=>de.pullRequestUpdatePrompt),me=f1(de=>de.pullRequestProviders),se=_.useMemo(()=>({pullRequestPrompt:ae,pullRequestUpdatePrompt:ue,pullRequestProviders:me}),[ae,me,ue]),oe=_.useMemo(()=>lN(J),[J]),ee=((Ie=s.runtime)==null?void 0:Ie.provider)??re,Q=Sae({isRefreshingActiveChat:s.isRefreshingActiveChat,messageCount:s.messages.length}),te=wae({isChatLoading:s.isChatLoading,isProviderRecovering:s.activeChatId!==null&&((Qe=s.chatSnapshot)==null?void 0:Qe.transcript.hydrationState)==="provider"&&s.chatSnapshot.transcript.hasOlder,isProviderUnavailable:s.activeChatId!==null&&((gt=s.chatSnapshot)==null?void 0:gt.transcript.hydrationState)==="provider"&&!s.chatSnapshot.transcript.hasOlder,isProcessing:s.isProcessing,messageCount:s.messages.length}),he=_.useMemo(()=>BE({currentProvider:ee,settings:se}),[ee,se]),ie=F.terminals.length>0,xe=!!(L&&F.isVisible&&ie),Ae=!!(L&&ie),Ke=!!(L&&H.isVisible),mt=!!(L&&!z&&Ke),Ye=!!(L&&z),Ze=Math.max(80,s.transcriptPaddingBottom-xae),{isAnimating:tt,mainPanelGroupRef:it,terminalFocusRequestVersion:ce,terminalPanelRef:Re,terminalVisualRef:Ue}=YZ({showTerminalPane:xe,shouldRenderTerminalLayout:Ae,projectId:L,terminalLayout:F,chatInputRef:u}),{isAnimating:Je,panelGroupRef:Ve,sidebarPanelRef:ze,sidebarVisualRef:He}=qZ({projectId:L,shouldRenderRightSidebarLayout:Ye,showRightSidebar:Ke,rightSidebarSize:H.size});Doe({rootRef:d,fallbackRef:u,enabled:s.hasSelectedProject&&s.processingStatus!=="waiting_for_user",canCancel:s.canCancel}),_.useEffect(()=>{var de;E===null&&(D.current=((de=s.runtime)==null?void 0:de.planMode)??!1)},[E,s.activeChatId,(Wt=s.runtime)==null?void 0:Wt.planMode]),_.useEffect(()=>{var Et;const de=((Et=s.runtime)==null?void 0:Et.planMode)??!1;if(E===null){D.current=de;return}const Oe=P.current;if(!Oe){D.current=de;return}if(s.activeChatId===null){wm(Oe),P.current=null,R(null),D.current=de;return}E.chatId===s.activeChatId&&de!==E.originalRuntimePlanMode&&(de!==E.value&&$o.getState().setComposerPlanMode(de),wm(Oe),P.current=null,R(null),D.current=de)},[E,s.activeChatId,(wt=s.runtime)==null?void 0:wt.planMode]);const Xe=()=>{if(L){if(ie){k(!1),B(L);return}j(L)}},ut=()=>{k(de=>!de)},ft=de=>{var An;if(!L||!xe||tt.current)return;const Oe=de.chat,Et=de.terminal;if(!Number.isFinite(Oe)||!Number.isFinite(Et))return;const _n=((An=c.current)==null?void 0:An.getBoundingClientRect().height)??0;if(zZ(_n,Et)){K(L),B(L);return}A(L,[Oe,Et])};_.useEffect(()=>{if(s.messages.length!==0)return;m(""),b(!1);let de=0;const Oe=window.setInterval(()=>{de+=1,m(Km.slice(0,de)),de>=Km.length&&(window.clearInterval(Oe),b(!0))},yae);return()=>window.clearInterval(Oe)},[s.activeChatId,s.messages.length]),_.useEffect(()=>{function de(Oe){if(L){if(Ya(oe,"toggleEmbeddedTerminal",Oe)){Oe.preventDefault(),Xe();return}if(Ya(oe,"toggleRightSidebar",Oe)){Oe.preventDefault(),$(L);return}if(Ya(oe,"openInFinder",Oe)){if(!Y)return;Oe.preventDefault(),s.handleOpenExternal("open_finder");return}if(Ya(oe,"openInEditor",Oe)){if(!Y)return;Oe.preventDefault(),s.handleOpenExternal("open_editor");return}Ya(oe,"addSplitTerminal",Oe)&&(Oe.preventDefault(),j(L))}}return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[j,Y,Xe,L,oe,$]),_.useEffect(()=>{xe||k(!1)},[xe]),_.useEffect(()=>{const de=window.requestAnimationFrame(()=>{s.updateScrollState()}),Oe=window.setTimeout(()=>{s.updateScrollState()},ou);return()=>{window.cancelAnimationFrame(de),window.clearTimeout(Oe)}},[Ae,xe,s.updateScrollState]),_.useEffect(()=>{function de(){s.updateScrollState()}return window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[s.updateScrollState]),_.useEffect(()=>{const de=c.current;if(!de||!Ae)return;const Oe=()=>{const _n=de.getBoundingClientRect().height;if(_n<=0)return;const An=_n*(F.mainSizes[1]/100);An<=0||x(Jn=>Math.abs(Jn-An)<1?Jn:An)},Et=new ResizeObserver(Oe);return Et.observe(de),Oe(),()=>Et.disconnect()},[L,Ae,F.mainSizes]);const rt=de=>Number.isFinite(de)?Math.min(Q_,Math.max(qg,de)):H.size,Tt=()=>{L&&$(L)},lt=_.useCallback(()=>{var de,Oe;return((de=s.runtime)==null?void 0:de.projectId)??s.selectedProjectId??((Oe=s.sidebarData.projectGroups[0])==null?void 0:Oe.groupKey)??null},[(xt=s.runtime)==null?void 0:xt.projectId,s.selectedProjectId,s.sidebarData.projectGroups]),ht=_.useCallback(async de=>{const Oe=lt();if(!Oe)throw new Error("Open a project first");const Et=await s.socket.command({type:"feature.create",projectId:Oe,title:de,description:"",generateOverview:fu.getState().showFeatureOverviewInSidebar});await s.handleCreateChat(Oe,Et.featureId)},[lt,s.handleCreateChat,s.socket]),Be=_.useCallback(()=>{const de=lt();if(!de)throw new Error("Open a project first");s.handleCreateFeature(de)},[lt,s.handleCreateFeature]),$e=_.useCallback(async(de,Oe)=>{var _n,An;const Et=de.text.trim();if(Et.startsWith("/")){const Jn=((_n=s.runtime)==null?void 0:_n.provider)??(Oe==null?void 0:Oe.provider)??re,$n=BE({currentProvider:Jn,settings:se}),tn=(An=Et.split(" ")[0])==null?void 0:An.slice(1).toLowerCase(),er=$n.find(lr=>lr.name.toLowerCase()===tn);if(er!=null&&er.handler){const lr={handleCompose:s.handleCompose,setPlanMode:Rn=>{var nn;if(!(E!==null&&E.chatId!==s.activeChatId)){if($o.getState().setComposerPlanMode(Rn),s.activeChatId){const Fr=((nn=s.runtime)==null?void 0:nn.planMode)??!1;if(Rn===Fr){wm(W),P.current=null,R(null);return}P.current=W,JA(W,{statusLabel:Rn?"Switching to plan mode...":"Switching to implement mode..."}),R({chatId:s.activeChatId,originalRuntimePlanMode:Fr,value:Rn})}else wm(W),P.current=null,R(null);O(Fr=>Fr+1)}},sendMessage:(Rn,nn)=>s.handleSend(Rn,nn),openFeatureModal:Be,createFeature:ht},Br=Et.slice(tn!=null&&tn.length?tn.length+1:0).trim();await er.handler(lr,{commandText:Et,remainder:Br,message:de,options:Oe});return}}return s.handleSend(de,Oe)},[re,se,W,lt,Be,ht,s.activeChatId,s.handleCancel,s.handleCompose,s.handleCreateFeature,s.handleCreateChat,s.handleSend,(Qt=s.runtime)==null?void 0:Qt.provider,s.socket]),Le=g.jsxs(bN,{ref:d,className:"bg-background h-full flex flex-col overflow-hidden border-0 rounded-none relative",children:[g.jsxs(yN,{className:"flex flex-1 min-h-0 flex-col p-0 overflow-hidden relative",children:[g.jsx(nG,{sidebarCollapsed:s.sidebarCollapsed,hasCompletedChats:s.completedChatIds.size>0,onOpenSidebar:s.openSidebar,onExpandSidebar:s.expandSidebar,usage:s.usage,localPath:s.navbarLocalPath,embeddedTerminalVisible:xe,onToggleEmbeddedTerminal:L?Xe:void 0,rightSidebarVisible:Ke,onToggleRightSidebar:L?()=>$(L):void 0,onOpenExternal:Y?de=>{s.handleOpenExternal(de)}:void 0,editorLabel:s.editorLabel,projectId:L??void 0,socket:s.socket,finderShortcut:Y?oe.bindings.openInFinder:void 0,editorShortcut:Y?oe.bindings.openInEditor:void 0,terminalShortcut:oe.bindings.toggleEmbeddedTerminal,rightSidebarShortcut:oe.bindings.toggleRightSidebar}),g.jsxs(BD,{ref:s.scrollRef,onScroll:s.updateScrollState,className:"flex-1 min-h-0 px-4 scroll-pt-[72px]",children:[(kt=s.runtime)!=null&&kt.inactiveProviderMessage?g.jsxs("div",{className:Ce("mx-auto mt-[72px] rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-900 dark:text-amber-200",Gm),children:["This thread uses ",s.runtime.provider,", which is currently inactive. ",s.runtime.inactiveProviderMessage]}):null,s.messages.length===0&&!s.isProcessing?g.jsx("div",{style:{height:s.transcriptPaddingBottom},"aria-hidden":"true"}):null,s.messages.length>0||s.isProcessing?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:Ce("mx-auto animate-fade-in space-y-5 pt-[72px]",Gm),children:[s.messages.length>0?g.jsx(Toe,{messages:s.messages,isLoading:s.isProcessing,hasOlderMessages:s.hasOlderMessages,oldestLoadedEntryId:s.oldestLoadedEntryId,isLoadingOlderMessages:s.isLoadingOlderMessages,isAtBottom:s.showScrollButton===!1,localPath:(Dt=s.runtime)==null?void 0:Dt.localPath,latestToolIds:s.latestToolIds,pendingTool:((wn=s.runtime)==null?void 0:wn.pendingTool)??null,onOpenLocalLink:s.handleOpenLocalLink,onAskUserQuestionSubmit:s.handleAskUserQuestion,onExitPlanModeConfirm:s.handleExitPlanMode,onHandoff:s.handleHandoff,onLoadOlder:s.loadOlderMessages,availableProviders:s.availableProviders,scrollContainerRef:s.scrollRef}):null,s.isProcessing?g.jsx(EZ,{status:s.processingStatus}):null,s.commandError?g.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3",children:s.commandError}):null]}),g.jsx("div",{style:{height:s.transcriptPaddingBottom},"aria-hidden":"true"})]}):null]}),Q?g.jsx("div",{className:"pointer-events-none absolute inset-x-4 z-20 animate-fade-in",style:{top:vR,bottom:s.transcriptPaddingBottom},children:g.jsx("div",{className:Ce("mx-auto flex h-full items-center justify-center",Gm),children:g.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-background/90 px-4 py-2 text-sm text-muted-foreground shadow-sm backdrop-blur",children:[g.jsx(Fn,{className:"size-4 animate-spin"}),g.jsx("span",{children:"Refreshing chat…"})]})})}):null,te?g.jsx("div",{className:"pointer-events-none absolute inset-x-4 animate-fade-in",style:{top:vR,bottom:s.transcriptPaddingBottom},children:g.jsx("div",{className:Ce("mx-auto flex h-full items-center justify-center",Gm),children:g.jsxs("div",{className:"flex flex-col items-center justify-center text-muted-foreground gap-4 opacity-70",children:[g.jsx(sh,{className:"size-8 text-muted-foreground kaizen-empty-state-flower"}),te==="loading"||te==="recovering"||te==="unavailable"?g.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[te==="unavailable"?null:g.jsx(Fn,{className:"size-10 animate-spin text-muted-foreground/80"}),g.jsx("div",{className:"text-sm text-muted-foreground/90",children:te==="recovering"?"Recovering chat…":te==="unavailable"?"Chat history is unavailable.":"Loading chat…"})]}):g.jsx("div",{className:"text-base font-normal text-muted-foreground text-center max-w-xs flex items-center kaizen-empty-state-text","aria-label":Km,children:g.jsxs("span",{className:"relative inline-grid place-items-start",children:[g.jsxs("span",{className:"invisible col-start-1 row-start-1 whitespace-pre flex items-center",children:[g.jsx("span",{children:Km}),g.jsx("span",{className:"kaizen-typewriter-cursor-slot","aria-hidden":"true"})]}),g.jsxs("span",{className:"col-start-1 row-start-1 whitespace-pre flex items-center",children:[g.jsx("span",{children:f}),g.jsx("span",{className:"kaizen-typewriter-cursor-slot","aria-hidden":"true",children:g.jsx("span",{className:"kaizen-typewriter-cursor","data-typing-complete":v?"true":"false"})})]})]})})]})})},s.activeChatId??"new-chat"):null,g.jsx("div",{style:{bottom:Ze},className:Ce("pointer-events-none absolute left-1/2 -translate-x-1/2 z-30 transition-all",s.showScrollButton&&!a?"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:g.jsx("button",{onClick:s.scrollToBottom,style:{lineHeight:0},className:"pointer-events-auto h-9 w-9 grid place-items-center transition-colors bg-background/80 dark:bg-card/40 backdrop-blur-lg hover:bg-muted/80 border border-border rounded-full cursor-pointer text-foreground/80 hover:text-foreground",children:g.jsx(AP,{style:{display:"block"},className:"h-4 w-4"})})})]}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:g.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:s.inputRef,children:g.jsx(QK,{ref:u,onSubmit:$e,onCancel:()=>{s.handleCancel()},disabled:!s.hasSelectedProject||((Zt=s.runtime)==null?void 0:Zt.status)==="waiting_for_user"||!!((bn=s.runtime)!=null&&bn.inactiveProviderMessage),canCancel:s.canCancel,chatId:s.activeChatId,activeProvider:((Hn=s.runtime)==null?void 0:Hn.provider)??null,activeModel:((dn=s.runtime)==null?void 0:dn.model)??null,activePlanMode:((pe=s.runtime)==null?void 0:pe.planMode)??!1,availableProviders:s.availableProviders,keybindings:oe,slashCommands:he,requestedPlanMode:(E==null?void 0:E.chatId)===s.activeChatId?E.value:null,requestedPlanModeVersion:M,pendingPlanMode:(E==null?void 0:E.chatId)===s.activeChatId?E.value:null},s.activeChatId??"new-chat")})})]});return g.jsxs("div",{ref:c,className:"flex-1 flex flex-col min-w-0 relative",children:[Ye&&L?g.jsxs(op,{groupRef:Ve,orientation:"horizontal",className:"flex-1 min-h-0",onLayoutChange:de=>{var Et;if(!Ke||Je.current)return;const Oe=rt(de.rightSidebar);Math.abs(Oe-de.rightSidebar)<.1||(Et=Ve.current)==null||Et.setLayout({workspace:100-Oe,rightSidebar:Oe})},onLayoutChanged:de=>{!Ke||Je.current||T(L,rt(de.rightSidebar))},children:[g.jsx(Ll,{id:"workspace",defaultSize:`${100-H.size}%`,minSize:"50%",className:"min-h-0 min-w-0",children:Ae?g.jsxs(op,{groupRef:it,orientation:"vertical",className:"flex-1 min-h-0",onLayoutChanged:ft,children:[g.jsx(Ll,{id:"chat",defaultSize:`${F.mainSizes[0]}%`,minSize:"25%",className:"min-h-0",children:Le}),g.jsx(ap,{withHandle:!0,orientation:"vertical",disabled:!xe,className:Ce(!xe&&"pointer-events-none opacity-0")}),g.jsx(Ll,{id:"terminal",defaultSize:`${F.mainSizes[1]}%`,minSize:"0%",className:"min-h-0",elementRef:Re,children:g.jsx("div",{ref:Ue,className:"h-full min-h-0 overflow-hidden relative","data-terminal-open":xe?"true":"false","data-terminal-animated":"false","data-terminal-visual":!0,style:{"--terminal-toggle-duration":`${ou}ms`},children:g.jsx("div",{style:S>0?{height:`${S}px`}:void 0,children:C?null:g.jsx(Wb,{projectId:L,layout:F,onAddTerminal:j,socket:s.socket,connectionStatus:s.connectionStatus,scrollback:X,minColumnWidth:Z,maximized:!1,splitTerminalShortcut:oe.bindings.addSplitTerminal,focusRequestVersion:ce,onToggleMaximized:ut,onRemoveTerminal:(de,Oe)=>{s.socket.command({type:"terminal.close",terminalId:Oe}).catch(()=>{}),G(de,Oe)},onTerminalLayout:I})})})})]},L):Le}),g.jsx(ap,{withHandle:!0,orientation:"horizontal",disabled:!Ke,className:Ce(!Ke&&"pointer-events-none opacity-0")}),g.jsx(Ll,{id:"rightSidebar",defaultSize:`${H.size}%`,maxSize:`${Q_}%`,className:"min-h-0 min-w-0",elementRef:ze,children:g.jsx("div",{ref:He,className:"h-full min-h-0 overflow-hidden","data-right-sidebar-open":Ke?"true":"false","data-right-sidebar-animated":"false","data-right-sidebar-visual":!0,style:{"--terminal-toggle-duration":`${ou}ms`},children:g.jsx(XE,{onClose:()=>$(L)})})})]},`${L}-right-sidebar`):Ae&&L?g.jsxs(op,{groupRef:it,orientation:"vertical",className:"flex-1 min-h-0",onLayoutChanged:ft,children:[g.jsx(Ll,{id:"chat",defaultSize:`${F.mainSizes[0]}%`,minSize:"25%",className:"min-h-0",children:Le}),g.jsx(ap,{withHandle:!0,orientation:"vertical",disabled:!xe,className:Ce(!xe&&"pointer-events-none opacity-0")}),g.jsx(Ll,{id:"terminal",defaultSize:`${F.mainSizes[1]}%`,minSize:"0%",className:"min-h-0",elementRef:Re,children:g.jsx("div",{ref:Ue,className:"h-full min-h-0 overflow-hidden relative","data-terminal-open":xe?"true":"false","data-terminal-animated":"false","data-terminal-visual":!0,style:{"--terminal-toggle-duration":`${ou}ms`},children:g.jsx("div",{style:S>0?{height:`${S}px`}:void 0,children:C?null:g.jsx(Wb,{projectId:L,layout:F,onAddTerminal:j,socket:s.socket,connectionStatus:s.connectionStatus,scrollback:X,minColumnWidth:Z,maximized:!1,splitTerminalShortcut:oe.bindings.addSplitTerminal,focusRequestVersion:ce,onToggleMaximized:ut,onRemoveTerminal:(de,Oe)=>{s.socket.command({type:"terminal.close",terminalId:Oe}).catch(()=>{}),G(de,Oe)},onTerminalLayout:I})})})})]},L):Le,C&&L&&xe?g.jsx("div",{className:"absolute inset-0 z-30 flex min-h-0 min-w-0 flex-col bg-background/96 backdrop-blur-sm",children:g.jsx(Wb,{projectId:L,layout:F,onAddTerminal:j,socket:s.socket,connectionStatus:s.connectionStatus,scrollback:X,minColumnWidth:Z,maximized:!0,splitTerminalShortcut:oe.bindings.addSplitTerminal,focusRequestVersion:ce,onToggleMaximized:ut,onRemoveTerminal:(de,Oe)=>{s.socket.command({type:"terminal.close",terminalId:Oe}).catch(()=>{}),G(de,Oe)},onTerminalLayout:I})}):null,mt?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"fixed inset-0 z-40 bg-black/40 md:hidden",onClick:Tt}),g.jsx("div",{className:"fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-2xl md:hidden",children:g.jsx(XE,{onClose:Tt,className:"h-[var(--app-shell-height)]"})})]}):null]})}const kae="web+kaizen";function hy(t){return!t||!t.startsWith("/")||t.startsWith("//")?"/":t}function Eae(t){const e=new URLSearchParams(t),n=hy(e.get("target"));if(n!=="/")return n;const r=e.get("launch");if(!r)return"/";try{const i=new URL(r);return hy(i.searchParams.get("target"))}catch{return"/"}}function Rae(t){const e=new URL(`${kae}://open`);return e.searchParams.set("target",hy(t)),e.toString()}function Tae(t){return t.innerWidth<=820||t.matchMedia("(pointer: coarse)").matches}function Mae(t){return/\b(?:Chrome|CriOS|Edg|EdgA|EdgiOS)\b/i.test(t)}function Aae(t){return/iPhone|iPad|iPod/i.test(t)?"In Safari, tap Share, then Add to Home Screen.":/Android/i.test(t)?"Use your browser menu to install Kaizen to the home screen.":"Use your browser install action to save Kaizen as an app, or continue in the browser."}function Nae(){const t=ke.c(29),e=Yr(),n=cN();let r;t[0]!==e.search?(r=Eae(e.search),t[0]=e.search,t[1]=r):r=t[1];const i=r,[s,a]=_.useState(!1),[c,d]=_.useState(null);let u,f;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const W=function(F){F.preventDefault(),d(F)};return window.addEventListener("beforeinstallprompt",W),()=>{window.removeEventListener("beforeinstallprompt",W)}},f=[],t[2]=u,t[3]=f):(u=t[2],f=t[3]),_.useEffect(u,f);let m,v;t[4]!==n||t[5]!==e.search||t[6]!==i?(m=()=>{if(n){window.location.replace(i);return}if(new URLSearchParams(e.search).has("launch")){window.location.replace(i);return}if(!Tae(window)){window.location.replace(i);return}if(!Mae(navigator.userAgent)){a(!0);return}const F=Rae(i),U=window.setTimeout(()=>{a(!0)},900),H=()=>{document.visibilityState==="hidden"&&window.clearTimeout(U)};return document.addEventListener("visibilitychange",H),window.location.assign(F),()=>{window.clearTimeout(U),document.removeEventListener("visibilitychange",H)}},v=[n,e.search,i],t[4]=n,t[5]=e.search,t[6]=i,t[7]=m,t[8]=v):(m=t[7],v=t[8]),_.useEffect(m,v);let b;t[9]!==c?(b=async function(){c&&(await c.prompt(),await c.userChoice.catch(Dae),d(null))},t[9]=c,t[10]=b):b=t[10];const S=b;let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=Aae(navigator.userAgent),t[11]=x):x=t[11];const C=x;let k;t[12]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx("div",{className:"absolute inset-x-0 top-0 h-40 bg-[radial-gradient(circle_at_center,rgba(249,115,22,0.12),transparent_68%)] dark:bg-[radial-gradient(circle_at_center,rgba(251,146,60,0.14),transparent_68%)]"}),t[12]=k):k=t[12];let E,R;t[13]===Symbol.for("react.memo_cache_sentinel")?(E=g.jsx("div",{className:"mb-6 inline-flex rounded-full border border-orange-200 bg-orange-50 px-3 py-1 text-xs font-semibold uppercase tracking-[0.2em] text-orange-700 dark:border-orange-400/30 dark:bg-orange-400/10 dark:text-orange-200",children:"Remote handoff"}),R=g.jsxs("h1",{className:"font-logo text-3xl leading-none tracking-tight",children:["Open ",ys]}),t[13]=E,t[14]=R):(E=t[13],R=t[14]);const M=s?"Kaizen could not jump straight into the installed app on this device. You can keep going in the browser or install it for one-tap launches next time.":"Trying to open your installed Kaizen app. If it does not switch automatically, use the browser fallback below.";let O;t[15]!==M?(O=g.jsx("p",{className:"mt-3 text-sm leading-6 text-slate-600 dark:text-slate-300",children:M}),t[15]=M,t[16]=O):O=t[16];let D;t[17]!==i?(D=g.jsx(Dh,{to:i,className:"block rounded-2xl bg-slate-950 px-4 py-3 text-center text-sm font-semibold text-white transition hover:bg-slate-800 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:"Continue in browser"}),t[17]=i,t[18]=D):D=t[18];let P;t[19]!==S||t[20]!==c?(P=c?g.jsx("button",{type:"button",onClick:()=>{S()},className:"block w-full rounded-2xl border border-orange-300 bg-orange-50 px-4 py-3 text-sm font-semibold text-orange-800 transition hover:bg-orange-100 dark:border-orange-400/40 dark:bg-orange-400/10 dark:text-orange-100 dark:hover:bg-orange-400/20",children:"Install Kaizen"}):null,t[19]=S,t[20]=c,t[21]=P):P=t[21];let z;t[22]!==D||t[23]!==P?(z=g.jsxs("div",{className:"mt-6 space-y-3",children:[D,P]}),t[22]=D,t[23]=P,t[24]=z):z=t[24];let Y;t[25]===Symbol.for("react.memo_cache_sentinel")?(Y=g.jsxs("div",{className:"mt-6 rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 text-sm leading-6 text-slate-700 dark:border-slate-700 dark:bg-slate-800/80 dark:text-slate-200",children:[g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"Install hint"}),g.jsx("p",{className:"mt-1",children:C})]}),t[25]=Y):Y=t[25];let L;return t[26]!==O||t[27]!==z?(L=g.jsxs("main",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-[radial-gradient(circle_at_top,rgba(241,245,249,0.96),rgba(255,255,255,1)_42%),linear-gradient(135deg,#fff8ef_0%,#ffffff_45%,#eef6ff_100%)] px-5 py-8 text-slate-950 dark:bg-[radial-gradient(circle_at_top,rgba(30,41,59,0.92),rgba(15,23,42,1)_46%),linear-gradient(135deg,#0f172a_0%,#111827_45%,#1f2937_100%)] dark:text-slate-50",children:[k,g.jsxs("section",{className:"relative w-full max-w-sm overflow-hidden rounded-[2rem] border border-white/70 bg-white/88 p-6 shadow-[0_30px_120px_-32px_rgba(15,23,42,0.42)] backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-900/88",children:[E,R,O,z,Y]})]}),t[26]=O,t[27]=z,t[28]=L):L=t[28],L}function Dae(){}const Oae=3210;function jae(t,e){const n=new URLSearchParams(t),r=Number(n.get("localPort"));if(Number.isFinite(r)&&r>0)return Math.round(r);const i=Number(e);return Number.isFinite(i)&&i>0?Math.round(i):Oae}function Lae(t){return`tailscale serve --bg --https 443 http://127.0.0.1:${String(t)}`}function Iae(t){return new URLSearchParams(t).get("reason")==="serve_permission_denied"?"serve_permission_denied":null}function Pae(t){const n=new URLSearchParams(t).get("setupCommand");return n!=null&&n.trim()?n:null}const zae="https://tailscale.com/download",Bae="https://tailscale.com/kb/1242/tailscale-serve",Fae="https://tailscale.com/docs/how-to/set-up-https-certificates";function Hae(){const t=ke.c(35),e=Yr();let n;t[0]!==e.search?(n=jae(e.search,window.location.port),t[0]=e.search,t[1]=n):n=t[1];const r=n;let i;t[2]!==e.search?(i=Iae(e.search),t[2]=e.search,t[3]=i):i=t[3];const s=i;let a;t[4]!==e.search?(a=Pae(e.search),t[4]=e.search,t[5]=a):a=t[5];const c=a;let d;t[6]!==r?(d=Lae(r),t[6]=r,t[7]=d):d=t[7];const u=d;let f;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=g.jsx("div",{className:"absolute inset-x-0 top-0 h-40 bg-[radial-gradient(circle_at_center,rgba(249,115,22,0.12),transparent_68%)] dark:bg-[radial-gradient(circle_at_center,rgba(251,146,60,0.14),transparent_68%)]"}),t[8]=f):f=t[8];let m,v,b;t[9]===Symbol.for("react.memo_cache_sentinel")?(m=g.jsx("div",{className:"mb-6 inline-flex rounded-full border border-orange-200 bg-orange-50 px-3 py-1 text-xs font-semibold uppercase tracking-[0.2em] text-orange-700 dark:border-orange-400/30 dark:bg-orange-400/10 dark:text-orange-200",children:"Remote setup"}),v=g.jsxs("h1",{className:"font-logo text-3xl leading-none tracking-tight",children:["Enable remote ",ys]}),b=g.jsx("p",{className:"mt-3 text-sm leading-6 text-slate-600 dark:text-slate-300",children:"Kaizen remote mode works best over Tailscale. If HTTPS handoff is not ready yet, use the steps below to install Tailscale, join your tailnet, and expose this local Kaizen session through Tailscale Serve."}),t[9]=m,t[10]=v,t[11]=b):(m=t[9],v=t[10],b=t[11]);let S;t[12]!==c||t[13]!==s?(S=s==="serve_permission_denied"&&c?g.jsxs("section",{className:"mt-6 rounded-2xl border border-orange-300 bg-orange-50/90 p-4 text-sm leading-6 text-orange-950 dark:border-orange-400/40 dark:bg-orange-400/10 dark:text-orange-100",children:[g.jsx("p",{className:"font-semibold",children:"One-time machine setup needed"}),g.jsx("p",{className:"mt-1",children:"Tailscale is connected, but this user is not allowed to change Serve config yet. Run this once on the Kaizen machine:"}),g.jsx("pre",{className:"mt-3 overflow-x-auto rounded-2xl bg-slate-950 p-4 text-xs text-slate-50",children:g.jsx("code",{children:c})})]}):null,t[12]=c,t[13]=s,t[14]=S):S=t[14];let x,C;t[15]===Symbol.for("react.memo_cache_sentinel")?(C=g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"1. Install and connect Tailscale"}),x=g.jsx("p",{className:"mt-1 text-slate-700 dark:text-slate-200",children:"Install Tailscale on this machine and on the device you want to open Kaizen from. Then sign in and connect both devices to the same tailnet."}),t[15]=x,t[16]=C):(x=t[15],C=t[16]);let k;t[17]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 dark:border-slate-700 dark:bg-slate-800/80",children:[C,x,g.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[g.jsx("a",{href:zae,target:"_blank",rel:"noreferrer",className:"rounded-xl border border-slate-300 px-3 py-2 font-medium text-slate-900 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700",children:"Download Tailscale"}),g.jsx("code",{className:"rounded-xl bg-slate-950 px-3 py-2 text-xs text-slate-50 dark:bg-slate-950",children:"tailscale up"})]})]}),t[17]=k):k=t[17];let E,R;t[18]===Symbol.for("react.memo_cache_sentinel")?(E=g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"2. Turn on HTTPS handoff with Tailscale Serve"}),R=g.jsx("p",{className:"mt-1 text-slate-700 dark:text-slate-200",children:"Run this on the machine where Kaizen is already running. It tells Tailscale to publish your local Kaizen port behind your tailnet HTTPS URL."}),t[18]=E,t[19]=R):(E=t[18],R=t[19]);let M;t[20]!==u?(M=g.jsx("pre",{className:"mt-3 overflow-x-auto rounded-2xl bg-slate-950 p-4 text-xs text-slate-50",children:g.jsx("code",{children:u})}),t[20]=u,t[21]=M):M=t[21];let O;t[22]===Symbol.for("react.memo_cache_sentinel")?(O=g.jsx("p",{className:"mt-3 text-slate-700 dark:text-slate-200",children:"If Tailscale says Serve is not enabled on your tailnet, an admin needs to enable HTTPS certificates and Serve support first."}),t[22]=O):O=t[22];let D;t[23]===Symbol.for("react.memo_cache_sentinel")?(D=g.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[g.jsx("a",{href:Bae,target:"_blank",rel:"noreferrer",className:"rounded-xl border border-slate-300 px-3 py-2 font-medium text-slate-900 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700",children:"Tailscale Serve docs"}),g.jsx("a",{href:Fae,target:"_blank",rel:"noreferrer",className:"rounded-xl border border-slate-300 px-3 py-2 font-medium text-slate-900 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700",children:"Enable HTTPS certs"})]}),t[23]=D):D=t[23];let P;t[24]!==M?(P=g.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 dark:border-slate-700 dark:bg-slate-800/80",children:[E,R,M,O,D]}),t[24]=M,t[25]=P):P=t[25];let z;t[26]===Symbol.for("react.memo_cache_sentinel")?(z=g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"3. Start Kaizen remote mode again"}),t[26]=z):z=t[26];let Y;t[27]===Symbol.for("react.memo_cache_sentinel")?(Y=g.jsx("pre",{className:"mt-3 overflow-x-auto rounded-2xl bg-slate-950 p-4 text-xs text-slate-50",children:g.jsx("code",{children:"kaizen --remote"})}),t[27]=Y):Y=t[27];let L;t[28]===Symbol.for("react.memo_cache_sentinel")?(L=g.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 dark:border-slate-700 dark:bg-slate-800/80",children:[z,Y,g.jsxs("p",{className:"mt-3 text-slate-700 dark:text-slate-200",children:["Once Serve is ready, Kaizen should print an"," ",g.jsx("span",{className:"font-semibold",children:"https://…ts.net/open"})," QR handoff URL instead of the HTTP fallback."]})]}),t[28]=L):L=t[28];let W;t[29]!==P?(W=g.jsxs("div",{className:"mt-6 space-y-4 text-sm leading-6",children:[k,P,L]}),t[29]=P,t[30]=W):W=t[30];let V;t[31]===Symbol.for("react.memo_cache_sentinel")?(V=g.jsx("div",{className:"mt-6 flex flex-wrap gap-3",children:g.jsx(Dh,{to:"/",className:"rounded-2xl bg-slate-950 px-4 py-3 text-sm font-semibold text-white transition hover:bg-slate-800 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:"Back to Kaizen"})}),t[31]=V):V=t[31];let F;return t[32]!==W||t[33]!==S?(F=g.jsxs("main",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-[radial-gradient(circle_at_top,rgba(241,245,249,0.96),rgba(255,255,255,1)_42%),linear-gradient(135deg,#fff8ef_0%,#ffffff_45%,#eef6ff_100%)] px-5 py-8 text-slate-950 dark:bg-[radial-gradient(circle_at_top,rgba(30,41,59,0.92),rgba(15,23,42,1)_46%),linear-gradient(135deg,#0f172a_0%,#111827_45%,#1f2937_100%)] dark:text-slate-50",children:[f,g.jsxs("section",{className:"relative w-full max-w-2xl overflow-hidden rounded-[2rem] border border-white/70 bg-white/88 p-6 shadow-[0_30px_120px_-32px_rgba(15,23,42,0.42)] backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-900/88",children:[m,v,b,S,W,V]})]}),t[32]=W,t[33]=S,t[34]=F):F=t[34],F}function bR(){return{baselineEstablished:!1,dedupeByChatId:new Map,statusByChatId:new Map}}function $ae(t){const e=[];for(const n of t.projectGroups){for(const r of n.generalChats)e.push({chat:r,projectTitle:n.title});for(const r of n.features)for(const i of r.chats)e.push({chat:i,projectTitle:n.title})}return e}function Vle(t=null){return sf()?Notification.permission:t??"unsupported"}function qle(t){return t==="granted"?"Allowed":t==="denied"?"Blocked":t==="default"?"Not requested":"Unsupported"}async function Kle(){return sf()?Notification.requestPermission():"unsupported"}function sf(){return typeof window<"u"&&window.isSecureContext&&typeof Notification<"u"}function Uae({activeChatId:t,chatId:e,documentVisible:n}){return!n||t!==e}function aO(t){return t==="starting"||t==="running"}function Wae(t,e){const n=aO(t),r=t==="waiting_for_user";return n&&e==="waiting_for_user"?"needs_input":(n||r)&&e==="idle"?"completed":null}function Vae({activeChatId:t,documentVisible:e,previousState:n,sidebarData:r}){const i=new Map,s=new Map(n.dedupeByChatId),a=[],c=$ae(r);for(const{chat:d,projectTitle:u}of c){const f=n.statusByChatId.get(d.chatId);if(i.set(d.chatId,d.status),(aO(d.status)||d.status==="failed")&&s.delete(d.chatId),!n.baselineEstablished)continue;const m=Wae(f,d.status);m&&Uae({activeChatId:t,chatId:d.chatId,documentVisible:e})&&s.get(d.chatId)!==m&&(s.set(d.chatId,m),a.push({chatId:d.chatId,chatTitle:d.title,eventId:`${d.chatId}:${m}:${Date.now()}`,projectTitle:u,kind:m}))}return{events:a,nextState:{baselineEstablished:!0,dedupeByChatId:s,statusByChatId:i}}}let g1=null;function qae(){if(typeof window>"u")return null;const t=window.AudioContext;return t?(g1||(g1=Promise.resolve(new t)),g1):null}function _R({audioContext:t,startAt:e,duration:n,frequency:r,gainValue:i}){const s=t.createOscillator(),a=t.createGain(),c=e+.012,d=e+Math.max(n-.08,.02),u=e+n;s.type="sine",s.frequency.setValueAtTime(r,e),a.gain.setValueAtTime(1e-4,e),a.gain.exponentialRampToValueAtTime(i,c),a.gain.setValueAtTime(i,d),a.gain.exponentialRampToValueAtTime(1e-4,u),s.connect(a),a.connect(t.destination),s.start(e),s.stop(u)}async function Kae(){const t=await qae();if(!t)return;t.state==="suspended"&&await t.resume();const e=t.currentTime;_R({audioContext:t,startAt:e,duration:.24,frequency:880,gainValue:.14}),_R({audioContext:t,startAt:e+.12,duration:.34,frequency:1318.51,gainValue:.18})}function Gae(t){typeof navigator>"u"||typeof navigator.vibrate!="function"||navigator.vibrate(t==="needs_input"?[180,100,180]:[120])}function Yae(t,e){if(!sf()||Notification.permission!=="granted")return null;const n=new Notification(t.chatTitle,{body:t.kind==="needs_input"?`${t.projectTitle} needs your input in ${ys}.`:`${t.projectTitle} finished responding in ${ys}.`,tag:t.eventId!==void 0?`kaizen:${t.eventId}`:`kaizen:${t.chatId}:${t.kind}:${Date.now()}`,icon:"/app-icon-192.png",badge:"/app-icon-96.png",requireInteraction:t.kind==="needs_input"});return n.onclick=()=>{window.focus(),e(),n.close()},n}async function Xae({event:t,onBrowserNotificationClick:e,preferences:n}){if(sf()){if(n.browserNotificationsEnabled&&Yae(t,e),n.soundEnabled)try{await Kae()}catch{}n.vibrationEnabled&&Gae(t.kind)}}function Qae(t){return{browserNotificationsEnabled:(t==null?void 0:t.browserNotificationsEnabled)===!0,soundEnabled:(t==null?void 0:t.soundEnabled)===!0,vibrationEnabled:(t==null?void 0:t.vibrationEnabled)===!0,lastPermissionState:(t==null?void 0:t.lastPermissionState)==="granted"||(t==null?void 0:t.lastPermissionState)==="denied"||(t==null?void 0:t.lastPermissionState)==="default"||(t==null?void 0:t.lastPermissionState)==="unsupported"?t.lastPermissionState:null}}function Zae(t){return t.signedIn&&t.browserNotificationsEnabled}const v1=fi()(Li(t=>({browserNotificationsEnabled:!1,soundEnabled:!1,vibrationEnabled:!1,lastPermissionState:null,setBrowserNotificationsEnabled:e=>t({browserNotificationsEnabled:e}),setSoundEnabled:e=>t({soundEnabled:e}),setVibrationEnabled:e=>t({vibrationEnabled:e}),setLastPermissionState:e=>t({lastPermissionState:e})}),{name:"notification-preferences",migrate:t=>Qae(t)}));function Jae(t){const e=ke.c(15),{activeChatId:n,connectionStatus:r,sidebarData:i}=t,s=tc(),{remoteAuth:a}=Hu(),c=Bg(a),d=v1(nle),u=v1(tle),f=v1(ele),m=Zae({browserNotificationsEnabled:d,signedIn:c.signedIn});let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=bR(),e[0]=v):v=e[0];const b=_.useRef(v),S=_.useRef(typeof document>"u"?!0:document.visibilityState==="visible");let x,C;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const O=function(){S.current=document.visibilityState==="visible"};return document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},C=[],e[1]=x,e[2]=C):(x=e[1],C=e[2]),_.useEffect(x,C);let k,E;e[3]!==r?(k=()=>{r!=="connected"&&(b.current={...bR(),dedupeByChatId:b.current.dedupeByChatId})},E=[r],e[3]=r,e[4]=k,e[5]=E):(k=e[4],E=e[5]),_.useEffect(k,E);let R,M;return e[6]!==c.features.browserNotifications.enabled||e[7]!==n||e[8]!==m||e[9]!==s||e[10]!==i||e[11]!==u||e[12]!==f?(R=()=>{if(!c.features.browserNotifications.enabled||!sf())return;const{events:O,nextState:D}=Vae({activeChatId:n,documentVisible:S.current,previousState:b.current,sidebarData:i});b.current=D;for(const P of O)Xae({event:P,onBrowserNotificationClick:()=>{s(`/chat/${P.chatId}`)},preferences:{browserNotificationsEnabled:m,soundEnabled:u,vibrationEnabled:f}})},M=[n,c.features.browserNotifications.enabled,m,s,i,u,f],e[6]=c.features.browserNotifications.enabled,e[7]=n,e[8]=m,e[9]=s,e[10]=i,e[11]=u,e[12]=f,e[13]=R,e[14]=M):(R=e[13],M=e[14]),_.useEffect(R,M),null}function ele(t){return t.vibrationEnabled}function tle(t){return t.soundEnabled}function nle(t){return t.browserNotificationsEnabled}function rle(){const t=typeof navigator<"u"&&navigator.standalone===!0,e=typeof window<"u"&&window.matchMedia("(display-mode: standalone)").matches;return t||e}function ile(){const t=window.visualViewport,e=Math.round((t==null?void 0:t.height)??window.innerHeight),n=Math.max(0,Math.round((t==null?void 0:t.offsetTop)??0));return{height:e,offsetTop:n}}function sle(){const t=ke.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],_.useLayoutEffect(ole,e)}function ole(){let t=0,e=null,n=0;const r=rle(),i=()=>{t=0;const{height:c,offsetTop:d}=ile();e===null&&(e=d),c>n&&(n=c);const u=Math.max(0,d-e),f=n-c>120||u>12,m=document.documentElement;m.style.setProperty("--app-shell-height",`${c}px`),m.style.setProperty("--app-shell-offset-top",r?f?`max(0px, calc(${u}px - env(safe-area-inset-top)))`:"0px":`${u}px`),m.style.setProperty("--app-composer-bottom-padding",r?f?"0px":"max(12px, env(safe-area-inset-bottom))":f?"12px":"20px")},s=()=>{t!==0&&window.cancelAnimationFrame(t),t=window.requestAnimationFrame(i)};s();const a=window.visualViewport;return window.addEventListener("resize",s),window.addEventListener("orientationchange",s),a==null||a.addEventListener("resize",s),a==null||a.addEventListener("scroll",s),()=>{t!==0&&window.cancelAnimationFrame(t),window.removeEventListener("resize",s),window.removeEventListener("orientationchange",s),a==null||a.removeEventListener("resize",s),a==null||a.removeEventListener("scroll",s)}}function ale(t){const e=ke.c(7),{children:n,activeChatId:r,activeOverviewFeatureId:i}=t;let s;e[0]!==r||e[1]!==n?(s=g.jsx(_ae,{activeChatId:r,children:n}),e[0]=r,e[1]=n,e[2]=s):s=e[2];let a;return e[3]!==r||e[4]!==i||e[5]!==s?(a=g.jsx(kK,{children:g.jsx(MK,{children:g.jsx(AK,{children:g.jsx(rae,{activeChatId:r,activeOverviewFeatureId:i,children:s})})})}),e[3]=r,e[4]=i,e[5]=s,e[6]=a):a=e[6],a}const lle=`${Ky}last-seen-version`,cle=_.lazy(()=>_y(()=>import("./FeatureOverviewPage-DGosnNE0.js"),__vite__mapDeps([0,1])).then(t=>({default:t.FeatureOverviewPage}))),ule=_.lazy(()=>_y(()=>import("./LocalProjectsPage-gWrmUSs2.js"),[]).then(t=>({default:t.LocalProjectsPage}))),dle=_.lazy(()=>_y(()=>import("./SettingsPage-BPpmk_eT.js"),__vite__mapDeps([2,1])).then(t=>({default:t.SettingsPage})));function b1(t){const e=ke.c(6),{label:n}=t;let r,i,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx("div",{className:"mb-3 h-4 w-32 animate-pulse rounded-full bg-muted"}),i=g.jsx("div",{className:"mb-2 h-7 w-56 animate-pulse rounded-full bg-muted"}),s=g.jsx("div",{className:"mb-6 h-4 w-72 animate-pulse rounded-full bg-muted"}),e[0]=r,e[1]=i,e[2]=s):(r=e[0],i=e[1],s=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsxs("div",{className:"grid gap-3",children:[g.jsx("div",{className:"h-16 animate-pulse rounded-2xl bg-muted/80"}),g.jsx("div",{className:"h-16 animate-pulse rounded-2xl bg-muted/70"}),g.jsx("div",{className:"h-16 animate-pulse rounded-2xl bg-muted/60"})]}),e[3]=a):a=e[3];let c;return e[4]!==n?(c=g.jsx("div",{className:"flex flex-1 min-w-0 items-center justify-center bg-background",children:g.jsx("div",{className:"w-full max-w-3xl px-6",children:g.jsxs("div",{className:"rounded-3xl border border-border/70 bg-card/60 p-6 shadow-sm",children:[r,i,s,a,g.jsx("div",{className:"mt-4 text-sm text-muted-foreground",children:n})]})})}),e[4]=n,e[5]=c):c=e[5],c}function hle(t,e){return!(!e||t.defaultPrevented||t.isComposing||Uq(t.target))}function fle(){const t=ke.c(4),e=IR(),n=e.chatId??null,r=e.featureId??null;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsx(mle,{}),t[0]=i):i=t[0];let s;return t[1]!==n||t[2]!==r?(s=g.jsx(ale,{activeChatId:n,activeOverviewFeatureId:r,children:i}),t[1]=n,t[2]=r,t[3]=s):s=t[3],s}function mle(){const t=ke.c(108),e=Yr(),n=IR(),r=Vh(),i=Hu(),s=hS(),a=oO(),c=Fu(),d=n.featureId??null;let u;t[0]!==a||t[1]!==r||t[2]!==i||t[3]!==s||t[4]!==d||t[5]!==c?(u={...r,...i,...s,...a,...c,activeOverviewFeatureId:d},t[0]=a,t[1]=r,t[2]=i,t[3]=s,t[4]=d,t[5]=c,t[6]=u):u=t[6];const f=u,m=zg("(min-width: 768px)"),v=PE(gle),b=PE(ple),S=e.pathname==="/";let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=LF.split("/")[1]??"unknown",t[7]=x):x=t[7];const C=x;let k;t[8]!==f.keybindings?(k=lN(f.keybindings),t[8]=f.keybindings,t[9]=k):k=t[9];const E=k;sle();let R,M;t[10]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{window.localStorage.setItem(lle,C)},M=[C],t[10]=R,t[11]=M):(R=t[10],M=t[11]),_.useEffect(R,M);let O;t[12]!==m||t[13]!==E||t[14]!==f?(O=()=>{const te=function(ie){const xe=Ya(E,"toggleProjectsSidebar",ie);hle(ie,xe)&&(ie.preventDefault(),f.toggleProjectsSidebar(m))};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},t[12]=m,t[13]=E,t[14]=f,t[15]=O):O=t[15];let D;t[16]!==m||t[17]!==E||t[18]!==f.toggleProjectsSidebar?(D=[m,E,f.toggleProjectsSidebar],t[16]=m,t[17]=E,t[18]=f.toggleProjectsSidebar,t[19]=D):D=t[19],_.useEffect(O,D);let P;t[20]===Symbol.for("react.memo_cache_sentinel")?(P={top:"var(--app-shell-offset-top)"},t[20]=P):P=t[20];let z,Y,L,W,V,F,U,H,j,G;t[21]!==f?(G=(te,he)=>{Ho(hr.chatCreate(te,he),()=>f.handleCreateChat(te,he),{statusLabel:"Starting chat..."})},z=te=>{f.handleCreateFeature(te)},Y=te=>{f.handleRenameFeature(te)},L=te=>{f.handleDeleteFeature(te)},W=(te,he)=>{f.handleSetProjectBrowserState(te,he)},V=(te,he)=>{f.handleSetProjectGeneralChatsBrowserState(te,he)},F=(te,he)=>{f.handleSetFeatureBrowserState(te,he)},U=(te,he)=>{f.handleSetFeatureStage(te,he)},H=(te,he)=>{f.handleSetChatFeature(te,he)},j=(te,he)=>{f.handleReorderFeatures(te,he)},t[21]=f,t[22]=z,t[23]=Y,t[24]=L,t[25]=W,t[26]=V,t[27]=F,t[28]=U,t[29]=H,t[30]=j,t[31]=G):(z=t[22],Y=t[23],L=t[24],W=t[25],V=t[26],F=t[27],U=t[28],H=t[29],j=t[30],G=t[31]);let B,K,A,I;t[32]!==f?(B=te=>{f.handleOpenFeatureOverview(te)},K=te=>{f.handleRenameChat(te)},A=te=>{f.handleDeleteChat(te)},I=te=>{Ho(hr.projectRemove(te),()=>f.handleRemoveProject(te),{statusLabel:"Hiding project..."})},t[32]=f,t[33]=B,t[34]=K,t[35]=A,t[36]=I):(B=t[33],K=t[34],A=t[35],I=t[36]);let $;t[37]!==f?($=te=>f.handleOpenProviderLogin(te),t[37]=f,t[38]=$):$=t[38];let T;t[39]!==f?(T=()=>{f.handleInstallUpdate()},t[39]=f,t[40]=T):T=t[40];let X;t[41]!==v||t[42]!==m||t[43]!==E.bindings.toggleProjectsSidebar||t[44]!==b||t[45]!==S||t[46]!==f.activeChatId||t[47]!==f.activeOverviewFeatureId||t[48]!==f.closeSidebar||t[49]!==f.completedChatIds||t[50]!==f.connectionStatus||t[51]!==f.expandSidebar||t[52]!==f.folderGroupsEnabled||t[53]!==f.handleRefreshProviderUsage||t[54]!==f.kanbanStatusesEnabled||t[55]!==f.openSidebar||t[56]!==f.providerSettings||t[57]!==f.remoteAuth||t[58]!==f.showFeatureOverviewInSidebar||t[59]!==f.sidebarCollapsed||t[60]!==f.sidebarData||t[61]!==f.sidebarOpen||t[62]!==f.sidebarReady||t[63]!==f.startingLocalPath||t[64]!==f.toggleProjectsSidebar||t[65]!==f.updateSnapshot||t[66]!==z||t[67]!==Y||t[68]!==L||t[69]!==W||t[70]!==V||t[71]!==F||t[72]!==U||t[73]!==H||t[74]!==j||t[75]!==B||t[76]!==K||t[77]!==A||t[78]!==I||t[79]!==$||t[80]!==T||t[81]!==G?(X=g.jsx(Tq,{data:f.sidebarData,completedChatIds:f.completedChatIds,activeChatId:f.activeChatId,activeOverviewFeatureId:f.activeOverviewFeatureId,connectionStatus:f.connectionStatus,ready:f.sidebarReady,open:f.sidebarOpen,collapsed:f.sidebarCollapsed,isDesktopViewport:m,showMobileOpenButton:S,onOpen:f.openSidebar,onClose:f.closeSidebar,onToggle:f.toggleProjectsSidebar,onExpand:f.expandSidebar,desktopWidth:v,toggleShortcut:E.bindings.toggleProjectsSidebar,onResizeDesktopWidth:b,onCreateChat:G,onCreateFeature:z,onRenameFeature:Y,onDeleteFeature:L,onSetProjectBrowserState:W,onSetProjectGeneralChatsBrowserState:V,onSetFeatureBrowserState:F,onSetFeatureStage:U,onSetChatFeature:H,onReorderFeatures:j,folderGroupsEnabled:f.folderGroupsEnabled,showFeatureOverviewInSidebar:f.showFeatureOverviewInSidebar,kanbanStatusesEnabled:f.kanbanStatusesEnabled,onOpenFeatureOverview:B,onRenameChat:K,onDeleteChat:A,onRemoveProject:I,onRefreshProviderUsage:f.handleRefreshProviderUsage,onOpenProviderLogin:$,providerSettings:f.providerSettings,remoteAuth:f.remoteAuth,startingLocalPath:f.startingLocalPath,updateSnapshot:f.updateSnapshot,onInstallUpdate:T}),t[41]=v,t[42]=m,t[43]=E.bindings.toggleProjectsSidebar,t[44]=b,t[45]=S,t[46]=f.activeChatId,t[47]=f.activeOverviewFeatureId,t[48]=f.closeSidebar,t[49]=f.completedChatIds,t[50]=f.connectionStatus,t[51]=f.expandSidebar,t[52]=f.folderGroupsEnabled,t[53]=f.handleRefreshProviderUsage,t[54]=f.kanbanStatusesEnabled,t[55]=f.openSidebar,t[56]=f.providerSettings,t[57]=f.remoteAuth,t[58]=f.showFeatureOverviewInSidebar,t[59]=f.sidebarCollapsed,t[60]=f.sidebarData,t[61]=f.sidebarOpen,t[62]=f.sidebarReady,t[63]=f.startingLocalPath,t[64]=f.toggleProjectsSidebar,t[65]=f.updateSnapshot,t[66]=z,t[67]=Y,t[68]=L,t[69]=W,t[70]=V,t[71]=F,t[72]=U,t[73]=H,t[74]=j,t[75]=B,t[76]=K,t[77]=A,t[78]=I,t[79]=$,t[80]=T,t[81]=G,t[82]=X):X=t[82];const Z=f.createFeatureModalProjectId!==null;let J,re;t[83]!==f?(J=te=>{te||f.handleCloseCreateFeatureModal()},re=te=>f.handleConfirmCreateFeature(te),t[83]=f,t[84]=J,t[85]=re):(J=t[84],re=t[85]);let ae;t[86]!==f.isCreatingFeature||t[87]!==Z||t[88]!==J||t[89]!==re?(ae=g.jsx(V7,{open:Z,isSubmitting:f.isCreatingFeature,onOpenChange:J,onConfirm:re}),t[86]=f.isCreatingFeature,t[87]=Z,t[88]=J,t[89]=re,t[90]=ae):ae=t[90];let ue,me;t[91]!==f?(ue=te=>{te||f.handleCloseCursorCurlImport()},me=te=>f.handleSubmitCursorCurlImport(te),t[91]=f,t[92]=ue,t[93]=me):(ue=t[92],me=t[93]);let se;t[94]!==f.cursorCurlImportOpen||t[95]!==ue||t[96]!==me?(se=g.jsx(q7,{open:f.cursorCurlImportOpen,onOpenChange:ue,onSubmit:me}),t[94]=f.cursorCurlImportOpen,t[95]=ue,t[96]=me,t[97]=se):se=t[97];let oe;t[98]!==f.activeChatId||t[99]!==f.connectionStatus||t[100]!==f.sidebarData?(oe=g.jsx(Jae,{activeChatId:f.activeChatId,connectionStatus:f.connectionStatus,sidebarData:f.sidebarData}),t[98]=f.activeChatId,t[99]=f.connectionStatus,t[100]=f.sidebarData,t[101]=oe):oe=t[101];let ee;t[102]===Symbol.for("react.memo_cache_sentinel")?(ee=g.jsx(aI,{}),t[102]=ee):ee=t[102];let Q;return t[103]!==X||t[104]!==ae||t[105]!==se||t[106]!==oe?(Q=g.jsxs("div",{className:"relative flex h-[var(--app-shell-height)] min-h-[var(--app-shell-height)] overflow-hidden",style:P,children:[X,ae,se,oe,ee]}),t[103]=X,t[104]=ae,t[105]=se,t[106]=oe,t[107]=Q):Q=t[107],Q}function ple(t){return t.setWidth}function gle(t){return t.widthPx}function vle(){const t=ke.c(8);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsx(jo,{path:"/open",element:g.jsx(Nae,{})}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=g.jsx(jo,{path:"/remote-setup",element:g.jsx(Hae,{})}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx(fle,{}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsx(jo,{path:"/",element:g.jsx(_.Suspense,{fallback:g.jsx(b1,{label:"Loading local projects..."}),children:g.jsx(ule,{})})}),t[3]=i):i=t[3];let s;t[4]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx(jo,{path:"/settings",element:g.jsx(oI,{to:"/settings/general",replace:!0})}),t[4]=s):s=t[4];let a;t[5]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsx(jo,{path:"/settings/:sectionId",element:g.jsx(_.Suspense,{fallback:g.jsx(b1,{label:"Loading settings..."}),children:g.jsx(dle,{})})}),t[5]=a):a=t[5];let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=g.jsx(jo,{path:"/chat/:chatId",element:g.jsx(Cae,{})}),t[6]=c):c=t[6];let d;return t[7]===Symbol.for("react.memo_cache_sentinel")?(d=g.jsx(TF,{children:g.jsxs($7,{children:[g.jsxs(cI,{children:[e,n,g.jsxs(jo,{element:r,children:[i,s,a,c,g.jsx(jo,{path:"/overview/:featureId",element:g.jsx(_.Suspense,{fallback:g.jsx(b1,{label:"Loading feature overview..."}),children:g.jsx(cle,{})})})]})]}),g.jsx(yP,{})]})}),t[7]=d):d=t[7],d}const lO=document.getElementById("root");if(!lO)throw new Error("Missing #root");lL.createRoot(lO).render(g.jsx(jI,{basename:uN(),children:g.jsx(oZ,{children:g.jsx(vle,{})})}));export{v4 as $,Oy as A,vt as B,bN as C,My as D,Ni as E,b8 as F,_le as G,ys as H,jy as I,Ele as J,n4 as K,Fn as L,nf as M,yy as N,LF as O,Ul as P,_s as Q,op as R,BD as S,fg as T,UV as U,sE as V,vu as W,di as X,lu as Y,oO as Z,Fu as _,ke as a,Bg as a0,pK as a1,Zn as a2,zV as a3,GA as a4,BV as a5,QA as a6,rc as a7,Ex as a8,ZA as a9,aK as aA,oK as aB,r_ as aC,cK as aD,lK as aE,i_ as aF,TH as aG,Dle as aH,jle as aI,sf as aJ,Vle as aK,Kle as aL,Zae as aM,Xae as aN,ZF as aO,sq as aP,Lo as aQ,aq as aR,Wse as aa,Lle as ab,f1 as ac,au as ad,qr as ae,JP as af,Ole as ag,Yr as ah,IR as ai,aZ as aj,Fp as ak,$o as al,fu as am,v1 as an,lN as ao,kle as ap,tH as aq,Tp as ar,Hg as as,JR as at,is as au,Nle as av,hK as aw,HV as ax,qle as ay,wle as az,Vh as b,st as c,Hu as d,hS as e,zg as f,hr as g,hu as h,Ce as i,Zh as j,g as k,RZ as l,Ho as m,rf as n,yN as o,Ll as p,ap as q,_ as r,zo as s,Bo as t,tc as u,Fo as v,hg as w,Dy as x,Ay as y,Cle as z};
608
+ `),i=ioe(n,r),s=soe(n,r,i);return ooe(s)}function ioe(t,e){const n=t.length,r=e.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let s=1;s<=n;s++)for(let a=1;a<=r;a++)i[s][a]=t[s-1]===e[a-1]?i[s-1][a-1]+1:Math.max(i[s-1][a],i[s][a-1]);return i}function soe(t,e,n){const r=[];let i=t.length,s=e.length;for(;i>0||s>0;)i>0&&s>0&&t[i-1]===e[s-1]?(r.push({type:"context",text:t[i-1],oldIdx:i,newIdx:s}),i--,s--):s>0&&(i===0||n[i][s-1]>=n[i-1][s])?(r.push({type:"added",text:e[s-1],oldIdx:i,newIdx:s}),s--):(r.push({type:"removed",text:t[i-1],oldIdx:i,newIdx:s}),i--);return r.reverse()}function ooe(t){return t.map(e=>{const n=e.type==="removed"?"-":e.type==="added"?"+":" ";return{type:e.type,content:`${n}${e.text}`}})}function h1(t){const e=ke.c(20),{content:n,isDiff:r,oldString:i,newString:s}=t,a=r===void 0?!1:r;let c;e:{if(a&&i!==void 0&&s!==void 0){let C;e[0]!==s||e[1]!==i?(C=roe(i,s),e[0]=s,e[1]=i,e[2]=C):C=e[2],c=C;break e}let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[3]=x):x=e[3],c=x}const d=c;let u;e:{if(!a){let C;e[4]!==n?(C=toe(n),e[4]=n,e[5]=C):C=e[5],u=C;break e}let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[6]=x):x=e[6],u=x}const f=u;let m;e[7]!==f?(m=f.some(loe),e[7]=f,e[8]=m):m=e[8];const v=m;if(a&&d.length>0){let x;e[9]!==d?(x=d.map(aoe),e[9]=d,e[10]=x):x=e[10];let C;return e[11]!==x?(C=g.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:g.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:g.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:g.jsx("tbody",{children:x})})})}),e[11]=x,e[12]=C):C=e[12],C}let b;if(e[13]!==v||e[14]!==f){let x;e[16]!==v?(x=(C,k)=>g.jsxs("tr",{children:[v&&g.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:C.lineNumber!==null?C.lineNumber:""}),g.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:noe(C.content)})]},k),e[16]=v,e[17]=x):x=e[17],b=f.map(x),e[13]=v,e[14]=f,e[15]=b}else b=e[15];let S;return e[18]!==b?(S=g.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:g.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:g.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:g.jsx("tbody",{children:b})})})}),e[18]=b,e[19]=S):S=e[19],S}function aoe(t,e){const n=t.type==="removed"?"bg-red-500/10 dark:bg-red-500/15":t.type==="added"?"bg-green-500/10 dark:bg-green-500/15":"",r=t.type==="removed"?"text-red-700 dark:text-red-400":t.type==="added"?"text-green-700 dark:text-green-400":"text-foreground";return g.jsxs("tr",{className:n,children:[g.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${t.type==="removed"?"text-red-500/50":t.type==="added"?"text-green-500/50":"text-muted-foreground/50"}`,children:t.type==="removed"?"-":t.type==="added"?"+":" "}),g.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${r}`,children:t.content.slice(1)})]},e)}function loe(t){return t.lineNumber!==null}function Q6(t){var $;const e=ke.c(78),{message:n,isLoading:r,localPath:i}=t,s=r===void 0?!1:r,a=n.result!==void 0,c=!a&&s;let d;e:{if(typeof n.result=="string"){d=n.result;break e}if(!n.result){d="";break e}if(typeof n.result=="object"&&n.result!==null&&"content"in n.result){const X=n.result.content;if(typeof X=="string"){d=X;break e}}let T;e[0]!==n.result?(T=JSON.stringify(n.result,null,2),e[0]=n.result,e[1]=T):T=e[1],d=T}const u=d;let f;if(e[2]!==n.input||e[3]!==n.toolKind||e[4]!==u){e:{if((n.toolKind==="read_file"||n.toolKind==="write_file"||n.toolKind==="edit_file")&&n.input.filePath){f=n.input.filePath;break e}if(n.toolKind==="edit_file"){const T=u.match(/^Updated\s+(.+)$/m);if(T!=null&&T[1]){f=T[1].trim();break e}}f=""}e[2]=n.input,e[3]=n.toolKind,e[4]=u,e[5]=f}else f=e[5];const m=f;let v;e:{if(n.toolKind==="skill"){v=n.input.skill;break e}if(n.toolKind==="glob"){v=`Search files ${n.input.pattern==="**/*"?"in all directories":`matching ${n.input.pattern}`}`;break e}if(n.toolKind==="grep"){const T=n.input.pattern,X=n.input.outputMode;if(X==="count"){v=`Count \`${T}\` occurrences`;break e}if(X==="content"){v=`Find \`${T}\` in text`;break e}v=`Find \`${T}\` in files`;break e}if(n.toolKind==="bash"){let T;e[6]!==n.input.command||e[7]!==n.input.description?(T=n.input.description||(n.input.command?LH(n.input.command):"Bash"),e[6]=n.input.command,e[7]=n.input.description,e[8]=T):T=e[8],v=T;break e}if(n.toolKind==="web_search"){v=n.input.query||"Web Search";break e}if(n.toolKind==="read_file"){let T;e[9]!==m||e[10]!==i?(T=m?`Read ${Vb(m,i)}`:"Read file",e[9]=m,e[10]=i,e[11]=T):T=e[11],v=T;break e}if(n.toolKind==="write_file"){let T;e[12]!==m||e[13]!==i?(T=m?`Write ${Vb(m,i)}`:"Write file",e[12]=m,e[13]=i,e[14]=T):T=e[14],v=T;break e}if(n.toolKind==="edit_file"){let T;e[15]!==m||e[16]!==i?(T=m?`Edit ${Vb(m,i)}`:"Edit file",e[15]=m,e[16]=i,e[17]=T):T=e[17],v=T;break e}if(n.toolKind==="mcp_generic"){let T;e[18]!==n.input.tool?(T=B1(n.input.tool),e[18]=n.input.tool,e[19]=T):T=e[19];let X;e[20]!==n.input.server?(X=B1(n.input.server),e[20]=n.input.server,e[21]=X):X=e[21],v=`${T} from ${X}`;break e}if(n.toolKind==="subagent_task"){v=n.input.subagentType||n.toolName;break e}v=n.toolName}const b=v,S=n.toolKind==="subagent_task";let x;e:{if(n.toolKind==="skill"){x=n.input.skill;break e}x=void 0}const C=x,k=n.toolKind==="bash",E=n.toolKind==="write_file",R=n.toolKind==="edit_file",M=n.toolKind==="read_file";let O;e[22]!==M||e[23]!==u?(O=M&&!!u.trim(),e[22]=M,e[23]=u,e[24]=O):O=e[24];const D=O;let P;e[25]!==R||e[26]!==n.input?(P=R&&(!!n.input.oldString.trim()||!!n.input.newString.trim()),e[25]=R,e[26]=n.input,e[27]=P):P=e[27];const z=P;let Y;e:switch(n.toolKind){case"bash":{Y=n.input.command;break e}case"write_file":{Y=n.input.content;break e}default:{let T;e[28]!==n.input?(T=JSON.stringify(n.input,null,2),e[28]=n.input,e[29]=T):T=e[29],Y=T}}const L=Y;let W;e[30]!==z||e[31]!==L||e[32]!==k||e[33]!==R||e[34]!==M||e[35]!==E||e[36]!==n.input||e[37]!==n.isError||e[38]!==u?(W=R?z?g.jsx(h1,{content:"",isDiff:!0,oldString:n.input.oldString,newString:n.input.newString}):u.trim()?g.jsx(qb,{label:n.isError?"Error":"Result",copyText:u,children:u}):g.jsx("div",{className:"text-muted-foreground text-xs",children:"Cursor completed this edit, but ACP did not include the file diff details."}):!M&&!E&&g.jsx(qb,{label:k?g.jsxs("span",{className:"flex items-center gap-2 w-full",children:[g.jsx("span",{children:"Command"}),!!n.input.timeoutMs&&g.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(n.input.timeoutMs),"ms"]}),!!n.input.runInBackground&&g.jsx("span",{className:"text-muted-foreground",children:"background"})]}):E?"Contents":"Input",copyText:L,children:L}),e[30]=z,e[31]=L,e[32]=k,e[33]=R,e[34]=M,e[35]=E,e[36]=n.input,e[37]=n.isError,e[38]=u,e[39]=W):W=e[39];let V;e[40]!==D||e[41]!==a||e[42]!==M||e[43]!==n.isError||e[44]!==u?(V=a&&M&&!n.isError&&(D?g.jsx(h1,{content:u}):g.jsx("div",{className:"text-muted-foreground text-xs",children:"Cursor completed this read, but ACP did not include the file contents."})),e[40]=D,e[41]=a,e[42]=M,e[43]=n.isError,e[44]=u,e[45]=V):V=e[45];let F;e[46]!==E||e[47]!==n.input||e[48]!==n.isError?(F=E&&!n.isError&&g.jsx(h1,{content:n.input.content}),e[46]=E,e[47]=n.input,e[48]=n.isError,e[49]=F):F=e[49];let U;e[50]!==a||e[51]!==R||e[52]!==M||e[53]!==E||e[54]!==n.isError||e[55]!==u?(U=a&&!M&&!(E&&!n.isError)&&!(R&&!n.isError)&&g.jsx(qb,{label:n.isError?"Error":"Result",copyText:u,children:u}),e[50]=a,e[51]=R,e[52]=M,e[53]=E,e[54]=n.isError,e[55]=u,e[56]=U):U=e[56];let H;e[57]!==V||e[58]!==F||e[59]!==U||e[60]!==W?(H=g.jsx(Qh,{className:"my-4 text-sm",children:g.jsxs("div",{className:"flex flex-col gap-2",children:[W,V,F,U]})}),e[57]=V,e[58]=F,e[59]=U,e[60]=W,e[61]=H):H=e[61];let j;e:{if(n.isError){let J;e[62]===Symbol.for("react.memo_cache_sentinel")?(J=g.jsx(is,{className:"size-4 text-destructive"}),e[62]=J):J=e[62],j=J;break e}if(S){let J;e[63]===Symbol.for("react.memo_cache_sentinel")?(J=g.jsx(xy,{className:"size-4 text-muted-icon"}),e[63]=J):J=e[63],j=J;break e}let T;e[64]!==n.toolName?(T=PD(n.toolName),e[64]=n.toolName,e[65]=T):T=e[65];const X=T;let Z;e[66]!==X?(Z=g.jsx(X,{className:"size-4 text-muted-icon"}),e[66]=X,e[67]=Z):Z=e[67],j=Z}let G;e[68]!==j?(G=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:j}),e[68]=j,e[69]=G):G=e[69];const B=Math.max(20,((($=C||b)==null?void 0:$.length)??33)*3),K=C||b;let A;e[70]!==c||e[71]!==B||e[72]!==K?(A=g.jsx(Yo,{className:"text-left transition-opacity duration-200 truncate",children:g.jsx(Eg,{animate:c,shimmerWidth:B,children:K})}),e[70]=c,e[71]=B,e[72]=K,e[73]=A):A=e[73];let I;return e[74]!==H||e[75]!==G||e[76]!==A?(I=g.jsx(ea,{className:"w-full",children:g.jsxs(Xh,{expandedContent:H,children:[G,A]})}),e[74]=H,e[75]=G,e[76]=A,e[77]=I):I=e[77],I}function coe(t){const e=ke.c(9),{message:n}=t,r=uoe;if(!n.success){const f=n.result||"An unknown error occurred.";let m;return e[0]!==f?(m=g.jsx("div",{className:"px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:f}),e[0]=f,e[1]=m):m=e[1],m}const i=`px-0.5 text-xs tracking-wide ${n.durationMs>6e4?"":"hidden"}`;let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx("div",{className:"w-full h-[1px] bg-border"}),e[2]=s):s=e[2];const a=r(n.durationMs);let c;e[3]!==a?(c=g.jsxs(Yo,{className:"whitespace-nowrap text-[11px] tracking-widest text-muted-foreground/60 uppercase flex-shrink-0",children:["Worked for ",a]}),e[3]=a,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=g.jsx("div",{className:"w-full h-[1px] bg-border"}),e[5]=d):d=e[5];let u;return e[6]!==i||e[7]!==c?(u=g.jsxs(ea,{className:i,children:[s,c,d]}),e[6]=i,e[7]=c,e[8]=u):u=e[8],u}function uoe(t){if(t<1e3)return`${t}ms`;const e=Math.floor(t/1e3),n=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return n>0?`${n}h${r>0?` ${r}m`:""}`:r>0?`${r}m${i>0?` ${i}s`:""}`:`${i}s`}function doe(t){const e=ke.c(1);let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=g.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground my-3",children:g.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:[g.jsx(YP,{className:"h-4 w-4 ml-1.5"}),g.jsx("em",{children:"Interrupted"})]})}),e[0]=n):n=e[0],n}function eg(t){const e=ke.c(15),{size:n}=t,r=n===void 0?4:n,i=`0 0 100 ${r}`,s=`${r}px`;let a;e[0]!==s?(a={height:s},e[0]=s,e[1]=a):a=e[1];const c=`M0 ${r} L${r/2} 0 L${r} ${r}`;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={stroke:"currentColor"},e[2]=d):d=e[2];let u;e[3]!==c?(u=g.jsx("path",{d:c,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:d}),e[3]=c,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==u?(f=g.jsx("pattern",{id:"zigzag",width:r,height:r,patternUnits:"userSpaceOnUse",children:u}),e[5]=r,e[6]=u,e[7]=f):f=e[7];let m;e[8]!==r?(m=g.jsx("rect",{width:"100%",height:r,fill:"url(#zigzag)",className:"text-muted-foreground/30"}),e[8]=r,e[9]=m):m=e[9];let v;return e[10]!==i||e[11]!==a||e[12]!==f||e[13]!==m?(v=g.jsxs("svg",{className:"flex-1",viewBox:i,preserveAspectRatio:"none",style:a,children:[f,m]}),e[10]=i,e[11]=a,e[12]=f,e[13]=m,e[14]=v):v=e[14],v}function hoe(){const t=ke.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(eg,{}),g.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),g.jsx(eg,{})]}),t[0]=e):e=t[0],e}function foe(){const t=ke.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(eg,{}),g.jsx("span",{className:"text-[11px] tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),g.jsx(eg,{})]}),t[0]=e):e=t[0],e}function moe(t){const e=ke.c(8),{message:n}=t;let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[rf],i=Zh(),e[0]=r,e[1]=i):(r=e[0],i=e[1]);let s;e[2]!==n.summary?(s=g.jsx(Qh,{className:"my-4 text-xs",children:g.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:g.jsx(nf,{remarkPlugins:r,components:i,children:n.summary})})}),e[2]=n.summary,e[3]=s):s=e[3];let a,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(QR,{className:"h-4.5 w-4.5 text-muted-foreground"})}),c=g.jsx(Yo,{children:"Summarized"}),e[4]=a,e[5]=c):(a=e[4],c=e[5]);let d;return e[6]!==s?(d=g.jsx(ea,{children:g.jsxs(Xh,{expandedContent:s,children:[a,c]})}),e[6]=s,e[7]=d):d=e[7],d}const poe={compacting:"Compacting..."};function goe(t){const e=ke.c(3),{message:n}=t,r=poe[n.status]||n.status;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(QR,{className:"h-4.5 w-4.5 text-muted-foreground"})}),e[0]=i):i=e[0];let s;return e[1]!==r?(s=g.jsxs(ea,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[i,g.jsx(Yo,{className:"text-left transition-opacity duration-200 truncate",children:r})]}),e[1]=r,e[2]=s):s=e[2],s}const voe={read_file:{key:"read",singular:"read",plural:"reads"},edit_file:{key:"edit",singular:"edit",plural:"edits"},write_file:{key:"write",singular:"write",plural:"writes"},bash:{key:"bash",singular:"command",plural:"commands"},grep:{key:"grep",singular:"search",plural:"searches"},glob:{key:"glob",singular:"glob",plural:"globs"},subagent_task:{key:"task",singular:"agent",plural:"agents"},web_search:{key:"websearch",singular:"web search",plural:"web searches"},skill:{key:"skill",singular:"skill",plural:"skills"},todo_write:{key:"todo",singular:"todo update",plural:"todo updates"}},boe={key:"other",singular:"tool call",plural:"tool calls"};function _oe(t){return voe[t]??boe}function yoe(t){const e=new Map,n=[];for(const r of t){const i=r.toolKind,s=_oe(i),a=e.get(s.key);a?a.count++:(e.set(s.key,{category:s,count:1}),n.push(s.key))}return n.map(r=>{const{category:i,count:s}=e.get(r);return`${s} ${s===1?i.singular:i.plural}`}).join(", ")}function xoe(t){const e=ke.c(26),{messages:n,isLoading:r,localPath:i}=t,[s,a]=_.useState(!1);let c;e[0]!==n?(c=yoe(n),e[0]=n,e[1]=c):c=e[1];const d=c;let u;e[2]!==n?(u=n.some(Soe),e[2]=n,e[3]=u):u=e[3];const m=u&&r;let v;e[4]!==s?(v=()=>a(!s),e[4]=s,e[5]=v):v=e[5];const b=`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!s&&!m?"hover:opacity-60 transition-opacity":""}`,S=`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${s?"rotate-90":""}`;let x;e[6]!==S?(x=g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(Ni,{className:S})}),e[6]=S,e[7]=x):x=e[7];let C;e[8]!==d||e[9]!==m?(C=g.jsx(Yo,{className:"text-left",children:g.jsx(Eg,{animate:m,children:d})}),e[8]=d,e[9]=m,e[10]=C):C=e[10];let k;e[11]!==x||e[12]!==C?(k=g.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[x,C]}),e[11]=x,e[12]=C,e[13]=k):k=e[13];let E;e[14]!==v||e[15]!==b||e[16]!==k?(E=g.jsx("button",{onClick:v,className:b,children:k}),e[14]=v,e[15]=b,e[16]=k,e[17]=E):E=e[17];let R;e[18]!==s||e[19]!==r||e[20]!==i||e[21]!==n?(R=s&&g.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[n.map(O=>g.jsx(Q6,{message:O,isLoading:r,localPath:i},O.id)),n.length>5&&g.jsx("button",{onClick:()=>a(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:g.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[g.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:g.jsx(Ni,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),g.jsx(Yo,{className:"text-left",children:"Collapse"})]})})]}),e[18]=s,e[19]=r,e[20]=i,e[21]=n,e[22]=R):R=e[22];let M;return e[23]!==R||e[24]!==E?(M=g.jsx(ea,{className:"w-full",children:g.jsxs("div",{className:"flex flex-col w-full",children:[E,R]})}),e[23]=R,e[24]=E,e[25]=M):M=e[25],M}function Soe(t){return t.result===void 0}const woe=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite"]);function aR(t){if(t.kind!=="tool")return!1;const e=t.toolName;return!woe.has(e)}function Coe(t,e,n){return t?t.kind==="status"&&e<n.length-1:!1}function koe(t,e={}){var s;const n=[];let r=0;const i=a=>(a==null?void 0:a.kind)==="tool"&&a.toolName==="TodoWrite"&&a.id!==e.TodoWrite;for(;r<t.length;){const a=t[r];if(aR(a)){const c=[a],d=r;for(r+=1;r<t.length;){const u=t[r];if(aR(u)){c.push(u),r+=1;continue}if(Coe(u,r,t)){r+=1;continue}if(i(u)){r+=1;continue}break}c.length>=2?n.push({type:"tool-group",key:`group-${((s=c[0])==null?void 0:s.id)??d}`,messages:c,startIndex:d}):n.push({type:"single",key:a.id,message:a,index:d});continue}n.push({type:"single",key:a.id,message:a,index:r}),r+=1}return n}function Eoe(t,e){var r;if(!e)return null;let n=-1;for(let i=t.length-1;i>=0;i-=1)if(((r=t[i])==null?void 0:r.kind)==="user_prompt"){n=i;break}if(n<0)return null;for(let i=t.length-1;i>n;i-=1){const s=t[i];if((s==null?void 0:s.kind)==="assistant_text")return s.id}return null}function Roe(t,e){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect().top-n.top+t.scrollTop;return{viewportHeight:t.clientHeight,viewportWidth:t.clientWidth,viewportStart:Math.max(0,t.scrollTop-i)}}function Toe(t){const e=ke.c(67),{messages:n,isLoading:r,hasOlderMessages:i,oldestLoadedEntryId:s,isLoadingOlderMessages:a,isAtBottom:c,localPath:d,latestToolIds:u,onOpenLocalLink:f,onAskUserQuestionSubmit:m,onExitPlanModeConfirm:v,onHandoff:b,onLoadOlder:S,pendingTool:x,availableProviders:C,scrollContainerRef:k}=t,E=_.useRef(null),R=_.useRef(null);let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={viewportHeight:0,viewportWidth:0,viewportStart:0},e[0]=M):M=e[0];const[O,D]=_.useState(M);let P;e[1]!==n?(P=n.filter(Noe),e[1]=n,e[2]=P):P=e[2];const z=P;let Y;e[3]!==u||e[4]!==z?(Y=koe(z,u),e[3]=u,e[4]=z,e[5]=Y):Y=e[5];const L=Y;let W;e[6]!==z?(W=z.findIndex(Aoe),e[6]=z,e[7]=W):W=e[7];const V=W;let F;e[8]!==z?(F=z.findIndex(Moe),e[8]=z,e[9]=F):F=e[9];const U=F;let H;e[10]!==r||e[11]!==z?(H=Eoe(z,r),e[10]=r,e[11]=z,e[12]=H):H=e[12];const j=H;let G;e[13]!==k?(G=()=>{const me=k.current,se=E.current;if(!me||!se)return;const oe=()=>{const Q=Roe(me,se);D(te=>te.viewportHeight===Q.viewportHeight&&te.viewportWidth===Q.viewportWidth&&te.viewportStart===Q.viewportStart?te:Q)};oe();const ee=new ResizeObserver(oe);return ee.observe(me),ee.observe(se),me.addEventListener("scroll",oe,{passive:!0}),()=>{ee.disconnect(),me.removeEventListener("scroll",oe)}},e[13]=k,e[14]=G):G=e[14];let B;e[15]!==n.length||e[16]!==k?(B=[n.length,k],e[15]=n.length,e[16]=k,e[17]=B):B=e[17],_.useEffect(G,B);let K,A;e[18]!==c||e[19]!==s||e[20]!==O.viewportStart?(A=()=>{if(c||O.viewportStart>480){R.current=null;return}s&&R.current!==s&&(R.current=null)},K=[c,s,O.viewportStart],e[18]=c,e[19]=s,e[20]=O.viewportStart,e[21]=K,e[22]=A):(K=e[21],A=e[22]),_.useEffect(A,K);let I;e[23]!==i||e[24]!==c||e[25]!==a||e[26]!==s||e[27]!==S||e[28]!==k||e[29]!==O.viewportStart?(I=()=>{if(!i||!s||a||c||O.viewportStart>480)return;const me=k.current;if(me){const se=me.scrollHeight-me.scrollTop-me.clientHeight;if(dN(se))return}R.current!==s&&(R.current=s,S())},e[23]=i,e[24]=c,e[25]=a,e[26]=s,e[27]=S,e[28]=k,e[29]=O.viewportStart,e[30]=I):I=e[30];let $;e[31]!==i||e[32]!==c||e[33]!==a||e[34]!==n.length||e[35]!==s||e[36]!==S||e[37]!==O.viewportStart?($=[i,c,s,a,n.length,S,O.viewportStart],e[31]=i,e[32]=c,e[33]=a,e[34]=n.length,e[35]=s,e[36]=S,e[37]=O.viewportStart,e[38]=$):$=e[38],_.useEffect(I,$);let T;e[39]!==C||e[40]!==U||e[41]!==V||e[42]!==r||e[43]!==j||e[44]!==u||e[45]!==d||e[46]!==m||e[47]!==v||e[48]!==b||e[49]!==x||e[50]!==z?(T=function(se,oe){if(se.kind==="user_prompt")return g.jsx(_se,{content:se.content,attachments:se.attachments},se.id);switch(se.kind){case"unknown":return g.jsx(wse,{json:se.json},se.id);case"system_init":return oe===V?g.jsx(Dse,{message:se,rawJson:se.debugRaw},se.id):null;case"account_info":return oe===U?g.jsx(jse,{message:se},se.id):null;case"assistant_text":return g.jsx(Lse,{message:se,isStreaming:r&&se.id===j},se.id);case"assistant_thought":return g.jsx(Ise,{message:se},se.id);case"tool":return se.toolKind==="ask_user_question"?g.jsx($se,{message:se,onSubmit:m,isLatest:se.id===u.AskUserQuestion},se.id):se.toolKind==="exit_plan_mode"?g.jsx(Xse,{message:se,onConfirm:v,onHandoff:b,isLatest:se.id===u.ExitPlanMode,isActionable:(x==null?void 0:x.toolKind)==="exit_plan_mode"&&x.toolUseId===se.toolId,availableProviders:C},se.id):se.toolKind==="todo_write"?se.id!==u.TodoWrite?null:g.jsx(eoe,{message:se},se.id):g.jsx(Q6,{message:se,isLoading:r,localPath:d},se.id);case"result":{const ee=z[oe+1],Q=z[oe-1];return(ee==null?void 0:ee.kind)==="context_cleared"||(Q==null?void 0:Q.kind)==="context_cleared"?null:g.jsx(coe,{message:se},se.id)}case"interrupted":return g.jsx(doe,{message:se},se.id);case"compact_boundary":return g.jsx(hoe,{},se.id);case"context_cleared":return g.jsx(foe,{},se.id);case"compact_summary":return g.jsx(moe,{message:se},se.id);case"status":return oe===z.length-1?g.jsx(goe,{message:se},se.id):null}},e[39]=C,e[40]=U,e[41]=V,e[42]=r,e[43]=j,e[44]=u,e[45]=d,e[46]=m,e[47]=v,e[48]=b,e[49]=x,e[50]=z,e[51]=T):T=e[51];const X=T;let Z;e[52]!==r||e[53]!==d||e[54]!==X?(Z=function(se,oe){if(se.type==="tool-group")return g.jsx("div",{className:oe?void 0:"pb-5",children:g.jsx("div",{className:"group relative",[Sp]:"",children:g.jsx(xoe,{messages:se.messages,isLoading:r,localPath:d})})},se.key);const ee=X(se.message,se.index);return ee?g.jsx("div",{className:oe?void 0:"pb-5",children:g.jsx("div",{id:`msg-${se.message.id}`,className:"group relative",[Sp]:"",children:ee})},se.key):null},e[52]=r,e[53]=d,e[54]=X,e[55]=Z):Z=e[55];const J=Z;let re;if(e[56]!==J||e[57]!==L){let me;e[59]!==J||e[60]!==L.length?(me=(se,oe)=>J(se,oe===L.length-1),e[59]=J,e[60]=L.length,e[61]=me):me=e[61],re=L.map(me),e[56]=J,e[57]=L,e[58]=re}else re=e[58];let ae;e[62]!==re?(ae=g.jsx("div",{ref:E,children:re}),e[62]=re,e[63]=ae):ae=e[63];let ue;return e[64]!==f||e[65]!==ae?(ue=g.jsx(xZ,{onOpenLocalLink:f,children:ae}),e[64]=f,e[65]=ae,e[66]=ue):ue=e[66],ue}function Moe(t){return t.kind==="account_info"}function Aoe(t){return t.kind==="system_init"}function Noe(t){return!t.hidden}function Doe(t){const e=ke.c(6),{rootRef:n,fallbackRef:r,enabled:i,canCancel:s}=t;let a,c;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==n?(a=()=>{if(!i)return;let d=0,u=null;const f=x=>{const C=x instanceof Element?x:null,k=n.current,E=r.current;if(Fk({trigger:"pointer",activeElement:document.activeElement,pointerStartTarget:u,pointerEndTarget:C,root:k,fallback:E,hasActiveOverlay:Bk(document),hasActiveSelection:z7(window.getSelection())})!=="restore"){u=null;return}E==null||E.focus({preventScroll:!0}),u=null},m=x=>{cancelAnimationFrame(d),u=x.target instanceof Element?x.target:null},v=x=>{cancelAnimationFrame(d),d=window.requestAnimationFrame(()=>{f(x.target)})},b=()=>{u=null;const x=r.current;!x||x.disabled||x.focus({preventScroll:!0})},S=x=>{if(x.key!=="Escape")return;const C=r.current;Fk({trigger:"escape",activeElement:document.activeElement,fallback:C,hasActiveOverlay:Bk(document),canCancel:s,defaultPrevented:x.defaultPrevented})==="escape-focus"&&(x.preventDefault(),C==null||C.focus({preventScroll:!0}))};return window.addEventListener("pointerdown",m,!0),window.addEventListener("pointerup",v,!0),window.addEventListener("keydown",S,!0),window.addEventListener(xp,b),()=>{cancelAnimationFrame(d),window.removeEventListener("pointerdown",m,!0),window.removeEventListener("pointerup",v,!0),window.removeEventListener("keydown",S,!0),window.removeEventListener(xp,b)}},c=[s,i,r,n],e[0]=s,e[1]=i,e[2]=r,e[3]=n,e[4]=a,e[5]=c):(a=e[4],c=e[5]),_.useEffect(a,c)}const $m="Use any pull-request skills to create a new pull request for these local changes. Write a clear, concise title, description, and testing summary.",Um="Use any pull-request skills to update the existing pull request for these local changes. Commit the local changes with a clear, concise message and summarize what changed.",au=["codex"],Ooe=new Set(rc.map(t=>t.id));function lR(t){if(!Array.isArray(t))return[...au];const e=t.filter(n=>typeof n=="string"&&Ooe.has(n));return e.length>0?Array.from(new Set(e)):[...au]}const f1=fi()(Li(t=>({pullRequestPrompt:$m,pullRequestUpdatePrompt:Um,pullRequestProviders:[...au],setPullRequestPrompt:e=>t({pullRequestPrompt:e}),setPullRequestUpdatePrompt:e=>t({pullRequestUpdatePrompt:e}),setPullRequestProviders:e=>t({pullRequestProviders:lR(e)}),togglePullRequestProvider:e=>t(n=>{const r=n.pullRequestProviders.includes(e)?n.pullRequestProviders.filter(i=>i!==e):[...n.pullRequestProviders,e];return{pullRequestProviders:r.length>0?r:[...au]}}),resetToDefaults:()=>t({pullRequestPrompt:$m,pullRequestUpdatePrompt:Um,pullRequestProviders:[...au]})}),{name:"slash-command-settings",version:1,migrate:t=>{if(!t||typeof t!="object")return{pullRequestPrompt:$m,pullRequestUpdatePrompt:Um,pullRequestProviders:[...au]};const e=t;return{...e,pullRequestPrompt:typeof e.pullRequestPrompt=="string"?e.pullRequestPrompt:$m,pullRequestUpdatePrompt:typeof e.pullRequestUpdatePrompt=="string"?e.pullRequestUpdatePrompt:Um,pullRequestProviders:lR(e.pullRequestProviders)}}}));function Wm(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function joe(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}function Loe(t,e){const n=joe(e);switch(t.toolKind){case"ask_user_question":{const i=Wm(n),s=Wm(i==null?void 0:i.answers)??(i||{});return{answers:Object.fromEntries(Object.entries(s).map(([a,c])=>Array.isArray(c)?[a,c.map(d=>String(d))]:c&&typeof c=="object"&&Array.isArray(c.answers)?[a,c.answers.map(d=>String(d))]:c==null||c===""?[a,[]]:[a,[String(c)]])),...(i==null?void 0:i.discarded)===!0?{discarded:!0}:{}}}case"exit_plan_mode":{const i=Wm(n);return{confirmed:typeof(i==null?void 0:i.confirmed)=="boolean"?i.confirmed:void 0,clearContext:typeof(i==null?void 0:i.clearContext)=="boolean"?i.clearContext:void 0,suppressFollowUp:typeof(i==null?void 0:i.suppressFollowUp)=="boolean"?i.suppressFollowUp:void 0,message:typeof(i==null?void 0:i.message)=="string"?i.message:void 0,...(i==null?void 0:i.discarded)===!0?{discarded:!0}:{}}}case"read_file":if(typeof n=="string")return n;const r=Wm(n);return{content:typeof(r==null?void 0:r.content)=="string"?r.content:JSON.stringify(n,null,2)};default:return n}}function Z6(t){return new Date(t).toISOString()}function Yi(t){return{id:t._id,messageId:t.messageId,timestamp:Z6(t.createdAt),hidden:t.hidden}}function Ioe(t){return{id:t._id,messageId:t.messageId,hidden:t.hidden,kind:"tool",toolKind:t.tool.toolKind,toolName:t.tool.toolName,toolId:t.tool.toolId,input:t.tool.input,timestamp:Z6(t.createdAt)}}function Poe(t){if(t.debugRaw)try{return JSON.parse(t.debugRaw).tool_use_result}catch{return}}function zoe(t){if(t!=null&&t.length)return t.map(e=>({...e,previewUrl:`/attachments/${e.relativePath.split("/").map(encodeURIComponent).join("/")}`}))}function cR(t,e){const n=t.at(-1);if((n==null?void 0:n.kind)===e.kind&&n.hidden===e.hidden&&n.messageId===e.messageId){n.text+=e.text;return}t.push(e)}function uR(t){if(!t||typeof t!="object"||!("answers"in t))return!1;const e=t.answers;return Object.values(e).some(n=>Array.isArray(n)&&n.length>0)}function Boe(t){const e=new Map,n=[];for(const r of t)switch(r.kind){case"user_prompt":n.push({...Yi(r),kind:"user_prompt",content:r.content,attachments:zoe(r.attachments)});break;case"system_init":n.push({...Yi(r),kind:"system_init",provider:r.provider,model:r.model,tools:r.tools,agents:r.agents,slashCommands:r.slashCommands,mcpServers:r.mcpServers,debugRaw:r.debugRaw});break;case"account_info":n.push({...Yi(r),kind:"account_info",accountInfo:r.accountInfo});break;case"assistant_text":cR(n,{...Yi(r),kind:"assistant_text",text:r.text});break;case"assistant_thought":cR(n,{...Yi(r),kind:"assistant_thought",text:r.text});break;case"tool_call":{const i=n.at(-1);(i==null?void 0:i.kind)==="assistant_text"&&r.tool.toolKind==="ask_user_question"&&(i.hidden=!0);const s=Ioe(r);e.set(r.tool.toolId,{hydrated:s,normalized:r.tool,precedingAssistantText:(i==null?void 0:i.kind)==="assistant_text"?i:void 0}),n.push(s);break}case"tool_result":{const i=e.get(r.toolId);if(i){const s=i.normalized.toolKind==="ask_user_question"||i.normalized.toolKind==="exit_plan_mode"?Poe(r)??r.content:r.content,a=Loe(i.normalized,s);(i.normalized.toolKind!=="ask_user_question"||!uR(i.hydrated.result)||uR(a))&&(i.hydrated.result=a,i.hydrated.rawResult=s),i.hydrated.isError=r.isError,i.normalized.toolKind==="exit_plan_mode"&&i.precedingAssistantText&&i.hydrated.result&&(i.precedingAssistantText.hidden=!0)}break}case"result":n.push({...Yi(r),kind:"result",success:!r.isError,cancelled:r.subtype==="cancelled",result:r.result,durationMs:r.durationMs,costUsd:r.costUsd});break;case"status":n.push({...Yi(r),kind:"status",status:r.status});break;case"compact_boundary":n.push({...Yi(r),kind:"compact_boundary"});break;case"compact_summary":n.push({...Yi(r),kind:"compact_summary",summary:r.summary});break;case"context_cleared":n.push({...Yi(r),kind:"context_cleared"});break;case"interrupted":n.push({...Yi(r),kind:"interrupted"});break;default:n.push({...Yi(r),kind:"unknown",json:JSON.stringify(r,null,2)});break}return n}const Foe=["AskUserQuestion","ExitPlanMode","TodoWrite"],Hoe=new Set(["TodoWrite"]);function $oe(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r.kind!=="tool")continue;const i=r;if(i.toolName===e&&!i.result)return i.id}return null}function Uoe(t,e){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(r.kind!=="tool")continue;const i=r;if(i.toolName===e)return i.id}return null}function Woe(t){const e={};for(const n of Foe)e[n]=Hoe.has(n)?Uoe(t,n):$oe(t,n);return e}function Voe(t){return t==="starting"||t==="running"||t==="waiting_for_user"}function cy(t){return t==="starting"||t==="running"||t==="waiting_for_user"}function J6(){return typeof window>"u"?null:(window.__KAIZEN_PERF__??(window.__KAIZEN_PERF__={timings:{},counters:{}}),window.__KAIZEN_PERF__)}function eO(){return typeof window>"u"?!1:window.localStorage.getItem("kaizen.debug.perf")==="1"}function tO(t,e,n){const r=J6();r&&(r.timings[t]={value:e,meta:n,recordedAt:Date.now()},eO()&&console.debug(`[kaizen][perf] timing ${t}=${e}`,n??{}))}function dR(t,e=1,n){var s;const r=J6();if(!r)return;const i=(((s=r.counters[t])==null?void 0:s.value)??0)+e;r.counters[t]={value:i,meta:n,recordedAt:Date.now()},eO()&&console.debug(`[kaizen][perf] counter ${t}=${i}`,n??{})}function qoe(t){const e=new Set;return t.filter(n=>{const r=n.localPath??n.projectId;return!r||e.has(r)?!1:(e.add(r),!0)})}function Koe(t,e,n){return{...t,projectGroups:t.projectGroups.map(r=>{if(r.groupKey!==e)return r;const i=new Map(r.features.map(a=>[a.featureId,a])),s=n.map(a=>i.get(a)).filter(a=>!!a);return s.length!==r.features.length?r:{...r,features:s}})}}function Goe(t,e){const n=t.stage==="done"?1:0,r=e.stage==="done"?1:0;return n!==r?n-r:t.sortOrder!==e.sortOrder?t.sortOrder-e.sortOrder:e.updatedAt-t.updatedAt}function Yoe(t,e,n){const r=t.filter(s=>s.featureId!==e);if(n==="done"){const s=r.filter(c=>c.stage==="done").map(c=>c.sortOrder),a=r.map(c=>c.sortOrder);return s.length>0?Math.max(...s)+1:a.length>0?Math.max(...a)+1:0}const i=r.filter(s=>s.stage!=="done").map(s=>s.sortOrder);return i.length===0?0:Math.max(...i)+1}function Xoe(t,e,n,r=Date.now()){return{...t,projectGroups:t.projectGroups.map(i=>{const s=i.features.find(d=>d.featureId===e);if(!s||s.stage===n)return i;const a=s.stage==="done"||n==="done",c=i.features.map(d=>d.featureId===e?{...d,stage:n,updatedAt:r,sortOrder:a?Yoe(i.features,e,n):d.sortOrder}:d).sort(Goe);return{...i,features:c}})}}function Qoe(){return{projectBrowserStateById:{},projectGeneralChatsBrowserStateById:{},featureBrowserStateById:{},featureStageById:{},featureOrderByProjectId:{}}}function Zoe(t,e){let n={...t,projectGroups:t.projectGroups.map(r=>{var i,s;return{...r,browserState:((i=e.projectBrowserStateById[r.groupKey])==null?void 0:i.value)??r.browserState,generalChatsBrowserState:((s=e.projectGeneralChatsBrowserStateById[r.groupKey])==null?void 0:s.value)??r.generalChatsBrowserState,features:r.features.map(a=>{var c;return{...a,browserState:((c=e.featureBrowserStateById[a.featureId])==null?void 0:c.value)??a.browserState}})}})};for(const[r,i]of Object.entries(e.featureOrderByProjectId))n=Koe(n,r,i.value);for(const[r,i]of Object.entries(e.featureStageById))n=Xoe(n,r,i.value);return n}function nO(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(t[n]!==e[n])return!1;return!0}function Vm(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>{var s,a,c,d;return((s=t[i])==null?void 0:s.value)===((a=e[i])==null?void 0:a.value)&&((c=t[i])==null?void 0:c.opId)===((d=e[i])==null?void 0:d.opId)})}function Joe(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>{var s,a;return e[i]?((s=t[i])==null?void 0:s.opId)===((a=e[i])==null?void 0:a.opId)&&nO(t[i].value,e[i].value):!1})}function m1(t,e){return t.projectGroups.find(n=>n.groupKey===e)}function hR(t,e){return t.projectGroups.flatMap(n=>n.features).find(n=>n.featureId===e)}function eae(t,e){const n=Object.fromEntries(Object.entries(e.projectBrowserStateById).filter(([c,d])=>{var u;return((u=m1(t,c))==null?void 0:u.browserState)!==d.value})),r=Object.fromEntries(Object.entries(e.projectGeneralChatsBrowserStateById).filter(([c,d])=>{var u;return((u=m1(t,c))==null?void 0:u.generalChatsBrowserState)!==d.value})),i=Object.fromEntries(Object.entries(e.featureBrowserStateById).filter(([c,d])=>{var u;return((u=hR(t,c))==null?void 0:u.browserState)!==d.value})),s=Object.fromEntries(Object.entries(e.featureStageById).filter(([c,d])=>{var u;return((u=hR(t,c))==null?void 0:u.stage)!==d.value})),a=Object.fromEntries(Object.entries(e.featureOrderByProjectId).filter(([c,d])=>{const u=m1(t,c);return u?!nO(u.features.map(f=>f.featureId),d.value):!1}));return{projectBrowserStateById:n,projectGeneralChatsBrowserStateById:r,featureBrowserStateById:i,featureStageById:s,featureOrderByProjectId:a}}function tae(t,e){return Vm(t.projectBrowserStateById,e.projectBrowserStateById)&&Vm(t.projectGeneralChatsBrowserStateById,e.projectGeneralChatsBrowserStateById)&&Vm(t.featureBrowserStateById,e.featureBrowserStateById)&&Vm(t.featureStageById,e.featureStageById)&&Joe(t.featureOrderByProjectId,e.featureOrderByProjectId)}function qd(t,e,n){var s;if(!(e in t)||((s=t[e])==null?void 0:s.opId)!==n)return t;const{[e]:r,...i}=t;return i}const rO=_.createContext(void 0);function nae(t){const e=new Map;for(const n of t.projectGroups)for(const r of[...n.generalChats,...n.features.flatMap(i=>i.chats)])e.set(r.chatId,r.status);return e}function uy(t,e){switch(e.type){case"sidebar.project-added":{const n=[...t.projectGroups];return n.splice(e.index,0,{...e.project,features:[],generalChats:[]}),{...t,projectGroups:n}}case"sidebar.project-removed":return{...t,projectGroups:t.projectGroups.filter(n=>n.groupKey!==e.projectId)};case"sidebar.project-moved":{const n=t.projectGroups.findIndex(s=>s.groupKey===e.projectId);if(n===-1)return t;const r=[...t.projectGroups],[i]=r.splice(n,1);return r.splice(e.index,0,i),{...t,projectGroups:r}}case"sidebar.project-fields-set":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey===e.projectId?{...n,...e.patch}:n)};case"sidebar.feature-added":return{...t,projectGroups:t.projectGroups.map(n=>{if(n.groupKey!==e.projectId)return n;const r=[...n.features];return r.splice(e.index,0,e.feature),{...n,features:r}})};case"sidebar.feature-removed":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:{...n,features:n.features.filter(r=>r.featureId!==e.featureId)})};case"sidebar.feature-moved":return{...t,projectGroups:t.projectGroups.map(n=>{if(n.groupKey!==e.projectId)return n;const r=n.features.findIndex(a=>a.featureId===e.featureId);if(r===-1)return n;const i=[...n.features],[s]=i.splice(r,1);return i.splice(e.index,0,s),{...n,features:i}})};case"sidebar.feature-fields-set":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:{...n,features:n.features.map(r=>r.featureId===e.featureId?{...r,...e.patch}:r)})};case"sidebar.chat-added":return{...t,projectGroups:t.projectGroups.map(n=>{if(n.groupKey!==e.projectId)return n;if(e.featureId)return{...n,features:n.features.map(i=>{if(i.featureId!==e.featureId)return i;const s=[...i.chats];return s.splice(e.index,0,e.chat),{...i,chats:s}})};const r=[...n.generalChats];return r.splice(e.index,0,e.chat),{...n,generalChats:r}})};case"sidebar.chat-removed":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:e.featureId?{...n,features:n.features.map(r=>r.featureId!==e.featureId?r:{...r,chats:r.chats.filter(i=>i.chatId!==e.chatId)})}:{...n,generalChats:n.generalChats.filter(r=>r.chatId!==e.chatId)})};case"sidebar.chat-moved":{const n=uy(t,{type:"sidebar.chat-removed",projectId:e.projectId,featureId:e.fromFeatureId,chatId:e.chatId}),r=t.projectGroups.flatMap(i=>[...i.generalChats,...i.features.flatMap(s=>s.chats)]).find(i=>i.chatId===e.chatId);return r?uy(n,{type:"sidebar.chat-added",projectId:e.projectId,featureId:e.toFeatureId,chat:{...r,featureId:e.toFeatureId},index:e.index}):n}case"sidebar.chat-fields-set":return{...t,projectGroups:t.projectGroups.map(n=>n.groupKey!==e.projectId?n:e.featureId?{...n,features:n.features.map(r=>r.featureId!==e.featureId?r:{...r,chats:r.chats.map(i=>i.chatId===e.chatId?{...i,...e.patch}:i)})}:{...n,generalChats:n.generalChats.map(r=>r.chatId===e.chatId?{...r,...e.patch}:r)})};case"sidebar.provider-usage-set":return{...t,providerUsage:e.providerUsage}}}function rae({children:t,activeChatId:e,activeOverviewFeatureId:n}){const r=tc(),i=Ly(),{socket:s}=Vh(),{setCommandError:a,handleOpenCreateFeatureModal:c}=Fu(),[d,u]=_.useState({projectGroups:[]}),[f,m]=_.useState(Qoe),[v,b]=_.useState(null),[S,x]=_.useState(null),[C,k]=_.useState(!1),[E,R]=_.useState(!1),[M,O]=_.useState(!1),[D,P]=_.useState(!1),[z,Y]=_.useState(new Set),L=_.useRef(1),W=_.useRef(d),V=_.useRef(new Map),F=_.useRef(typeof document>"u"?!0:document.visibilityState==="visible"),U=dh(ee=>ee.setVisibility),H=_.useMemo(()=>Zoe(d,f),[d,f]),j=_.useCallback(ee=>{W.current=ee,u(ee),m(Q=>{const te=eae(ee,Q);return tae(Q,te)?Q:te})},[]);function G(){const ee=L.current;return L.current+=1,ee}_.useEffect(()=>{function ee(){const Q=document.visibilityState==="visible";F.current=Q,!(!Q||!e)&&Y(te=>{if(!te.has(e))return te;const he=new Set(te);return he.delete(e),he})}return document.addEventListener("visibilitychange",ee),()=>document.removeEventListener("visibilitychange",ee)},[e]),_.useEffect(()=>s.subscribe({type:"sidebar"},ee=>{j(ee),k(!0),a(null)},ee=>{const Q=performance.now(),te=uy(W.current,ee);j(te),tO("sidebar_event_apply_ms",Math.round(performance.now()-Q),{type:ee.type}),k(!0),a(null)}),[j,a,s]),_.useEffect(()=>{const ee=nae(H),Q=V.current,te=F.current;Y(he=>{let ie=he;for(const[xe,Ae]of ee){const Ke=Q.get(xe);cy(Ae)&&ie.has(xe)&&(ie===he&&(ie=new Set(he)),ie.delete(xe)),Ke&&cy(Ke)&&Ae==="idle"&&(xe!==e||!te)&&(ie===he&&(ie=new Set(he)),ie.add(xe))}return ie}),V.current=ee},[e,H]),_.useEffect(()=>s.subscribe({type:"local-projects"},ee=>{b(ee),R(!0),a(null)}),[a,s]),_.useEffect(()=>{if(!n){x(null);return}return x(null),s.subscribe({type:"feature-overview",featureId:n},ee=>{x(ee),a(null)})},[n,a,s]),_.useEffect(()=>{if(!e)return;const ee=u_(H.projectGroups,e);ee&&U(ee,!1)},[e,U,H.projectGroups]);function B(ee){Y(Q=>{if(!Q.has(ee))return Q;const te=new Set(Q);return te.delete(ee),te})}async function K(ee){const Q=ee.split("/").filter(Boolean).pop()??ee;if(await i.confirm({title:"Hide Project",description:`Hide "${Q}" from ${ys}? This only removes it from ${ys} until you re-add it or reset local state.`,confirmLabel:"Hide",confirmVariant:"destructive"}))try{await s.command({type:"project.hide",localPath:ee}),a(null)}catch(he){a(he instanceof Error?he.message:String(he))}}async function A(ee){const Q=new URL(Hg("/api/directories"),window.location.origin);ee&&Q.searchParams.set("path",ee);const te=await fetch(Q.toString());if(!te.ok){let ie="Failed to load directories";try{const xe=await te.json();xe.error&&(ie=xe.error)}catch{}throw new Error(ie)}const he=await te.json();return a(null),he}async function I(ee){const Q=H.projectGroups.flatMap(he=>he.features).find(he=>he.featureId===ee);if(!Q)return;const te=await i.prompt({title:"Rename Feature",placeholder:"Feature name",initialValue:Q.title,confirmLabel:"Rename"});if(!(!te||te===Q.title))try{await s.command({type:"feature.rename",featureId:ee,title:te}),a(null)}catch(he){a(he instanceof Error?he.message:String(he))}}async function $(ee){const Q=H.projectGroups.flatMap(he=>he.features).find(he=>he.featureId===ee);if(!(!Q||!await i.confirm({title:"Delete Feature",description:`Delete "${Q.title}"? Its chats will move to General and the feature folder will be removed.`,confirmLabel:"Delete",confirmVariant:"destructive"})))try{await s.command({type:"feature.delete",featureId:ee}),n===ee&&r("/"),a(null)}catch(he){a(he instanceof Error?he.message:String(he))}}async function T(ee,Q){const te=G();m(he=>({...he,featureBrowserStateById:{...he.featureBrowserStateById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"feature.setBrowserState",featureId:ee,browserState:Q}),a(null)}catch(he){m(ie=>({...ie,featureBrowserStateById:qd(ie.featureBrowserStateById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function X(ee,Q){const te=G();m(he=>({...he,projectBrowserStateById:{...he.projectBrowserStateById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"project.setBrowserState",projectId:ee,browserState:Q}),a(null)}catch(he){m(ie=>({...ie,projectBrowserStateById:qd(ie.projectBrowserStateById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function Z(ee,Q){const te=G();m(he=>({...he,projectGeneralChatsBrowserStateById:{...he.projectGeneralChatsBrowserStateById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"project.setGeneralChatsBrowserState",projectId:ee,browserState:Q}),a(null)}catch(he){m(ie=>({...ie,projectGeneralChatsBrowserStateById:qd(ie.projectGeneralChatsBrowserStateById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function J(ee,Q){const te=G();m(he=>({...he,featureStageById:{...he.featureStageById,[ee]:{value:Q,opId:te}}}));try{await s.command({type:"feature.setStage",featureId:ee,stage:Q}),a(null)}catch(he){m(ie=>({...ie,featureStageById:qd(ie.featureStageById,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function re(ee,Q){try{const te=await s.command({type:"feature.updateOverview",featureId:ee,content:Q});return a(null),te}catch(te){const he=te instanceof Error?te.message:String(te);throw a(he),te}}async function ae(ee,Q){const te=G();m(he=>({...he,featureOrderByProjectId:{...he.featureOrderByProjectId,[ee]:{value:Q,opId:te}}}));try{const he=await s.command({type:"feature.reorder",projectId:ee,orderedFeatureIds:Q});j(he.sidebar),a(null)}catch(he){m(ie=>({...ie,featureOrderByProjectId:qd(ie.featureOrderByProjectId,ee,te)})),a(he instanceof Error?he.message:String(he))}}async function ue(ee,Q){await s.command({type:"project.setProjectMetadataDirectoryCommitMode",projectId:ee.projectId,localPath:ee.localPath,commitProjectMetadata:Q})}async function me(ee){try{await Promise.all(qoe((v==null?void 0:v.projects.map(Q=>({localPath:Q.localPath})))??H.projectGroups.map(Q=>({projectId:Q.groupKey,localPath:Q.localPath}))).map(Q=>ue(Q,ee))),a(null)}catch(Q){throw a(Q instanceof Error?Q.message:String(Q)),Q}}async function se(ee){const Q=H.projectGroups.find(ie=>ie.groupKey===ee);if(!Q)return;const te=Q.localPath.split("/").filter(Boolean).pop()??Q.localPath;if(await i.confirm({title:"Hide Project",description:`Hide "${te}" from ${ys}? Existing chats for this project will be removed from ${ys}, but the project itself is not deleted.`,confirmLabel:"Hide",confirmVariant:"destructive"}))try{await s.command({type:"project.remove",projectId:ee}),Ha.getState().clearProject(ee),dh.getState().clearProject(ee),(e&&u_(H.projectGroups,e)===ee||(S==null?void 0:S.projectId)===ee)&&r("/"),a(null)}catch(ie){a(ie instanceof Error?ie.message:String(ie))}}const oe=_.useMemo(()=>({sidebarData:H,completedChatIds:z,localProjects:v,featureOverviewSnapshot:S,sidebarReady:C,localProjectsReady:E,sidebarOpen:M,sidebarCollapsed:D,openSidebar:()=>O(!0),closeSidebar:()=>O(!1),collapseSidebar:()=>P(!0),expandSidebar:()=>P(!1),toggleProjectsSidebar:ee=>{if(ee){O(!1),P(Q=>!Q);return}O(Q=>!Q)},clearCompletedChatId:B,handleCreateFeature:ee=>c(ee),handleOpenFeatureOverview:ee=>{r(`/overview/${ee}`),O(!1),a(null)},handleRenameFeature:I,handleDeleteFeature:$,handleSetProjectBrowserState:X,handleSetProjectGeneralChatsBrowserState:Z,handleSetFeatureBrowserState:T,handleSetFeatureStage:J,handleReorderFeatures:ae,handleHideLocalProject:K,handleListDirectories:A,handleRemoveProject:se,handleUpdateFeatureOverview:re,handleSetCommitProjectMetadataDirectory:me}),[z,S,B,$,K,c,A,se,I,ae,me,T,J,X,Z,re,v,E,r,a,D,H,M,C,s]);return g.jsx(rO.Provider,{value:oe,children:t})}function hS(){const t=_.useContext(rO);if(!t)throw new Error("useSidebarContext must be used within SidebarProvider");return t}const iae=1e3,sae=4,oae=40*1024*1024,iO=_.createContext(void 0);function Kd(t,e){return!!(t&&e&&t.runtime.chatId===e)}function qm(t,e){return(t?JSON.stringify(t).length:0)+JSON.stringify(e).length+256}function aae(t){return!!(t.activeChatId&&t.restoredFromCache&&!t.restoredFromFreshCache)}function lae(t){var n;if(!(t!=null&&t.length))return null;let e=((n=t[0])==null?void 0:n.createdAt)??null;for(const r of t)(e===null||r.createdAt>e)&&(e=r.createdAt);return e}function p1(t,e){const n=t.filter(r=>r._id!==e);return n.length===t.length?t:n}const dy="optimistic:";function fR(t){return t.startsWith(dy)}function cae(t){const e=tl(t.loadedTranscriptEntries,[t.entry]);return{snapshot:t.snapshot&&t.snapshot.runtime.chatId===t.chatId?{...t.snapshot,messages:tl(t.snapshot.messages,[t.entry]),transcript:{...t.snapshot.transcript,entries:tl(t.snapshot.transcript.entries,[t.entry])}}:t.snapshot,loadedTranscriptEntries:e}}function uae(t){return{snapshot:t.snapshot===null?null:{...t.snapshot,messages:p1(t.snapshot.messages,t.entryId),transcript:{...t.snapshot.transcript,entries:p1(t.snapshot.transcript.entries,t.entryId)}},loadedTranscriptEntries:p1(t.loadedTranscriptEntries,t.entryId)}}function dae(t){return t.map(e=>JSON.stringify({_id:e._id,messageId:e.messageId??null,createdAt:e.createdAt,hidden:e.hidden??!1,kind:e.kind,payload:hae(e)})).join("")}function hae(t){switch(t.kind){case"user_prompt":return{content:t.content,attachments:t.attachments??[]};case"system_init":return{provider:t.provider,model:t.model,tools:t.tools,agents:t.agents,slashCommands:t.slashCommands,mcpServers:t.mcpServers,debugRaw:t.debugRaw??null};case"account_info":return t.accountInfo;case"assistant_text":case"assistant_thought":return t.text;case"tool_call":return t.tool;case"tool_result":return{toolId:t.toolId,content:t.content,isError:t.isError??!1,debugRaw:t.debugRaw??null};case"result":return{subtype:t.subtype,isError:t.isError,durationMs:t.durationMs,result:t.result,costUsd:t.costUsd??null};case"status":return t.status;case"compact_boundary":case"context_cleared":case"interrupted":return null;case"compact_summary":return t.summary;default:return t}}function fae(t){var n,r,i;const e=lae(t.loadedTranscriptEntries.length>0?t.loadedTranscriptEntries:(n=t.snapshot)==null?void 0:n.transcript.entries);return{cachedStatus:((r=t.snapshot)==null?void 0:r.runtime.status)??null,cachedUpdatedAt:((i=t.snapshot)==null?void 0:i.runtime.updatedAt)??e}}function mae(t){return t?t.updatedAt??t.lastMessageAt??null:null}function pae(t){return t.queuedReason===t.nextReason&&t.isQueued}function gae(t){return t.currentChat?t.cachedStatus===t.currentChat.status&&t.cachedUpdatedAt===mae(t.currentChat):!1}function tl(t,e){if(e.length===0)return t;if(t.length===0)return e===t?t:[...e];const n=new Set(t.map(f=>f._id)),r=new Set(t.flatMap(f=>f.kind==="tool_result"&&f.toolId&&fR(f._id)?[f.toolId]:[]));let i=!0,s=t[t.length-1];for(const f of e){if(n.has(f._id)){i=!1;break}if(f.createdAt<s.createdAt||f.createdAt===s.createdAt&&f._id.localeCompare(s._id)<=0){i=!1;break}if(f.kind==="tool_result"&&f.toolId&&r.has(f.toolId)){i=!1;break}s=f}if(i)return[...t,...e];const a=new Map;for(const f of t)a.set(f._id,f);for(const f of e)a.set(f._id,f);const c=new Set,d=new Map;for(const f of a.values()){if(f.kind!=="tool_result"||!f.toolId)continue;const m=d.get(f.toolId)??[];m.push(f._id),d.set(f.toolId,m),fR(f._id)&&c.add(f._id)}for(const f of d.values()){if(f.length<2)continue;const m=f.some(b=>c.has(b)),v=f.filter(b=>!c.has(b));if(!(!m||v.length!==1))for(const b of f)c.has(b)&&a.delete(b)}const u=[...a.values()].sort((f,m)=>f.createdAt!==m.createdAt?f.createdAt-m.createdAt:f._id.localeCompare(m._id));if(t.length===u.length){let f=!1;for(let m=0;m<t.length;m+=1){const v=t[m],b=u[m];if((v==null?void 0:v._id)!==(b==null?void 0:b._id)||!vae(v,b)){f=!0;break}}if(!f)return t}return u}function vae(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const i of n)if(!(i in e)||!Object.is(t[i],e[i]))return!1;return!0}function sO(t){return t.flatMap(e=>[...e.generalChats,...e.features.flatMap(n=>n.chats)])}function mR(t){return sO(t).some(e=>e.status==="starting"||e.status==="running")}function pR(t){return t.chat.chatId===t.activeChatId||t.chat.provider!=="claude"&&t.chat.provider!=="codex"&&t.chat.provider!=="cursor"||t.chat.status==="starting"||t.chat.status==="running"?null:t.chat.status==="waiting_for_user"?"waiting_for_user":t.completedChatIds.has(t.chat.chatId)?"completed":null}function bae(t){const e=[];for(const n of t.cachedChatIdsNewestFirst){if(e.length>=t.limit)break;if(n===t.activeChatId)continue;const r=tu(t.projectGroups,n);r&&(r.status!=="starting"&&r.status!=="running"||e.push(n))}return e}function gR(t,e){if(!t||t.runtime.chatId!==e.chatId)return t;switch(e.type){case"chat.message-appended":{const n=tl(t.transcript.entries,[e.entry]),r=Math.max(t.runtime.updatedAt??0,e.entry.createdAt);return{...t,messages:n,runtime:{...t.runtime,updatedAt:r},transcript:{...t.transcript,entries:n}}}case"chat.messages-appended":{const n=tl(t.transcript.entries,e.entries),r=e.entries.reduce((i,s)=>Math.max(i,s.createdAt),t.runtime.updatedAt??0);return{...t,messages:n,runtime:{...t.runtime,updatedAt:r},transcript:{...t.transcript,entries:n}}}case"chat.status-set":return{...t,runtime:{...t.runtime,status:e.status}};case"chat.title-set":return{...t,runtime:{...t.runtime,title:e.title}};case"chat.provider-set":return{...t,runtime:{...t.runtime,provider:e.provider}};case"chat.plan-mode-set":return{...t,runtime:{...t.runtime,planMode:e.planMode}};case"chat.pending-tool-set":return{...t,runtime:{...t.runtime,pendingTool:e.pendingTool}};case"chat.session-token-set":return{...t,runtime:{...t.runtime,sessionToken:e.sessionToken,hydrationState:e.hydrationState}};case"chat.usage-set":return{...t,usage:e.usage};case"chat.available-providers-set":return{...t,availableProviders:e.availableProviders,providerSettings:e.providerSettings??t.providerSettings};case"chat.transcript-window-meta-set":return{...t,transcript:{...t.transcript,hasOlder:e.hasOlder,oldestEntryId:e.oldestEntryId,hydrationState:e.hydrationState??t.transcript.hydrationState}};case"chat.deleted":return null}}function _ae({children:t,activeChatId:e}){var so,oo,na;const n=tc(),r=Ly(),{socket:i}=Vh(),{providerSettings:s}=Hu(),{sidebarData:a,sidebarReady:c,localProjects:d,featureOverviewSnapshot:u,closeSidebar:f,completedChatIds:m,clearCompletedChatId:v}=hS(),{createFeatureModalProjectId:b,handleCloseCreateFeatureModal:S,setCommandError:x}=Fu(),[C,k]=_.useState(null),[E,R]=_.useState(!1),[M,O]=_.useState(null),[D,P]=_.useState(null),[z,Y]=_.useState([]),L=_.useRef([]),[W,V]=_.useState(!1),[F,U]=_.useState(null),[H,j]=_.useState(!1),[G,B]=_.useState(null),[K,A]=_.useState(!1),[I,$]=_.useState(!1),[T,X]=_.useState(148),[Z,J]=_.useState(!0),re=_.useRef(null),ae=_.useRef(!1),ue=_.useRef(null),me=_.useRef(!0),se=_.useRef(null),oe=_.useRef(null),ee=_.useRef(!1),Q=_.useRef(null),te=_.useRef(null),he=_.useRef(null),ie=_.useRef(null),xe=_.useRef(!1),Ae=_.useRef(null),Ke=_.useRef(null),mt=_.useRef(new Map),Ye=_.useRef(null),Ze=_.useRef(new Map),tt=_.useRef(0),it=_.useRef(new Map),ce=_.useRef([]),Re=_.useRef(new Map),Ue=_.useRef(null),[Je,Ve]=_.useState(0),[ze,He]=_.useState(0);function Xe(){Ke.current=null,oe.current=null,L.current=[],k(null),Y([]),V(!1),U(null),j(!1)}function ut(be){const we=Ae.current;if(!we)return()=>{};const Te=cae({snapshot:oe.current,chatId:we,loadedTranscriptEntries:L.current,entry:be}),Pe=Te.snapshot;return Pe&&(oe.current=Pe,k(Pe)),L.current=Te.loadedTranscriptEntries,Y(Te.loadedTranscriptEntries),()=>{var Ft;if(Ae.current!==we)return;const Ge=uae({snapshot:((Ft=oe.current)==null?void 0:Ft.runtime.chatId)===we?oe.current:null,loadedTranscriptEntries:L.current,entryId:be._id});oe.current=Ge.snapshot,L.current=Ge.loadedTranscriptEntries,k(Ge.snapshot),Y(Ge.loadedTranscriptEntries)}}function ft(be){const we=Ze.current.get(be);we&&(tt.current-=we.estimatedBytes,Ze.current.delete(be),Ve(Te=>Te+1))}function rt(be,we){const Te=Ze.current.get(be);Te&&(tt.current-=Te.estimatedBytes,Ze.current.delete(be));const Pe={...we,...fae({snapshot:we.snapshot,loadedTranscriptEntries:we.loadedTranscriptEntries})};for(Ze.current.set(be,Pe),tt.current+=Pe.estimatedBytes,Ve(Ge=>Ge+1);tt.current>oae&&Ze.current.size>1;){const Ge=Ze.current.keys().next().value;if(!Ge||Ge===e)break;const Ft=Ze.current.get(Ge);Ft&&(tt.current-=Ft.estimatedBytes),Ze.current.delete(Ge),Ve(hn=>hn+1)}}function Tt(be){const we=Ze.current.get(be);if(!we)return null;if(!Kd(we.snapshot,be))return tt.current-=we.estimatedBytes,Ze.current.delete(be),null;const Te={...we,isFresh:gae({cachedStatus:we.cachedStatus,cachedUpdatedAt:we.cachedUpdatedAt,currentChat:tu(a.projectGroups,be)})};return Ze.current.delete(be),Ze.current.set(be,Te),oe.current=Te.snapshot,k(Te.snapshot),Y(Te.loadedTranscriptEntries),Ke.current=Te.oldestLoadedEntryId,V(Te.hasOlderMessages),U(Te.oldestLoadedEntryId),j(!1),R(!0),Te}_.useLayoutEffect(()=>{L.current=z},[z]),_.useLayoutEffect(()=>{me.current=Z}),_.useEffect(()=>{if(!e){Ae.current=null,te.current=null,Ke.current=null,ie.current=null,oe.current=null,k(null),Y([]),V(!1),U(null),j(!1),A(!1),R(!0);return}const we=Ae.current!==e;if(Ae.current=e,we){Ye.current={chatId:e,startedAt:performance.now()},te.current=null,he.current=null,ie.current=null,Xe(),R(!1);const Te=Tt(e),Pe=!!Te;A(aae({activeChatId:e,restoredFromCache:Pe,restoredFromFreshCache:Te==null?void 0:Te.isFresh})),Pe?dR("chat_cache_hit_count",1,{chatId:e}):(dR("chat_cache_miss_count",1,{chatId:e}),Xe())}return i.subscribe({type:"chat",chatId:e},Te=>{Ae.current===e&&(oe.current=Te,k(Te),A(!1),R(!0),x(null))},Te=>{if(Ae.current!==e)return;A(!1);const Pe=gR(oe.current,Te);Pe===null?(ft(e),Xe()):(oe.current=Pe,k(Pe)),R(!0),x(null)})},[e,x,i]),_.useEffect(()=>{e&&v(e)},[e,v]),_.useEffect(()=>{const be=new Set(bae({cachedChatIdsNewestFirst:[...Ze.current.keys()].reverse(),projectGroups:a.projectGroups,activeChatId:e,limit:sae}));for(const[we,Te]of it.current)be.has(we)||(Te(),it.current.delete(we));for(const we of be){if(it.current.has(we))continue;const Te=i.subscribe({type:"chat",chatId:we},Pe=>{if(Ae.current!==we){if(!Kd(Pe,we)){ft(we);return}rt(we,{snapshot:Pe,loadedTranscriptEntries:[...Pe.transcript.entries],hasOlderMessages:Pe.transcript.hasOlder,oldestLoadedEntryId:Pe.transcript.oldestEntryId,estimatedBytes:qm(Pe,Pe.transcript.entries),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})}},Pe=>{if(Ae.current===we)return;const Ge=Ze.current.get(we),Ft=gR((Ge==null?void 0:Ge.snapshot)??null,Pe);if(Ft===null){ft(we);return}const hn=tl((Ge==null?void 0:Ge.loadedTranscriptEntries)??[],Ft.transcript.entries);rt(we,{snapshot:Ft,loadedTranscriptEntries:hn,hasOlderMessages:(Ge==null?void 0:Ge.hasOlderMessages)??Ft.transcript.hasOlder,oldestLoadedEntryId:(Ge==null?void 0:Ge.oldestLoadedEntryId)??Ft.transcript.oldestEntryId,estimatedBytes:qm(Ft,hn),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})});it.current.set(we,Te)}},[e,Je,a.projectGroups,i]),_.useEffect(()=>{const be=new Set,we=ce.current.filter(Pe=>{const Ge=tu(a.projectGroups,Pe);return!!(Ge&&Ge.chatId!==e)});let Te=we.length!==ce.current.length;for(const Pe of sO(a.projectGroups)){be.add(Pe.chatId);const Ge=pR({chat:Pe,activeChatId:e,completedChatIds:m});if(!Ge){Re.current.delete(Pe.chatId);continue}const Ft=we.includes(Pe.chatId);pae({queuedReason:Re.current.get(Pe.chatId),nextReason:Ge,isQueued:Ft})||(Re.current.set(Pe.chatId,Ge),Ft||(we.push(Pe.chatId),Te=!0))}for(const Pe of[...Re.current.keys()])be.has(Pe)||Re.current.delete(Pe);Te&&(ce.current=we,He(Pe=>Pe+1))},[e,m,a.projectGroups]),_.useEffect(()=>{u&&O(u.projectId)},[u]),_.useEffect(()=>()=>{for(const be of it.current.values())be();it.current.clear()},[]),_.useEffect(()=>{if(Ue.current||mR(a.projectGroups))return;const be=ce.current.find(Te=>Te!==e);if(!be)return;const we=window.setTimeout(()=>{const Te=tu(a.projectGroups,be),Pe=Te?pR({chat:Te,activeChatId:e,completedChatIds:m}):null;if(!Te||!Pe||mR(a.projectGroups)){ce.current=ce.current.filter(Ge=>Ge!==be),He(Ge=>Ge+1);return}Ue.current=be,i.command({type:"chat.prefetch",chatId:be}).then(Ge=>{if(!Kd(Ge,be)){ft(be);return}rt(be,{snapshot:Ge,loadedTranscriptEntries:[...Ge.transcript.entries],hasOlderMessages:Ge.transcript.hasOlder,oldestLoadedEntryId:Ge.transcript.oldestEntryId,estimatedBytes:qm(Ge,Ge.transcript.entries),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})}).catch(Ge=>{}).finally(()=>{Ue.current===be&&(Ue.current=null),ce.current=ce.current.filter(Ge=>Ge!==be),He(Ge=>Ge+1)})},iae);return()=>window.clearTimeout(we)},[e,ze,m,a.projectGroups,i]),_.useEffect(()=>{if(M)return;const be=a.projectGroups[0];be&&O(be.groupKey)},[M,a.projectGroups]),_.useEffect(()=>{if(!e||!c||!E)return;if(a.projectGroups.some(we=>[...we.generalChats,...we.features.flatMap(Te=>Te.chats)].some(Te=>Te.chatId===e))){D===e&&P(null);return}D!==e&&n("/")},[e,E,n,D,a.projectGroups,c]),_.useEffect(()=>{e&&Kd(C,e)&&rt(e,{snapshot:C,loadedTranscriptEntries:z,hasOlderMessages:W,oldestLoadedEntryId:F,estimatedBytes:qm(C,z),cachedStatus:null,cachedUpdatedAt:null,isFresh:!0})},[e,C,W,z,F]),_.useEffect(()=>{if(!C)return;O(C.runtime.projectId),C.transcript.hydrationState==="provider"?ie.current=C.runtime.chatId:ie.current===C.runtime.chatId&&(ie.current=null),!!Ke.current&&Ke.current!==C.transcript.oldestEntryId?(Y(we=>{var Pe;const Te=tl(we,C.transcript.entries);return Ke.current=((Pe=Te[0])==null?void 0:Pe._id)??null,Te}),V(we=>we&&C.transcript.hasOlder)):(Ke.current=C.transcript.oldestEntryId,Y([...C.transcript.entries]),V(C.transcript.hasOlder),U(C.transcript.oldestEntryId))},[C]),_.useEffect(()=>{ee.current=!1,Q.current!==null&&(window.cancelAnimationFrame(Q.current),Q.current=null),ie.current=null,ae.current=!1,ue.current=null,J(!0)},[e]),_.useEffect(()=>()=>{Q.current!==null&&window.cancelAnimationFrame(Q.current)},[]),_.useLayoutEffect(()=>{if(!ee.current)return;const be=re.current;be&&me.current&&(be.scrollTop=be.scrollHeight)},[e,z]),_.useLayoutEffect(()=>{const be=se.current;if(!be)return;const we=new ResizeObserver(()=>{X(be.getBoundingClientRect().height)});return we.observe(be),X(be.getBoundingClientRect().height),()=>we.disconnect()},[]);const lt=e?(()=>{const be=Ze.current.get(e)??null;return Kd((be==null?void 0:be.snapshot)??null,e)?be:null})():null,ht=_.useMemo(()=>{const be=xK(C,e);return be||((lt==null?void 0:lt.snapshot)??null)},[lt,e,C]),Be=z.length>0?z:(lt==null?void 0:lt.loadedTranscriptEntries)??[],$e=_.useMemo(()=>{const be=ht;if(!be)return[];const we=Be,Te=be.runtime.chatId,Pe=dae(we),Ge=mt.current.get(Te);if((Ge==null?void 0:Ge.signature)===Pe)return Ge.messages;const Ft=Boe(we);return mt.current.set(Te,{signature:Pe,messages:Ft}),Ft},[ht,Be]),Le=_.useMemo(()=>Woe($e),[$e]),Fe=(ht==null?void 0:ht.runtime)??null,ye=(ht==null?void 0:ht.usage)??null,Ie=e&&D===e&&!Fe?"starting":Fe==null?void 0:Fe.status,Qe=!!(e&&!ht),gt=(ht==null?void 0:ht.availableProviders)??jT((s==null?void 0:s.settings)??Tp),Wt=cy(Ie),wt=Voe(Ie),xt=vK(T),Qt=!Z&&$e.length>0,kt=((so=d==null?void 0:d.projects[0])==null?void 0:so.localPath)??null,Dt=(u==null?void 0:u.localPath)??(Fe==null?void 0:Fe.localPath)??kt??((oo=a.projectGroups[0])==null?void 0:oo.localPath),wn=!!(M??(u==null?void 0:u.projectId)??(Fe==null?void 0:Fe.projectId)??((na=a.projectGroups[0])==null?void 0:na.groupKey)??kt);_.useEffect(()=>{!e||!ht||H||z.length>0||ht.transcript.hydrationState==="provider"&&he.current!==e&&(he.current=e,dn())},[e,ht,H,z.length]),_.useEffect(()=>{const be=Ye.current;!e||!be||be.chatId!==e||!E||($e.length>0||Fe)&&(tO("chat_switch_ready_ms",Math.round(performance.now()-be.startedAt),{chatId:e,cached:!!lt}),Ye.current=null)},[lt,e,E,$e.length,Fe==null?void 0:Fe.status]),_.useLayoutEffect(()=>{if(ee.current)return;const be=re.current;be&&(e&&!Fe||(be.scrollTo({top:be.scrollHeight,behavior:"auto"}),Q.current!==null&&window.cancelAnimationFrame(Q.current),Q.current=window.requestAnimationFrame(()=>{const we=re.current;we&&(we.scrollTo({top:we.scrollHeight,behavior:"auto"}),Q.current=null)}),ee.current=!0))},[e,T,$e.length,Fe]),_.useEffect(()=>{if(!ee.current||!Z)return;const be=window.requestAnimationFrame(()=>{const we=re.current;!we||!Z||(we.scrollTop=we.scrollHeight)});return()=>window.cancelAnimationFrame(be)},[e,T,Z]);function Zt(){const be=re.current;if(!be)return;const we=be.scrollTop,Te=be.scrollHeight-we-be.clientHeight,Pe=dN(Te);ue.current!==null&&we<ue.current&&(ae.current=!1),ue.current=we,Pe&&(ae.current=!1),ae.current||J(Pe)}function bn(){const be=re.current;J(!0),be&&(be.scrollTop=be.scrollHeight,ue.current=be.scrollTop,ae.current=!1)}function Hn(){bn()}async function dn(){var Ft,hn;const be=F??"",we=te.current;if(we&&we.chatId===e&&we.beforeEntryId===be)return;const Te=(ht==null?void 0:ht.transcript.hydrationState)==="provider"&&z.length===0;if(!e||H||!Te&&!F)return;const Pe=e,Ge=be;try{te.current={chatId:Pe,beforeEntryId:Ge},j(!0);const fn=await i.command({type:"chat.loadMore",chatId:Pe,beforeEntryId:Te?void 0:Ge||void 0});if(Ae.current!==Pe)return;Y(as=>tl(as,fn.entries)),fn.hydrationState==="provider"?ie.current=Pe:ie.current===Pe&&(ie.current=null),Ke.current=fn.oldestEntryId,V(fn.hasOlder),U(fn.oldestEntryId),x(null)}catch(fn){Ae.current===Pe&&x(fn instanceof Error?fn.message:String(fn))}finally{((Ft=te.current)==null?void 0:Ft.chatId)===Pe&&((hn=te.current)==null?void 0:hn.beforeEntryId)===Ge&&(te.current=null),Ae.current===Pe&&j(!1)}}async function pe(be,we){$o.getState().initializeComposerForNewChat();const Te=await i.command({type:"chat.create",projectId:be,featureId:we});O(be),P(Te.chatId),n(`/chat/${Te.chatId}`),f(),x(null)}async function de(be,we=fu.getState().commitProjectMetadataDirectory){await i.command({type:"project.setProjectMetadataDirectoryCommitMode",projectId:be.projectId,localPath:be.localPath,commitProjectMetadata:we})}async function Oe(be){return be.kind==="project_id"?{projectId:be.projectId}:be.kind==="local_path"?{projectId:(await i.command({type:"project.open",localPath:be.localPath})).projectId,localPath:be.localPath}:{projectId:(await i.command(be.project.mode==="new"?{type:"project.create",localPath:be.project.localPath,title:be.project.title}:{type:"project.open",localPath:be.project.localPath})).projectId,localPath:be.project.localPath}}async function Et(be){try{const we=be.kind==="project_id"?null:be.kind==="local_path"?be.localPath:be.project.localPath;we&&B(we);const{projectId:Te}=await Oe(be);await de({projectId:Te}),await pe(Te)}catch(we){x(we instanceof Error?we.message:String(we))}finally{B(null)}}async function _n(be,we){try{await pe(be,we)}catch(Te){x(Te instanceof Error?Te.message:String(Te))}}async function An(be){const we=b;if(we&&!(I||xe.current))try{xe.current=!0,$(!0);const Te=await i.command({type:"feature.create",projectId:we,title:be.title,description:be.description,generateOverview:fu.getState().showFeatureOverviewInSidebar});S(),await pe(we,Te.featureId)}catch(Te){x(Te instanceof Error?Te.message:String(Te))}finally{xe.current=!1,$(!1)}}async function Jn(be){await Et({kind:"local_path",localPath:be})}async function $n(be){await Et({kind:"project_request",project:be})}async function tn(be,we){var Te;try{let Pe=M??((Te=a.projectGroups[0])==null?void 0:Te.groupKey)??null;if(!e&&!Pe&&kt&&(Pe=(await i.command({type:"project.open",localPath:kt})).projectId,O(Pe)),!e&&!Pe)throw new Error("Open a project first");if(we!=null&&we.provider&&!JF(we.provider,(s==null?void 0:s.settings)??Tp))throw new Error(`${we.provider} is inactive.`);bn();const Ge=await i.command({type:"chat.send",chatId:e??void 0,projectId:e?void 0:Pe??void 0,provider:we==null?void 0:we.provider,message:be,model:we==null?void 0:we.model,modelOptions:we==null?void 0:we.modelOptions,planMode:we==null?void 0:we.planMode});!e&&Ge.chatId&&(P(Ge.chatId),n(`/chat/${Ge.chatId}`)),x(null)}catch(Pe){throw x(Pe instanceof Error?Pe.message:String(Pe)),Pe}}async function er(){if(e)try{await i.command({type:"chat.cancel",chatId:e})}catch(be){x(be instanceof Error?be.message:String(be))}}async function lr(be){if(await r.confirm({title:"Delete Chat",description:`Delete "${be.title}"? This cannot be undone.`,confirmLabel:"Delete",confirmVariant:"destructive"}))try{if(await i.command({type:"chat.delete",chatId:be.chatId}),be.chatId===e){const Te=gK(a.projectGroups,be.chatId);n(Te?`/chat/${Te}`:"/")}}catch(Te){x(Te instanceof Error?Te.message:String(Te))}}async function Br(be){const we=await r.prompt({title:"Rename Chat",placeholder:"Chat name",initialValue:be.title,confirmLabel:"Rename"}),Te=we==null?void 0:we.trim();if(!(!Te||Te===be.title))try{await i.command({type:"chat.rename",chatId:be.chatId,title:Te}),x(null)}catch(Pe){x(Pe instanceof Error?Pe.message:String(Pe))}}async function Rn(be,we){try{await i.command({type:"chat.setFeature",chatId:be,featureId:we}),x(null)}catch(Te){x(Te instanceof Error?Te.message:String(Te))}}async function nn(be){var Te,Pe;const we=(Fe==null?void 0:Fe.localPath)??((Te=d==null?void 0:d.projects[0])==null?void 0:Te.localPath)??((Pe=a.projectGroups[0])==null?void 0:Pe.localPath);if(we)try{x(null),await a_({socket:i,action:be,localPath:we})}catch(Ge){x(Ge instanceof Error?Ge.message:String(Ge))}}function Fr(){var Pe;const be=e?tu(a.projectGroups,e):null,we=e?u_(a.projectGroups,e):null;if(be&&we){x(null),_n(we,be.featureId??void 0);return}const Te=yK({selectedProjectId:M,sidebarProjectId:(Pe=a.projectGroups[0])==null?void 0:Pe.groupKey,fallbackLocalProjectPath:kt});if(Te){x(null),Et(Te);return}x("Open a project first")}async function xr(be,we,Te){if(!e)return;const Pe=ut({_id:`${dy}${Ai()}`,createdAt:Date.now(),kind:"tool_result",toolId:be,content:{answers:Te},isError:!1});try{await i.command({type:"chat.respondTool",chatId:e,toolUseId:be,result:{questions:we,answers:Te}})}catch(Ge){Pe(),x(Ge instanceof Error?Ge.message:String(Ge))}}async function Jr(be,we,Te,Pe,Ge){if(!e)return;const Ft={confirmed:we,...Te?{clearContext:!0}:{},...Pe?{message:Pe}:{},...Ge?{attachments:Ge}:{}},hn=ut({_id:`${dy}${Ai()}`,createdAt:Date.now(),kind:"tool_result",toolId:be,content:Ft,isError:!1});try{await i.command({type:"chat.respondTool",chatId:e,toolUseId:be,result:Ft}),we&&$o.getState().setComposerPlanMode(!1)}catch(fn){hn(),we&&$o.getState().setComposerPlanMode(!0),x(fn instanceof Error?fn.message:String(fn))}}async function Un(be,we,Te){if(!e||!(Fe!=null&&Fe.projectId))return;const Pe=Fe.projectId,Ge=tu(a.projectGroups,e),Ft=(Ge==null?void 0:Ge.featureId)??void 0;try{const hn=await CK({socket:i,sourceChatId:e,toolUseId:be,projectId:Pe,featureId:Ft,entry:Te,planText:we});$o.getState().setComposerPlanMode(!1),O(Pe),P(hn.chatId),n(`/chat/${hn.chatId}`),f(),x(null)}catch(hn){throw x(hn instanceof Error?hn.message:String(hn)),hn}}const ul=_.useMemo(()=>({activeChatId:e,chatSnapshot:C,runtime:Fe,usage:ye,messages:$e,latestToolIds:Le,availableProviders:gt,processingStatus:Ie,isChatLoading:Qe,isRefreshingActiveChat:K,isProcessing:Wt,canCancel:wt,chatReady:E,pendingChatId:D,selectedProjectId:M,startingLocalPath:G,hasSelectedProject:wn,navbarLocalPath:Dt,scrollRef:re,inputRef:se,transcriptPaddingBottom:xt,showScrollButton:Qt,hasOlderMessages:W,oldestLoadedEntryId:F,isLoadingOlderMessages:H,updateScrollState:Zt,scrollToBottom:Hn,loadOlderMessages:dn,createChatForProject:pe,handleCreateChat:_n,handleConfirmCreateFeature:An,handleOpenLocalProject:Jn,handleCreateProject:$n,handleSend:tn,handleCancel:er,handleRenameChat:Br,handleDeleteChat:lr,handleSetChatFeature:Rn,handleOpenExternal:nn,handleCompose:Fr,handleAskUserQuestion:xr,handleExitPlanMode:Jr,handleHandoff:Un,isCreatingFeature:I}),[e,gt,wt,E,C,pe,b,r,bn,kt,xr,er,Fr,An,_n,$n,lr,Jr,Un,nn,Jn,tn,Rn,Br,wn,W,Qe,I,H,Wt,K,Le,dn,$e,Dt,n,F,D,Ie,s,Fe,M,x,Qt,a.projectGroups,G,Hn,i,xt,Zt,ye]);return g.jsx(iO.Provider,{value:ul,children:t})}function oO(){const t=_.useContext(iO);if(!t)throw new Error("useChatContext must be used within ChatProvider");return t}const Km="How can I help you?",yae=19,vR=72,xae=48,Gm="max-w-[800px] md:max-w-[920px]";function Sae(t){return t.isRefreshingActiveChat&&t.messageCount>0}function wae(t){return t.messageCount>0?null:t.isChatLoading?"loading":t.isProviderRecovering?"recovering":t.isProviderUnavailable?"unavailable":t.isProcessing?null:"empty"}function Cae(){var Fe,ye,Ie,Qe,gt,Wt,wt,xt,Qt,kt,Dt,wn,Zt,bn,Hn,dn,pe;const t=Vh(),e=Hu(),n=hS(),r=oO(),i=Fu(),s={...t,...e,...n,...r,...i},a=oN(de=>de.isOpen),c=_.useRef(null),d=_.useRef(null),u=_.useRef(null),[f,m]=_.useState(""),[v,b]=_.useState(!1),[S,x]=_.useState(0),[C,k]=_.useState(!1),[E,R]=_.useState(null),[M,O]=_.useState(0),D=_.useRef(((Fe=s.runtime)==null?void 0:Fe.planMode)??!1),P=_.useRef(null),z=zg("(min-width: 768px)"),Y=typeof window>"u"?!0:RZ(window.location.hostname),L=((ye=s.runtime)==null?void 0:ye.projectId)??null,W=_.useMemo(()=>hr.chatPlanMode(s.activeChatId??L??"composer"),[L,s.activeChatId]),F=Ha(de=>L?de.projects[L]:void 0)??LZ,H=dh(de=>L?de.projects[L]:void 0)??AZ,j=Ha(de=>de.addTerminal),G=Ha(de=>de.removeTerminal),B=Ha(de=>de.toggleVisibility),K=Ha(de=>de.resetMainSizes),A=Ha(de=>de.setMainSizes),I=Ha(de=>de.setTerminalSizes),$=dh(de=>de.toggleVisibility),T=dh(de=>de.setSize),X=Fp(de=>de.scrollbackLines),Z=Fp(de=>de.minColumnWidth),J=s.keybindings,re=$o(de=>de.composerState.provider),ae=f1(de=>de.pullRequestPrompt),ue=f1(de=>de.pullRequestUpdatePrompt),me=f1(de=>de.pullRequestProviders),se=_.useMemo(()=>({pullRequestPrompt:ae,pullRequestUpdatePrompt:ue,pullRequestProviders:me}),[ae,me,ue]),oe=_.useMemo(()=>lN(J),[J]),ee=((Ie=s.runtime)==null?void 0:Ie.provider)??re,Q=Sae({isRefreshingActiveChat:s.isRefreshingActiveChat,messageCount:s.messages.length}),te=wae({isChatLoading:s.isChatLoading,isProviderRecovering:s.activeChatId!==null&&((Qe=s.chatSnapshot)==null?void 0:Qe.transcript.hydrationState)==="provider"&&s.chatSnapshot.transcript.hasOlder,isProviderUnavailable:s.activeChatId!==null&&((gt=s.chatSnapshot)==null?void 0:gt.transcript.hydrationState)==="provider"&&!s.chatSnapshot.transcript.hasOlder,isProcessing:s.isProcessing,messageCount:s.messages.length}),he=_.useMemo(()=>BE({currentProvider:ee,settings:se}),[ee,se]),ie=F.terminals.length>0,xe=!!(L&&F.isVisible&&ie),Ae=!!(L&&ie),Ke=!!(L&&H.isVisible),mt=!!(L&&!z&&Ke),Ye=!!(L&&z),Ze=Math.max(80,s.transcriptPaddingBottom-xae),{isAnimating:tt,mainPanelGroupRef:it,terminalFocusRequestVersion:ce,terminalPanelRef:Re,terminalVisualRef:Ue}=YZ({showTerminalPane:xe,shouldRenderTerminalLayout:Ae,projectId:L,terminalLayout:F,chatInputRef:u}),{isAnimating:Je,panelGroupRef:Ve,sidebarPanelRef:ze,sidebarVisualRef:He}=qZ({projectId:L,shouldRenderRightSidebarLayout:Ye,showRightSidebar:Ke,rightSidebarSize:H.size});Doe({rootRef:d,fallbackRef:u,enabled:s.hasSelectedProject&&s.processingStatus!=="waiting_for_user",canCancel:s.canCancel}),_.useEffect(()=>{var de;E===null&&(D.current=((de=s.runtime)==null?void 0:de.planMode)??!1)},[E,s.activeChatId,(Wt=s.runtime)==null?void 0:Wt.planMode]),_.useEffect(()=>{var Et;const de=((Et=s.runtime)==null?void 0:Et.planMode)??!1;if(E===null){D.current=de;return}const Oe=P.current;if(!Oe){D.current=de;return}if(s.activeChatId===null){wm(Oe),P.current=null,R(null),D.current=de;return}E.chatId===s.activeChatId&&de!==E.originalRuntimePlanMode&&(de!==E.value&&$o.getState().setComposerPlanMode(de),wm(Oe),P.current=null,R(null),D.current=de)},[E,s.activeChatId,(wt=s.runtime)==null?void 0:wt.planMode]);const Xe=()=>{if(L){if(ie){k(!1),B(L);return}j(L)}},ut=()=>{k(de=>!de)},ft=de=>{var An;if(!L||!xe||tt.current)return;const Oe=de.chat,Et=de.terminal;if(!Number.isFinite(Oe)||!Number.isFinite(Et))return;const _n=((An=c.current)==null?void 0:An.getBoundingClientRect().height)??0;if(zZ(_n,Et)){K(L),B(L);return}A(L,[Oe,Et])};_.useEffect(()=>{if(s.messages.length!==0)return;m(""),b(!1);let de=0;const Oe=window.setInterval(()=>{de+=1,m(Km.slice(0,de)),de>=Km.length&&(window.clearInterval(Oe),b(!0))},yae);return()=>window.clearInterval(Oe)},[s.activeChatId,s.messages.length]),_.useEffect(()=>{function de(Oe){if(L){if(Ya(oe,"toggleEmbeddedTerminal",Oe)){Oe.preventDefault(),Xe();return}if(Ya(oe,"toggleRightSidebar",Oe)){Oe.preventDefault(),$(L);return}if(Ya(oe,"openInFinder",Oe)){if(!Y)return;Oe.preventDefault(),s.handleOpenExternal("open_finder");return}if(Ya(oe,"openInEditor",Oe)){if(!Y)return;Oe.preventDefault(),s.handleOpenExternal("open_editor");return}Ya(oe,"addSplitTerminal",Oe)&&(Oe.preventDefault(),j(L))}}return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[j,Y,Xe,L,oe,$]),_.useEffect(()=>{xe||k(!1)},[xe]),_.useEffect(()=>{const de=window.requestAnimationFrame(()=>{s.updateScrollState()}),Oe=window.setTimeout(()=>{s.updateScrollState()},ou);return()=>{window.cancelAnimationFrame(de),window.clearTimeout(Oe)}},[Ae,xe,s.updateScrollState]),_.useEffect(()=>{function de(){s.updateScrollState()}return window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[s.updateScrollState]),_.useEffect(()=>{const de=c.current;if(!de||!Ae)return;const Oe=()=>{const _n=de.getBoundingClientRect().height;if(_n<=0)return;const An=_n*(F.mainSizes[1]/100);An<=0||x(Jn=>Math.abs(Jn-An)<1?Jn:An)},Et=new ResizeObserver(Oe);return Et.observe(de),Oe(),()=>Et.disconnect()},[L,Ae,F.mainSizes]);const rt=de=>Number.isFinite(de)?Math.min(Q_,Math.max(qg,de)):H.size,Tt=()=>{L&&$(L)},lt=_.useCallback(()=>{var de,Oe;return((de=s.runtime)==null?void 0:de.projectId)??s.selectedProjectId??((Oe=s.sidebarData.projectGroups[0])==null?void 0:Oe.groupKey)??null},[(xt=s.runtime)==null?void 0:xt.projectId,s.selectedProjectId,s.sidebarData.projectGroups]),ht=_.useCallback(async de=>{const Oe=lt();if(!Oe)throw new Error("Open a project first");const Et=await s.socket.command({type:"feature.create",projectId:Oe,title:de,description:"",generateOverview:fu.getState().showFeatureOverviewInSidebar});await s.handleCreateChat(Oe,Et.featureId)},[lt,s.handleCreateChat,s.socket]),Be=_.useCallback(()=>{const de=lt();if(!de)throw new Error("Open a project first");s.handleCreateFeature(de)},[lt,s.handleCreateFeature]),$e=_.useCallback(async(de,Oe)=>{var _n,An;const Et=de.text.trim();if(Et.startsWith("/")){const Jn=((_n=s.runtime)==null?void 0:_n.provider)??(Oe==null?void 0:Oe.provider)??re,$n=BE({currentProvider:Jn,settings:se}),tn=(An=Et.split(" ")[0])==null?void 0:An.slice(1).toLowerCase(),er=$n.find(lr=>lr.name.toLowerCase()===tn);if(er!=null&&er.handler){const lr={handleCompose:s.handleCompose,setPlanMode:Rn=>{var nn;if(!(E!==null&&E.chatId!==s.activeChatId)){if($o.getState().setComposerPlanMode(Rn),s.activeChatId){const Fr=((nn=s.runtime)==null?void 0:nn.planMode)??!1;if(Rn===Fr){wm(W),P.current=null,R(null);return}P.current=W,JA(W,{statusLabel:Rn?"Switching to plan mode...":"Switching to implement mode..."}),R({chatId:s.activeChatId,originalRuntimePlanMode:Fr,value:Rn})}else wm(W),P.current=null,R(null);O(Fr=>Fr+1)}},sendMessage:(Rn,nn)=>s.handleSend(Rn,nn),openFeatureModal:Be,createFeature:ht},Br=Et.slice(tn!=null&&tn.length?tn.length+1:0).trim();await er.handler(lr,{commandText:Et,remainder:Br,message:de,options:Oe});return}}return s.handleSend(de,Oe)},[re,se,W,lt,Be,ht,s.activeChatId,s.handleCancel,s.handleCompose,s.handleCreateFeature,s.handleCreateChat,s.handleSend,(Qt=s.runtime)==null?void 0:Qt.provider,s.socket]),Le=g.jsxs(bN,{ref:d,className:"bg-background h-full flex flex-col overflow-hidden border-0 rounded-none relative",children:[g.jsxs(yN,{className:"flex flex-1 min-h-0 flex-col p-0 overflow-hidden relative",children:[g.jsx(nG,{sidebarCollapsed:s.sidebarCollapsed,hasCompletedChats:s.completedChatIds.size>0,onOpenSidebar:s.openSidebar,onExpandSidebar:s.expandSidebar,usage:s.usage,localPath:s.navbarLocalPath,embeddedTerminalVisible:xe,onToggleEmbeddedTerminal:L?Xe:void 0,rightSidebarVisible:Ke,onToggleRightSidebar:L?()=>$(L):void 0,onOpenExternal:Y?de=>{s.handleOpenExternal(de)}:void 0,editorLabel:s.editorLabel,projectId:L??void 0,socket:s.socket,finderShortcut:Y?oe.bindings.openInFinder:void 0,editorShortcut:Y?oe.bindings.openInEditor:void 0,terminalShortcut:oe.bindings.toggleEmbeddedTerminal,rightSidebarShortcut:oe.bindings.toggleRightSidebar}),g.jsxs(BD,{ref:s.scrollRef,onScroll:s.updateScrollState,className:"flex-1 min-h-0 px-4 scroll-pt-[72px]",children:[(kt=s.runtime)!=null&&kt.inactiveProviderMessage?g.jsxs("div",{className:Ce("mx-auto mt-[72px] rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-900 dark:text-amber-200",Gm),children:["This thread uses ",s.runtime.provider,", which is currently inactive. ",s.runtime.inactiveProviderMessage]}):null,s.messages.length===0&&!s.isProcessing?g.jsx("div",{style:{height:s.transcriptPaddingBottom},"aria-hidden":"true"}):null,s.messages.length>0||s.isProcessing?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:Ce("mx-auto animate-fade-in space-y-5 pt-[72px]",Gm),children:[s.messages.length>0?g.jsx(Toe,{messages:s.messages,isLoading:s.isProcessing,hasOlderMessages:s.hasOlderMessages,oldestLoadedEntryId:s.oldestLoadedEntryId,isLoadingOlderMessages:s.isLoadingOlderMessages,isAtBottom:s.showScrollButton===!1,localPath:(Dt=s.runtime)==null?void 0:Dt.localPath,latestToolIds:s.latestToolIds,pendingTool:((wn=s.runtime)==null?void 0:wn.pendingTool)??null,onOpenLocalLink:s.handleOpenLocalLink,onAskUserQuestionSubmit:s.handleAskUserQuestion,onExitPlanModeConfirm:s.handleExitPlanMode,onHandoff:s.handleHandoff,onLoadOlder:s.loadOlderMessages,availableProviders:s.availableProviders,scrollContainerRef:s.scrollRef}):null,s.isProcessing?g.jsx(EZ,{status:s.processingStatus}):null,s.commandError?g.jsx("div",{className:"text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3",children:s.commandError}):null]}),g.jsx("div",{style:{height:s.transcriptPaddingBottom},"aria-hidden":"true"})]}):null]}),Q?g.jsx("div",{className:"pointer-events-none absolute inset-x-4 z-20 animate-fade-in",style:{top:vR,bottom:s.transcriptPaddingBottom},children:g.jsx("div",{className:Ce("mx-auto flex h-full items-center justify-center",Gm),children:g.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border bg-background/90 px-4 py-2 text-sm text-muted-foreground shadow-sm backdrop-blur",children:[g.jsx(Fn,{className:"size-4 animate-spin"}),g.jsx("span",{children:"Refreshing chat…"})]})})}):null,te?g.jsx("div",{className:"pointer-events-none absolute inset-x-4 animate-fade-in",style:{top:vR,bottom:s.transcriptPaddingBottom},children:g.jsx("div",{className:Ce("mx-auto flex h-full items-center justify-center",Gm),children:g.jsxs("div",{className:"flex flex-col items-center justify-center text-muted-foreground gap-4 opacity-70",children:[g.jsx(sh,{className:"size-8 text-muted-foreground kaizen-empty-state-flower"}),te==="loading"||te==="recovering"||te==="unavailable"?g.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[te==="unavailable"?null:g.jsx(Fn,{className:"size-10 animate-spin text-muted-foreground/80"}),g.jsx("div",{className:"text-sm text-muted-foreground/90",children:te==="recovering"?"Recovering chat…":te==="unavailable"?"Chat history is unavailable.":"Loading chat…"})]}):g.jsx("div",{className:"text-base font-normal text-muted-foreground text-center max-w-xs flex items-center kaizen-empty-state-text","aria-label":Km,children:g.jsxs("span",{className:"relative inline-grid place-items-start",children:[g.jsxs("span",{className:"invisible col-start-1 row-start-1 whitespace-pre flex items-center",children:[g.jsx("span",{children:Km}),g.jsx("span",{className:"kaizen-typewriter-cursor-slot","aria-hidden":"true"})]}),g.jsxs("span",{className:"col-start-1 row-start-1 whitespace-pre flex items-center",children:[g.jsx("span",{children:f}),g.jsx("span",{className:"kaizen-typewriter-cursor-slot","aria-hidden":"true",children:g.jsx("span",{className:"kaizen-typewriter-cursor","data-typing-complete":v?"true":"false"})})]})]})})]})})},s.activeChatId??"new-chat"):null,g.jsx("div",{style:{bottom:Ze},className:Ce("pointer-events-none absolute left-1/2 -translate-x-1/2 z-30 transition-all",s.showScrollButton&&!a?"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:g.jsx("button",{onClick:s.scrollToBottom,style:{lineHeight:0},className:"pointer-events-auto h-9 w-9 grid place-items-center transition-colors bg-background/80 dark:bg-card/40 backdrop-blur-lg hover:bg-muted/80 border border-border rounded-full cursor-pointer text-foreground/80 hover:text-foreground",children:g.jsx(AP,{style:{display:"block"},className:"h-4 w-4"})})})]}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 pointer-events-none",children:g.jsx("div",{className:"bg-gradient-to-t from-background via-background pointer-events-auto",ref:s.inputRef,children:g.jsx(QK,{ref:u,onSubmit:$e,onCancel:()=>{s.handleCancel()},disabled:!s.hasSelectedProject||((Zt=s.runtime)==null?void 0:Zt.status)==="waiting_for_user"||!!((bn=s.runtime)!=null&&bn.inactiveProviderMessage),canCancel:s.canCancel,chatId:s.activeChatId,activeProvider:((Hn=s.runtime)==null?void 0:Hn.provider)??null,activeModel:((dn=s.runtime)==null?void 0:dn.model)??null,activePlanMode:((pe=s.runtime)==null?void 0:pe.planMode)??!1,availableProviders:s.availableProviders,keybindings:oe,slashCommands:he,requestedPlanMode:(E==null?void 0:E.chatId)===s.activeChatId?E.value:null,requestedPlanModeVersion:M,pendingPlanMode:(E==null?void 0:E.chatId)===s.activeChatId?E.value:null},s.activeChatId??"new-chat")})})]});return g.jsxs("div",{ref:c,className:"flex-1 flex flex-col min-w-0 relative",children:[Ye&&L?g.jsxs(op,{groupRef:Ve,orientation:"horizontal",className:"flex-1 min-h-0",onLayoutChange:de=>{var Et;if(!Ke||Je.current)return;const Oe=rt(de.rightSidebar);Math.abs(Oe-de.rightSidebar)<.1||(Et=Ve.current)==null||Et.setLayout({workspace:100-Oe,rightSidebar:Oe})},onLayoutChanged:de=>{!Ke||Je.current||T(L,rt(de.rightSidebar))},children:[g.jsx(Ll,{id:"workspace",defaultSize:`${100-H.size}%`,minSize:"50%",className:"min-h-0 min-w-0",children:Ae?g.jsxs(op,{groupRef:it,orientation:"vertical",className:"flex-1 min-h-0",onLayoutChanged:ft,children:[g.jsx(Ll,{id:"chat",defaultSize:`${F.mainSizes[0]}%`,minSize:"25%",className:"min-h-0",children:Le}),g.jsx(ap,{withHandle:!0,orientation:"vertical",disabled:!xe,className:Ce(!xe&&"pointer-events-none opacity-0")}),g.jsx(Ll,{id:"terminal",defaultSize:`${F.mainSizes[1]}%`,minSize:"0%",className:"min-h-0",elementRef:Re,children:g.jsx("div",{ref:Ue,className:"h-full min-h-0 overflow-hidden relative","data-terminal-open":xe?"true":"false","data-terminal-animated":"false","data-terminal-visual":!0,style:{"--terminal-toggle-duration":`${ou}ms`},children:g.jsx("div",{style:S>0?{height:`${S}px`}:void 0,children:C?null:g.jsx(Wb,{projectId:L,layout:F,onAddTerminal:j,socket:s.socket,connectionStatus:s.connectionStatus,scrollback:X,minColumnWidth:Z,maximized:!1,splitTerminalShortcut:oe.bindings.addSplitTerminal,focusRequestVersion:ce,onToggleMaximized:ut,onRemoveTerminal:(de,Oe)=>{s.socket.command({type:"terminal.close",terminalId:Oe}).catch(()=>{}),G(de,Oe)},onTerminalLayout:I})})})})]},L):Le}),g.jsx(ap,{withHandle:!0,orientation:"horizontal",disabled:!Ke,className:Ce(!Ke&&"pointer-events-none opacity-0")}),g.jsx(Ll,{id:"rightSidebar",defaultSize:`${H.size}%`,maxSize:`${Q_}%`,className:"min-h-0 min-w-0",elementRef:ze,children:g.jsx("div",{ref:He,className:"h-full min-h-0 overflow-hidden","data-right-sidebar-open":Ke?"true":"false","data-right-sidebar-animated":"false","data-right-sidebar-visual":!0,style:{"--terminal-toggle-duration":`${ou}ms`},children:g.jsx(XE,{onClose:()=>$(L)})})})]},`${L}-right-sidebar`):Ae&&L?g.jsxs(op,{groupRef:it,orientation:"vertical",className:"flex-1 min-h-0",onLayoutChanged:ft,children:[g.jsx(Ll,{id:"chat",defaultSize:`${F.mainSizes[0]}%`,minSize:"25%",className:"min-h-0",children:Le}),g.jsx(ap,{withHandle:!0,orientation:"vertical",disabled:!xe,className:Ce(!xe&&"pointer-events-none opacity-0")}),g.jsx(Ll,{id:"terminal",defaultSize:`${F.mainSizes[1]}%`,minSize:"0%",className:"min-h-0",elementRef:Re,children:g.jsx("div",{ref:Ue,className:"h-full min-h-0 overflow-hidden relative","data-terminal-open":xe?"true":"false","data-terminal-animated":"false","data-terminal-visual":!0,style:{"--terminal-toggle-duration":`${ou}ms`},children:g.jsx("div",{style:S>0?{height:`${S}px`}:void 0,children:C?null:g.jsx(Wb,{projectId:L,layout:F,onAddTerminal:j,socket:s.socket,connectionStatus:s.connectionStatus,scrollback:X,minColumnWidth:Z,maximized:!1,splitTerminalShortcut:oe.bindings.addSplitTerminal,focusRequestVersion:ce,onToggleMaximized:ut,onRemoveTerminal:(de,Oe)=>{s.socket.command({type:"terminal.close",terminalId:Oe}).catch(()=>{}),G(de,Oe)},onTerminalLayout:I})})})})]},L):Le,C&&L&&xe?g.jsx("div",{className:"absolute inset-0 z-30 flex min-h-0 min-w-0 flex-col bg-background/96 backdrop-blur-sm",children:g.jsx(Wb,{projectId:L,layout:F,onAddTerminal:j,socket:s.socket,connectionStatus:s.connectionStatus,scrollback:X,minColumnWidth:Z,maximized:!0,splitTerminalShortcut:oe.bindings.addSplitTerminal,focusRequestVersion:ce,onToggleMaximized:ut,onRemoveTerminal:(de,Oe)=>{s.socket.command({type:"terminal.close",terminalId:Oe}).catch(()=>{}),G(de,Oe)},onTerminalLayout:I})}):null,mt?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"fixed inset-0 z-40 bg-black/40 md:hidden",onClick:Tt}),g.jsx("div",{className:"fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-2xl md:hidden",children:g.jsx(XE,{onClose:Tt,className:"h-[var(--app-shell-height)]"})})]}):null]})}const kae="web+kaizen";function hy(t){return!t||!t.startsWith("/")||t.startsWith("//")?"/":t}function Eae(t){const e=new URLSearchParams(t),n=hy(e.get("target"));if(n!=="/")return n;const r=e.get("launch");if(!r)return"/";try{const i=new URL(r);return hy(i.searchParams.get("target"))}catch{return"/"}}function Rae(t){const e=new URL(`${kae}://open`);return e.searchParams.set("target",hy(t)),e.toString()}function Tae(t){return t.innerWidth<=820||t.matchMedia("(pointer: coarse)").matches}function Mae(t){return/\b(?:Chrome|CriOS|Edg|EdgA|EdgiOS)\b/i.test(t)}function Aae(t){return/iPhone|iPad|iPod/i.test(t)?"In Safari, tap Share, then Add to Home Screen.":/Android/i.test(t)?"Use your browser menu to install Kaizen to the home screen.":"Use your browser install action to save Kaizen as an app, or continue in the browser."}function Nae(){const t=ke.c(29),e=Yr(),n=cN();let r;t[0]!==e.search?(r=Eae(e.search),t[0]=e.search,t[1]=r):r=t[1];const i=r,[s,a]=_.useState(!1),[c,d]=_.useState(null);let u,f;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const W=function(F){F.preventDefault(),d(F)};return window.addEventListener("beforeinstallprompt",W),()=>{window.removeEventListener("beforeinstallprompt",W)}},f=[],t[2]=u,t[3]=f):(u=t[2],f=t[3]),_.useEffect(u,f);let m,v;t[4]!==n||t[5]!==e.search||t[6]!==i?(m=()=>{if(n){window.location.replace(i);return}if(new URLSearchParams(e.search).has("launch")){window.location.replace(i);return}if(!Tae(window)){window.location.replace(i);return}if(!Mae(navigator.userAgent)){a(!0);return}const F=Rae(i),U=window.setTimeout(()=>{a(!0)},900),H=()=>{document.visibilityState==="hidden"&&window.clearTimeout(U)};return document.addEventListener("visibilitychange",H),window.location.assign(F),()=>{window.clearTimeout(U),document.removeEventListener("visibilitychange",H)}},v=[n,e.search,i],t[4]=n,t[5]=e.search,t[6]=i,t[7]=m,t[8]=v):(m=t[7],v=t[8]),_.useEffect(m,v);let b;t[9]!==c?(b=async function(){c&&(await c.prompt(),await c.userChoice.catch(Dae),d(null))},t[9]=c,t[10]=b):b=t[10];const S=b;let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=Aae(navigator.userAgent),t[11]=x):x=t[11];const C=x;let k;t[12]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsx("div",{className:"absolute inset-x-0 top-0 h-40 bg-[radial-gradient(circle_at_center,rgba(249,115,22,0.12),transparent_68%)] dark:bg-[radial-gradient(circle_at_center,rgba(251,146,60,0.14),transparent_68%)]"}),t[12]=k):k=t[12];let E,R;t[13]===Symbol.for("react.memo_cache_sentinel")?(E=g.jsx("div",{className:"mb-6 inline-flex rounded-full border border-orange-200 bg-orange-50 px-3 py-1 text-xs font-semibold uppercase tracking-[0.2em] text-orange-700 dark:border-orange-400/30 dark:bg-orange-400/10 dark:text-orange-200",children:"Remote handoff"}),R=g.jsxs("h1",{className:"font-logo text-3xl leading-none tracking-tight",children:["Open ",ys]}),t[13]=E,t[14]=R):(E=t[13],R=t[14]);const M=s?"Kaizen could not jump straight into the installed app on this device. You can keep going in the browser or install it for one-tap launches next time.":"Trying to open your installed Kaizen app. If it does not switch automatically, use the browser fallback below.";let O;t[15]!==M?(O=g.jsx("p",{className:"mt-3 text-sm leading-6 text-slate-600 dark:text-slate-300",children:M}),t[15]=M,t[16]=O):O=t[16];let D;t[17]!==i?(D=g.jsx(Dh,{to:i,className:"block rounded-2xl bg-slate-950 px-4 py-3 text-center text-sm font-semibold text-white transition hover:bg-slate-800 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:"Continue in browser"}),t[17]=i,t[18]=D):D=t[18];let P;t[19]!==S||t[20]!==c?(P=c?g.jsx("button",{type:"button",onClick:()=>{S()},className:"block w-full rounded-2xl border border-orange-300 bg-orange-50 px-4 py-3 text-sm font-semibold text-orange-800 transition hover:bg-orange-100 dark:border-orange-400/40 dark:bg-orange-400/10 dark:text-orange-100 dark:hover:bg-orange-400/20",children:"Install Kaizen"}):null,t[19]=S,t[20]=c,t[21]=P):P=t[21];let z;t[22]!==D||t[23]!==P?(z=g.jsxs("div",{className:"mt-6 space-y-3",children:[D,P]}),t[22]=D,t[23]=P,t[24]=z):z=t[24];let Y;t[25]===Symbol.for("react.memo_cache_sentinel")?(Y=g.jsxs("div",{className:"mt-6 rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 text-sm leading-6 text-slate-700 dark:border-slate-700 dark:bg-slate-800/80 dark:text-slate-200",children:[g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"Install hint"}),g.jsx("p",{className:"mt-1",children:C})]}),t[25]=Y):Y=t[25];let L;return t[26]!==O||t[27]!==z?(L=g.jsxs("main",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-[radial-gradient(circle_at_top,rgba(241,245,249,0.96),rgba(255,255,255,1)_42%),linear-gradient(135deg,#fff8ef_0%,#ffffff_45%,#eef6ff_100%)] px-5 py-8 text-slate-950 dark:bg-[radial-gradient(circle_at_top,rgba(30,41,59,0.92),rgba(15,23,42,1)_46%),linear-gradient(135deg,#0f172a_0%,#111827_45%,#1f2937_100%)] dark:text-slate-50",children:[k,g.jsxs("section",{className:"relative w-full max-w-sm overflow-hidden rounded-[2rem] border border-white/70 bg-white/88 p-6 shadow-[0_30px_120px_-32px_rgba(15,23,42,0.42)] backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-900/88",children:[E,R,O,z,Y]})]}),t[26]=O,t[27]=z,t[28]=L):L=t[28],L}function Dae(){}const Oae=3210;function jae(t,e){const n=new URLSearchParams(t),r=Number(n.get("localPort"));if(Number.isFinite(r)&&r>0)return Math.round(r);const i=Number(e);return Number.isFinite(i)&&i>0?Math.round(i):Oae}function Lae(t){return`tailscale serve --bg --https 443 http://127.0.0.1:${String(t)}`}function Iae(t){return new URLSearchParams(t).get("reason")==="serve_permission_denied"?"serve_permission_denied":null}function Pae(t){const n=new URLSearchParams(t).get("setupCommand");return n!=null&&n.trim()?n:null}const zae="https://tailscale.com/download",Bae="https://tailscale.com/kb/1242/tailscale-serve",Fae="https://tailscale.com/docs/how-to/set-up-https-certificates";function Hae(){const t=ke.c(35),e=Yr();let n;t[0]!==e.search?(n=jae(e.search,window.location.port),t[0]=e.search,t[1]=n):n=t[1];const r=n;let i;t[2]!==e.search?(i=Iae(e.search),t[2]=e.search,t[3]=i):i=t[3];const s=i;let a;t[4]!==e.search?(a=Pae(e.search),t[4]=e.search,t[5]=a):a=t[5];const c=a;let d;t[6]!==r?(d=Lae(r),t[6]=r,t[7]=d):d=t[7];const u=d;let f;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=g.jsx("div",{className:"absolute inset-x-0 top-0 h-40 bg-[radial-gradient(circle_at_center,rgba(249,115,22,0.12),transparent_68%)] dark:bg-[radial-gradient(circle_at_center,rgba(251,146,60,0.14),transparent_68%)]"}),t[8]=f):f=t[8];let m,v,b;t[9]===Symbol.for("react.memo_cache_sentinel")?(m=g.jsx("div",{className:"mb-6 inline-flex rounded-full border border-orange-200 bg-orange-50 px-3 py-1 text-xs font-semibold uppercase tracking-[0.2em] text-orange-700 dark:border-orange-400/30 dark:bg-orange-400/10 dark:text-orange-200",children:"Remote setup"}),v=g.jsxs("h1",{className:"font-logo text-3xl leading-none tracking-tight",children:["Enable remote ",ys]}),b=g.jsx("p",{className:"mt-3 text-sm leading-6 text-slate-600 dark:text-slate-300",children:"Kaizen remote mode works best over Tailscale. If HTTPS handoff is not ready yet, use the steps below to install Tailscale, join your tailnet, and expose this local Kaizen session through Tailscale Serve."}),t[9]=m,t[10]=v,t[11]=b):(m=t[9],v=t[10],b=t[11]);let S;t[12]!==c||t[13]!==s?(S=s==="serve_permission_denied"&&c?g.jsxs("section",{className:"mt-6 rounded-2xl border border-orange-300 bg-orange-50/90 p-4 text-sm leading-6 text-orange-950 dark:border-orange-400/40 dark:bg-orange-400/10 dark:text-orange-100",children:[g.jsx("p",{className:"font-semibold",children:"One-time machine setup needed"}),g.jsx("p",{className:"mt-1",children:"Tailscale is connected, but this user is not allowed to change Serve config yet. Run this once on the Kaizen machine:"}),g.jsx("pre",{className:"mt-3 overflow-x-auto rounded-2xl bg-slate-950 p-4 text-xs text-slate-50",children:g.jsx("code",{children:c})})]}):null,t[12]=c,t[13]=s,t[14]=S):S=t[14];let x,C;t[15]===Symbol.for("react.memo_cache_sentinel")?(C=g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"1. Install and connect Tailscale"}),x=g.jsx("p",{className:"mt-1 text-slate-700 dark:text-slate-200",children:"Install Tailscale on this machine and on the device you want to open Kaizen from. Then sign in and connect both devices to the same tailnet."}),t[15]=x,t[16]=C):(x=t[15],C=t[16]);let k;t[17]===Symbol.for("react.memo_cache_sentinel")?(k=g.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 dark:border-slate-700 dark:bg-slate-800/80",children:[C,x,g.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[g.jsx("a",{href:zae,target:"_blank",rel:"noreferrer",className:"rounded-xl border border-slate-300 px-3 py-2 font-medium text-slate-900 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700",children:"Download Tailscale"}),g.jsx("code",{className:"rounded-xl bg-slate-950 px-3 py-2 text-xs text-slate-50 dark:bg-slate-950",children:"tailscale up"})]})]}),t[17]=k):k=t[17];let E,R;t[18]===Symbol.for("react.memo_cache_sentinel")?(E=g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"2. Turn on HTTPS handoff with Tailscale Serve"}),R=g.jsx("p",{className:"mt-1 text-slate-700 dark:text-slate-200",children:"Run this on the machine where Kaizen is already running. It tells Tailscale to publish your local Kaizen port behind your tailnet HTTPS URL."}),t[18]=E,t[19]=R):(E=t[18],R=t[19]);let M;t[20]!==u?(M=g.jsx("pre",{className:"mt-3 overflow-x-auto rounded-2xl bg-slate-950 p-4 text-xs text-slate-50",children:g.jsx("code",{children:u})}),t[20]=u,t[21]=M):M=t[21];let O;t[22]===Symbol.for("react.memo_cache_sentinel")?(O=g.jsx("p",{className:"mt-3 text-slate-700 dark:text-slate-200",children:"If Tailscale says Serve is not enabled on your tailnet, an admin needs to enable HTTPS certificates and Serve support first."}),t[22]=O):O=t[22];let D;t[23]===Symbol.for("react.memo_cache_sentinel")?(D=g.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[g.jsx("a",{href:Bae,target:"_blank",rel:"noreferrer",className:"rounded-xl border border-slate-300 px-3 py-2 font-medium text-slate-900 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700",children:"Tailscale Serve docs"}),g.jsx("a",{href:Fae,target:"_blank",rel:"noreferrer",className:"rounded-xl border border-slate-300 px-3 py-2 font-medium text-slate-900 transition hover:bg-slate-100 dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700",children:"Enable HTTPS certs"})]}),t[23]=D):D=t[23];let P;t[24]!==M?(P=g.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 dark:border-slate-700 dark:bg-slate-800/80",children:[E,R,M,O,D]}),t[24]=M,t[25]=P):P=t[25];let z;t[26]===Symbol.for("react.memo_cache_sentinel")?(z=g.jsx("p",{className:"font-semibold text-slate-950 dark:text-white",children:"3. Start Kaizen remote mode again"}),t[26]=z):z=t[26];let Y;t[27]===Symbol.for("react.memo_cache_sentinel")?(Y=g.jsx("pre",{className:"mt-3 overflow-x-auto rounded-2xl bg-slate-950 p-4 text-xs text-slate-50",children:g.jsx("code",{children:"kaizen --remote"})}),t[27]=Y):Y=t[27];let L;t[28]===Symbol.for("react.memo_cache_sentinel")?(L=g.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-slate-50/90 p-4 dark:border-slate-700 dark:bg-slate-800/80",children:[z,Y,g.jsxs("p",{className:"mt-3 text-slate-700 dark:text-slate-200",children:["Once Serve is ready, Kaizen should print an"," ",g.jsx("span",{className:"font-semibold",children:"https://…ts.net/open"})," QR handoff URL instead of the HTTP fallback."]})]}),t[28]=L):L=t[28];let W;t[29]!==P?(W=g.jsxs("div",{className:"mt-6 space-y-4 text-sm leading-6",children:[k,P,L]}),t[29]=P,t[30]=W):W=t[30];let V;t[31]===Symbol.for("react.memo_cache_sentinel")?(V=g.jsx("div",{className:"mt-6 flex flex-wrap gap-3",children:g.jsx(Dh,{to:"/",className:"rounded-2xl bg-slate-950 px-4 py-3 text-sm font-semibold text-white transition hover:bg-slate-800 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:"Back to Kaizen"})}),t[31]=V):V=t[31];let F;return t[32]!==W||t[33]!==S?(F=g.jsxs("main",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-[radial-gradient(circle_at_top,rgba(241,245,249,0.96),rgba(255,255,255,1)_42%),linear-gradient(135deg,#fff8ef_0%,#ffffff_45%,#eef6ff_100%)] px-5 py-8 text-slate-950 dark:bg-[radial-gradient(circle_at_top,rgba(30,41,59,0.92),rgba(15,23,42,1)_46%),linear-gradient(135deg,#0f172a_0%,#111827_45%,#1f2937_100%)] dark:text-slate-50",children:[f,g.jsxs("section",{className:"relative w-full max-w-2xl overflow-hidden rounded-[2rem] border border-white/70 bg-white/88 p-6 shadow-[0_30px_120px_-32px_rgba(15,23,42,0.42)] backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-900/88",children:[m,v,b,S,W,V]})]}),t[32]=W,t[33]=S,t[34]=F):F=t[34],F}function bR(){return{baselineEstablished:!1,dedupeByChatId:new Map,statusByChatId:new Map}}function $ae(t){const e=[];for(const n of t.projectGroups){for(const r of n.generalChats)e.push({chat:r,projectTitle:n.title});for(const r of n.features)for(const i of r.chats)e.push({chat:i,projectTitle:n.title})}return e}function Vle(t=null){return sf()?Notification.permission:t??"unsupported"}function qle(t){return t==="granted"?"Allowed":t==="denied"?"Blocked":t==="default"?"Not requested":"Unsupported"}async function Kle(){return sf()?Notification.requestPermission():"unsupported"}function sf(){return typeof window<"u"&&window.isSecureContext&&typeof Notification<"u"}function Uae({activeChatId:t,chatId:e,documentVisible:n}){return!n||t!==e}function aO(t){return t==="starting"||t==="running"}function Wae(t,e){const n=aO(t),r=t==="waiting_for_user";return n&&e==="waiting_for_user"?"needs_input":(n||r)&&e==="idle"?"completed":null}function Vae({activeChatId:t,documentVisible:e,previousState:n,sidebarData:r}){const i=new Map,s=new Map(n.dedupeByChatId),a=[],c=$ae(r);for(const{chat:d,projectTitle:u}of c){const f=n.statusByChatId.get(d.chatId);if(i.set(d.chatId,d.status),(aO(d.status)||d.status==="failed")&&s.delete(d.chatId),!n.baselineEstablished)continue;const m=Wae(f,d.status);m&&Uae({activeChatId:t,chatId:d.chatId,documentVisible:e})&&s.get(d.chatId)!==m&&(s.set(d.chatId,m),a.push({chatId:d.chatId,chatTitle:d.title,eventId:`${d.chatId}:${m}:${Date.now()}`,projectTitle:u,kind:m}))}return{events:a,nextState:{baselineEstablished:!0,dedupeByChatId:s,statusByChatId:i}}}let g1=null;function qae(){if(typeof window>"u")return null;const t=window.AudioContext;return t?(g1||(g1=Promise.resolve(new t)),g1):null}function _R({audioContext:t,startAt:e,duration:n,frequency:r,gainValue:i}){const s=t.createOscillator(),a=t.createGain(),c=e+.012,d=e+Math.max(n-.08,.02),u=e+n;s.type="sine",s.frequency.setValueAtTime(r,e),a.gain.setValueAtTime(1e-4,e),a.gain.exponentialRampToValueAtTime(i,c),a.gain.setValueAtTime(i,d),a.gain.exponentialRampToValueAtTime(1e-4,u),s.connect(a),a.connect(t.destination),s.start(e),s.stop(u)}async function Kae(){const t=await qae();if(!t)return;t.state==="suspended"&&await t.resume();const e=t.currentTime;_R({audioContext:t,startAt:e,duration:.24,frequency:880,gainValue:.14}),_R({audioContext:t,startAt:e+.12,duration:.34,frequency:1318.51,gainValue:.18})}function Gae(t){typeof navigator>"u"||typeof navigator.vibrate!="function"||navigator.vibrate(t==="needs_input"?[180,100,180]:[120])}function Yae(t,e){if(!sf()||Notification.permission!=="granted")return null;const n=new Notification(t.chatTitle,{body:t.kind==="needs_input"?`${t.projectTitle} needs your input in ${ys}.`:`${t.projectTitle} finished responding in ${ys}.`,tag:t.eventId!==void 0?`kaizen:${t.eventId}`:`kaizen:${t.chatId}:${t.kind}:${Date.now()}`,icon:"/app-icon-192.png",badge:"/app-icon-96.png",requireInteraction:t.kind==="needs_input"});return n.onclick=()=>{window.focus(),e(),n.close()},n}async function Xae({event:t,onBrowserNotificationClick:e,preferences:n}){if(sf()){if(n.browserNotificationsEnabled&&Yae(t,e),n.soundEnabled)try{await Kae()}catch{}n.vibrationEnabled&&Gae(t.kind)}}function Qae(t){return{browserNotificationsEnabled:(t==null?void 0:t.browserNotificationsEnabled)===!0,soundEnabled:(t==null?void 0:t.soundEnabled)===!0,vibrationEnabled:(t==null?void 0:t.vibrationEnabled)===!0,lastPermissionState:(t==null?void 0:t.lastPermissionState)==="granted"||(t==null?void 0:t.lastPermissionState)==="denied"||(t==null?void 0:t.lastPermissionState)==="default"||(t==null?void 0:t.lastPermissionState)==="unsupported"?t.lastPermissionState:null}}function Zae(t){return t.signedIn&&t.browserNotificationsEnabled}const v1=fi()(Li(t=>({browserNotificationsEnabled:!1,soundEnabled:!1,vibrationEnabled:!1,lastPermissionState:null,setBrowserNotificationsEnabled:e=>t({browserNotificationsEnabled:e}),setSoundEnabled:e=>t({soundEnabled:e}),setVibrationEnabled:e=>t({vibrationEnabled:e}),setLastPermissionState:e=>t({lastPermissionState:e})}),{name:"notification-preferences",migrate:t=>Qae(t)}));function Jae(t){const e=ke.c(15),{activeChatId:n,connectionStatus:r,sidebarData:i}=t,s=tc(),{remoteAuth:a}=Hu(),c=Bg(a),d=v1(nle),u=v1(tle),f=v1(ele),m=Zae({browserNotificationsEnabled:d,signedIn:c.signedIn});let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=bR(),e[0]=v):v=e[0];const b=_.useRef(v),S=_.useRef(typeof document>"u"?!0:document.visibilityState==="visible");let x,C;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const O=function(){S.current=document.visibilityState==="visible"};return document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},C=[],e[1]=x,e[2]=C):(x=e[1],C=e[2]),_.useEffect(x,C);let k,E;e[3]!==r?(k=()=>{r!=="connected"&&(b.current={...bR(),dedupeByChatId:b.current.dedupeByChatId})},E=[r],e[3]=r,e[4]=k,e[5]=E):(k=e[4],E=e[5]),_.useEffect(k,E);let R,M;return e[6]!==c.features.browserNotifications.enabled||e[7]!==n||e[8]!==m||e[9]!==s||e[10]!==i||e[11]!==u||e[12]!==f?(R=()=>{if(!c.features.browserNotifications.enabled||!sf())return;const{events:O,nextState:D}=Vae({activeChatId:n,documentVisible:S.current,previousState:b.current,sidebarData:i});b.current=D;for(const P of O)Xae({event:P,onBrowserNotificationClick:()=>{s(`/chat/${P.chatId}`)},preferences:{browserNotificationsEnabled:m,soundEnabled:u,vibrationEnabled:f}})},M=[n,c.features.browserNotifications.enabled,m,s,i,u,f],e[6]=c.features.browserNotifications.enabled,e[7]=n,e[8]=m,e[9]=s,e[10]=i,e[11]=u,e[12]=f,e[13]=R,e[14]=M):(R=e[13],M=e[14]),_.useEffect(R,M),null}function ele(t){return t.vibrationEnabled}function tle(t){return t.soundEnabled}function nle(t){return t.browserNotificationsEnabled}function rle(){const t=typeof navigator<"u"&&navigator.standalone===!0,e=typeof window<"u"&&window.matchMedia("(display-mode: standalone)").matches;return t||e}function ile(){const t=window.visualViewport,e=Math.round((t==null?void 0:t.height)??window.innerHeight),n=Math.max(0,Math.round((t==null?void 0:t.offsetTop)??0));return{height:e,offsetTop:n}}function sle(){const t=ke.c(1);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],_.useLayoutEffect(ole,e)}function ole(){let t=0,e=null,n=0;const r=rle(),i=()=>{t=0;const{height:c,offsetTop:d}=ile();e===null&&(e=d),c>n&&(n=c);const u=Math.max(0,d-e),f=n-c>120||u>12,m=document.documentElement;m.style.setProperty("--app-shell-height",`${c}px`),m.style.setProperty("--app-shell-offset-top",r?f?`max(0px, calc(${u}px - env(safe-area-inset-top)))`:"0px":`${u}px`),m.style.setProperty("--app-composer-bottom-padding",r?f?"0px":"max(12px, env(safe-area-inset-bottom))":f?"12px":"20px")},s=()=>{t!==0&&window.cancelAnimationFrame(t),t=window.requestAnimationFrame(i)};s();const a=window.visualViewport;return window.addEventListener("resize",s),window.addEventListener("orientationchange",s),a==null||a.addEventListener("resize",s),a==null||a.addEventListener("scroll",s),()=>{t!==0&&window.cancelAnimationFrame(t),window.removeEventListener("resize",s),window.removeEventListener("orientationchange",s),a==null||a.removeEventListener("resize",s),a==null||a.removeEventListener("scroll",s)}}function ale(t){const e=ke.c(7),{children:n,activeChatId:r,activeOverviewFeatureId:i}=t;let s;e[0]!==r||e[1]!==n?(s=g.jsx(_ae,{activeChatId:r,children:n}),e[0]=r,e[1]=n,e[2]=s):s=e[2];let a;return e[3]!==r||e[4]!==i||e[5]!==s?(a=g.jsx(kK,{children:g.jsx(MK,{children:g.jsx(AK,{children:g.jsx(rae,{activeChatId:r,activeOverviewFeatureId:i,children:s})})})}),e[3]=r,e[4]=i,e[5]=s,e[6]=a):a=e[6],a}const lle=`${Ky}last-seen-version`,cle=_.lazy(()=>_y(()=>import("./FeatureOverviewPage-Cbp5uhtA.js"),__vite__mapDeps([0,1])).then(t=>({default:t.FeatureOverviewPage}))),ule=_.lazy(()=>_y(()=>import("./LocalProjectsPage-CihqlQOs.js"),[]).then(t=>({default:t.LocalProjectsPage}))),dle=_.lazy(()=>_y(()=>import("./SettingsPage-jZce-i3Z.js"),__vite__mapDeps([2,1])).then(t=>({default:t.SettingsPage})));function b1(t){const e=ke.c(6),{label:n}=t;let r,i,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx("div",{className:"mb-3 h-4 w-32 animate-pulse rounded-full bg-muted"}),i=g.jsx("div",{className:"mb-2 h-7 w-56 animate-pulse rounded-full bg-muted"}),s=g.jsx("div",{className:"mb-6 h-4 w-72 animate-pulse rounded-full bg-muted"}),e[0]=r,e[1]=i,e[2]=s):(r=e[0],i=e[1],s=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsxs("div",{className:"grid gap-3",children:[g.jsx("div",{className:"h-16 animate-pulse rounded-2xl bg-muted/80"}),g.jsx("div",{className:"h-16 animate-pulse rounded-2xl bg-muted/70"}),g.jsx("div",{className:"h-16 animate-pulse rounded-2xl bg-muted/60"})]}),e[3]=a):a=e[3];let c;return e[4]!==n?(c=g.jsx("div",{className:"flex flex-1 min-w-0 items-center justify-center bg-background",children:g.jsx("div",{className:"w-full max-w-3xl px-6",children:g.jsxs("div",{className:"rounded-3xl border border-border/70 bg-card/60 p-6 shadow-sm",children:[r,i,s,a,g.jsx("div",{className:"mt-4 text-sm text-muted-foreground",children:n})]})})}),e[4]=n,e[5]=c):c=e[5],c}function hle(t,e){return!(!e||t.defaultPrevented||t.isComposing||Uq(t.target))}function fle(){const t=ke.c(4),e=IR(),n=e.chatId??null,r=e.featureId??null;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsx(mle,{}),t[0]=i):i=t[0];let s;return t[1]!==n||t[2]!==r?(s=g.jsx(ale,{activeChatId:n,activeOverviewFeatureId:r,children:i}),t[1]=n,t[2]=r,t[3]=s):s=t[3],s}function mle(){const t=ke.c(108),e=Yr(),n=IR(),r=Vh(),i=Hu(),s=hS(),a=oO(),c=Fu(),d=n.featureId??null;let u;t[0]!==a||t[1]!==r||t[2]!==i||t[3]!==s||t[4]!==d||t[5]!==c?(u={...r,...i,...s,...a,...c,activeOverviewFeatureId:d},t[0]=a,t[1]=r,t[2]=i,t[3]=s,t[4]=d,t[5]=c,t[6]=u):u=t[6];const f=u,m=zg("(min-width: 768px)"),v=PE(gle),b=PE(ple),S=e.pathname==="/";let x;t[7]===Symbol.for("react.memo_cache_sentinel")?(x=LF.split("/")[1]??"unknown",t[7]=x):x=t[7];const C=x;let k;t[8]!==f.keybindings?(k=lN(f.keybindings),t[8]=f.keybindings,t[9]=k):k=t[9];const E=k;sle();let R,M;t[10]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{window.localStorage.setItem(lle,C)},M=[C],t[10]=R,t[11]=M):(R=t[10],M=t[11]),_.useEffect(R,M);let O;t[12]!==m||t[13]!==E||t[14]!==f?(O=()=>{const te=function(ie){const xe=Ya(E,"toggleProjectsSidebar",ie);hle(ie,xe)&&(ie.preventDefault(),f.toggleProjectsSidebar(m))};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},t[12]=m,t[13]=E,t[14]=f,t[15]=O):O=t[15];let D;t[16]!==m||t[17]!==E||t[18]!==f.toggleProjectsSidebar?(D=[m,E,f.toggleProjectsSidebar],t[16]=m,t[17]=E,t[18]=f.toggleProjectsSidebar,t[19]=D):D=t[19],_.useEffect(O,D);let P;t[20]===Symbol.for("react.memo_cache_sentinel")?(P={top:"var(--app-shell-offset-top)"},t[20]=P):P=t[20];let z,Y,L,W,V,F,U,H,j,G;t[21]!==f?(G=(te,he)=>{Ho(hr.chatCreate(te,he),()=>f.handleCreateChat(te,he),{statusLabel:"Starting chat..."})},z=te=>{f.handleCreateFeature(te)},Y=te=>{f.handleRenameFeature(te)},L=te=>{f.handleDeleteFeature(te)},W=(te,he)=>{f.handleSetProjectBrowserState(te,he)},V=(te,he)=>{f.handleSetProjectGeneralChatsBrowserState(te,he)},F=(te,he)=>{f.handleSetFeatureBrowserState(te,he)},U=(te,he)=>{f.handleSetFeatureStage(te,he)},H=(te,he)=>{f.handleSetChatFeature(te,he)},j=(te,he)=>{f.handleReorderFeatures(te,he)},t[21]=f,t[22]=z,t[23]=Y,t[24]=L,t[25]=W,t[26]=V,t[27]=F,t[28]=U,t[29]=H,t[30]=j,t[31]=G):(z=t[22],Y=t[23],L=t[24],W=t[25],V=t[26],F=t[27],U=t[28],H=t[29],j=t[30],G=t[31]);let B,K,A,I;t[32]!==f?(B=te=>{f.handleOpenFeatureOverview(te)},K=te=>{f.handleRenameChat(te)},A=te=>{f.handleDeleteChat(te)},I=te=>{Ho(hr.projectRemove(te),()=>f.handleRemoveProject(te),{statusLabel:"Hiding project..."})},t[32]=f,t[33]=B,t[34]=K,t[35]=A,t[36]=I):(B=t[33],K=t[34],A=t[35],I=t[36]);let $;t[37]!==f?($=te=>f.handleOpenProviderLogin(te),t[37]=f,t[38]=$):$=t[38];let T;t[39]!==f?(T=()=>{f.handleInstallUpdate()},t[39]=f,t[40]=T):T=t[40];let X;t[41]!==v||t[42]!==m||t[43]!==E.bindings.toggleProjectsSidebar||t[44]!==b||t[45]!==S||t[46]!==f.activeChatId||t[47]!==f.activeOverviewFeatureId||t[48]!==f.closeSidebar||t[49]!==f.completedChatIds||t[50]!==f.connectionStatus||t[51]!==f.expandSidebar||t[52]!==f.folderGroupsEnabled||t[53]!==f.handleRefreshProviderUsage||t[54]!==f.kanbanStatusesEnabled||t[55]!==f.openSidebar||t[56]!==f.providerSettings||t[57]!==f.remoteAuth||t[58]!==f.showFeatureOverviewInSidebar||t[59]!==f.sidebarCollapsed||t[60]!==f.sidebarData||t[61]!==f.sidebarOpen||t[62]!==f.sidebarReady||t[63]!==f.startingLocalPath||t[64]!==f.toggleProjectsSidebar||t[65]!==f.updateSnapshot||t[66]!==z||t[67]!==Y||t[68]!==L||t[69]!==W||t[70]!==V||t[71]!==F||t[72]!==U||t[73]!==H||t[74]!==j||t[75]!==B||t[76]!==K||t[77]!==A||t[78]!==I||t[79]!==$||t[80]!==T||t[81]!==G?(X=g.jsx(Tq,{data:f.sidebarData,completedChatIds:f.completedChatIds,activeChatId:f.activeChatId,activeOverviewFeatureId:f.activeOverviewFeatureId,connectionStatus:f.connectionStatus,ready:f.sidebarReady,open:f.sidebarOpen,collapsed:f.sidebarCollapsed,isDesktopViewport:m,showMobileOpenButton:S,onOpen:f.openSidebar,onClose:f.closeSidebar,onToggle:f.toggleProjectsSidebar,onExpand:f.expandSidebar,desktopWidth:v,toggleShortcut:E.bindings.toggleProjectsSidebar,onResizeDesktopWidth:b,onCreateChat:G,onCreateFeature:z,onRenameFeature:Y,onDeleteFeature:L,onSetProjectBrowserState:W,onSetProjectGeneralChatsBrowserState:V,onSetFeatureBrowserState:F,onSetFeatureStage:U,onSetChatFeature:H,onReorderFeatures:j,folderGroupsEnabled:f.folderGroupsEnabled,showFeatureOverviewInSidebar:f.showFeatureOverviewInSidebar,kanbanStatusesEnabled:f.kanbanStatusesEnabled,onOpenFeatureOverview:B,onRenameChat:K,onDeleteChat:A,onRemoveProject:I,onRefreshProviderUsage:f.handleRefreshProviderUsage,onOpenProviderLogin:$,providerSettings:f.providerSettings,remoteAuth:f.remoteAuth,startingLocalPath:f.startingLocalPath,updateSnapshot:f.updateSnapshot,onInstallUpdate:T}),t[41]=v,t[42]=m,t[43]=E.bindings.toggleProjectsSidebar,t[44]=b,t[45]=S,t[46]=f.activeChatId,t[47]=f.activeOverviewFeatureId,t[48]=f.closeSidebar,t[49]=f.completedChatIds,t[50]=f.connectionStatus,t[51]=f.expandSidebar,t[52]=f.folderGroupsEnabled,t[53]=f.handleRefreshProviderUsage,t[54]=f.kanbanStatusesEnabled,t[55]=f.openSidebar,t[56]=f.providerSettings,t[57]=f.remoteAuth,t[58]=f.showFeatureOverviewInSidebar,t[59]=f.sidebarCollapsed,t[60]=f.sidebarData,t[61]=f.sidebarOpen,t[62]=f.sidebarReady,t[63]=f.startingLocalPath,t[64]=f.toggleProjectsSidebar,t[65]=f.updateSnapshot,t[66]=z,t[67]=Y,t[68]=L,t[69]=W,t[70]=V,t[71]=F,t[72]=U,t[73]=H,t[74]=j,t[75]=B,t[76]=K,t[77]=A,t[78]=I,t[79]=$,t[80]=T,t[81]=G,t[82]=X):X=t[82];const Z=f.createFeatureModalProjectId!==null;let J,re;t[83]!==f?(J=te=>{te||f.handleCloseCreateFeatureModal()},re=te=>f.handleConfirmCreateFeature(te),t[83]=f,t[84]=J,t[85]=re):(J=t[84],re=t[85]);let ae;t[86]!==f.isCreatingFeature||t[87]!==Z||t[88]!==J||t[89]!==re?(ae=g.jsx(V7,{open:Z,isSubmitting:f.isCreatingFeature,onOpenChange:J,onConfirm:re}),t[86]=f.isCreatingFeature,t[87]=Z,t[88]=J,t[89]=re,t[90]=ae):ae=t[90];let ue,me;t[91]!==f?(ue=te=>{te||f.handleCloseCursorCurlImport()},me=te=>f.handleSubmitCursorCurlImport(te),t[91]=f,t[92]=ue,t[93]=me):(ue=t[92],me=t[93]);let se;t[94]!==f.cursorCurlImportOpen||t[95]!==ue||t[96]!==me?(se=g.jsx(q7,{open:f.cursorCurlImportOpen,onOpenChange:ue,onSubmit:me}),t[94]=f.cursorCurlImportOpen,t[95]=ue,t[96]=me,t[97]=se):se=t[97];let oe;t[98]!==f.activeChatId||t[99]!==f.connectionStatus||t[100]!==f.sidebarData?(oe=g.jsx(Jae,{activeChatId:f.activeChatId,connectionStatus:f.connectionStatus,sidebarData:f.sidebarData}),t[98]=f.activeChatId,t[99]=f.connectionStatus,t[100]=f.sidebarData,t[101]=oe):oe=t[101];let ee;t[102]===Symbol.for("react.memo_cache_sentinel")?(ee=g.jsx(aI,{}),t[102]=ee):ee=t[102];let Q;return t[103]!==X||t[104]!==ae||t[105]!==se||t[106]!==oe?(Q=g.jsxs("div",{className:"relative flex h-[var(--app-shell-height)] min-h-[var(--app-shell-height)] overflow-hidden",style:P,children:[X,ae,se,oe,ee]}),t[103]=X,t[104]=ae,t[105]=se,t[106]=oe,t[107]=Q):Q=t[107],Q}function ple(t){return t.setWidth}function gle(t){return t.widthPx}function vle(){const t=ke.c(8);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=g.jsx(jo,{path:"/open",element:g.jsx(Nae,{})}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=g.jsx(jo,{path:"/remote-setup",element:g.jsx(Hae,{})}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=g.jsx(fle,{}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=g.jsx(jo,{path:"/",element:g.jsx(_.Suspense,{fallback:g.jsx(b1,{label:"Loading local projects..."}),children:g.jsx(ule,{})})}),t[3]=i):i=t[3];let s;t[4]===Symbol.for("react.memo_cache_sentinel")?(s=g.jsx(jo,{path:"/settings",element:g.jsx(oI,{to:"/settings/general",replace:!0})}),t[4]=s):s=t[4];let a;t[5]===Symbol.for("react.memo_cache_sentinel")?(a=g.jsx(jo,{path:"/settings/:sectionId",element:g.jsx(_.Suspense,{fallback:g.jsx(b1,{label:"Loading settings..."}),children:g.jsx(dle,{})})}),t[5]=a):a=t[5];let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=g.jsx(jo,{path:"/chat/:chatId",element:g.jsx(Cae,{})}),t[6]=c):c=t[6];let d;return t[7]===Symbol.for("react.memo_cache_sentinel")?(d=g.jsx(TF,{children:g.jsxs($7,{children:[g.jsxs(cI,{children:[e,n,g.jsxs(jo,{element:r,children:[i,s,a,c,g.jsx(jo,{path:"/overview/:featureId",element:g.jsx(_.Suspense,{fallback:g.jsx(b1,{label:"Loading feature overview..."}),children:g.jsx(cle,{})})})]})]}),g.jsx(yP,{})]})}),t[7]=d):d=t[7],d}const lO=document.getElementById("root");if(!lO)throw new Error("Missing #root");lL.createRoot(lO).render(g.jsx(jI,{basename:uN(),children:g.jsx(oZ,{children:g.jsx(vle,{})})}));export{v4 as $,Oy as A,vt as B,bN as C,My as D,Ni as E,b8 as F,_le as G,ys as H,jy as I,Ele as J,n4 as K,Fn as L,nf as M,yy as N,LF as O,Ul as P,_s as Q,op as R,BD as S,fg as T,UV as U,sE as V,vu as W,di as X,lu as Y,oO as Z,Fu as _,ke as a,Bg as a0,pK as a1,Zn as a2,zV as a3,GA as a4,BV as a5,QA as a6,rc as a7,Ex as a8,ZA as a9,aK as aA,oK as aB,r_ as aC,cK as aD,lK as aE,i_ as aF,TH as aG,Dle as aH,jle as aI,sf as aJ,Vle as aK,Kle as aL,Zae as aM,Xae as aN,ZF as aO,sq as aP,Lo as aQ,aq as aR,Wse as aa,Lle as ab,f1 as ac,au as ad,qr as ae,JP as af,Ole as ag,Yr as ah,IR as ai,aZ as aj,Fp as ak,$o as al,fu as am,v1 as an,lN as ao,kle as ap,tH as aq,Tp as ar,Hg as as,JR as at,is as au,Nle as av,hK as aw,HV as ax,qle as ay,wle as az,Vh as b,st as c,Hu as d,hS as e,zg as f,hr as g,hu as h,Ce as i,Zh as j,g as k,RZ as l,Ho as m,rf as n,yN as o,Ll as p,ap as q,_ as r,zo as s,Bo as t,tc as u,Fo as v,hg as w,Dy as x,Ay as y,Cle as z};