@cuongtran001/kanna 1.41.0 → 1.41.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.
- package/dist/client/assets/{arc-Drhl3g-C.js → arc-BjpfMxgS.js} +1 -1
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-BfS0m03j.js → architectureDiagram-3BPJPVTR-BUHVFhDO.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-DLaK8B8P.js → blockDiagram-GPEHLZMM-C42kXW-r.js} +1 -1
- package/dist/client/assets/{c4Diagram-AAUBKEIU-gAtsTPOb.js → c4Diagram-AAUBKEIU-N0iKjkPj.js} +1 -1
- package/dist/client/assets/channel-SPxCM3v3.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-k1LctMXB.js → chunk-2J33WTMH-KK-LRvfb.js} +1 -1
- package/dist/client/assets/{chunk-4BX2VUAB-DhEywIQH.js → chunk-4BX2VUAB-Bn9bYLtB.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-C8Ou7w8B.js → chunk-55IACEB6-CJERiQXe.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-Deuw6jbl.js → chunk-727SXJPM-Dgid5beD.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-BuXktpma.js → chunk-AQP2D5EJ-CrBUb80H.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-B6uzAjQx.js → chunk-FMBD7UC4-BHYf0WjD.js} +1 -1
- package/dist/client/assets/{chunk-ND2GUHAM-DK5doAX9.js → chunk-ND2GUHAM-DB_eDch5.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-Bt7Z-Bnn.js → chunk-QZHKN3VN-D_QoJmDX.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-BOI_EPhE.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-BOI_EPhE.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-DOtr78IP.js → cose-bilkent-S5V4N54A-DohLT3sP.js} +1 -1
- package/dist/client/assets/{dagre-BM42HDAG-0XyBXh0T.js → dagre-BM42HDAG-CHvbggmQ.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-ByMFbHr_.js → diagram-2AECGRRQ-GaVcQ5o0.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-eSFbSqtN.js → diagram-5GNKFQAL-V-xTJaTx.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-C11kVdU2.js → diagram-KO2AKTUF-B1beqOTW.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-CzqDGrmv.js → diagram-LMA3HP47-DFim9Wgm.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-Dp8N1y4M.js → diagram-OG6HWLK6-DTXkLNS5.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-Dd-nM2jB.js → erDiagram-TEJ5UH35-rTdCCoMI.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-D6UPYZ1H.js → flowDiagram-I6XJVG4X-CNOsM7BH.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-akbYQCeK.js → ganttDiagram-6RSMTGT7-B5wwTLMw.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-Ds3ZVP26.js → gitGraphDiagram-PVQCEYII-xoqlhaUB.js} +1 -1
- package/dist/client/assets/{index-B5iDxpcO.js → index-CbfAvmid.js} +1 -1
- package/dist/client/assets/index-CiKd-0SZ.css +32 -0
- package/dist/client/assets/{index-DfnMuOS5.js → index-DxxsM33V.js} +3 -3
- package/dist/client/assets/{infoDiagram-5YYISTIA-8PScaxei.js → infoDiagram-5YYISTIA-DHPSFURC.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Dq-5Llhx.js → ishikawaDiagram-YF4QCWOH-C3Bun_7L.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-CsISJQRj.js → journeyDiagram-JHISSGLW-BFgSHdrE.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-Boc4D-oQ.js → kanban-definition-UN3LZRKU-CO3ZCqeg.js} +1 -1
- package/dist/client/assets/{linear-CpSec-HR.js → linear-ghdlcjF_.js} +1 -1
- package/dist/client/assets/{mermaid.core-CDJeRmO6.js → mermaid.core-htyOC5rr.js} +4 -4
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-DeKLAVD5.js → mindmap-definition-RKZ34NQL-BVeJs4LU.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-C7Fq-_kD.js → pieDiagram-4H26LBE5-BzPxIZE3.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-qnBfMRYL.js → quadrantDiagram-W4KKPZXB-4A3EVVmd.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-CynnS8Bd.js → requirementDiagram-4Y6WPE33-DUtc-5Xs.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-qxLcaArB.js → sankeyDiagram-5OEKKPKP-zVvX9qXj.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-OQDCB1y9.js → sequenceDiagram-3UESZ5HK-CwuZ1y2d.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-D3scHDWm.js → stateDiagram-AJRCARHV-DcAKaJp9.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-DPR0HY0t.js +1 -0
- package/dist/client/assets/{timeline-definition-PNZ67QCA-C2Y5x91x.js → timeline-definition-PNZ67QCA-BTqiioOE.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-Ppm4fFdN.js → vennDiagram-CIIHVFJN-C2K8ITbO.js} +1 -1
- package/dist/client/assets/{wardley-L42UT6IY-j4JXs0DR.js → wardley-L42UT6IY-D8NDkHkL.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-BaxX9l16.js → wardleyDiagram-YWT4CUSO-9p9h3HEo.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-D7yqxdlO.js → xychartDiagram-2RQKCTM6-CjF6Foj-.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/src/server/event-store-messages.adapter.test.ts +7 -7
- package/src/server/event-store-messages.adapter.ts +1 -1
- package/dist/client/assets/channel-CfY9XKZH.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-DJjH6n9i.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DJjH6n9i.js +0 -1
- package/dist/client/assets/index-BUbZO15R.css +0 -32
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-CvhIInaF.js +0 -1
|
@@ -828,7 +828,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
828
828
|
`)!==n.readPathDeny.join(`
|
|
829
829
|
`)&&(w.readPathDeny=x),y.join(`
|
|
830
830
|
`)!==n.writePathDeny.join(`
|
|
831
|
-
`)&&(w.writePathDeny=y),Object.keys(w).length===0?null:w}function g(){r(m())}function v(){r(null)}return c.jsxs(c.Fragment,{children:[c.jsx(La,{open:e,onOpenChange:x=>{x||i()},children:c.jsxs(ra,{className:"max-w-2xl",children:[c.jsxs($a,{children:["Permissions — ",t]}),c.jsxs(vl,{className:"space-y-5",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Default action"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Behaviour when a tool call has no explicit allow/deny rule. ",c.jsx("strong",{children:"auto-allow"})," bypasses prompts and runs untrusted shell commands without supervision — use a worktree."]}),c.jsx(Ji,{value:s,onValueChange:h,options:[{value:"ask",label:"Ask"},{value:"auto-allow",label:"Auto-allow (unsafe)"},{value:"auto-deny",label:"Auto-deny"}]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Read-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot read paths matching any entry. Defaults shown below — edit to add or remove."}),c.jsx("textarea",{value:o,onChange:x=>f.getState().setReadDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Write-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot edit or write paths matching any entry."}),c.jsx("textarea",{value:a,onChange:x=>f.getState().setWriteDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]})]}),c.jsxs(ju,{className:"justify-between",children:[c.jsx(Ee,{variant:"ghost",onClick:v,children:"Reset to defaults"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ee,{variant:"ghost",onClick:i,children:"Cancel"}),c.jsx(Ee,{onClick:g,children:"Apply"})]})]})]})}),c.jsx(La,{open:l,onOpenChange:x=>{x||(f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null))},children:c.jsxs(ra,{className:"max-w-md",children:[c.jsx($a,{children:"Enable auto-allow for this chat?"}),c.jsxs(vl,{className:"space-y-3 text-sm",children:[c.jsx("p",{children:"Auto-allow disables tool-call prompts. The model can run shell commands, write files, and edit code without asking. Read/write deny lists still apply."}),c.jsx("p",{className:"text-warning",children:"Use a worktree for risky tasks."})]}),c.jsxs(ju,{className:"justify-end gap-2",children:[c.jsx(Ee,{variant:"ghost",onClick:()=>{f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null)},children:"Cancel"}),c.jsx(Ee,{variant:"destructive",onClick:()=>{const x=f.getState();u&&x.setDefaultAction(u),x.setConfirmUnsafeOpen(!1),x.setPendingDefaultAction(null)},children:"Enable auto-allow"})]})]})})]})}const w_e={defaultAction:"ask",bash:{autoAllowVerbs:["ls","pwd","git status","git diff","git log"]},readPathDeny:["~/.ssh","~/.aws","~/.gcp","~/.config/gh","~/.claude","~/.kanna","~/Library/Keychains","/etc/shadow","/etc/sudoers","~/.gnupg","~/.gitconfig","**/.git/config","~/.npmrc","~/.netrc","~/.docker/config.json","**/.env","**/.env.*","**/credentials*","**/*.pem","**/*.key","**/id_rsa*","**/id_ed25519*"],writePathDeny:["/etc/**","/usr/**","/System/**","~/.ssh/**","~/.aws/**","~/.config/gh/**","~/.claude/**","~/.kanna/**","~/.gnupg/**","~/.gitconfig","**/.git/config"],toolDenyList:[{tool:"mcp__kanna__bash",pattern:"rm\\s+-rf\\s+(/|~|\\$HOME)(?:\\b|$|\\s)"},{tool:"mcp__kanna__bash",pattern:"git\\s+push\\b.*--force"}],toolAllowList:[]},Jn={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},setInterval(e,t){return window.setInterval(e,t)},clearInterval(e){window.clearInterval(e)},requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)}},Bt=_.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{ref:r,type:t,className:ce("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...n}));Bt.displayName="Input";const JY=_.createContext(null);function C_e({children:e,ports:t={}}){const n=t.timer??Jn,[r,i]=_.useState(null),[s,o]=_.useState(""),a=_.useRef(null);_.useEffect(()=>{(r==null?void 0:r.kind)==="prompt"&&(o(r.options.initialValue??""),n.setTimeout(()=>{var y,w;(y=a.current)==null||y.focus(),(w=a.current)==null||w.select()},0))},[r,n]);const l=_.useCallback(()=>{i(null),o("")},[]),u=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!1):r.kind==="prompt"?r.resolve(null):r.resolve(),l())},[l,r]),f=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!0):r.kind==="prompt"?r.resolve(s.trim()||null):r.resolve(),l())},[l,r,s]),h=_.useCallback(y=>new Promise(w=>{i({kind:"confirm",options:y,resolve:w})}),[]),m=_.useCallback(y=>new Promise(w=>{i({kind:"prompt",options:y,resolve:w})}),[]),g=_.useCallback(y=>new Promise(w=>{i({kind:"alert",options:y,resolve:w})}),[]),v=_.useMemo(()=>({confirm:h,prompt:m,alert:g}),[g,h,m]);let x="Confirm";return r&&(r.kind==="alert"?x=r.options.closeLabel??"OK":"confirmLabel"in r.options&&(x=r.options.confirmLabel??"Confirm")),c.jsxs(JY.Provider,{value:v,children:[e,c.jsx(La,{open:r!==null,onOpenChange:y=>{y||!r||u()},children:c.jsx(ra,{size:"sm",onKeyDown:y=>{y.key!=="Enter"||y.shiftKey||!r||r.kind!=="confirm"||(y.preventDefault(),f())},children:r?c.jsxs(c.Fragment,{children:[c.jsxs(vl,{className:"space-y-4",children:[c.jsx($a,{children:r.options.title}),r.options.description?c.jsx(h0,{children:r.options.description}):null,r.kind==="prompt"?c.jsx(Bt,{ref:a,type:"text",value:s,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),f())},placeholder:r.options.placeholder}):null]}),c.jsxs(ju,{children:[c.jsx(Ee,{variant:"ghost",size:"sm",onClick:u,className:r.kind==="alert"?"hidden":void 0,children:"cancelLabel"in r.options?r.options.cancelLabel??"Cancel":"Cancel"}),c.jsx(Ee,{variant:r.kind==="confirm"?r.options.confirmVariant??"default":"secondary",size:"sm",onClick:f,disabled:r.kind==="prompt"&&!s.trim(),children:x})]})]}):null})})]})}function $E(){const e=_.useContext(JY);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const qD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("bg-card text-card-foreground",e),...t}));qD.displayName="Card";const YD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("flex flex-col space-y-1.5 p-2",e),...t}));YD.displayName="CardHeader";const ZY=_.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ce("text-2xl font-semibold leading-none tracking-tight",e),...t}));ZY.displayName="CardTitle";const eX=_.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ce("text-sm text-muted-foreground",e),...t}));eX.displayName="CardDescription";const XD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("p-6 pt-0",e),...t}));XD.displayName="CardContent";const k_e=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("flex items-center p-6 pt-0",e),...t}));k_e.displayName="CardFooter";const E_e={info:{dotVar:"var(--info)",bgClass:"bg-info/[0.06]"},warning:{dotVar:"var(--warning)",bgClass:"bg-warning/[0.06]"},success:{dotVar:"var(--success)",bgClass:"bg-success/[0.06]"},error:{dotVar:"var(--destructive)",bgClass:"bg-destructive/[0.06]"}};function N_e({variant:e,children:t,dot:n=!0,className:r}){const i=E_e[e];return c.jsxs("div",{role:"status",className:ce("flex flex-wrap items-center justify-center gap-x-2 gap-y-1 border-b border-border px-4 py-2 text-xs leading-tight",i.bgClass,r),children:[n?c.jsx("span",{"aria-hidden":"true",className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:i.dotVar}}):null,t]})}const T_e="modulepreload",A_e=function(e){return"/"+e},T6={},Z=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(u=>{if(u=A_e(u),u in T6)return;T6[u]=!0;const f=u.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":T_e,f||(m.as="script"),m.crossOrigin="",m.href=u,l&&m.setAttribute("nonce",l),document.head.appendChild(m),f)return new Promise((g,v)=>{m.addEventListener("load",g),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},j_e=_.lazy(()=>Z(()=>import("./index-B5iDxpcO.js"),[]).then(e=>({default:e.Toaster})));function R_e(){return c.jsx(_.Suspense,{fallback:null,children:c.jsx(j_e,{position:"bottom-right",theme:"system",closeButton:!0,duration:6e3})})}const M_e="1.41.0",P_e={version:M_e},Vr="Kanna",A6="kanna",I_e=".kanna",O_e=".kanna-dev",D_e="KANNA_RUNTIME_PROFILE",QD=`kanna/${P_e.version}`,L_e="[kanna]",$_e=`~/${Vr}`;function BE(){const e=Reflect.get(globalThis,"process");return e==null?void 0:e.env}function B_e(e=BE()){var t;return((t=e==null?void 0:e[D_e])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function F_e(e=BE()){return B_e(e)==="dev"?O_e:I_e}function z_e(e=BE()){return`~/${F_e(e)}`}function U_e(e=BE()){return`${z_e(e)}/keybindings.json`}function ww(e){return e?`${A6} ${e}`:A6}const tX="always",nX="funk",H_e=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function W_e(e){switch(e){case"never":case"unfocused":case"always":return e;default:return tX}}function V_e(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return nX}}const np=Yt()(e=>({chatSoundPreference:tX,chatSoundId:nX,setChatSoundPreference:t=>e({chatSoundPreference:W_e(t)}),setChatSoundId:t=>e({chatSoundId:V_e(t)})})),K_e={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function G_e(e=Et){return e.getVisibilityState()!=="visible"||!e.hasFocus()}function q_e(e){const t=new Audio(K_e[e]);return t.preload="auto",t.play()}async function vM(e,t,n=Jn){if(t<=0)return;const r=Array.from({length:t},(i,s)=>new Promise(o=>{n.setTimeout(()=>{q_e(e).catch(()=>{}).finally(()=>o())},s*90)}));await Promise.all(r)}function Y_e(e,t=Et){return e==="never"?!1:e==="always"?!0:G_e(t)}function X_e(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function j6(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function Q_e(e,t){if(!e)return 0;const n=j6(e),r=j6(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}const rX="h-[var(--shell-top-band)] max-h-[var(--shell-top-band)]",J_e="md:my-2 md:mr-2 md:rounded-2xl md:border md:border-border",Z_e="flex min-h-0 flex-1 flex-col overflow-y-auto";function hu({tooltip:e,children:t,className:n,inline:r=!1,side:i}){const s=ce("truncate",n);return c.jsx(v0,{children:c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:r?c.jsx("span",{className:s,children:t}):c.jsx("div",{className:s,children:t})}),c.jsx(si,{side:i,children:e})]})})}function ia({label:e,children:t,side:n}){return c.jsx(v0,{children:c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:t}),c.jsx(si,{side:n,children:e})]})})}const e0e=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;function t0e(e){const t=e.match(e0e);return!t||t.length===0?null:t[t.length-1].toLowerCase()}function n0e(e){const t=[];for(const n of e.split(/[\s,]+/)){if(!n)continue;const r=t0e(n);r&&!t.includes(r)&&t.push(r)}return t}const bM=Yt()(e=>({text:"",setText:t=>e({text:t}),resetForOpen:()=>e({text:""})})),r0e=()=>bM(e=>e.text),Ma=_.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{"data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false","data-1p-ignore":!0,autoComplete:"off",className:ce("flex w-full rounded-lg border border-border bg-background px-2.5 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ma.displayName="Textarea";function i0e({open:e,busy:t,onClose:n,onImportAll:r,onImportSessions:i}){const s=r0e(),o=bM(m=>m.setText),a=bM(m=>m.resetForOpen);_.useEffect(()=>{e&&a()},[e,a]);const l=_.useMemo(()=>n0e(s),[s]),f=s.trim().length>0&&l.length===0,h=()=>{l.length===0||t||i(l)};return c.jsx(La,{open:e,onOpenChange:m=>{m||n()},children:c.jsxs(ra,{size:"sm",children:[c.jsxs(vl,{className:"space-y-3",children:[c.jsx($a,{children:"Import Claude sessions"}),c.jsx(Ma,{value:s,onChange:m=>o(m.target.value),placeholder:"Paste one or more session ids (uuid, filename, or full path)…",rows:4}),f?c.jsx("p",{className:"text-xs text-destructive",children:"No valid session id found in the pasted text."}):null,c.jsx("p",{className:"text-xs text-muted-foreground",children:"Empty input imports ALL sessions (full scan). Active sessions import as a live view — sending a message there takes over the session."})]}),c.jsxs(ju,{children:[c.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,disabled:t,children:"Cancel"}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:"Import all"}),c.jsxs(Ee,{variant:"secondary",size:"sm",onClick:h,disabled:l.length===0||t,children:["Import ",l.length===1?"session":"sessions"]})]})]})})}function xM(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const s0e=[/^(?:\/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 iX(e){const t=e.trim();for(const n of s0e){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function b0(e){return e.split("/").pop()||e}const o0e=1440*6e4;function a0e(e,t){const n=Math.max(0,t-e),r=Math.floor(n/1e3),i=Math.floor(r/3600),s=Math.floor(r%3600/60),o=r%60;return i>0?`${i}h ${s}m`:s>0?`${s}m ${o}s`:`${o}s`}function l0e(e){const t=new Date(e),n=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0");return`${n}:${r}`}function c0e(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=o0e,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function sX(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}const u0e=80;function d0e(e){return sX(e,u0e)}function f0e(e){return e.lastMessageAt??e._creationTime}const FE=1e3,Sy=60*FE,rp=60*Sy,WC=24*rp;function xo(e){const t=Math.max(0,e);if(t<Sy)return`${Math.floor(t/FE)}s`;if(t<rp)return`${Math.floor(t/Sy)}m`;if(t<WC){const i=Math.floor(t/rp),s=Math.floor(t%rp/Sy);return s===0?`${i}h`:`${i}h ${s}m`}const n=Math.floor(t/WC),r=Math.floor(t%WC/rp);return r===0?`${n}d`:`${n}d ${r}h`}function h0e(e){const t=Math.max(0,e),n=Math.ceil(t/FE);if(n<60)return`${String(n)}s`;const r=Math.ceil(t/Sy);if(r<60)return`${String(r)}m`;const i=Math.ceil(t/rp);return i<24?`${String(i)}h`:`${String(Math.ceil(t/WC))}d`}function Pu(e){const t=Math.max(0,e);if(t>=rp)return xo(t);const n=Math.floor(t/FE),r=Math.floor(n/60),i=n%60;return`${r}:${i.toString().padStart(2,"0")}`}function kf(e){switch(e){case"idle":return"Idle";case"starting":return"Starting";case"running":return"Running";case"waiting_for_user":return"Waiting";case"failed":return"Failed"}}function R6(e){switch(e){case"running":return"active";case"waiting_for_user":return"attention";case"failed":return"destructive";case"idle":case"starting":default:return"muted"}}function Jy(e){switch(e){case"active":return"text-emerald-500 dark:text-emerald-400";case"attention":return"text-amber-500 dark:text-amber-400";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function oX(e){switch(e){case"active":return"bg-emerald-500 dark:bg-emerald-400";case"attention":return"bg-amber-500 dark:bg-amber-400";case"destructive":return"bg-destructive";case"muted":default:return"bg-muted-foreground"}}function p0e(e){switch(e){case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed";case"killed":return"Killed";case"unknown":return"Unknown"}}function aX(e){switch(e){case"running":return"active";case"failed":return"destructive";case"killed":return"attention";case"completed":case"unknown":default:return"muted"}}function zE(e){return e.status==="running"||e.status==="starting"?{tone:"warning",label:kf(e.status)}:e.status==="waiting_for_user"?{tone:"info",label:kf(e.status)}:e.status==="failed"?{tone:"destructive",label:kf(e.status)}:e.unread?{tone:"success",label:"Unread"}:null}function UE(e){switch(e){case"warning":return"bg-warning";case"info":return"bg-info";case"success":return"bg-success";case"destructive":return"bg-destructive";case"muted":return"bg-muted-foreground";default:return""}}function lX(e){switch(e){case"warning":return"text-warning";case"info":return"text-info";case"success":return"text-success";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function cX(e){switch(e){case"active":return{glyph:"●",toneClass:"text-success",title:"Claude PTY session active"};case"warming":return{glyph:"◐",toneClass:"text-warning",title:"Claude PTY session warming"};case"idle":return{glyph:"○",toneClass:"text-muted-foreground",title:"Claude PTY session idle"};case"cooling":return{glyph:"◌",toneClass:"text-muted-foreground",title:"Claude PTY session cooling down"};case"cold":default:return null}}function JD(e){const t=e+"CollectionProvider",[n,r]=qu(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:y,children:w}=x,C=Dn.useRef(null),k=Dn.useRef(new Map).current;return c.jsx(i,{scope:y,itemMap:k,collectionRef:C,children:w})};o.displayName=t;const a=e+"CollectionSlot",l=Ip(a),u=Dn.forwardRef((x,y)=>{const{scope:w,children:C}=x,k=s(a,w),E=Un(y,k.collectionRef);return c.jsx(l,{ref:E,children:C})});u.displayName=a;const f=e+"CollectionItemSlot",h="data-radix-collection-item",m=Ip(f),g=Dn.forwardRef((x,y)=>{const{scope:w,children:C,...k}=x,E=Dn.useRef(null),N=Un(y,E),T=s(f,w);return Dn.useEffect(()=>(T.itemMap.set(E,{ref:E,...k}),()=>void T.itemMap.delete(E))),c.jsx(m,{[h]:"",ref:N,children:C})});g.displayName=f;function v(x){const y=s(e+"CollectionConsumer",x);return Dn.useCallback(()=>{const C=y.collectionRef.current;if(!C)return[];const k=Array.from(C.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((T,R)=>k.indexOf(T.ref.current)-k.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:g},v,r]}var m0e=_.createContext(void 0);function ZD(e){const t=_.useContext(m0e);return e||t||"ltr"}var jA="rovingFocusGroup.onEntryFocus",g0e={bubbles:!1,cancelable:!0},x0="RovingFocusGroup",[yM,uX,v0e]=JD(x0),[b0e,dX]=qu(x0,[v0e]),[x0e,y0e]=b0e(x0),fX=_.forwardRef((e,t)=>c.jsx(yM.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(yM.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(_0e,{...e,ref:t})})}));fX.displayName=x0;var _0e=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,m=_.useRef(null),g=Un(t,m),v=ZD(s),[x,y]=Rv({prop:o,defaultProp:a??null,onChange:l,caller:x0}),[w,C]=_.useState(!1),k=gl(u),E=uX(n),N=_.useRef(!1),[T,R]=_.useState(0);return _.useEffect(()=>{const M=m.current;if(M)return M.addEventListener(jA,k),()=>M.removeEventListener(jA,k)},[k]),c.jsx(x0e,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(M=>y(M),[y]),onItemShiftTab:_.useCallback(()=>C(!0),[]),onFocusableItemAdd:_.useCallback(()=>R(M=>M+1),[]),onFocusableItemRemove:_.useCallback(()=>R(M=>M-1),[]),children:c.jsx(wn.div,{tabIndex:w||T===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:st(e.onMouseDown,()=>{N.current=!0}),onFocus:st(e.onFocus,M=>{const P=!N.current;if(M.target===M.currentTarget&&P&&!w){const B=new CustomEvent(jA,g0e);if(M.currentTarget.dispatchEvent(B),!B.defaultPrevented){const U=E().filter(z=>z.focusable),D=U.find(z=>z.active),$=U.find(z=>z.id===x),V=[D,$,...U].filter(Boolean).map(z=>z.ref.current);mX(V,f)}}N.current=!1}),onBlur:st(e.onBlur,()=>C(!1))})})}),hX="RovingFocusGroupItem",pX=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=ku(),u=s||l,f=y0e(hX,n),h=f.currentTabStopId===u,m=uX(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),c.jsx(yM.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:c.jsx(wn.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:st(e.onMouseDown,y=>{r?f.onItemFocus(u):y.preventDefault()}),onFocus:st(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:st(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=C0e(y,f.orientation,f.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let k=m().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")k.reverse();else if(w==="prev"||w==="next"){w==="prev"&&k.reverse();const E=k.indexOf(y.currentTarget);k=f.loop?k0e(k,E+1):k.slice(E+1)}setTimeout(()=>mX(k))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});pX.displayName=hX;var S0e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function w0e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function C0e(e,t,n){const r=w0e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return S0e[r]}function mX(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function k0e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var E0e=fX,N0e=pX,_M=["Enter"," "],T0e=["ArrowDown","PageUp","Home"],gX=["ArrowUp","PageDown","End"],A0e=[...T0e,...gX],j0e={ltr:[..._M,"ArrowRight"],rtl:[..._M,"ArrowLeft"]},R0e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},y0="Menu",[Zy,M0e,P0e]=JD(y0),[lm,vX]=qu(y0,[P0e,Gf,dX]),HE=Gf(),bX=dX(),[I0e,cm]=lm(y0),[O0e,_0]=lm(y0),xX=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=HE(t),[l,u]=_.useState(null),f=_.useRef(!1),h=gl(s),m=ZD(i);return _.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(PE,{...a,children:c.jsx(I0e,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:u,children:c.jsx(O0e,{scope:t,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};xX.displayName=y0;var D0e="MenuAnchor",eL=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=HE(n);return c.jsx(m0,{...i,...r,ref:t})});eL.displayName=D0e;var tL="MenuPortal",[L0e,yX]=lm(tL,{forceMount:void 0}),_X=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=cm(tL,t);return c.jsx(L0e,{scope:t,forceMount:n,children:c.jsx(Ga,{present:n||s.open,children:c.jsx(db,{asChild:!0,container:i,children:r})})})};_X.displayName=tL;var Pa="MenuContent",[$0e,nL]=lm(Pa),SX=_.forwardRef((e,t)=>{const n=yX(Pa,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=cm(Pa,e.__scopeMenu),o=_0(Pa,e.__scopeMenu);return c.jsx(Zy.Provider,{scope:e.__scopeMenu,children:c.jsx(Ga,{present:r||s.open,children:c.jsx(Zy.Slot,{scope:e.__scopeMenu,children:o.modal?c.jsx(B0e,{...i,ref:t}):c.jsx(F0e,{...i,ref:t})})})})}),B0e=_.forwardRef((e,t)=>{const n=cm(Pa,e.__scopeMenu),r=_.useRef(null),i=Un(t,r);return _.useEffect(()=>{const s=r.current;if(s)return NE(s)},[]),c.jsx(rL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:st(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),F0e=_.forwardRef((e,t)=>{const n=cm(Pa,e.__scopeMenu);return c.jsx(rL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),z0e=Ip("MenuContent.ScrollLock"),rL=_.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,disableOutsideScroll:v,...x}=e,y=cm(Pa,n),w=_0(Pa,n),C=HE(n),k=bX(n),E=M0e(n),[N,T]=_.useState(null),R=_.useRef(null),M=Un(t,R,y.onContentChange),P=_.useRef(0),B=_.useRef(""),U=_.useRef(0),D=_.useRef(null),$=_.useRef("right"),I=_.useRef(0),V=v?f0:_.Fragment,z=v?{as:z0e,allowPinchZoom:!0}:void 0,H=Y=>{var oe,ge;const F=B.current+Y,O=E().filter(ne=>!ne.disabled),X=document.activeElement,te=(oe=O.find(ne=>ne.ref.current===X))==null?void 0:oe.textValue,ie=O.map(ne=>ne.textValue),ue=Z0e(ie,F,te),se=(ge=O.find(ne=>ne.textValue===ue))==null?void 0:ge.ref.current;(function ne(de){B.current=de,window.clearTimeout(P.current),de!==""&&(P.current=window.setTimeout(()=>ne(""),1e3))})(F),se&&setTimeout(()=>se.focus())};_.useEffect(()=>()=>window.clearTimeout(P.current),[]),kE();const W=_.useCallback(Y=>{var O,X;return $.current===((O=D.current)==null?void 0:O.side)&&tSe(Y,(X=D.current)==null?void 0:X.area)},[]);return c.jsx($0e,{scope:n,searchRef:B,onItemEnter:_.useCallback(Y=>{W(Y)&&Y.preventDefault()},[W]),onItemLeave:_.useCallback(Y=>{var F;W(Y)||((F=R.current)==null||F.focus(),T(null))},[W]),onTriggerLeave:_.useCallback(Y=>{W(Y)&&Y.preventDefault()},[W]),pointerGraceTimerRef:U,onPointerGraceIntentChange:_.useCallback(Y=>{D.current=Y},[]),children:c.jsx(V,{...z,children:c.jsx(d0,{asChild:!0,trapped:i,onMountAutoFocus:st(s,Y=>{var F;Y.preventDefault(),(F=R.current)==null||F.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:c.jsx(ub,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,children:c.jsx(E0e,{asChild:!0,...k,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:T,onEntryFocus:st(l,Y=>{w.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(IE,{role:"menu","aria-orientation":"vertical","data-state":$X(y.open),"data-radix-menu-content":"",dir:w.dir,...C,...x,ref:M,style:{outline:"none",...x.style},onKeyDown:st(x.onKeyDown,Y=>{const O=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,X=Y.ctrlKey||Y.altKey||Y.metaKey,te=Y.key.length===1;O&&(Y.key==="Tab"&&Y.preventDefault(),!X&&te&&H(Y.key));const ie=R.current;if(Y.target!==ie||!A0e.includes(Y.key))return;Y.preventDefault();const se=E().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);gX.includes(Y.key)&&se.reverse(),Q0e(se)}),onBlur:st(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(P.current),B.current="")}),onPointerMove:st(e.onPointerMove,e_(Y=>{const F=Y.target,O=I.current!==Y.clientX;if(Y.currentTarget.contains(F)&&O){const X=Y.clientX>I.current?"right":"left";$.current=X,I.current=Y.clientX}}))})})})})})})});SX.displayName=Pa;var U0e="MenuGroup",iL=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"group",...r,ref:t})});iL.displayName=U0e;var H0e="MenuLabel",wX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{...r,ref:t})});wX.displayName=H0e;var q1="MenuItem",M6="menu.itemSelect",WE=_.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=_.useRef(null),o=_0(q1,e.__scopeMenu),a=nL(q1,e.__scopeMenu),l=Un(t,s),u=_.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(M6,{bubbles:!0,cancelable:!0});h.addEventListener(M6,g=>r==null?void 0:r(g),{once:!0}),Oq(h,m),m.defaultPrevented?u.current=!1:o.onClose()}};return c.jsx(CX,{...i,ref:l,disabled:n,onClick:st(e.onClick,f),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:st(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:st(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||_M.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});WE.displayName=q1;var CX=_.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=nL(q1,n),a=bX(n),l=_.useRef(null),u=Un(t,l),[f,h]=_.useState(!1),[m,g]=_.useState("");return _.useEffect(()=>{const v=l.current;v&&g((v.textContent??"").trim())},[s.children]),c.jsx(Zy.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:c.jsx(N0e,{asChild:!0,...a,focusable:!r,children:c.jsx(wn.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:st(e.onPointerMove,e_(v=>{r?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:st(e.onPointerLeave,e_(v=>o.onItemLeave(v))),onFocus:st(e.onFocus,()=>h(!0)),onBlur:st(e.onBlur,()=>h(!1))})})})}),W0e="MenuCheckboxItem",kX=_.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return c.jsx(jX,{scope:e.__scopeMenu,checked:n,children:c.jsx(WE,{role:"menuitemcheckbox","aria-checked":Y1(n)?"mixed":n,...i,ref:t,"data-state":oL(n),onSelect:st(i.onSelect,()=>r==null?void 0:r(Y1(n)?!0:!n),{checkForDefaultPrevented:!1})})})});kX.displayName=W0e;var EX="MenuRadioGroup",[V0e,K0e]=lm(EX,{value:void 0,onValueChange:()=>{}}),NX=_.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gl(r);return c.jsx(V0e,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(iL,{...i,ref:t})})});NX.displayName=EX;var TX="MenuRadioItem",AX=_.forwardRef((e,t)=>{const{value:n,...r}=e,i=K0e(TX,e.__scopeMenu),s=n===i.value;return c.jsx(jX,{scope:e.__scopeMenu,checked:s,children:c.jsx(WE,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":oL(s),onSelect:st(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});AX.displayName=TX;var sL="MenuItemIndicator",[jX,G0e]=lm(sL,{checked:!1}),RX=_.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=G0e(sL,n);return c.jsx(Ga,{present:r||Y1(s.checked)||s.checked===!0,children:c.jsx(wn.span,{...i,ref:t,"data-state":oL(s.checked)})})});RX.displayName=sL;var q0e="MenuSeparator",MX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});MX.displayName=q0e;var Y0e="MenuArrow",PX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=HE(n);return c.jsx(OE,{...i,...r,ref:t})});PX.displayName=Y0e;var X0e="MenuSub",[jet,IX]=lm(X0e),Qx="MenuSubTrigger",OX=_.forwardRef((e,t)=>{const n=cm(Qx,e.__scopeMenu),r=_0(Qx,e.__scopeMenu),i=IX(Qx,e.__scopeMenu),s=nL(Qx,e.__scopeMenu),o=_.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},f=_.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),c.jsx(eL,{asChild:!0,...u,children:c.jsx(CX,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":$X(n.open),...e,ref:jD(t,i.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:st(e.onPointerMove,e_(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:st(e.onPointerLeave,e_(h=>{var g,v;f();const m=(g=n.content)==null?void 0:g.getBoundingClientRect();if(m){const x=(v=n.content)==null?void 0:v.dataset.side,y=x==="right",w=y?-5:5,C=m[y?"left":"right"],k=m[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:C,y:m.top},{x:k,y:m.top},{x:k,y:m.bottom},{x:C,y:m.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:st(e.onKeyDown,h=>{var g;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||j0e[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});OX.displayName=Qx;var DX="MenuSubContent",LX=_.forwardRef((e,t)=>{const n=yX(Pa,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=cm(Pa,e.__scopeMenu),o=_0(Pa,e.__scopeMenu),a=IX(DX,e.__scopeMenu),l=_.useRef(null),u=Un(t,l);return c.jsx(Zy.Provider,{scope:e.__scopeMenu,children:c.jsx(Ga,{present:r||s.open,children:c.jsx(Zy.Slot,{scope:e.__scopeMenu,children:c.jsx(rL,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:st(e.onFocusOutside,f=>{f.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:st(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:st(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),m=R0e[o.dir].includes(f.key);h&&m&&(s.onOpenChange(!1),(g=a.trigger)==null||g.focus(),f.preventDefault())})})})})})});LX.displayName=DX;function $X(e){return e?"open":"closed"}function Y1(e){return e==="indeterminate"}function oL(e){return Y1(e)?"indeterminate":e?"checked":"unchecked"}function Q0e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function J0e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Z0e(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=J0e(e,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function eSe(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],u=a.x,f=a.y,h=l.x,m=l.y;f>r!=m>r&&n<(h-u)*(r-f)/(m-f)+u&&(i=!i)}return i}function tSe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return eSe(n,t)}function e_(e){return t=>t.pointerType==="mouse"?e(t):void 0}var nSe=xX,rSe=eL,iSe=_X,sSe=SX,oSe=iL,aSe=wX,lSe=WE,cSe=kX,uSe=NX,dSe=AX,fSe=RX,hSe=MX,pSe=PX,mSe=OX,gSe=LX,aL="ContextMenu",[vSe]=qu(aL,[vX]),io=vX(),[bSe,BX]=vSe(aL),FX=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:s=!0}=e,[o,a]=_.useState(!1),l=io(t),u=gl(r),f=_.useCallback(h=>{a(h),u(h)},[u]);return c.jsx(bSe,{scope:t,open:o,onOpenChange:f,modal:s,children:c.jsx(nSe,{...l,dir:i,open:o,onOpenChange:f,modal:s,children:n})})};FX.displayName=aL;var zX="ContextMenuTrigger",UX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=BX(zX,n),o=io(n),a=_.useRef({x:0,y:0}),l=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(u.current),[]),h=m=>{a.current={x:m.clientX,y:m.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),c.jsxs(c.Fragment,{children:[c.jsx(rSe,{...o,virtualRef:l}),c.jsx(wn.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:st(e.onContextMenu,m=>{f(),h(m),m.preventDefault()}),onPointerDown:r?e.onPointerDown:st(e.onPointerDown,Cw(m=>{f(),u.current=window.setTimeout(()=>h(m),700)})),onPointerMove:r?e.onPointerMove:st(e.onPointerMove,Cw(f)),onPointerCancel:r?e.onPointerCancel:st(e.onPointerCancel,Cw(f)),onPointerUp:r?e.onPointerUp:st(e.onPointerUp,Cw(f))})]})});UX.displayName=zX;var xSe="ContextMenuPortal",HX=e=>{const{__scopeContextMenu:t,...n}=e,r=io(t);return c.jsx(iSe,{...r,...n})};HX.displayName=xSe;var WX="ContextMenuContent",VX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=BX(WX,n),s=io(n),o=_.useRef(!1);return c.jsx(sSe,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,a),!a.defaultPrevented&&o.current&&a.preventDefault(),o.current=!1},onInteractOutside:a=>{var l;(l=e.onInteractOutside)==null||l.call(e,a),!a.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.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)"}})});VX.displayName=WX;var ySe="ContextMenuGroup",_Se=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(oSe,{...i,...r,ref:t})});_Se.displayName=ySe;var SSe="ContextMenuLabel",wSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(aSe,{...i,...r,ref:t})});wSe.displayName=SSe;var CSe="ContextMenuItem",KX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(lSe,{...i,...r,ref:t})});KX.displayName=CSe;var kSe="ContextMenuCheckboxItem",ESe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(cSe,{...i,...r,ref:t})});ESe.displayName=kSe;var NSe="ContextMenuRadioGroup",TSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(uSe,{...i,...r,ref:t})});TSe.displayName=NSe;var ASe="ContextMenuRadioItem",jSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(dSe,{...i,...r,ref:t})});jSe.displayName=ASe;var RSe="ContextMenuItemIndicator",MSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(fSe,{...i,...r,ref:t})});MSe.displayName=RSe;var PSe="ContextMenuSeparator",GX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(hSe,{...i,...r,ref:t})});GX.displayName=PSe;var ISe="ContextMenuArrow",OSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(pSe,{...i,...r,ref:t})});OSe.displayName=ISe;var DSe="ContextMenuSubTrigger",LSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(mSe,{...i,...r,ref:t})});LSe.displayName=DSe;var $Se="ContextMenuSubContent",BSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(gSe,{...i,...r,ref:t,style:{...e.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)"}})});BSe.displayName=$Se;function Cw(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var FSe=FX,zSe=UX,USe=HX,qX=VX,YX=KX,XX=GX;const QX=_.createContext(null);function qf({onOpenChange:e,...t}){const[n,r]=_.useState(0),i=_.useCallback(()=>{r(s=>s+1),e==null||e(!1)},[e]);return c.jsx(QX.Provider,{value:i,children:c.jsx(FSe,{onOpenChange:e,...t},n)})}const Yf=zSe,Xu=_.forwardRef(({className:e,...t},n)=>c.jsx(USe,{children:c.jsx(qX,{ref:n,className:ce("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...t})}));Xu.displayName=qX.displayName;const Xn=_.forwardRef(({className:e,onSelect:t,...n},r)=>{const i=_.useContext(QX);return c.jsx(YX,{ref:r,className:ce("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium text-foreground outline-hidden transition-colors hover:bg-muted focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onSelect:s=>{t==null||t(s),i==null||i()},...n})});Xn.displayName=YX.displayName;const VE=_.forwardRef(({className:e,...t},n)=>c.jsx(XX,{ref:n,className:ce("-mx-1 my-1 h-px bg-border",e),...t}));VE.displayName=XX.displayName;var KE="Popover",[JX]=qu(KE,[Gf]),S0=Gf(),[HSe,Xf]=JX(KE),ZX=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,a=S0(t),l=_.useRef(null),[u,f]=_.useState(!1),[h,m]=Rv({prop:r,defaultProp:i??!1,onChange:s,caller:KE});return c.jsx(PE,{...a,children:c.jsx(HSe,{scope:t,contentId:ku(),triggerRef:l,open:h,onOpenChange:m,onOpenToggle:_.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>f(!0),[]),onCustomAnchorRemove:_.useCallback(()=>f(!1),[]),modal:o,children:n})})};ZX.displayName=KE;var eQ="PopoverAnchor",WSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Xf(eQ,n),s=S0(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=i;return _.useEffect(()=>(o(),()=>a()),[o,a]),c.jsx(m0,{...s,...r,ref:t})});WSe.displayName=eQ;var tQ="PopoverTrigger",nQ=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Xf(tQ,n),s=S0(n),o=Un(t,i.triggerRef),a=c.jsx(wn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":aQ(i.open),...r,ref:o,onClick:st(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:c.jsx(m0,{asChild:!0,...s,children:a})});nQ.displayName=tQ;var lL="PopoverPortal",[VSe,KSe]=JX(lL,{forceMount:void 0}),rQ=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Xf(lL,t);return c.jsx(VSe,{scope:t,forceMount:n,children:c.jsx(Ga,{present:n||s.open,children:c.jsx(db,{asChild:!0,container:i,children:r})})})};rQ.displayName=lL;var Iv="PopoverContent",iQ=_.forwardRef((e,t)=>{const n=KSe(Iv,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Xf(Iv,e.__scopePopover);return c.jsx(Ga,{present:r||s.open,children:s.modal?c.jsx(qSe,{...i,ref:t}):c.jsx(YSe,{...i,ref:t})})});iQ.displayName=Iv;var GSe=Ip("PopoverContent.RemoveScroll"),qSe=_.forwardRef((e,t)=>{const n=Xf(Iv,e.__scopePopover),r=_.useRef(null),i=Un(t,r),s=_.useRef(!1);return _.useEffect(()=>{const o=r.current;if(o)return NE(o)},[]),c.jsx(f0,{as:GSe,allowPinchZoom:!0,children:c.jsx(sQ,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:st(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:st(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:st(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),YSe=_.forwardRef((e,t)=>{const n=Xf(Iv,e.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return c.jsx(sQ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),sQ=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:f,...h}=e,m=Xf(Iv,n),g=S0(n);return kE(),c.jsx(d0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:c.jsx(ub,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:c.jsx(IE,{"data-state":aQ(m.open),role:"dialog",id:m.contentId,...g,...h,ref:t,style:{...h.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)"}})})})}),oQ="PopoverClose",XSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Xf(oQ,n);return c.jsx(wn.button,{type:"button",...r,ref:t,onClick:st(e.onClick,()=>i.onOpenChange(!1))})});XSe.displayName=oQ;var QSe="PopoverArrow",JSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=S0(n);return c.jsx(OE,{...i,...r,ref:t})});JSe.displayName=QSe;function aQ(e){return e?"open":"closed"}var ZSe=ZX,ewe=nQ,twe=rQ,lQ=iQ;const _c=ZSe,Sc=ewe,Nl=_.forwardRef(({className:e,align:t="center",sideOffset:n=4,ports:r={},...i},s)=>{const o=r.dom??Et;return c.jsx(twe,{children:c.jsx(lQ,{ref:s,align:t,sideOffset:n,[z1]:"",onCloseAutoFocus:a=>{var l;a.preventDefault(),o.dispatchCustomWindowEvent(DD),(l=i.onCloseAutoFocus)==null||l.call(i,a)},className:ce("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...i})})});Nl.displayName=lQ.displayName;const SM=Xt("StackActionsPopover",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function nwe({editorLabel:e,onOpenBoards:t,starred:n,onCopyPath:r,onShowArchived:i,onOpenInFinder:s,onOpenInEditor:o,onToggleStar:a,onHide:l,children:u}){return c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:u}),c.jsxs(Xu,{children:[t?c.jsxs(c.Fragment,{children:[c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),t()},children:[c.jsx(_E,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Boards"})]}),c.jsx(VE,{})]}):null,c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),a()},children:[n?c.jsx(Wge,{className:"h-3.5 w-3.5"}):c.jsx(mq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:n?"Unstar project":"Star project"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),r()},children:[c.jsx(na,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Copy Path"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),i()},children:[c.jsx(bD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show Archived"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),s()},children:[c.jsx(yE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show in Finder"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),o()},children:[c.jsx(xD,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Open in ",e]})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),l()},className:"text-destructive hover:bg-destructive/10 focus:bg-destructive/10",children:[c.jsx(Ape,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})]})]})}function rwe({canFork:e,onRename:t,onOpenInFinder:n,onFork:r,onArchive:i,onDelete:s,onEditPermissions:o,children:a}){return c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:a}),c.jsxs(Xu,{children:[c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),t()},children:[c.jsx(om,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),n()},children:[c.jsx(yE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Open in Finder"})]}),c.jsxs(Xn,{disabled:!e,onSelect:l=>{l.preventDefault(),e&&r()},children:[c.jsx(hq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Fork"})]}),o?c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),o()},children:[c.jsx(kD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Permissions…"})]}):null,c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),i()},children:[c.jsx(bD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Archive"})]}),c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),s()},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:[c.jsx(xc,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Delete"})]})]})]})}function iwe({stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s}){const o=SM.useScopedStore(u=>u.open),a=SM.useScopedStore(u=>u.setOpen);function l(u){return()=>{a(!1),u()}}return c.jsxs(_c,{open:o,onOpenChange:a,children:[c.jsx(Sc,{asChild:!0,children:s}),c.jsxs(Nl,{align:"end",sideOffset:4,className:"w-44 p-1",role:"menu","aria-label":`Actions for ${e}`,children:[t?c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:l(t),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(_E,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Boards"})]}),c.jsx("div",{className:"my-1 h-px bg-border"})]}):null,c.jsxs("button",{type:"button",role:"menuitem",onClick:l(n),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(om,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Rename"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:l(r),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(vq,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Edit members"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:l(i),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium text-destructive dark:text-red-400 hover:bg-destructive/10 focus-visible:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus-visible:bg-red-500/20 outline-hidden",children:[c.jsx(xc,{className:"h-3.5 w-3.5"}),c.jsxs("span",{children:["Delete ",e]})]})]})]})}function swe({stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s}){return c.jsx(SM.Provider,{init:{},children:c.jsx(iwe,{stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s})})}function owe({stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s}){return c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:s}),c.jsxs(Xu,{children:[t?c.jsxs(c.Fragment,{children:[c.jsxs(Xn,{onSelect:o=>{o.stopPropagation(),t()},children:[c.jsx(_E,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Boards"})]}),c.jsx(VE,{})]}):null,c.jsxs(Xn,{onSelect:o=>{o.preventDefault(),n()},children:[c.jsx(om,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(Xn,{onSelect:o=>{o.preventDefault(),r()},children:[c.jsx(vq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Edit members"})]}),c.jsxs(Xn,{onSelect:o=>{o.preventDefault(),i()},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:[c.jsx(xc,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Delete ",e]})]})]})]})}function awe({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onRenameChat:o,onOpenInFinder:a,onForkChat:l,onArchiveChat:u,onDeleteChat:f,onEditPermissions:h,silent:m=!1}){var R;const g=(e.status==="running"||e.status==="waiting_for_user")&&e.stateEnteredAt!=null,v=g&&e.stateEnteredAt!=null?`${kf(e.status)} ${Pu(n-e.stateEnteredAt)}`:xo(n-(e.lastMessageAt??e._creationTime)),x=i&&r?r:v,y=i&&!!r,w=rbe(e.chatId),C=t===w,k=((R=zE(e))==null?void 0:R.tone)??null;let E;e.canFork?E="w-12":g?E="w-12 md:w-20":E="w-6 md:w-14";let N=null;x&&(y?N=c.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-11 text-foreground transition-opacity duration-150 group-hover:opacity-0",children:c.jsx(XY,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-10",children:r})}):N=c.jsx("span",{className:ce("hidden md:flex absolute inset-0 items-center justify-end pr-1 text-11 tabular-nums transition-opacity duration-150 group-hover:opacity-0 whitespace-nowrap",g?lX(k):"text-muted-foreground"),children:x}));const T=c.jsxs("div",{"data-chat-id":w,className:ce("group flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-md cursor-pointer transition-colors duration-150",C?"bg-muted":"hover:bg-muted/40"),onClick:()=>s(e.chatId),children:[c.jsx("span",{className:"relative flex h-3.5 w-3.5 shrink-0 items-center justify-center","aria-hidden":!0,children:k?c.jsx("span",{className:ce("h-2 w-2 rounded-full",UE(k))}):null}),(()=>{const M=cX(e.sessionState);return M?c.jsx(ia,{label:M.title,children:c.jsx("span",{className:ce("shrink-0 text-10 leading-none",M.toneClass),"aria-label":M.title,children:M.glyph})}):null})(),e.hasPolicyOverride?c.jsx(kD,{className:"size-3 shrink-0 text-warning","aria-label":"Per-chat permission override active"}):null,c.jsx("span",{className:ce("truncate flex-1 text-sm",C?"text-foreground font-medium":"text-foreground/90",e.status==="idle"&&!e.unread&&!C?"text-muted-foreground":""),children:e.title}),m?c.jsx(XG,{className:"size-3 shrink-0 text-muted-foreground","aria-label":"Silenced"}):null,c.jsxs("div",{className:ce("relative h-6 shrink-0",E),children:[N,c.jsxs("div",{className:ce("absolute inset-0 flex items-center justify-end gap-0 transition-opacity duration-150",x?"opacity-100 md:opacity-0 md:group-hover:opacity-100":"opacity-100"),children:[e.canFork?c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:M=>{M.stopPropagation(),l(e.chatId)},title:"Fork chat",children:c.jsx(hq,{className:"size-3.5"})}):null,c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:M=>{M.stopPropagation(),u(e.chatId)},title:"Archive chat",children:c.jsx(bD,{className:"size-3.5"})})]})]})]},e._id);return c.jsx(rwe,{canFork:e.canFork,onRename:()=>o(e.chatId),onOpenInFinder:()=>a(e.localPath),onFork:()=>l(e.chatId),onArchive:()=>u(e.chatId),onDelete:()=>f(e.chatId),onEditPermissions:h?()=>h(e.chatId):void 0,children:T})}const lwe=_.memo(awe);function cwe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const GE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pb(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function cL(e){return"nodeType"in e}function Ao(e){var t,n;return e?pb(e)?e:cL(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function uL(e){const{Document:t}=Ao(e);return e instanceof t}function w0(e){return pb(e)?!1:e instanceof Ao(e).HTMLElement}function cQ(e){return e instanceof Ao(e).SVGElement}function mb(e){return e?pb(e)?e.document:cL(e)?uL(e)?e:w0(e)||cQ(e)?e.ownerDocument:document:document:document}const fc=GE?_.useLayoutEffect:_.useEffect;function dL(e){const t=_.useRef(e);return fc(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function uwe(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function t_(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return fc(()=>{n.current!==e&&(n.current=e)},t),n}function C0(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function X1(e){const t=dL(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function wM(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let RA={};function k0(e,t){return _.useMemo(()=>{if(t)return t;const n=RA[e]==null?0:RA[e]+1;return RA[e]=n,e+"-"+n},[e,t])}function uQ(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const a=Object.entries(o);for(const[l,u]of a){const f=s[l];f!=null&&(s[l]=f+e*u)}return s},{...t})}}const Jg=uQ(1),Q1=uQ(-1);function dwe(e){return"clientX"in e&&"clientY"in e}function fL(e){if(!e)return!1;const{KeyboardEvent:t}=Ao(e.target);return t&&e instanceof t}function fwe(e){if(!e)return!1;const{TouchEvent:t}=Ao(e.target);return t&&e instanceof t}function CM(e){if(fwe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return dwe(e)?{x:e.clientX,y:e.clientY}:null}const n_=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[n_.Translate.toString(e),n_.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),P6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function hwe(e){return e.matches(P6)?e:e.querySelector(P6)}const pwe={display:"none"};function mwe(e){let{id:t,value:n}=e;return Dn.createElement("div",{id:t,style:pwe},n)}function gwe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Dn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function vwe(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const dQ=_.createContext(null);function bwe(e){const t=_.useContext(dQ);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function xwe(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var a;return(a=o[i])==null?void 0:a.call(o,s)})},[e]),t]}const ywe={draggable:`
|
|
831
|
+
`)&&(w.writePathDeny=y),Object.keys(w).length===0?null:w}function g(){r(m())}function v(){r(null)}return c.jsxs(c.Fragment,{children:[c.jsx(La,{open:e,onOpenChange:x=>{x||i()},children:c.jsxs(ra,{className:"max-w-2xl",children:[c.jsxs($a,{children:["Permissions — ",t]}),c.jsxs(vl,{className:"space-y-5",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Default action"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Behaviour when a tool call has no explicit allow/deny rule. ",c.jsx("strong",{children:"auto-allow"})," bypasses prompts and runs untrusted shell commands without supervision — use a worktree."]}),c.jsx(Ji,{value:s,onValueChange:h,options:[{value:"ask",label:"Ask"},{value:"auto-allow",label:"Auto-allow (unsafe)"},{value:"auto-deny",label:"Auto-deny"}]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Read-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot read paths matching any entry. Defaults shown below — edit to add or remove."}),c.jsx("textarea",{value:o,onChange:x=>f.getState().setReadDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Write-path deny list"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"One glob per line. The model cannot edit or write paths matching any entry."}),c.jsx("textarea",{value:a,onChange:x=>f.getState().setWriteDenyText(x.target.value),rows:8,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs",spellCheck:!1})]})]}),c.jsxs(ju,{className:"justify-between",children:[c.jsx(Ee,{variant:"ghost",onClick:v,children:"Reset to defaults"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ee,{variant:"ghost",onClick:i,children:"Cancel"}),c.jsx(Ee,{onClick:g,children:"Apply"})]})]})]})}),c.jsx(La,{open:l,onOpenChange:x=>{x||(f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null))},children:c.jsxs(ra,{className:"max-w-md",children:[c.jsx($a,{children:"Enable auto-allow for this chat?"}),c.jsxs(vl,{className:"space-y-3 text-sm",children:[c.jsx("p",{children:"Auto-allow disables tool-call prompts. The model can run shell commands, write files, and edit code without asking. Read/write deny lists still apply."}),c.jsx("p",{className:"text-warning",children:"Use a worktree for risky tasks."})]}),c.jsxs(ju,{className:"justify-end gap-2",children:[c.jsx(Ee,{variant:"ghost",onClick:()=>{f.getState().setConfirmUnsafeOpen(!1),f.getState().setPendingDefaultAction(null)},children:"Cancel"}),c.jsx(Ee,{variant:"destructive",onClick:()=>{const x=f.getState();u&&x.setDefaultAction(u),x.setConfirmUnsafeOpen(!1),x.setPendingDefaultAction(null)},children:"Enable auto-allow"})]})]})})]})}const w_e={defaultAction:"ask",bash:{autoAllowVerbs:["ls","pwd","git status","git diff","git log"]},readPathDeny:["~/.ssh","~/.aws","~/.gcp","~/.config/gh","~/.claude","~/.kanna","~/Library/Keychains","/etc/shadow","/etc/sudoers","~/.gnupg","~/.gitconfig","**/.git/config","~/.npmrc","~/.netrc","~/.docker/config.json","**/.env","**/.env.*","**/credentials*","**/*.pem","**/*.key","**/id_rsa*","**/id_ed25519*"],writePathDeny:["/etc/**","/usr/**","/System/**","~/.ssh/**","~/.aws/**","~/.config/gh/**","~/.claude/**","~/.kanna/**","~/.gnupg/**","~/.gitconfig","**/.git/config"],toolDenyList:[{tool:"mcp__kanna__bash",pattern:"rm\\s+-rf\\s+(/|~|\\$HOME)(?:\\b|$|\\s)"},{tool:"mcp__kanna__bash",pattern:"git\\s+push\\b.*--force"}],toolAllowList:[]},Jn={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)},setInterval(e,t){return window.setInterval(e,t)},clearInterval(e){window.clearInterval(e)},requestAnimationFrame(e){return window.requestAnimationFrame(e)},cancelAnimationFrame(e){window.cancelAnimationFrame(e)}},Bt=_.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{ref:r,type:t,className:ce("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...n}));Bt.displayName="Input";const JY=_.createContext(null);function C_e({children:e,ports:t={}}){const n=t.timer??Jn,[r,i]=_.useState(null),[s,o]=_.useState(""),a=_.useRef(null);_.useEffect(()=>{(r==null?void 0:r.kind)==="prompt"&&(o(r.options.initialValue??""),n.setTimeout(()=>{var y,w;(y=a.current)==null||y.focus(),(w=a.current)==null||w.select()},0))},[r,n]);const l=_.useCallback(()=>{i(null),o("")},[]),u=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!1):r.kind==="prompt"?r.resolve(null):r.resolve(),l())},[l,r]),f=_.useCallback(()=>{r&&(r.kind==="confirm"?r.resolve(!0):r.kind==="prompt"?r.resolve(s.trim()||null):r.resolve(),l())},[l,r,s]),h=_.useCallback(y=>new Promise(w=>{i({kind:"confirm",options:y,resolve:w})}),[]),m=_.useCallback(y=>new Promise(w=>{i({kind:"prompt",options:y,resolve:w})}),[]),g=_.useCallback(y=>new Promise(w=>{i({kind:"alert",options:y,resolve:w})}),[]),v=_.useMemo(()=>({confirm:h,prompt:m,alert:g}),[g,h,m]);let x="Confirm";return r&&(r.kind==="alert"?x=r.options.closeLabel??"OK":"confirmLabel"in r.options&&(x=r.options.confirmLabel??"Confirm")),c.jsxs(JY.Provider,{value:v,children:[e,c.jsx(La,{open:r!==null,onOpenChange:y=>{y||!r||u()},children:c.jsx(ra,{size:"sm",onKeyDown:y=>{y.key!=="Enter"||y.shiftKey||!r||r.kind!=="confirm"||(y.preventDefault(),f())},children:r?c.jsxs(c.Fragment,{children:[c.jsxs(vl,{className:"space-y-4",children:[c.jsx($a,{children:r.options.title}),r.options.description?c.jsx(h0,{children:r.options.description}):null,r.kind==="prompt"?c.jsx(Bt,{ref:a,type:"text",value:s,onChange:y=>o(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),f())},placeholder:r.options.placeholder}):null]}),c.jsxs(ju,{children:[c.jsx(Ee,{variant:"ghost",size:"sm",onClick:u,className:r.kind==="alert"?"hidden":void 0,children:"cancelLabel"in r.options?r.options.cancelLabel??"Cancel":"Cancel"}),c.jsx(Ee,{variant:r.kind==="confirm"?r.options.confirmVariant??"default":"secondary",size:"sm",onClick:f,disabled:r.kind==="prompt"&&!s.trim(),children:x})]})]}):null})})]})}function $E(){const e=_.useContext(JY);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const qD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("bg-card text-card-foreground",e),...t}));qD.displayName="Card";const YD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("flex flex-col space-y-1.5 p-2",e),...t}));YD.displayName="CardHeader";const ZY=_.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ce("text-2xl font-semibold leading-none tracking-tight",e),...t}));ZY.displayName="CardTitle";const eX=_.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ce("text-sm text-muted-foreground",e),...t}));eX.displayName="CardDescription";const XD=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("p-6 pt-0",e),...t}));XD.displayName="CardContent";const k_e=_.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ce("flex items-center p-6 pt-0",e),...t}));k_e.displayName="CardFooter";const E_e={info:{dotVar:"var(--info)",bgClass:"bg-info/[0.06]"},warning:{dotVar:"var(--warning)",bgClass:"bg-warning/[0.06]"},success:{dotVar:"var(--success)",bgClass:"bg-success/[0.06]"},error:{dotVar:"var(--destructive)",bgClass:"bg-destructive/[0.06]"}};function N_e({variant:e,children:t,dot:n=!0,className:r}){const i=E_e[e];return c.jsxs("div",{role:"status",className:ce("flex flex-wrap items-center justify-center gap-x-2 gap-y-1 border-b border-border px-4 py-2 text-xs leading-tight",i.bgClass,r),children:[n?c.jsx("span",{"aria-hidden":"true",className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:i.dotVar}}):null,t]})}const T_e="modulepreload",A_e=function(e){return"/"+e},T6={},Z=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(u=>{if(u=A_e(u),u in T6)return;T6[u]=!0;const f=u.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":T_e,f||(m.as="script"),m.crossOrigin="",m.href=u,l&&m.setAttribute("nonce",l),document.head.appendChild(m),f)return new Promise((g,v)=>{m.addEventListener("load",g),m.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},j_e=_.lazy(()=>Z(()=>import("./index-CbfAvmid.js"),[]).then(e=>({default:e.Toaster})));function R_e(){return c.jsx(_.Suspense,{fallback:null,children:c.jsx(j_e,{position:"bottom-right",theme:"system",closeButton:!0,duration:6e3})})}const M_e="1.41.2",P_e={version:M_e},Vr="Kanna",A6="kanna",I_e=".kanna",O_e=".kanna-dev",D_e="KANNA_RUNTIME_PROFILE",QD=`kanna/${P_e.version}`,L_e="[kanna]",$_e=`~/${Vr}`;function BE(){const e=Reflect.get(globalThis,"process");return e==null?void 0:e.env}function B_e(e=BE()){var t;return((t=e==null?void 0:e[D_e])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function F_e(e=BE()){return B_e(e)==="dev"?O_e:I_e}function z_e(e=BE()){return`~/${F_e(e)}`}function U_e(e=BE()){return`${z_e(e)}/keybindings.json`}function ww(e){return e?`${A6} ${e}`:A6}const tX="always",nX="funk",H_e=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function W_e(e){switch(e){case"never":case"unfocused":case"always":return e;default:return tX}}function V_e(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return nX}}const np=Yt()(e=>({chatSoundPreference:tX,chatSoundId:nX,setChatSoundPreference:t=>e({chatSoundPreference:W_e(t)}),setChatSoundId:t=>e({chatSoundId:V_e(t)})})),K_e={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function G_e(e=Et){return e.getVisibilityState()!=="visible"||!e.hasFocus()}function q_e(e){const t=new Audio(K_e[e]);return t.preload="auto",t.play()}async function vM(e,t,n=Jn){if(t<=0)return;const r=Array.from({length:t},(i,s)=>new Promise(o=>{n.setTimeout(()=>{q_e(e).catch(()=>{}).finally(()=>o())},s*90)}));await Promise.all(r)}function Y_e(e,t=Et){return e==="never"?!1:e==="always"?!0:G_e(t)}function X_e(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function j6(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function Q_e(e,t){if(!e)return 0;const n=j6(e),r=j6(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}const rX="h-[var(--shell-top-band)] max-h-[var(--shell-top-band)]",J_e="md:my-2 md:mr-2 md:rounded-2xl md:border md:border-border",Z_e="flex min-h-0 flex-1 flex-col overflow-y-auto";function hu({tooltip:e,children:t,className:n,inline:r=!1,side:i}){const s=ce("truncate",n);return c.jsx(v0,{children:c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:r?c.jsx("span",{className:s,children:t}):c.jsx("div",{className:s,children:t})}),c.jsx(si,{side:i,children:e})]})})}function ia({label:e,children:t,side:n}){return c.jsx(v0,{children:c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:t}),c.jsx(si,{side:n,children:e})]})})}const e0e=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;function t0e(e){const t=e.match(e0e);return!t||t.length===0?null:t[t.length-1].toLowerCase()}function n0e(e){const t=[];for(const n of e.split(/[\s,]+/)){if(!n)continue;const r=t0e(n);r&&!t.includes(r)&&t.push(r)}return t}const bM=Yt()(e=>({text:"",setText:t=>e({text:t}),resetForOpen:()=>e({text:""})})),r0e=()=>bM(e=>e.text),Ma=_.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{"data-gramm":"false","data-gramm_editor":"false","data-enable-grammarly":"false","data-1p-ignore":!0,autoComplete:"off",className:ce("flex w-full rounded-lg border border-border bg-background px-2.5 py-2 text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ma.displayName="Textarea";function i0e({open:e,busy:t,onClose:n,onImportAll:r,onImportSessions:i}){const s=r0e(),o=bM(m=>m.setText),a=bM(m=>m.resetForOpen);_.useEffect(()=>{e&&a()},[e,a]);const l=_.useMemo(()=>n0e(s),[s]),f=s.trim().length>0&&l.length===0,h=()=>{l.length===0||t||i(l)};return c.jsx(La,{open:e,onOpenChange:m=>{m||n()},children:c.jsxs(ra,{size:"sm",children:[c.jsxs(vl,{className:"space-y-3",children:[c.jsx($a,{children:"Import Claude sessions"}),c.jsx(Ma,{value:s,onChange:m=>o(m.target.value),placeholder:"Paste one or more session ids (uuid, filename, or full path)…",rows:4}),f?c.jsx("p",{className:"text-xs text-destructive",children:"No valid session id found in the pasted text."}):null,c.jsx("p",{className:"text-xs text-muted-foreground",children:"Empty input imports ALL sessions (full scan). Active sessions import as a live view — sending a message there takes over the session."})]}),c.jsxs(ju,{children:[c.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,disabled:t,children:"Cancel"}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:"Import all"}),c.jsxs(Ee,{variant:"secondary",size:"sm",onClick:h,disabled:l.length===0||t,children:["Import ",l.length===1?"session":"sessions"]})]})]})})}function xM(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const s0e=[/^(?:\/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 iX(e){const t=e.trim();for(const n of s0e){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function b0(e){return e.split("/").pop()||e}const o0e=1440*6e4;function a0e(e,t){const n=Math.max(0,t-e),r=Math.floor(n/1e3),i=Math.floor(r/3600),s=Math.floor(r%3600/60),o=r%60;return i>0?`${i}h ${s}m`:s>0?`${s}m ${o}s`:`${o}s`}function l0e(e){const t=new Date(e),n=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0");return`${n}:${r}`}function c0e(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=o0e,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function sX(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`}const u0e=80;function d0e(e){return sX(e,u0e)}function f0e(e){return e.lastMessageAt??e._creationTime}const FE=1e3,Sy=60*FE,rp=60*Sy,WC=24*rp;function xo(e){const t=Math.max(0,e);if(t<Sy)return`${Math.floor(t/FE)}s`;if(t<rp)return`${Math.floor(t/Sy)}m`;if(t<WC){const i=Math.floor(t/rp),s=Math.floor(t%rp/Sy);return s===0?`${i}h`:`${i}h ${s}m`}const n=Math.floor(t/WC),r=Math.floor(t%WC/rp);return r===0?`${n}d`:`${n}d ${r}h`}function h0e(e){const t=Math.max(0,e),n=Math.ceil(t/FE);if(n<60)return`${String(n)}s`;const r=Math.ceil(t/Sy);if(r<60)return`${String(r)}m`;const i=Math.ceil(t/rp);return i<24?`${String(i)}h`:`${String(Math.ceil(t/WC))}d`}function Pu(e){const t=Math.max(0,e);if(t>=rp)return xo(t);const n=Math.floor(t/FE),r=Math.floor(n/60),i=n%60;return`${r}:${i.toString().padStart(2,"0")}`}function kf(e){switch(e){case"idle":return"Idle";case"starting":return"Starting";case"running":return"Running";case"waiting_for_user":return"Waiting";case"failed":return"Failed"}}function R6(e){switch(e){case"running":return"active";case"waiting_for_user":return"attention";case"failed":return"destructive";case"idle":case"starting":default:return"muted"}}function Jy(e){switch(e){case"active":return"text-emerald-500 dark:text-emerald-400";case"attention":return"text-amber-500 dark:text-amber-400";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function oX(e){switch(e){case"active":return"bg-emerald-500 dark:bg-emerald-400";case"attention":return"bg-amber-500 dark:bg-amber-400";case"destructive":return"bg-destructive";case"muted":default:return"bg-muted-foreground"}}function p0e(e){switch(e){case"running":return"Running";case"completed":return"Completed";case"failed":return"Failed";case"killed":return"Killed";case"unknown":return"Unknown"}}function aX(e){switch(e){case"running":return"active";case"failed":return"destructive";case"killed":return"attention";case"completed":case"unknown":default:return"muted"}}function zE(e){return e.status==="running"||e.status==="starting"?{tone:"warning",label:kf(e.status)}:e.status==="waiting_for_user"?{tone:"info",label:kf(e.status)}:e.status==="failed"?{tone:"destructive",label:kf(e.status)}:e.unread?{tone:"success",label:"Unread"}:null}function UE(e){switch(e){case"warning":return"bg-warning";case"info":return"bg-info";case"success":return"bg-success";case"destructive":return"bg-destructive";case"muted":return"bg-muted-foreground";default:return""}}function lX(e){switch(e){case"warning":return"text-warning";case"info":return"text-info";case"success":return"text-success";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function cX(e){switch(e){case"active":return{glyph:"●",toneClass:"text-success",title:"Claude PTY session active"};case"warming":return{glyph:"◐",toneClass:"text-warning",title:"Claude PTY session warming"};case"idle":return{glyph:"○",toneClass:"text-muted-foreground",title:"Claude PTY session idle"};case"cooling":return{glyph:"◌",toneClass:"text-muted-foreground",title:"Claude PTY session cooling down"};case"cold":default:return null}}function JD(e){const t=e+"CollectionProvider",[n,r]=qu(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:y,children:w}=x,C=Dn.useRef(null),k=Dn.useRef(new Map).current;return c.jsx(i,{scope:y,itemMap:k,collectionRef:C,children:w})};o.displayName=t;const a=e+"CollectionSlot",l=Ip(a),u=Dn.forwardRef((x,y)=>{const{scope:w,children:C}=x,k=s(a,w),E=Un(y,k.collectionRef);return c.jsx(l,{ref:E,children:C})});u.displayName=a;const f=e+"CollectionItemSlot",h="data-radix-collection-item",m=Ip(f),g=Dn.forwardRef((x,y)=>{const{scope:w,children:C,...k}=x,E=Dn.useRef(null),N=Un(y,E),T=s(f,w);return Dn.useEffect(()=>(T.itemMap.set(E,{ref:E,...k}),()=>void T.itemMap.delete(E))),c.jsx(m,{[h]:"",ref:N,children:C})});g.displayName=f;function v(x){const y=s(e+"CollectionConsumer",x);return Dn.useCallback(()=>{const C=y.collectionRef.current;if(!C)return[];const k=Array.from(C.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((T,R)=>k.indexOf(T.ref.current)-k.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:u,ItemSlot:g},v,r]}var m0e=_.createContext(void 0);function ZD(e){const t=_.useContext(m0e);return e||t||"ltr"}var jA="rovingFocusGroup.onEntryFocus",g0e={bubbles:!1,cancelable:!0},x0="RovingFocusGroup",[yM,uX,v0e]=JD(x0),[b0e,dX]=qu(x0,[v0e]),[x0e,y0e]=b0e(x0),fX=_.forwardRef((e,t)=>c.jsx(yM.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(yM.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(_0e,{...e,ref:t})})}));fX.displayName=x0;var _0e=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,m=_.useRef(null),g=Un(t,m),v=ZD(s),[x,y]=Rv({prop:o,defaultProp:a??null,onChange:l,caller:x0}),[w,C]=_.useState(!1),k=gl(u),E=uX(n),N=_.useRef(!1),[T,R]=_.useState(0);return _.useEffect(()=>{const M=m.current;if(M)return M.addEventListener(jA,k),()=>M.removeEventListener(jA,k)},[k]),c.jsx(x0e,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(M=>y(M),[y]),onItemShiftTab:_.useCallback(()=>C(!0),[]),onFocusableItemAdd:_.useCallback(()=>R(M=>M+1),[]),onFocusableItemRemove:_.useCallback(()=>R(M=>M-1),[]),children:c.jsx(wn.div,{tabIndex:w||T===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:st(e.onMouseDown,()=>{N.current=!0}),onFocus:st(e.onFocus,M=>{const P=!N.current;if(M.target===M.currentTarget&&P&&!w){const B=new CustomEvent(jA,g0e);if(M.currentTarget.dispatchEvent(B),!B.defaultPrevented){const U=E().filter(z=>z.focusable),D=U.find(z=>z.active),$=U.find(z=>z.id===x),V=[D,$,...U].filter(Boolean).map(z=>z.ref.current);mX(V,f)}}N.current=!1}),onBlur:st(e.onBlur,()=>C(!1))})})}),hX="RovingFocusGroupItem",pX=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=ku(),u=s||l,f=y0e(hX,n),h=f.currentTabStopId===u,m=uX(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),c.jsx(yM.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:c.jsx(wn.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:st(e.onMouseDown,y=>{r?f.onItemFocus(u):y.preventDefault()}),onFocus:st(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:st(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=C0e(y,f.orientation,f.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let k=m().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")k.reverse();else if(w==="prev"||w==="next"){w==="prev"&&k.reverse();const E=k.indexOf(y.currentTarget);k=f.loop?k0e(k,E+1):k.slice(E+1)}setTimeout(()=>mX(k))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});pX.displayName=hX;var S0e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function w0e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function C0e(e,t,n){const r=w0e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return S0e[r]}function mX(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function k0e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var E0e=fX,N0e=pX,_M=["Enter"," "],T0e=["ArrowDown","PageUp","Home"],gX=["ArrowUp","PageDown","End"],A0e=[...T0e,...gX],j0e={ltr:[..._M,"ArrowRight"],rtl:[..._M,"ArrowLeft"]},R0e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},y0="Menu",[Zy,M0e,P0e]=JD(y0),[lm,vX]=qu(y0,[P0e,Gf,dX]),HE=Gf(),bX=dX(),[I0e,cm]=lm(y0),[O0e,_0]=lm(y0),xX=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=HE(t),[l,u]=_.useState(null),f=_.useRef(!1),h=gl(s),m=ZD(i);return _.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(PE,{...a,children:c.jsx(I0e,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:u,children:c.jsx(O0e,{scope:t,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:m,modal:o,children:r})})})};xX.displayName=y0;var D0e="MenuAnchor",eL=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=HE(n);return c.jsx(m0,{...i,...r,ref:t})});eL.displayName=D0e;var tL="MenuPortal",[L0e,yX]=lm(tL,{forceMount:void 0}),_X=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=cm(tL,t);return c.jsx(L0e,{scope:t,forceMount:n,children:c.jsx(Ga,{present:n||s.open,children:c.jsx(db,{asChild:!0,container:i,children:r})})})};_X.displayName=tL;var Pa="MenuContent",[$0e,nL]=lm(Pa),SX=_.forwardRef((e,t)=>{const n=yX(Pa,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=cm(Pa,e.__scopeMenu),o=_0(Pa,e.__scopeMenu);return c.jsx(Zy.Provider,{scope:e.__scopeMenu,children:c.jsx(Ga,{present:r||s.open,children:c.jsx(Zy.Slot,{scope:e.__scopeMenu,children:o.modal?c.jsx(B0e,{...i,ref:t}):c.jsx(F0e,{...i,ref:t})})})})}),B0e=_.forwardRef((e,t)=>{const n=cm(Pa,e.__scopeMenu),r=_.useRef(null),i=Un(t,r);return _.useEffect(()=>{const s=r.current;if(s)return NE(s)},[]),c.jsx(rL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:st(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),F0e=_.forwardRef((e,t)=>{const n=cm(Pa,e.__scopeMenu);return c.jsx(rL,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),z0e=Ip("MenuContent.ScrollLock"),rL=_.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,disableOutsideScroll:v,...x}=e,y=cm(Pa,n),w=_0(Pa,n),C=HE(n),k=bX(n),E=M0e(n),[N,T]=_.useState(null),R=_.useRef(null),M=Un(t,R,y.onContentChange),P=_.useRef(0),B=_.useRef(""),U=_.useRef(0),D=_.useRef(null),$=_.useRef("right"),I=_.useRef(0),V=v?f0:_.Fragment,z=v?{as:z0e,allowPinchZoom:!0}:void 0,H=Y=>{var oe,ge;const F=B.current+Y,O=E().filter(ne=>!ne.disabled),X=document.activeElement,te=(oe=O.find(ne=>ne.ref.current===X))==null?void 0:oe.textValue,ie=O.map(ne=>ne.textValue),ue=Z0e(ie,F,te),se=(ge=O.find(ne=>ne.textValue===ue))==null?void 0:ge.ref.current;(function ne(de){B.current=de,window.clearTimeout(P.current),de!==""&&(P.current=window.setTimeout(()=>ne(""),1e3))})(F),se&&setTimeout(()=>se.focus())};_.useEffect(()=>()=>window.clearTimeout(P.current),[]),kE();const W=_.useCallback(Y=>{var O,X;return $.current===((O=D.current)==null?void 0:O.side)&&tSe(Y,(X=D.current)==null?void 0:X.area)},[]);return c.jsx($0e,{scope:n,searchRef:B,onItemEnter:_.useCallback(Y=>{W(Y)&&Y.preventDefault()},[W]),onItemLeave:_.useCallback(Y=>{var F;W(Y)||((F=R.current)==null||F.focus(),T(null))},[W]),onTriggerLeave:_.useCallback(Y=>{W(Y)&&Y.preventDefault()},[W]),pointerGraceTimerRef:U,onPointerGraceIntentChange:_.useCallback(Y=>{D.current=Y},[]),children:c.jsx(V,{...z,children:c.jsx(d0,{asChild:!0,trapped:i,onMountAutoFocus:st(s,Y=>{var F;Y.preventDefault(),(F=R.current)==null||F.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:c.jsx(ub,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:m,onDismiss:g,children:c.jsx(E0e,{asChild:!0,...k,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:N,onCurrentTabStopIdChange:T,onEntryFocus:st(l,Y=>{w.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(IE,{role:"menu","aria-orientation":"vertical","data-state":$X(y.open),"data-radix-menu-content":"",dir:w.dir,...C,...x,ref:M,style:{outline:"none",...x.style},onKeyDown:st(x.onKeyDown,Y=>{const O=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,X=Y.ctrlKey||Y.altKey||Y.metaKey,te=Y.key.length===1;O&&(Y.key==="Tab"&&Y.preventDefault(),!X&&te&&H(Y.key));const ie=R.current;if(Y.target!==ie||!A0e.includes(Y.key))return;Y.preventDefault();const se=E().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);gX.includes(Y.key)&&se.reverse(),Q0e(se)}),onBlur:st(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(P.current),B.current="")}),onPointerMove:st(e.onPointerMove,e_(Y=>{const F=Y.target,O=I.current!==Y.clientX;if(Y.currentTarget.contains(F)&&O){const X=Y.clientX>I.current?"right":"left";$.current=X,I.current=Y.clientX}}))})})})})})})});SX.displayName=Pa;var U0e="MenuGroup",iL=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"group",...r,ref:t})});iL.displayName=U0e;var H0e="MenuLabel",wX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{...r,ref:t})});wX.displayName=H0e;var q1="MenuItem",M6="menu.itemSelect",WE=_.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=_.useRef(null),o=_0(q1,e.__scopeMenu),a=nL(q1,e.__scopeMenu),l=Un(t,s),u=_.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(M6,{bubbles:!0,cancelable:!0});h.addEventListener(M6,g=>r==null?void 0:r(g),{once:!0}),Oq(h,m),m.defaultPrevented?u.current=!1:o.onClose()}};return c.jsx(CX,{...i,ref:l,disabled:n,onClick:st(e.onClick,f),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:st(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:st(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||_M.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});WE.displayName=q1;var CX=_.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=nL(q1,n),a=bX(n),l=_.useRef(null),u=Un(t,l),[f,h]=_.useState(!1),[m,g]=_.useState("");return _.useEffect(()=>{const v=l.current;v&&g((v.textContent??"").trim())},[s.children]),c.jsx(Zy.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:c.jsx(N0e,{asChild:!0,...a,focusable:!r,children:c.jsx(wn.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:st(e.onPointerMove,e_(v=>{r?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:st(e.onPointerLeave,e_(v=>o.onItemLeave(v))),onFocus:st(e.onFocus,()=>h(!0)),onBlur:st(e.onBlur,()=>h(!1))})})})}),W0e="MenuCheckboxItem",kX=_.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return c.jsx(jX,{scope:e.__scopeMenu,checked:n,children:c.jsx(WE,{role:"menuitemcheckbox","aria-checked":Y1(n)?"mixed":n,...i,ref:t,"data-state":oL(n),onSelect:st(i.onSelect,()=>r==null?void 0:r(Y1(n)?!0:!n),{checkForDefaultPrevented:!1})})})});kX.displayName=W0e;var EX="MenuRadioGroup",[V0e,K0e]=lm(EX,{value:void 0,onValueChange:()=>{}}),NX=_.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gl(r);return c.jsx(V0e,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(iL,{...i,ref:t})})});NX.displayName=EX;var TX="MenuRadioItem",AX=_.forwardRef((e,t)=>{const{value:n,...r}=e,i=K0e(TX,e.__scopeMenu),s=n===i.value;return c.jsx(jX,{scope:e.__scopeMenu,checked:s,children:c.jsx(WE,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":oL(s),onSelect:st(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});AX.displayName=TX;var sL="MenuItemIndicator",[jX,G0e]=lm(sL,{checked:!1}),RX=_.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=G0e(sL,n);return c.jsx(Ga,{present:r||Y1(s.checked)||s.checked===!0,children:c.jsx(wn.span,{...i,ref:t,"data-state":oL(s.checked)})})});RX.displayName=sL;var q0e="MenuSeparator",MX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(wn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});MX.displayName=q0e;var Y0e="MenuArrow",PX=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=HE(n);return c.jsx(OE,{...i,...r,ref:t})});PX.displayName=Y0e;var X0e="MenuSub",[jet,IX]=lm(X0e),Qx="MenuSubTrigger",OX=_.forwardRef((e,t)=>{const n=cm(Qx,e.__scopeMenu),r=_0(Qx,e.__scopeMenu),i=IX(Qx,e.__scopeMenu),s=nL(Qx,e.__scopeMenu),o=_.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},f=_.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),c.jsx(eL,{asChild:!0,...u,children:c.jsx(CX,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":$X(n.open),...e,ref:jD(t,i.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:st(e.onPointerMove,e_(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:st(e.onPointerLeave,e_(h=>{var g,v;f();const m=(g=n.content)==null?void 0:g.getBoundingClientRect();if(m){const x=(v=n.content)==null?void 0:v.dataset.side,y=x==="right",w=y?-5:5,C=m[y?"left":"right"],k=m[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+w,y:h.clientY},{x:C,y:m.top},{x:k,y:m.top},{x:k,y:m.bottom},{x:C,y:m.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:st(e.onKeyDown,h=>{var g;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||j0e[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});OX.displayName=Qx;var DX="MenuSubContent",LX=_.forwardRef((e,t)=>{const n=yX(Pa,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=cm(Pa,e.__scopeMenu),o=_0(Pa,e.__scopeMenu),a=IX(DX,e.__scopeMenu),l=_.useRef(null),u=Un(t,l);return c.jsx(Zy.Provider,{scope:e.__scopeMenu,children:c.jsx(Ga,{present:r||s.open,children:c.jsx(Zy.Slot,{scope:e.__scopeMenu,children:c.jsx(rL,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:st(e.onFocusOutside,f=>{f.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:st(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:st(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),m=R0e[o.dir].includes(f.key);h&&m&&(s.onOpenChange(!1),(g=a.trigger)==null||g.focus(),f.preventDefault())})})})})})});LX.displayName=DX;function $X(e){return e?"open":"closed"}function Y1(e){return e==="indeterminate"}function oL(e){return Y1(e)?"indeterminate":e?"checked":"unchecked"}function Q0e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function J0e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Z0e(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=J0e(e,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function eSe(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],u=a.x,f=a.y,h=l.x,m=l.y;f>r!=m>r&&n<(h-u)*(r-f)/(m-f)+u&&(i=!i)}return i}function tSe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return eSe(n,t)}function e_(e){return t=>t.pointerType==="mouse"?e(t):void 0}var nSe=xX,rSe=eL,iSe=_X,sSe=SX,oSe=iL,aSe=wX,lSe=WE,cSe=kX,uSe=NX,dSe=AX,fSe=RX,hSe=MX,pSe=PX,mSe=OX,gSe=LX,aL="ContextMenu",[vSe]=qu(aL,[vX]),io=vX(),[bSe,BX]=vSe(aL),FX=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:s=!0}=e,[o,a]=_.useState(!1),l=io(t),u=gl(r),f=_.useCallback(h=>{a(h),u(h)},[u]);return c.jsx(bSe,{scope:t,open:o,onOpenChange:f,modal:s,children:c.jsx(nSe,{...l,dir:i,open:o,onOpenChange:f,modal:s,children:n})})};FX.displayName=aL;var zX="ContextMenuTrigger",UX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=BX(zX,n),o=io(n),a=_.useRef({x:0,y:0}),l=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(u.current),[]),h=m=>{a.current={x:m.clientX,y:m.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),c.jsxs(c.Fragment,{children:[c.jsx(rSe,{...o,virtualRef:l}),c.jsx(wn.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:st(e.onContextMenu,m=>{f(),h(m),m.preventDefault()}),onPointerDown:r?e.onPointerDown:st(e.onPointerDown,Cw(m=>{f(),u.current=window.setTimeout(()=>h(m),700)})),onPointerMove:r?e.onPointerMove:st(e.onPointerMove,Cw(f)),onPointerCancel:r?e.onPointerCancel:st(e.onPointerCancel,Cw(f)),onPointerUp:r?e.onPointerUp:st(e.onPointerUp,Cw(f))})]})});UX.displayName=zX;var xSe="ContextMenuPortal",HX=e=>{const{__scopeContextMenu:t,...n}=e,r=io(t);return c.jsx(iSe,{...r,...n})};HX.displayName=xSe;var WX="ContextMenuContent",VX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=BX(WX,n),s=io(n),o=_.useRef(!1);return c.jsx(sSe,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,a),!a.defaultPrevented&&o.current&&a.preventDefault(),o.current=!1},onInteractOutside:a=>{var l;(l=e.onInteractOutside)==null||l.call(e,a),!a.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.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)"}})});VX.displayName=WX;var ySe="ContextMenuGroup",_Se=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(oSe,{...i,...r,ref:t})});_Se.displayName=ySe;var SSe="ContextMenuLabel",wSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(aSe,{...i,...r,ref:t})});wSe.displayName=SSe;var CSe="ContextMenuItem",KX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(lSe,{...i,...r,ref:t})});KX.displayName=CSe;var kSe="ContextMenuCheckboxItem",ESe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(cSe,{...i,...r,ref:t})});ESe.displayName=kSe;var NSe="ContextMenuRadioGroup",TSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(uSe,{...i,...r,ref:t})});TSe.displayName=NSe;var ASe="ContextMenuRadioItem",jSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(dSe,{...i,...r,ref:t})});jSe.displayName=ASe;var RSe="ContextMenuItemIndicator",MSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(fSe,{...i,...r,ref:t})});MSe.displayName=RSe;var PSe="ContextMenuSeparator",GX=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(hSe,{...i,...r,ref:t})});GX.displayName=PSe;var ISe="ContextMenuArrow",OSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(pSe,{...i,...r,ref:t})});OSe.displayName=ISe;var DSe="ContextMenuSubTrigger",LSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(mSe,{...i,...r,ref:t})});LSe.displayName=DSe;var $Se="ContextMenuSubContent",BSe=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=io(n);return c.jsx(gSe,{...i,...r,ref:t,style:{...e.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)"}})});BSe.displayName=$Se;function Cw(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var FSe=FX,zSe=UX,USe=HX,qX=VX,YX=KX,XX=GX;const QX=_.createContext(null);function qf({onOpenChange:e,...t}){const[n,r]=_.useState(0),i=_.useCallback(()=>{r(s=>s+1),e==null||e(!1)},[e]);return c.jsx(QX.Provider,{value:i,children:c.jsx(FSe,{onOpenChange:e,...t},n)})}const Yf=zSe,Xu=_.forwardRef(({className:e,...t},n)=>c.jsx(USe,{children:c.jsx(qX,{ref:n,className:ce("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...t})}));Xu.displayName=qX.displayName;const Xn=_.forwardRef(({className:e,onSelect:t,...n},r)=>{const i=_.useContext(QX);return c.jsx(YX,{ref:r,className:ce("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium text-foreground outline-hidden transition-colors hover:bg-muted focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onSelect:s=>{t==null||t(s),i==null||i()},...n})});Xn.displayName=YX.displayName;const VE=_.forwardRef(({className:e,...t},n)=>c.jsx(XX,{ref:n,className:ce("-mx-1 my-1 h-px bg-border",e),...t}));VE.displayName=XX.displayName;var KE="Popover",[JX]=qu(KE,[Gf]),S0=Gf(),[HSe,Xf]=JX(KE),ZX=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,a=S0(t),l=_.useRef(null),[u,f]=_.useState(!1),[h,m]=Rv({prop:r,defaultProp:i??!1,onChange:s,caller:KE});return c.jsx(PE,{...a,children:c.jsx(HSe,{scope:t,contentId:ku(),triggerRef:l,open:h,onOpenChange:m,onOpenToggle:_.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>f(!0),[]),onCustomAnchorRemove:_.useCallback(()=>f(!1),[]),modal:o,children:n})})};ZX.displayName=KE;var eQ="PopoverAnchor",WSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Xf(eQ,n),s=S0(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=i;return _.useEffect(()=>(o(),()=>a()),[o,a]),c.jsx(m0,{...s,...r,ref:t})});WSe.displayName=eQ;var tQ="PopoverTrigger",nQ=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Xf(tQ,n),s=S0(n),o=Un(t,i.triggerRef),a=c.jsx(wn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":aQ(i.open),...r,ref:o,onClick:st(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:c.jsx(m0,{asChild:!0,...s,children:a})});nQ.displayName=tQ;var lL="PopoverPortal",[VSe,KSe]=JX(lL,{forceMount:void 0}),rQ=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Xf(lL,t);return c.jsx(VSe,{scope:t,forceMount:n,children:c.jsx(Ga,{present:n||s.open,children:c.jsx(db,{asChild:!0,container:i,children:r})})})};rQ.displayName=lL;var Iv="PopoverContent",iQ=_.forwardRef((e,t)=>{const n=KSe(Iv,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Xf(Iv,e.__scopePopover);return c.jsx(Ga,{present:r||s.open,children:s.modal?c.jsx(qSe,{...i,ref:t}):c.jsx(YSe,{...i,ref:t})})});iQ.displayName=Iv;var GSe=Ip("PopoverContent.RemoveScroll"),qSe=_.forwardRef((e,t)=>{const n=Xf(Iv,e.__scopePopover),r=_.useRef(null),i=Un(t,r),s=_.useRef(!1);return _.useEffect(()=>{const o=r.current;if(o)return NE(o)},[]),c.jsx(f0,{as:GSe,allowPinchZoom:!0,children:c.jsx(sQ,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:st(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:st(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:st(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),YSe=_.forwardRef((e,t)=>{const n=Xf(Iv,e.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return c.jsx(sQ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),sQ=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:f,...h}=e,m=Xf(Iv,n),g=S0(n);return kE(),c.jsx(d0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:c.jsx(ub,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:c.jsx(IE,{"data-state":aQ(m.open),role:"dialog",id:m.contentId,...g,...h,ref:t,style:{...h.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)"}})})})}),oQ="PopoverClose",XSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Xf(oQ,n);return c.jsx(wn.button,{type:"button",...r,ref:t,onClick:st(e.onClick,()=>i.onOpenChange(!1))})});XSe.displayName=oQ;var QSe="PopoverArrow",JSe=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=S0(n);return c.jsx(OE,{...i,...r,ref:t})});JSe.displayName=QSe;function aQ(e){return e?"open":"closed"}var ZSe=ZX,ewe=nQ,twe=rQ,lQ=iQ;const _c=ZSe,Sc=ewe,Nl=_.forwardRef(({className:e,align:t="center",sideOffset:n=4,ports:r={},...i},s)=>{const o=r.dom??Et;return c.jsx(twe,{children:c.jsx(lQ,{ref:s,align:t,sideOffset:n,[z1]:"",onCloseAutoFocus:a=>{var l;a.preventDefault(),o.dispatchCustomWindowEvent(DD),(l=i.onCloseAutoFocus)==null||l.call(i,a)},className:ce("z-50 w-72 rounded-xl border border-border bg-background p-4 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...i})})});Nl.displayName=lQ.displayName;const SM=Xt("StackActionsPopover",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function nwe({editorLabel:e,onOpenBoards:t,starred:n,onCopyPath:r,onShowArchived:i,onOpenInFinder:s,onOpenInEditor:o,onToggleStar:a,onHide:l,children:u}){return c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:u}),c.jsxs(Xu,{children:[t?c.jsxs(c.Fragment,{children:[c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),t()},children:[c.jsx(_E,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Boards"})]}),c.jsx(VE,{})]}):null,c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),a()},children:[n?c.jsx(Wge,{className:"h-3.5 w-3.5"}):c.jsx(mq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:n?"Unstar project":"Star project"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),r()},children:[c.jsx(na,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Copy Path"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),i()},children:[c.jsx(bD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show Archived"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),s()},children:[c.jsx(yE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Show in Finder"})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),o()},children:[c.jsx(xD,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Open in ",e]})]}),c.jsxs(Xn,{onSelect:f=>{f.stopPropagation(),l()},className:"text-destructive hover:bg-destructive/10 focus:bg-destructive/10",children:[c.jsx(Ape,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})]})]})}function rwe({canFork:e,onRename:t,onOpenInFinder:n,onFork:r,onArchive:i,onDelete:s,onEditPermissions:o,children:a}){return c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:a}),c.jsxs(Xu,{children:[c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),t()},children:[c.jsx(om,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),n()},children:[c.jsx(yE,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Open in Finder"})]}),c.jsxs(Xn,{disabled:!e,onSelect:l=>{l.preventDefault(),e&&r()},children:[c.jsx(hq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Fork"})]}),o?c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),o()},children:[c.jsx(kD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Permissions…"})]}):null,c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),i()},children:[c.jsx(bD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Archive"})]}),c.jsxs(Xn,{onSelect:l=>{l.preventDefault(),s()},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:[c.jsx(xc,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Delete"})]})]})]})}function iwe({stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s}){const o=SM.useScopedStore(u=>u.open),a=SM.useScopedStore(u=>u.setOpen);function l(u){return()=>{a(!1),u()}}return c.jsxs(_c,{open:o,onOpenChange:a,children:[c.jsx(Sc,{asChild:!0,children:s}),c.jsxs(Nl,{align:"end",sideOffset:4,className:"w-44 p-1",role:"menu","aria-label":`Actions for ${e}`,children:[t?c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:l(t),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(_E,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Boards"})]}),c.jsx("div",{className:"my-1 h-px bg-border"})]}):null,c.jsxs("button",{type:"button",role:"menuitem",onClick:l(n),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(om,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Rename"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:l(r),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium hover:bg-muted focus-visible:bg-muted outline-hidden",children:[c.jsx(vq,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:"Edit members"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:l(i),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-xs font-medium text-destructive dark:text-red-400 hover:bg-destructive/10 focus-visible:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus-visible:bg-red-500/20 outline-hidden",children:[c.jsx(xc,{className:"h-3.5 w-3.5"}),c.jsxs("span",{children:["Delete ",e]})]})]})]})}function swe({stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s}){return c.jsx(SM.Provider,{init:{},children:c.jsx(iwe,{stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s})})}function owe({stackTitle:e,onOpenBoards:t,onRename:n,onEditMembers:r,onDelete:i,children:s}){return c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:s}),c.jsxs(Xu,{children:[t?c.jsxs(c.Fragment,{children:[c.jsxs(Xn,{onSelect:o=>{o.stopPropagation(),t()},children:[c.jsx(_E,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Boards"})]}),c.jsx(VE,{})]}):null,c.jsxs(Xn,{onSelect:o=>{o.preventDefault(),n()},children:[c.jsx(om,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),c.jsxs(Xn,{onSelect:o=>{o.preventDefault(),r()},children:[c.jsx(vq,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Edit members"})]}),c.jsxs(Xn,{onSelect:o=>{o.preventDefault(),i()},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:[c.jsx(xc,{className:"h-3.5 w-3.5"}),c.jsxs("span",{className:"text-xs font-medium",children:["Delete ",e]})]})]})]})}function awe({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onRenameChat:o,onOpenInFinder:a,onForkChat:l,onArchiveChat:u,onDeleteChat:f,onEditPermissions:h,silent:m=!1}){var R;const g=(e.status==="running"||e.status==="waiting_for_user")&&e.stateEnteredAt!=null,v=g&&e.stateEnteredAt!=null?`${kf(e.status)} ${Pu(n-e.stateEnteredAt)}`:xo(n-(e.lastMessageAt??e._creationTime)),x=i&&r?r:v,y=i&&!!r,w=rbe(e.chatId),C=t===w,k=((R=zE(e))==null?void 0:R.tone)??null,E=e.canFork?"min-w-12":"min-w-6";let N=null;x&&(y?N=c.jsx("span",{className:"hidden md:flex items-center justify-end pr-0.5 text-11 text-foreground transition-opacity duration-150 group-hover:opacity-0",children:c.jsx(XY,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-10",children:r})}):N=c.jsx("span",{className:ce("hidden md:flex items-center justify-end pr-1 text-11 tabular-nums transition-opacity duration-150 group-hover:opacity-0 whitespace-nowrap",g?lX(k):"text-muted-foreground"),children:x}));const T=c.jsxs("div",{"data-chat-id":w,className:ce("group flex items-center gap-2 pl-2 pr-1 py-1.5 rounded-md cursor-pointer transition-colors duration-150",C?"bg-muted":"hover:bg-muted/40"),onClick:()=>s(e.chatId),children:[c.jsx("span",{className:"relative flex h-3.5 w-3.5 shrink-0 items-center justify-center","aria-hidden":!0,children:k?c.jsx("span",{className:ce("h-2 w-2 rounded-full",UE(k))}):null}),(()=>{const M=cX(e.sessionState);return M?c.jsx(ia,{label:M.title,children:c.jsx("span",{className:ce("shrink-0 text-10 leading-none",M.toneClass),"aria-label":M.title,children:M.glyph})}):null})(),e.hasPolicyOverride?c.jsx(kD,{className:"size-3 shrink-0 text-warning","aria-label":"Per-chat permission override active"}):null,c.jsx("span",{className:ce("truncate flex-1 text-sm",C?"text-foreground font-medium":"text-foreground/90",e.status==="idle"&&!e.unread&&!C?"text-muted-foreground":""),children:e.title}),c.jsxs("div",{className:ce("relative flex items-center justify-end gap-1.5 h-6 shrink-0",E),children:[m?c.jsx(XG,{className:ce("size-3 shrink-0 text-muted-foreground transition-opacity duration-150",x?"group-hover:opacity-0":""),"aria-label":"Silenced"}):null,N,c.jsxs("div",{className:ce("absolute inset-0 flex items-center justify-end gap-0 transition-opacity duration-150",x?"opacity-100 md:opacity-0 md:group-hover:opacity-100":"opacity-100"),children:[e.canFork?c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:M=>{M.stopPropagation(),l(e.chatId)},title:"Fork chat",children:c.jsx(hq,{className:"size-3.5"})}):null,c.jsx(Ee,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:M=>{M.stopPropagation(),u(e.chatId)},title:"Archive chat",children:c.jsx(bD,{className:"size-3.5"})})]})]})]},e._id);return c.jsx(rwe,{canFork:e.canFork,onRename:()=>o(e.chatId),onOpenInFinder:()=>a(e.localPath),onFork:()=>l(e.chatId),onArchive:()=>u(e.chatId),onDelete:()=>f(e.chatId),onEditPermissions:h?()=>h(e.chatId):void 0,children:T})}const lwe=_.memo(awe);function cwe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const GE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function pb(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function cL(e){return"nodeType"in e}function Ao(e){var t,n;return e?pb(e)?e:cL(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function uL(e){const{Document:t}=Ao(e);return e instanceof t}function w0(e){return pb(e)?!1:e instanceof Ao(e).HTMLElement}function cQ(e){return e instanceof Ao(e).SVGElement}function mb(e){return e?pb(e)?e.document:cL(e)?uL(e)?e:w0(e)||cQ(e)?e.ownerDocument:document:document:document}const fc=GE?_.useLayoutEffect:_.useEffect;function dL(e){const t=_.useRef(e);return fc(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function uwe(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function t_(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return fc(()=>{n.current!==e&&(n.current=e)},t),n}function C0(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function X1(e){const t=dL(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function wM(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let RA={};function k0(e,t){return _.useMemo(()=>{if(t)return t;const n=RA[e]==null?0:RA[e]+1;return RA[e]=n,e+"-"+n},[e,t])}function uQ(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const a=Object.entries(o);for(const[l,u]of a){const f=s[l];f!=null&&(s[l]=f+e*u)}return s},{...t})}}const Jg=uQ(1),Q1=uQ(-1);function dwe(e){return"clientX"in e&&"clientY"in e}function fL(e){if(!e)return!1;const{KeyboardEvent:t}=Ao(e.target);return t&&e instanceof t}function fwe(e){if(!e)return!1;const{TouchEvent:t}=Ao(e.target);return t&&e instanceof t}function CM(e){if(fwe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return dwe(e)?{x:e.clientX,y:e.clientY}:null}const n_=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[n_.Translate.toString(e),n_.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),P6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function hwe(e){return e.matches(P6)?e:e.querySelector(P6)}const pwe={display:"none"};function mwe(e){let{id:t,value:n}=e;return Dn.createElement("div",{id:t,style:pwe},n)}function gwe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Dn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function vwe(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const dQ=_.createContext(null);function bwe(e){const t=_.useContext(dQ);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function xwe(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var a;return(a=o[i])==null?void 0:a.call(o,s)})},[e]),t]}const ywe={draggable:`
|
|
832
832
|
To pick up a draggable item, press the space bar.
|
|
833
833
|
While dragging, use the arrow keys to move the item.
|
|
834
834
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -2750,7 +2750,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[hN(e),e])),Bje=new Map([["s",Ni(383)],[Ni(38
|
|
|
2750
2750
|
`:"").join("");return c.jsx(qre,{source:r,lang:n},Bi())}if(Ot(e)){const n=e.getListType(),r=Dd(e),i=Bi();return n==="number"?c.jsx("ol",{className:"list-decimal ml-5 my-2",children:r},i):c.jsx("ul",{className:"list-disc ml-5 my-2",children:r},i)}if(Sn(e)){const n=e.getChecked(),r=Dd(e),i=Bi();return n!==void 0?c.jsxs("li",{className:"my-0.5 list-none flex items-start gap-1.5",children:[c.jsx("input",{type:"checkbox",readOnly:!0,checked:n,className:"mt-[3px] shrink-0"}),c.jsx("span",{children:r})]},i):c.jsx("li",{className:"my-0.5",children:r},i)}if(bo(e)||nf(e)){const n=e.getURL();return c.jsx("a",{href:n,className:"transition-all underline decoration-2 text-logo decoration-logo/50 hover:text-logo/70 dark:text-logo dark:decoration-logo/70 dark:hover:text-logo/60 dark:hover:decoration-logo/40",target:"_blank",rel:"noopener noreferrer",children:Dd(e)},Bi())}if(hr(e)){const n=e.getChildren(),r=n[0],i=r!==void 0&&lr(r)&&r.getChildren().every(a=>kt(a)&&(a.getHeaderStyles()&An.ROW)!==0),s=i?r:void 0,o=i?n.slice(1):n;return c.jsx("div",{className:"border border-border rounded-xl overflow-x-auto",children:c.jsxs("table",{className:"table-auto min-w-full divide-y divide-border bg-background",children:[s!==void 0&&c.jsx("thead",{children:c.jsx("tr",{children:s.getChildren().map(a=>c.jsx("th",{className:"text-left text-xs uppercase text-muted-foreground tracking-wider p-2 pl-0 first:pl-3 bg-muted dark:bg-card [&_*]:font-semibold",children:Dd(a)},Bi()))})}),c.jsx("tbody",{className:"divide-y divide-border",children:o.map(a=>lr(a)?c.jsx("tr",{children:a.getChildren().map(l=>kt(l)?c.jsx("td",{className:"text-left p-2 pl-0 first:pl-3 [&_*]:font-normal",children:Dd(l)},Bi()):null)},Bi()):null)})]})},Bi())}if(bi(e))return c.jsx("br",{},Bi());if($e(e))return J3e(e);if(Yv(e))return c.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:e.getTextContent()},Bi());const t=e.getTextContent();return t?c.jsx("span",{children:t},Bi()):null}function J3e(e){const t=e.getFormat(),n=e.getTextContent(),r=(t&w_)!==0,i=(t&C_)!==0,s=(t&k_)!==0,o=(t&x5)!==0;let a=n;return o?c.jsx("code",{className:"break-all px-1 bg-border/60 py-0.5 rounded text-sm",children:n},Bi()):(s&&(a=c.jsx("del",{className:"line-through",children:a},Bi())),i&&(a=c.jsx("em",{className:"italic",children:a},Bi())),r&&(a=c.jsx("strong",{className:"font-semibold",children:a},Bi())),!r&&!i&&!s?n:a)}function Dd(e){return e.getChildren().map(Xre)}function Z3e(){Yre=0;const t=Mn().getChildren();return c.jsx(c.Fragment,{children:t.map(Xre)})}function Yp(e,t=Vre){const n=one(m3({namespace:"kanna-md-renderer",nodes:Q3e,editable:!1}));return n.update(()=>{Ire(e,t,void 0,!0)},{discrete:!0}),n.getEditorState().read(()=>Z3e())}const vI=Xt("ThinkingBlock",()=>e=>({expanded:!1,setExpanded:t=>e({expanded:t})}));function e$e({content:e}){const t=vI.useScopedStore(i=>i.expanded),n=vI.useScopedStore(i=>i.setExpanded),r=e.trim();return r.length===0?null:c.jsxs("div",{className:"my-3 first:mt-0 last:mb-0",children:[c.jsxs("button",{type:"button",onClick:()=>n(!t),"aria-expanded":t,className:"group/thinking flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[c.jsx(BC,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Thinking"}),c.jsx(Da,{className:ce("h-3.5 w-3.5 transition-transform duration-200",t&&"rotate-90")})]}),t&&c.jsx("div",{className:"mt-2 border-l-2 border-muted-foreground/20 pl-3 text-sm text-muted-foreground italic prose prose-sm dark:prose-invert max-w-[70ch]",children:Yp(r)})]})}const KN=_.memo(({content:e})=>c.jsx(vI.Provider,{init:void 0,children:c.jsx(e$e,{content:e})}));class z_ extends ed{constructor(n,r,i,s,o=Et){super(s);K(this,"__mentionKind");K(this,"__value");K(this,"__label");K(this,"__dom");this.__mentionKind=n,this.__value=r,this.__label=i,this.__dom=o}static getType(){return"kanna-mention"}static clone(n){return new z_(n.__mentionKind,n.__value,n.__label,n.__key,n.__dom)}static importJSON(n){return bI({mentionKind:n.mentionKind,value:n.value,label:n.label})}exportJSON(){return{type:z_.getType(),version:1,mentionKind:this.__mentionKind,value:this.__value,label:this.__label}}createDOM(n,r){const i=this.__dom.createElement("span");return i.dataset.lexicalDecorator="true",i}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return this.__mentionKind==="agent"?`@agent/${this.__value}`:`@${this.__value}`}decorate(n,r){const i=this.__label;return this.__mentionKind==="agent"?c.jsx("span",{className:ce("inline-flex items-center rounded px-1 text-sm","bg-primary/10 text-primary border border-primary/20"),children:i}):c.jsx("span",{className:ce("inline-flex items-center rounded px-1 text-sm","bg-muted text-muted-foreground border border-border"),children:i})}}function bI(e){return yi(new z_(e.mentionKind,e.value,e.label))}class U_ extends ed{constructor(n,r,i,s=Et){super(i);K(this,"__commandName");K(this,"__hasArgument");K(this,"__dom");this.__commandName=n,this.__hasArgument=r,this.__dom=s}static getType(){return"kanna-slash-command"}static clone(n){return new U_(n.__commandName,n.__hasArgument,n.__key,n.__dom)}static importJSON(n){return Qre({commandName:n.commandName,hasArgument:n.hasArgument})}exportJSON(){return{type:U_.getType(),version:1,commandName:this.__commandName,hasArgument:this.__hasArgument}}createDOM(n,r){const i=this.__dom.createElement("span");return i.dataset.lexicalDecorator="true",i}updateDOM(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return this.__hasArgument?`/${this.__commandName} `:`/${this.__commandName}`}decorate(n,r){return c.jsx("span",{className:ce("inline-flex items-center rounded px-1 text-sm font-mono","bg-muted text-muted-foreground border border-border"),children:`/${this.__commandName}`})}}function Qre(e){return yi(new U_(e.commandName,e.hasArgument))}class Jv extends ed{constructor(n,r,i=Et){super(r);K(this,"__attachment");K(this,"__dom");this.__attachment=n,this.__dom=i}static getType(){return"kanna-attachment"}static clone(n){return new Jv(n.__attachment,n.__key,n.__dom)}static importJSON(n){return g3(n.attachment)}getAttachment(){return this.getLatest().__attachment}isInline(){return!0}isKeyboardSelectable(){return!0}getTextContent(){return""}createDOM(n,r){return this.__dom.createElement("span")}updateDOM(){return!1}exportJSON(){return{type:Jv.getType(),version:1,attachment:this.__attachment}}decorate(n,r){const i=this.getLatest().__attachment;return i.kind==="image"&&i.contentUrl?c.jsx(vN,{attachment:i,size:"composer"}):c.jsx(ea,{attachment:i})}}function g3(e){return yi(new Jv(e))}function t$e(){return sOe(Jv)}const n$e=.25,r$e=8,cW=.25;function uW(e){return Math.min(r$e,Math.max(n$e,e))}function i$e(){return e=>({scale:1,offset:{x:0,y:0},drag:null,zoomIn:()=>e(t=>{const n=uW(t.scale+cW);return n===t.scale?t:{scale:n}}),zoomOut:()=>e(t=>{const n=uW(t.scale-cW);return n===t.scale?t:{scale:n}}),resetView:()=>e({scale:1,offset:{x:0,y:0}}),beginDrag:(t,n)=>e(r=>({drag:{x:t-r.offset.x,y:n-r.offset.y}})),dragTo:(t,n)=>e(r=>r.drag?{offset:{x:t-r.drag.x,y:n-r.drag.y}}:r),endDrag:()=>e({drag:null})})}const su=Xt("MermaidZoomModal",i$e);function s$e({svg:e,onClose:t,ports:n}){const r=(n==null?void 0:n.dom)??Et,i=su.useScopedStore(v=>v.scale),s=su.useScopedStore(v=>v.offset),o=su.useScopedStore(v=>v.zoomIn),a=su.useScopedStore(v=>v.zoomOut),l=su.useScopedStore(v=>v.resetView),u=su.useScopedStore(v=>v.beginDrag),f=su.useScopedStore(v=>v.dragTo),h=su.useScopedStore(v=>v.endDrag);_.useEffect(()=>{const v=x=>{x.key==="Escape"&&t()};return r.addWindowListener("keydown",v)},[t,r]);const m=v=>u(v.clientX,v.clientY),g=v=>f(v.clientX,v.clientY);return to.createPortal(c.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-background/95",role:"dialog","aria-modal":"true","aria-label":"Diagram zoom view",children:[c.jsxs("div",{className:"flex justify-end gap-1 p-2",children:[c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":"Zoom out",className:"h-9 w-9",onClick:a,children:c.jsx(lq,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":"Zoom in",className:"h-9 w-9",onClick:o,children:c.jsx(No,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":"Reset view",className:"h-9 w-9",onClick:l,children:c.jsx(dge,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":"Close",className:"h-9 w-9",onClick:t,children:c.jsx(xi,{className:"h-4 w-4"})})]}),c.jsx("div",{className:"flex-1 overflow-hidden touch-none cursor-grab active:cursor-grabbing",onPointerDown:m,onPointerMove:g,onPointerUp:h,onPointerLeave:h,children:c.jsx("div",{"data-mermaid-stage":!0,className:"w-full h-full flex items-center justify-center",style:{transform:`translate(${s.x}px, ${s.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e}})})]}),r.getBodyElement())}function o$e({svg:e,onClose:t,ports:n}){return c.jsx(su.Provider,{init:void 0,children:c.jsx(s$e,{svg:e,onClose:t,ports:n})})}const ou=Xt("MermaidDiagram",()=>e=>({renderState:{status:"loading"},showSource:!1,zoomOpen:!1,copied:!1,setRenderState:t=>e({renderState:t}),setShowSource:t=>e({showSource:t}),setZoomOpen:t=>e({zoomOpen:t}),setCopied:t=>e({copied:t})})),dW=/error on line (\d+)\s*[.:]?\s*(.*)$/i,a$e=/^[\s-]*\^\s*$/;function fW(e){return e.map(t=>t.trim()).filter(t=>t.length>0).join(" ")}function l$e(e){const t=e.trim();if(t.length===0)return{line:null,summary:"Unknown error",excerpt:null};const n=t.split(`
|
|
2751
2751
|
`),r=n.findIndex(h=>dW.test(h)),i=r===-1?null:dW.exec(n[r]??"");if(i===null)return{line:null,summary:fW(n),excerpt:null};const s=Number(i[1]),o=n.slice(r+1),a=o.findIndex(h=>a$e.test(h)),l=a===-1?null:o.slice(0,a+1).join(`
|
|
2752
2752
|
`),u=a===-1?o:o.slice(a+1),f=fW([i[2]??"",...u]);return{line:Number.isInteger(s)?s:null,summary:f.length>0?f:`Parse error on line ${String(s)}`,excerpt:l}}const c$e=[{from:"-.x",to:"-.-x"},{from:"-.o",to:"-.-o"}],fC={"[":"]","(":")","{":"}"};function u$e(e){const t=[];let n="",r=1,i=0,s=!1,o=!1,a=!1;const l=[];for(;i<e.length;){const u=e[i]??"";if(u===`
|
|
2753
|
-
`){o=!1,a=!1,s=!1,l.length=0,r+=1,n+=u,i+=1;continue}if(o){n+=u,i+=1;continue}if(s){u==='"'&&(s=!1),n+=u,i+=1;continue}if(u==='"'){s=!0,n+=u,i+=1;continue}if(e.startsWith("%%",i)){o=!0,n+="%%",i+=2;continue}if(l.length>0){u===l[l.length-1]?l.pop():fC[u]&&l.push(fC[u]),n+=u,i+=1;continue}if(fC[u]){l.push(fC[u]),n+=u,i+=1;continue}if(u==="|"){a=!a,n+=u,i+=1;continue}if(a){n+=u,i+=1;continue}const f=c$e.find(h=>e.startsWith(h.from,i));if(f){n+=f.to,t.push({line:r,from:f.from,to:f.to}),i+=f.from.length;continue}n+=u,i+=1}return{source:n,repairs:t}}const d$e=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed"];function f$e(e){const t=e.message.toLowerCase();return d$e.some(n=>t.includes(n))}function h$e(e){let t=null;return()=>(t||(t=e().catch(n=>{throw t=null,m5(n)})),t)}const p$e=h$e(()=>Z(()=>import("./mermaid.core-CDJeRmO6.js").then(e=>e.bm),[]).then(e=>e.default));async function m$e(e,t,n){try{const{svg:r}=await e.render(t,n);return{svg:r,repairs:[]}}catch(r){const i=u$e(n);if(i.repairs.length===0)throw r;try{const{svg:s}=await e.render(`${t}-repaired`,i.source);return{svg:s,repairs:i.repairs}}catch{throw r}}}function g$e(e){const t=[];for(const n of e){const r=`${n.from} → ${n.to}`;t.includes(r)||t.push(r)}return t.join(", ")}function v$e({source:e,ports:t}){const{resolvedTheme:n}=VN(),r=n==="dark"?"dark":"default",i=ou.useScopedStore(k=>k.renderState),s=i.status==="error"?i.message:void 0,o=i.status==="error"&&i.kind==="stale-chunk",a=ou.useScopedStore(k=>k.showSource),l=ou.useScopedStore(k=>k.zoomOpen),u=ou.useScopedStore(k=>k.copied),f=ou.useScopedStore(k=>k.setRenderState),h=ou.useScopedStore(k=>k.setShowSource),m=ou.useScopedStore(k=>k.setZoomOpen),g=ou.useScopedStore(k=>k.setCopied),x=`mermaid-${_.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=_.useCallback(()=>m(!1),[m]),w=async()=>{await((t==null?void 0:t.clipboard)??aa).writeText(e),g(!0),((t==null?void 0:t.timer)??Jn).setTimeout(()=>g(!1),2e3)},C=(t==null?void 0:t.loadMermaid)??p$e;if(_.useEffect(()=>{let k=!1;return C().then(async E=>{E.initialize({startOnLoad:!1,securityLevel:"strict",theme:r});const{svg:N,repairs:T}=await m$e(E,x,e);k||f({status:"ready",svg:N,repairs:T})}).catch(E=>{if(k)return;const N=m5(E);if(f$e(N)){f({status:"error",kind:"stale-chunk"});return}f({status:"error",message:N.message})}),()=>{k=!0}},[e,r,x,f,C]),o)return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(Mf,{className:"size-3.5 shrink-0"}),c.jsx("span",{children:"This diagram needs the latest version of the app."}),c.jsxs(Ee,{variant:"ghost",size:"sm","aria-label":"Reload the app",className:"h-6 px-2 text-xs",onClick:()=>((t==null?void 0:t.dom)??Et).reload(),children:[c.jsx(u0,{className:"size-3 mr-1"}),"Reload"]})]}),c.jsx(Jw,{source:e})]});if(i.status==="error"){const k=l$e(s??"");return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-destructive mb-1",children:[c.jsx(Mf,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("span",{children:["Couldn't render this Mermaid diagram",k.line!==null?c.jsxs("span",{className:"text-muted-foreground",children:[" — line ",c.jsx("span",{className:"tabular-nums",children:k.line})]}):null]}),c.jsx("div",{className:"text-muted-foreground",children:k.summary}),k.excerpt?c.jsx("pre",{className:"mt-1 overflow-x-auto rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs leading-snug whitespace-pre text-muted-foreground",children:k.excerpt}):null]})]}),c.jsx(Jw,{source:e,highlightLine:k.line??void 0})]})}return i.status==="loading"?c.jsx("div",{className:"relative group/mermaid",children:c.jsx(Jw,{source:e})}):a?c.jsxs("div",{className:"relative group/mermaid",children:[c.jsx(Jw,{source:e}),c.jsx(hW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:void 0})]}):c.jsxs("div",{className:"relative group/mermaid my-3",children:[i.repairs.length>0&&c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(cve,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("span",{children:["Corrected ",c.jsx("span",{className:"tabular-nums",children:i.repairs.length}),i.repairs.length===1?" invalid link":" invalid links"," to render this (",c.jsx("span",{className:"font-mono",children:g$e(i.repairs)}),"). The source is unchanged."]})]}),c.jsx("div",{className:"flex justify-center overflow-x-auto",dangerouslySetInnerHTML:{__html:i.svg}}),c.jsx(hW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:()=>m(!0)}),l&&c.jsx(o$e,{svg:i.svg,onClose:y})]})}function Jre({source:e,ports:t}){return c.jsx(ou.Provider,{init:void 0,children:c.jsx(v$e,{source:e,ports:t})})}function hW({showSource:e,onToggleSource:t,onCopy:n,copied:r,onZoom:i}){return c.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 opacity-100 md:opacity-0 md:group-hover/mermaid:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",children:[i&&!e&&c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":"Zoom diagram",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:i,children:c.jsx(Pme,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":e?"View rendered diagram":"View diagram source",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:t,children:c.jsx(aM,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":r?"Copied":"Copy diagram source",className:ce("h-8 w-8 rounded-md text-muted-foreground",!r&&"hover:text-foreground",r&&"hover:!bg-transparent"),onClick:n,children:r?c.jsx(Cs,{className:"h-4 w-4 text-success"}):c.jsx(na,{className:"h-4 w-4"})})]})}class zf extends ed{constructor(n,r,i=Et){super(r);K(this,"__source");K(this,"__dom");this.__source=n,this.__dom=i}static getType(){return"kanna-mermaid"}static clone(n){return new zf(n.__source,n.__key,n.__dom)}static importJSON(n){return Zre(n.source)}exportJSON(){return{type:zf.getType(),version:1,source:this.__source}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__source}decorate(n,r){return c.jsx(Jre,{source:this.__source})}}function Zre(e){return yi(new zf(e))}function b$e(e){return e instanceof zf}function x$e(e,t=28){if(e.length<=t)return e;const n="…",r=e.lastIndexOf("."),i=r>0&&e.length-r<=6,s=i?e.slice(r):"",o=i?e.slice(0,r):e,a=t-n.length-s.length;if(a<=2){const f=t-n.length,h=Math.ceil(f/2),m=Math.floor(f/2);return`${e.slice(0,h)}${n}${e.slice(e.length-m)}`}const l=Math.ceil(a/2),u=a-l;return`${o.slice(0,l)}${n}${o.slice(o.length-u)}${s}`}const y$e=new Set([".c",".cc",".cfg",".conf",".cpp",".cs",".css",".diff",".env",".go",".graphql",".h",".hpp",".html",".ini",".java",".js",".json",".jsonc",".jsx",".kt",".log",".lua",".md",".mjs",".patch",".php",".pl",".properties",".py",".rb",".rs",".scss",".sh",".sql",".swift",".toml",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml",".zsh"]),_$e=new Set([".gitignore",".npmrc",".prettierrc",".python-version",".ruby-version",".tool-versions","Dockerfile","Gemfile","Makefile","Procfile"]);function hC(e){if(!e)return;const t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function pW(e){var r,i;const t=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(e);if((r=t==null?void 0:t.groups)!=null&&r.path)return{path:t.groups.path,line:hC(t.groups.line),column:hC(t.groups.column)};const n=/^(?<path>\/.+?):(?<line>\d+)(?::(?<column>\d+))?$/.exec(e);return(i=n==null?void 0:n.groups)!=null&&i.path?{path:n.groups.path,line:hC(n.groups.line),column:hC(n.groups.column)}:e.startsWith("/")?{path:e}:null}function S$e(e,t=Et){if(!e)return null;const n=e.trim();if(!n||/^(mailto:|ftp:|file:)/i.test(n))return null;if(/^https?:/i.test(n))try{const r=new URL(n);return r.origin!==t.getOrigin()||!r.pathname.startsWith("/")?null:pW(`${r.pathname}${r.hash}`)}catch{return null}return pW(n)}function w$e(e){const t=e.split(/[\\/]/);for(;t.length>0&&t[t.length-1]==="";)t.pop();const n=t.length>0?t[t.length-1]:e;if(_$e.has(n))return!0;const r=n.lastIndexOf(".");if(r<0)return!0;const i=n.slice(r).toLowerCase();return y$e.has(i)}const C$e=["/Users/","/home/","/private/","/tmp/","/var/","/opt/","/root/"];function k$e(e){return e?e.startsWith("file://")?!0:C$e.some(t=>e.startsWith(t)):!1}function eie(e){let t=e;if(t.startsWith("file://"))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.slice(7)}return`/api/local-file?path=${encodeURIComponent(t)}`}function bf(e,t){if(!e)return"";if(t){const n=t.endsWith("/")?t:`${t}/`;if(e.startsWith(n))return e.slice(n.length);if(e===t)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function Ab(e,t){return{id:e.id,contentUrl:e.contentUrl,displayName:e.displayName,fileName:e.displayName,relativePath:e.relativePath,mimeType:e.mimeType,size:e.size,origin:t}}const sy=Xt("LocalFileLinkCard",()=>e=>({probe:{kind:"loading"},previewOpen:!1,setProbe:t=>e({probe:t}),setPreviewOpen:t=>e({previewOpen:t})}));function E$e(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function N$e({path:e,linkText:t}){const n=_.useMemo(()=>eie(e),[e]),r=sy.useScopedStore(T=>T.probe),i=sy.useScopedStore(T=>T.previewOpen),s=sy.useScopedStore(T=>T.setProbe),o=sy.useScopedStore(T=>T.setPreviewOpen);_.useEffect(()=>{const T=new AbortController;return g5(n,{signal:T.signal}).then(R=>{T.signal.aborted||s(R)}),()=>T.abort()},[n,s]);const a=E$e(e),l=t||a,u=x$e(l,28),f=r.kind==="ready"?r.mimeType:"application/octet-stream",h=r.kind==="ready"?r.size:0,m={id:`local-file-${n}`,kind:"file",displayName:u,absolutePath:e,relativePath:e,contentUrl:n,mimeType:f,size:h};if(r.kind==="missing")return c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(ea,{attachment:m,disabledReason:"File no longer available"})});const g=mm(m),v=P0(g,f),x=h>0?gm(h):null,y=r.kind==="loading",w=r.kind==="error";let C;y?C=c.jsx("span",{className:"text-muted-foreground",children:"Fetching…"}):w?C=c.jsx("span",{className:"text-muted-foreground",children:"Unable to load"}):C=c.jsxs(c.Fragment,{children:[v,x?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:x})]}):null]});const k=r.kind==="ready"?_b(m):null,E=k!==null&&!k.openInNewTab,N=[E?"Preview":"Download",l,v,x].filter(T=>!!T);return E?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(ea,{attachment:m,onClick:()=>o(!0),meta:C,ariaLabel:N.join(", ")})}),c.jsx(Sm,{source:i?Ab(m,"local_file_link"):null,open:i,onOpenChange:o})]}):c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(ea,{attachment:m,href:n,download:a,meta:C,ariaLabel:N.join(", ")})})}function T$e({path:e,linkText:t}){return c.jsx(sy.Provider,{init:void 0,children:c.jsx(N$e,{path:e,linkText:t})})}class Uf extends ed{constructor(n,r,i,s,o=Et){super(s);K(this,"__path");K(this,"__line");K(this,"__column");K(this,"__dom");this.__path=n,this.__line=r,this.__column=i,this.__dom=o}static getType(){return"kanna-local-file-link"}static clone(n){return new Uf(n.__path,n.__line,n.__column,n.__key,n.__dom)}static importJSON(n){return tie({path:n.path,line:n.line,column:n.column})}exportJSON(){const n={type:Uf.getType(),version:1,path:this.__path};return this.__line!==void 0&&(n.line=this.__line),this.__column!==void 0&&(n.column=this.__column),n}createDOM(n,r){return this.__dom.createElement("span")}updateDOM(){return!1}isInline(){return!0}getTextContent(){return this.__path}decorate(n,r){const i=this.__line!==void 0?`${this.__path}:${this.__line}${this.__column!==void 0?`:${this.__column}`:""}`:void 0;return c.jsx(T$e,{path:this.__path,linkText:i})}}function tie(e){return yi(new Uf(e.path,e.line,e.column))}function A$e(e){return e instanceof Uf}class H_ extends ed{constructor(n,r,i=Et){super(r);K(this,"__content");K(this,"__dom");this.__content=n,this.__dom=i}static getType(){return"kanna-thinking"}static clone(n){return new H_(n.__content,n.__key,n.__dom)}static importJSON(n){return j$e(n.content)}exportJSON(){return{type:H_.getType(),version:1,content:this.__content}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__content}decorate(n,r){return c.jsx(KN,{content:this.__content})}}function j$e(e){return yi(new H_(e))}const R$e=[z_,U_,Jv],M$e=[zf,Uf,H_],P$e=/^[ \t]*(`{3,})[ \t]*mermaid[ \t]*$/i,I$e=/^[ \t]*`{3,}[ \t]*$/;function O$e(e){return new RegExp(`^[ \\t]*\`{${String(e)},}[ \\t]*$`)}function D$e(e,t,n){const r=O$e(n.length),i=[];let s=t;for(let o=t+1;o<e.length;o++){const a=e[o];if(a===void 0||(s=o,r.test(a)))break;i.push(a)}return{source:i.join(`
|
|
2753
|
+
`){o=!1,a=!1,s=!1,l.length=0,r+=1,n+=u,i+=1;continue}if(o){n+=u,i+=1;continue}if(s){u==='"'&&(s=!1),n+=u,i+=1;continue}if(u==='"'){s=!0,n+=u,i+=1;continue}if(e.startsWith("%%",i)){o=!0,n+="%%",i+=2;continue}if(l.length>0){u===l[l.length-1]?l.pop():fC[u]&&l.push(fC[u]),n+=u,i+=1;continue}if(fC[u]){l.push(fC[u]),n+=u,i+=1;continue}if(u==="|"){a=!a,n+=u,i+=1;continue}if(a){n+=u,i+=1;continue}const f=c$e.find(h=>e.startsWith(h.from,i));if(f){n+=f.to,t.push({line:r,from:f.from,to:f.to}),i+=f.from.length;continue}n+=u,i+=1}return{source:n,repairs:t}}const d$e=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed"];function f$e(e){const t=e.message.toLowerCase();return d$e.some(n=>t.includes(n))}function h$e(e){let t=null;return()=>(t||(t=e().catch(n=>{throw t=null,m5(n)})),t)}const p$e=h$e(()=>Z(()=>import("./mermaid.core-htyOC5rr.js").then(e=>e.bm),[]).then(e=>e.default));async function m$e(e,t,n){try{const{svg:r}=await e.render(t,n);return{svg:r,repairs:[]}}catch(r){const i=u$e(n);if(i.repairs.length===0)throw r;try{const{svg:s}=await e.render(`${t}-repaired`,i.source);return{svg:s,repairs:i.repairs}}catch{throw r}}}function g$e(e){const t=[];for(const n of e){const r=`${n.from} → ${n.to}`;t.includes(r)||t.push(r)}return t.join(", ")}function v$e({source:e,ports:t}){const{resolvedTheme:n}=VN(),r=n==="dark"?"dark":"default",i=ou.useScopedStore(k=>k.renderState),s=i.status==="error"?i.message:void 0,o=i.status==="error"&&i.kind==="stale-chunk",a=ou.useScopedStore(k=>k.showSource),l=ou.useScopedStore(k=>k.zoomOpen),u=ou.useScopedStore(k=>k.copied),f=ou.useScopedStore(k=>k.setRenderState),h=ou.useScopedStore(k=>k.setShowSource),m=ou.useScopedStore(k=>k.setZoomOpen),g=ou.useScopedStore(k=>k.setCopied),x=`mermaid-${_.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=_.useCallback(()=>m(!1),[m]),w=async()=>{await((t==null?void 0:t.clipboard)??aa).writeText(e),g(!0),((t==null?void 0:t.timer)??Jn).setTimeout(()=>g(!1),2e3)},C=(t==null?void 0:t.loadMermaid)??p$e;if(_.useEffect(()=>{let k=!1;return C().then(async E=>{E.initialize({startOnLoad:!1,securityLevel:"strict",theme:r});const{svg:N,repairs:T}=await m$e(E,x,e);k||f({status:"ready",svg:N,repairs:T})}).catch(E=>{if(k)return;const N=m5(E);if(f$e(N)){f({status:"error",kind:"stale-chunk"});return}f({status:"error",message:N.message})}),()=>{k=!0}},[e,r,x,f,C]),o)return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(Mf,{className:"size-3.5 shrink-0"}),c.jsx("span",{children:"This diagram needs the latest version of the app."}),c.jsxs(Ee,{variant:"ghost",size:"sm","aria-label":"Reload the app",className:"h-6 px-2 text-xs",onClick:()=>((t==null?void 0:t.dom)??Et).reload(),children:[c.jsx(u0,{className:"size-3 mr-1"}),"Reload"]})]}),c.jsx(Jw,{source:e})]});if(i.status==="error"){const k=l$e(s??"");return c.jsxs("div",{className:"my-3",children:[c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-destructive mb-1",children:[c.jsx(Mf,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("span",{children:["Couldn't render this Mermaid diagram",k.line!==null?c.jsxs("span",{className:"text-muted-foreground",children:[" — line ",c.jsx("span",{className:"tabular-nums",children:k.line})]}):null]}),c.jsx("div",{className:"text-muted-foreground",children:k.summary}),k.excerpt?c.jsx("pre",{className:"mt-1 overflow-x-auto rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs leading-snug whitespace-pre text-muted-foreground",children:k.excerpt}):null]})]}),c.jsx(Jw,{source:e,highlightLine:k.line??void 0})]})}return i.status==="loading"?c.jsx("div",{className:"relative group/mermaid",children:c.jsx(Jw,{source:e})}):a?c.jsxs("div",{className:"relative group/mermaid",children:[c.jsx(Jw,{source:e}),c.jsx(hW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:void 0})]}):c.jsxs("div",{className:"relative group/mermaid my-3",children:[i.repairs.length>0&&c.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground mb-1",children:[c.jsx(cve,{className:"size-3.5 shrink-0 mt-px"}),c.jsxs("span",{children:["Corrected ",c.jsx("span",{className:"tabular-nums",children:i.repairs.length}),i.repairs.length===1?" invalid link":" invalid links"," to render this (",c.jsx("span",{className:"font-mono",children:g$e(i.repairs)}),"). The source is unchanged."]})]}),c.jsx("div",{className:"flex justify-center overflow-x-auto",dangerouslySetInnerHTML:{__html:i.svg}}),c.jsx(hW,{showSource:a,onToggleSource:()=>h(!a),onCopy:w,copied:u,onZoom:()=>m(!0)}),l&&c.jsx(o$e,{svg:i.svg,onClose:y})]})}function Jre({source:e,ports:t}){return c.jsx(ou.Provider,{init:void 0,children:c.jsx(v$e,{source:e,ports:t})})}function hW({showSource:e,onToggleSource:t,onCopy:n,copied:r,onZoom:i}){return c.jsxs("div",{className:"absolute top-1.5 right-1.5 flex gap-1 opacity-100 md:opacity-0 md:group-hover/mermaid:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",children:[i&&!e&&c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":"Zoom diagram",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:i,children:c.jsx(Pme,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":e?"View rendered diagram":"View diagram source",className:"h-8 w-8 rounded-md text-muted-foreground hover:text-foreground",onClick:t,children:c.jsx(aM,{className:"h-4 w-4"})}),c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":r?"Copied":"Copy diagram source",className:ce("h-8 w-8 rounded-md text-muted-foreground",!r&&"hover:text-foreground",r&&"hover:!bg-transparent"),onClick:n,children:r?c.jsx(Cs,{className:"h-4 w-4 text-success"}):c.jsx(na,{className:"h-4 w-4"})})]})}class zf extends ed{constructor(n,r,i=Et){super(r);K(this,"__source");K(this,"__dom");this.__source=n,this.__dom=i}static getType(){return"kanna-mermaid"}static clone(n){return new zf(n.__source,n.__key,n.__dom)}static importJSON(n){return Zre(n.source)}exportJSON(){return{type:zf.getType(),version:1,source:this.__source}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__source}decorate(n,r){return c.jsx(Jre,{source:this.__source})}}function Zre(e){return yi(new zf(e))}function b$e(e){return e instanceof zf}function x$e(e,t=28){if(e.length<=t)return e;const n="…",r=e.lastIndexOf("."),i=r>0&&e.length-r<=6,s=i?e.slice(r):"",o=i?e.slice(0,r):e,a=t-n.length-s.length;if(a<=2){const f=t-n.length,h=Math.ceil(f/2),m=Math.floor(f/2);return`${e.slice(0,h)}${n}${e.slice(e.length-m)}`}const l=Math.ceil(a/2),u=a-l;return`${o.slice(0,l)}${n}${o.slice(o.length-u)}${s}`}const y$e=new Set([".c",".cc",".cfg",".conf",".cpp",".cs",".css",".diff",".env",".go",".graphql",".h",".hpp",".html",".ini",".java",".js",".json",".jsonc",".jsx",".kt",".log",".lua",".md",".mjs",".patch",".php",".pl",".properties",".py",".rb",".rs",".scss",".sh",".sql",".swift",".toml",".ts",".tsx",".txt",".vue",".xml",".yaml",".yml",".zsh"]),_$e=new Set([".gitignore",".npmrc",".prettierrc",".python-version",".ruby-version",".tool-versions","Dockerfile","Gemfile","Makefile","Procfile"]);function hC(e){if(!e)return;const t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function pW(e){var r,i;const t=/^(?<path>\/.+?)#L(?<line>\d+)(?:C(?<column>\d+))?$/.exec(e);if((r=t==null?void 0:t.groups)!=null&&r.path)return{path:t.groups.path,line:hC(t.groups.line),column:hC(t.groups.column)};const n=/^(?<path>\/.+?):(?<line>\d+)(?::(?<column>\d+))?$/.exec(e);return(i=n==null?void 0:n.groups)!=null&&i.path?{path:n.groups.path,line:hC(n.groups.line),column:hC(n.groups.column)}:e.startsWith("/")?{path:e}:null}function S$e(e,t=Et){if(!e)return null;const n=e.trim();if(!n||/^(mailto:|ftp:|file:)/i.test(n))return null;if(/^https?:/i.test(n))try{const r=new URL(n);return r.origin!==t.getOrigin()||!r.pathname.startsWith("/")?null:pW(`${r.pathname}${r.hash}`)}catch{return null}return pW(n)}function w$e(e){const t=e.split(/[\\/]/);for(;t.length>0&&t[t.length-1]==="";)t.pop();const n=t.length>0?t[t.length-1]:e;if(_$e.has(n))return!0;const r=n.lastIndexOf(".");if(r<0)return!0;const i=n.slice(r).toLowerCase();return y$e.has(i)}const C$e=["/Users/","/home/","/private/","/tmp/","/var/","/opt/","/root/"];function k$e(e){return e?e.startsWith("file://")?!0:C$e.some(t=>e.startsWith(t)):!1}function eie(e){let t=e;if(t.startsWith("file://"))try{t=decodeURIComponent(new URL(t).pathname)}catch{t=t.slice(7)}return`/api/local-file?path=${encodeURIComponent(t)}`}function bf(e,t){if(!e)return"";if(t){const n=t.endsWith("/")?t:`${t}/`;if(e.startsWith(n))return e.slice(n.length);if(e===t)return""}return e.replace(/^\/home\/user\/workspace\//,"")}function Ab(e,t){return{id:e.id,contentUrl:e.contentUrl,displayName:e.displayName,fileName:e.displayName,relativePath:e.relativePath,mimeType:e.mimeType,size:e.size,origin:t}}const sy=Xt("LocalFileLinkCard",()=>e=>({probe:{kind:"loading"},previewOpen:!1,setProbe:t=>e({probe:t}),setPreviewOpen:t=>e({previewOpen:t})}));function E$e(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function N$e({path:e,linkText:t}){const n=_.useMemo(()=>eie(e),[e]),r=sy.useScopedStore(T=>T.probe),i=sy.useScopedStore(T=>T.previewOpen),s=sy.useScopedStore(T=>T.setProbe),o=sy.useScopedStore(T=>T.setPreviewOpen);_.useEffect(()=>{const T=new AbortController;return g5(n,{signal:T.signal}).then(R=>{T.signal.aborted||s(R)}),()=>T.abort()},[n,s]);const a=E$e(e),l=t||a,u=x$e(l,28),f=r.kind==="ready"?r.mimeType:"application/octet-stream",h=r.kind==="ready"?r.size:0,m={id:`local-file-${n}`,kind:"file",displayName:u,absolutePath:e,relativePath:e,contentUrl:n,mimeType:f,size:h};if(r.kind==="missing")return c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(ea,{attachment:m,disabledReason:"File no longer available"})});const g=mm(m),v=P0(g,f),x=h>0?gm(h):null,y=r.kind==="loading",w=r.kind==="error";let C;y?C=c.jsx("span",{className:"text-muted-foreground",children:"Fetching…"}):w?C=c.jsx("span",{className:"text-muted-foreground",children:"Unable to load"}):C=c.jsxs(c.Fragment,{children:[v,x?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:x})]}):null]});const k=r.kind==="ready"?_b(m):null,E=k!==null&&!k.openInNewTab,N=[E?"Preview":"Download",l,v,x].filter(T=>!!T);return E?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(ea,{attachment:m,onClick:()=>o(!0),meta:C,ariaLabel:N.join(", ")})}),c.jsx(Sm,{source:i?Ab(m,"local_file_link"):null,open:i,onOpenChange:o})]}):c.jsx("span",{className:"inline-flex align-bottom","data-testid":"local-file-link",children:c.jsx(ea,{attachment:m,href:n,download:a,meta:C,ariaLabel:N.join(", ")})})}function T$e({path:e,linkText:t}){return c.jsx(sy.Provider,{init:void 0,children:c.jsx(N$e,{path:e,linkText:t})})}class Uf extends ed{constructor(n,r,i,s,o=Et){super(s);K(this,"__path");K(this,"__line");K(this,"__column");K(this,"__dom");this.__path=n,this.__line=r,this.__column=i,this.__dom=o}static getType(){return"kanna-local-file-link"}static clone(n){return new Uf(n.__path,n.__line,n.__column,n.__key,n.__dom)}static importJSON(n){return tie({path:n.path,line:n.line,column:n.column})}exportJSON(){const n={type:Uf.getType(),version:1,path:this.__path};return this.__line!==void 0&&(n.line=this.__line),this.__column!==void 0&&(n.column=this.__column),n}createDOM(n,r){return this.__dom.createElement("span")}updateDOM(){return!1}isInline(){return!0}getTextContent(){return this.__path}decorate(n,r){const i=this.__line!==void 0?`${this.__path}:${this.__line}${this.__column!==void 0?`:${this.__column}`:""}`:void 0;return c.jsx(T$e,{path:this.__path,linkText:i})}}function tie(e){return yi(new Uf(e.path,e.line,e.column))}function A$e(e){return e instanceof Uf}class H_ extends ed{constructor(n,r,i=Et){super(r);K(this,"__content");K(this,"__dom");this.__content=n,this.__dom=i}static getType(){return"kanna-thinking"}static clone(n){return new H_(n.__content,n.__key,n.__dom)}static importJSON(n){return j$e(n.content)}exportJSON(){return{type:H_.getType(),version:1,content:this.__content}}createDOM(n,r){return this.__dom.createElement("div")}updateDOM(){return!1}isInline(){return!1}getTextContent(){return this.__content}decorate(n,r){return c.jsx(KN,{content:this.__content})}}function j$e(e){return yi(new H_(e))}const R$e=[z_,U_,Jv],M$e=[zf,Uf,H_],P$e=/^[ \t]*(`{3,})[ \t]*mermaid[ \t]*$/i,I$e=/^[ \t]*`{3,}[ \t]*$/;function O$e(e){return new RegExp(`^[ \\t]*\`{${String(e)},}[ \\t]*$`)}function D$e(e,t,n){const r=O$e(n.length),i=[];let s=t;for(let o=t+1;o<e.length;o++){const a=e[o];if(a===void 0||(s=o,r.test(a)))break;i.push(a)}return{source:i.join(`
|
|
2754
2754
|
`),lastLineIndex:s}}const L$e={type:"multiline-element",dependencies:[zf],regExpStart:P$e,regExpEnd:{optional:!0,regExp:I$e},handleImportAfterStartMatch({lines:e,rootNode:t,startLineIndex:n,startMatch:r}){const{source:i,lastLineIndex:s}=D$e(e,n,r[1]??"```");return t.append(Zre(i)),[!0,s]},replace(e,t,n,r,i,s){return!1},export(e){return e instanceof zf?`\`\`\`mermaid
|
|
2755
2755
|
${e.getTextContent()}
|
|
2756
2756
|
\`\`\``:null}},nie="(?:file://|/(?:Users|home|private|tmp|var|opt|root)/)",$$e=new RegExp(`\\[(.+?)\\]\\((${nie}[^)\\s]*)\\)`),B$e=new RegExp(`\\[([^[\\]]+)\\]\\((${nie}[^)\\s]*)\\)$`),F$e={type:"text-match",dependencies:[Uf],importRegExp:$$e,regExp:B$e,trigger:")",replace(e,t){const n=t[2];if(!n)return;const r=S$e(n);if(!r||!k$e(r.path)&&!n.startsWith("/"))return;const i=tie({path:r.path,line:r.line,column:r.column});e.replace(i)},export(e){if(!(e instanceof Uf))return null;const t=e.getTextContent();return`[${t}](${t})`}},z$e=[L$e,F$e,...Vre],U$e=[Tb,Nb,rd,Cc,Eb,q0,Jf,zN,Wu,_m,mc,...M$e];let rie=0;function ui(){return String(rie++)}let Ug=null,Hg=null;const mW={h1:"text-20 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h2:"text-18 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h3:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h4:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h5:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0",h6:"text-16 font-normal leading-tight mt-5 mb-3 first:mt-0 last:mb-0"};function iie(e){if(b$e(e)&&Ug&&Hg)return c.jsx("span",{children:e.decorate(Ug,Hg)},ui());if(A$e(e)&&Ug&&Hg)return c.jsx("span",{children:e.decorate(Ug,Hg)},ui());if(h3(e)){const n=e.getTag(),r=Ld(e),i=mW[n]??mW.h1,s=ui();switch(n){case"h1":return c.jsx("h1",{className:i,children:r},s);case"h2":return c.jsx("h2",{className:i,children:r},s);case"h3":return c.jsx("h3",{className:i,children:r},s);case"h4":return c.jsx("h4",{className:i,children:r},s);case"h5":return c.jsx("h5",{className:i,children:r},s);default:return c.jsx("h6",{className:i,children:r},s)}}if(B_(e))return c.jsx("blockquote",{className:"my-2 mt-5 mb-3 first:mt-0 last:mb-0 border-l-2 border-border/80 pl-2 text-muted-foreground",children:Ld(e)},ui());if(qa(e))return c.jsx("p",{className:"break-words mt-5 mb-3 first:mt-0 last:mb-0",children:Ld(e)},ui());if(G0(e)){const n=e.getLanguage()??"",r=e.getChildren().map(i=>$e(i)||Yv(i)?i.getTextContent():bi(i)?`
|
|
@@ -2828,7 +2828,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2828
2828
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oae(e){return k9e(e)||E9e(e)||tae(e)||N9e()}var T9e=Gu(function(){return navigator.userAgent.includes("Firefox")}),Z3=Gu(function(){var t=navigator,n=t.userAgent;return n.includes("AppleWebKit")&&!n.includes("Chrome")}),kO={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function A9e(e){var t=e.dragLeave;return Z3()?t.hasOwnProperty(kO.isLeavingWindow):!1}(function(){if(typeof window>"u"||!Z3())return;function t(){return{enterCount:0,isOverWindow:!1}}var n=t();function r(){n=t()}nb.bindAll(window,[{type:"dragstart",listener:function(){n.enterCount=0,n.isOverWindow=!0}},{type:"drop",listener:r},{type:"dragend",listener:r},{type:"dragenter",listener:function(s){!n.isOverWindow&&n.enterCount===0&&(s[kO.isEnteringWindow]=!0),n.isOverWindow=!0,n.enterCount++}},{type:"dragleave",listener:function(s){n.enterCount--,n.isOverWindow&&n.enterCount===0&&(s[kO.isLeavingWindow]=!0,n.isOverWindow=!1)}}],{capture:!0})})();function j9e(e){return"nodeName"in e}function R9e(e){return j9e(e)&&e.ownerDocument!==document}function M9e(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n!=="dragleave"?!1:Z3()?A9e({dragLeave:t}):r==null?!0:T9e()?R9e(r):r instanceof HTMLIFrameElement}function P9e(e){var t=e.onDragEnd;return[{type:"pointermove",listener:(function(){var n=0;return function(){if(n<20){n++;return}t()}})()},{type:"pointerdown",listener:t}]}function Fy(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var I9e=function(t){var n=[],r=null,i=function(){for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];n=a,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i},bR=I9e(function(e){return e()}),TC=(function(){var e=null;function t(r){var i=requestAnimationFrame(function(){e=null,r()});e={frameId:i,fn:r}}function n(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return{schedule:t,flush:n}})();function O9e(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function s(a){r(a),i={dropTargets:a.payload.location.current.dropTargets}}var o={start:function(l){var u=l.nativeSetDragImage,f={current:n,previous:i,initial:n};s({eventName:"onGenerateDragPreview",payload:{source:t,location:f,nativeSetDragImage:u}}),TC.schedule(function(){s({eventName:"onDragStart",payload:{source:t,location:f}})})},dragUpdate:function(l){var u=l.current;TC.flush(),bR.cancel(),s({eventName:"onDropTargetChange",payload:{source:t,location:{initial:n,previous:i,current:u}}})},drag:function(l){var u=l.current;bR(function(){TC.flush();var f={initial:n,previous:i,current:u};s({eventName:"onDrag",payload:{source:t,location:f}})})},drop:function(l){var u=l.current,f=l.updatedSourcePayload;TC.flush(),bR.cancel(),s({eventName:"onDrop",payload:{source:f??t,location:{current:u,previous:i,initial:n}}})}};return o}var EO={isActive:!1};function aae(){return!EO.isActive}function D9e(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function L9e(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function $9e(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!aae())return;var s=B9e({event:t,dragType:n,getDropTargetsOver:r});EO.isActive=!0;var o={current:s};xR({event:t,current:s.dropTargets});var a=O9e({source:n.payload,dispatchEvent:i,initial:s});function l(g){var v=L9e({current:o.current.dropTargets,next:g.dropTargets});o.current=g,v&&a.dragUpdate({current:o.current})}function u(g){var v=Fy(g),x=sae(g.target)?J3({x:v.clientX,y:v.clientY}):g.target,y=r({target:x,input:v,source:n.payload,current:o.current.dropTargets});y.length&&(g.preventDefault(),xR({event:g,current:y})),l({dropTargets:y,input:v})}function f(){o.current.dropTargets.length&&l({dropTargets:[],input:o.current.input}),a.drop({current:o.current,updatedSourcePayload:null}),h()}function h(){EO.isActive=!1,m()}var m=nb.bindAll(window,[{type:"dragover",listener:function(v){u(v),a.drag({current:o.current})}},{type:"dragenter",listener:u},{type:"dragleave",listener:function(v){M9e({dragLeave:v})&&(l({input:o.current.input,dropTargets:[]}),n.startedFrom==="external"&&f())}},{type:"drop",listener:function(v){if(o.current={dropTargets:o.current.dropTargets,input:Fy(v)},!o.current.dropTargets.length){f();return}v.preventDefault(),xR({event:v,current:o.current.dropTargets}),a.drop({current:o.current,updatedSourcePayload:n.type==="external"?n.getDropPayload(v):null}),h()}},{type:"dragend",listener:function(v){o.current={dropTargets:o.current.dropTargets,input:Fy(v)},f()}}].concat(oae(P9e({onDragEnd:f}))),{capture:!0});a.start({nativeSetDragImage:D9e(t)})}function xR(e){var t,n=e.event,r=e.current,i=(t=r[0])===null||t===void 0?void 0:t.dropEffect;i!=null&&n.dataTransfer&&(n.dataTransfer.dropEffect=i)}function B9e(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=Fy(t);if(n.startedFrom==="external")return{input:i,dropTargets:[]};var s=r({input:i,source:n.payload,target:t.target,current:[]});return{input:i,dropTargets:s}}var wV={canStart:aae,start:$9e},NO=new Map;function F9e(e){var t=e.typeKey,n=e.mount,r=NO.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return NO.set(t,i),i}function z9e(e){var t=F9e(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),NO.delete(e.typeKey))}}function lae(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function CV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ud(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?CV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):CV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function yR(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=U9e(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2829
2829
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return o=u.done,u},e:function(u){a=!0,s=u},f:function(){try{o||n.return==null||n.return()}finally{if(a)throw s}}}}function U9e(e,t){if(e){if(typeof e=="string")return kV(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kV(e,t):void 0}}function kV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _R(e){return e.slice(0).reverse()}function H9e(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i="data-drop-target-for-".concat(t),s="[".concat(i,"]");function o(g){return r.set(g.element,g),function(){return r.delete(g.element)}}function a(g){var v=Pb(lae(g.element,{attribute:i,value:"true"}),o(g));return Gu(v)}function l(g){var v,x,y,w,C=g.source,k=g.target,E=g.input,N=g.result,T=N===void 0?[]:N;if(k==null)return T;if(!(k instanceof Element))return k instanceof Node?l({source:C,target:k.parentElement,input:E,result:T}):T;var R=k.closest(s);if(R==null)return T;var M=r.get(R);if(M==null)return T;var P={input:E,source:C,element:M.element};if(M.canDrop&&!M.canDrop(P))return l({source:C,target:M.element.parentElement,input:E,result:T});var B=(v=(x=M.getData)===null||x===void 0?void 0:x.call(M,P))!==null&&v!==void 0?v:{},U=(y=(w=M.getDropEffect)===null||w===void 0?void 0:w.call(M,P))!==null&&y!==void 0?y:n,D={data:B,element:M.element,dropEffect:U,isActiveDueToStickiness:!1};return l({source:C,target:M.element.parentElement,input:E,result:[].concat(oae(T),[D])})}function u(g){var v=g.eventName,x=g.payload,y=yR(x.location.current.dropTargets),w;try{for(y.s();!(w=y.n()).done;){var C,k=w.value,E=r.get(k.element),N=Ud(Ud({},x),{},{self:k});E==null||(C=E[v])===null||C===void 0||C.call(E,N)}}catch(T){y.e(T)}finally{y.f()}}var f={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:function(v){var x=v.payload,y=new Set(x.location.current.dropTargets.map(function(H){return H.element})),w=new Set,C=yR(x.location.previous.dropTargets),k;try{for(C.s();!(k=C.n()).done;){var E,N=k.value;w.add(N.element);var T=r.get(N.element),R=y.has(N.element),M=Ud(Ud({},x),{},{self:N});if(T==null||(E=T.onDropTargetChange)===null||E===void 0||E.call(T,M),!R){var P;T==null||(P=T.onDragLeave)===null||P===void 0||P.call(T,M)}}}catch(H){C.e(H)}finally{C.f()}var B=yR(x.location.current.dropTargets),U;try{for(B.s();!(U=B.n()).done;){var D,$,I=U.value;if(!w.has(I.element)){var V=Ud(Ud({},x),{},{self:I}),z=r.get(I.element);z==null||(D=z.onDropTargetChange)===null||D===void 0||D.call(z,V),z==null||($=z.onDragEnter)===null||$===void 0||$.call(z,V)}}}catch(H){B.e(H)}finally{B.f()}}};function h(g){f[g.eventName](g)}function m(g){var v=g.source,x=g.target,y=g.input,w=g.current,C=l({source:v,target:x,input:y});if(C.length>=w.length)return C;for(var k=_R(w),E=_R(C),N=[],T=0;T<k.length;T++){var R,M=k[T],P=E[T];if(P!=null){N.push(P);continue}var B=N[T-1],U=k[T-1];if((B==null?void 0:B.element)!==(U==null?void 0:U.element))break;var D=r.get(M.element);if(!D)break;var $={input:y,source:v,element:D.element};if(D.canDrop&&!D.canDrop($)||!((R=D.getIsSticky)!==null&&R!==void 0&&R.call(D,$)))break;N.push(Ud(Ud({},M),{},{isActiveDueToStickiness:!0}))}return _R(N)}return{dropTargetForConsumers:a,getIsOver:m,dispatchEvent:h}}function W9e(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=V9e(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2830
2830
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return o=u.done,u},e:function(u){a=!0,s=u},f:function(){try{o||n.return==null||n.return()}finally{if(a)throw s}}}}function V9e(e,t){if(e){if(typeof e=="string")return EV(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?EV(e,t):void 0}}function EV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function NV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function K9e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?NV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):NV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function G9e(){var e=new Set,t=null;function n(s){t&&(!s.canMonitor||s.canMonitor(t.canMonitorArgs))&&t.active.add(s)}function r(s){var o=K9e({},s);e.add(o),n(o);function a(){e.delete(o),t&&t.active.delete(o)}return Gu(a)}function i(s){var o=s.eventName,a=s.payload;if(o==="onGenerateDragPreview"){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var l=W9e(e),u;try{for(l.s();!(u=l.n()).done;){var f=u.value;n(f)}}catch(y){l.e(y)}finally{l.f()}}if(t){for(var h=Array.from(t.active),m=0,g=h;m<g.length;m++){var v=g[m];if(t.active.has(v)){var x;(x=v[o])===null||x===void 0||x.call(v,a)}}o==="onDrop"&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function q9e(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,s=e.defaultDropEffect,o=G9e(),a=H9e({typeKey:t,defaultDropEffect:s});function l(h){r==null||r(h),a.dispatchEvent(h),o.dispatchEvent(h),i==null||i(h)}function u(h){var m=h.event,g=h.dragType;wV.start({event:m,dragType:g,getDropTargetsOver:a.getIsOver,dispatchEvent:l})}function f(){function h(){var m={canStart:wV.canStart,start:u};return n(m)}return z9e({typeKey:t,mount:h})}return{registerUsage:f,dropTarget:a.dropTargetForConsumers,monitor:o.monitorForConsumers}}var Y9e=Gu(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),X9e="pdnd:android-fallback",TV="text/plain",Q9e="text/uri-list",J9e="application/vnd.pdnd",uE=new WeakMap;function Z9e(e){return uE.set(e.element,e),function(){uE.delete(e.element)}}var AV=C9e(),e$=q9e({typeKey:"element",defaultDropEffect:"move",mount:function(t){return Pb(AV.bindEvents(),nb.bind(document,{type:"dragstart",listener:function(r){var i,s,o,a,l,u;if(t.canStart(r)&&!r.defaultPrevented&&r.dataTransfer){var f=r.target;if(f instanceof HTMLElement){var h=uE.get(f);if(h){var m=Fy(r),g={element:h.element,dragHandle:(i=h.dragHandle)!==null&&i!==void 0?i:null,input:m};if(h.canDrag&&!h.canDrag(g)){r.preventDefault();return}if(h.dragHandle){var v=J3({x:m.clientX,y:m.clientY});if(!h.dragHandle.contains(v)){r.preventDefault();return}}var x=(s=(o=h.getInitialDataForExternal)===null||o===void 0?void 0:o.call(h,g))!==null&&s!==void 0?s:null;if(x)for(var y=0,w=Object.entries(x);y<w.length;y++){var C=nae(w[y],2),k=C[0],E=C[1];r.dataTransfer.setData(k,E??"")}Y9e()&&!r.dataTransfer.types.includes(TV)&&!r.dataTransfer.types.includes(Q9e)&&r.dataTransfer.setData(TV,X9e),r.dataTransfer.setData(J9e,"");var N={element:h.element,dragHandle:(a=h.dragHandle)!==null&&a!==void 0?a:null,data:(l=(u=h.getInitialData)===null||u===void 0?void 0:u.call(h,g))!==null&&l!==void 0?l:{}},T={type:"element",payload:N,startedFrom:"internal"};t.start({event:r,dragType:T})}}}}}))},dispatchEventToSource:function(t){var n,r,i=t.eventName,s=t.payload;(n=uE.get(s.source.element))===null||n===void 0||(r=n[i])===null||r===void 0||r.call(n,s)},onPostDispatch:AV.getOnPostDispatch()}),TO=e$.dropTarget,eVe=e$.monitor;function cae(e){var t=Pb(e$.registerUsage(),Z9e(e),lae(e.element,{attribute:"draggable",value:"true"}));return Gu(t)}var J_=new Map,M1=new Set;function uae(e){tVe(e);var t=J_.get(e);if(t)return t;var n={timeOfEngagementStart:Date.now()};return J_.set(e,n),n}function tVe(e){M1.add(e)}function nVe(e){M1.clear(),e(),J_.forEach(function(t,n){M1.has(n)||J_.delete(n)}),M1.clear()}function rVe(){J_.clear()}var jV=new Map;function iVe(e){var t=jV.get(e);if(t)return t;var n=sVe(e);return jV.set(e,n),n}function sVe(e){var t={type:"idle"},n=[];function r(l){if(t.type==="running"){var u=l-t.timeLastFrameFinished,f=t,h=f.latestArgs,m=J3({x:h.location.current.input.clientX,y:h.location.current.input.clientY});nVe(function(){n.forEach(function(g){return g({underUsersPointer:m,latestArgs:h,timeSinceLastFrame:u})})}),t.timeLastFrameFinished=l,t.frameId=requestAnimationFrame(r)}}function i(){t.type!=="idle"&&(cancelAnimationFrame(t.frameId),rVe(),t={type:"idle"})}function s(l){t.type==="idle"&&(t={type:"initializing",latestArgs:l,frameId:requestAnimationFrame(function(u){t.type==="initializing"&&(t={type:"running",timeLastFrameFinished:u,latestArgs:t.latestArgs,frameId:requestAnimationFrame(r)})})})}function o(l){if(t.type==="idle"){s(l);return}t.latestArgs=l}e({onDragStart:s,onDropTargetChange:o,onDrag:o,onDrop:i});var a={onFrame:function(u){n.push(u)}};return a}var AO="data-auto-scrollable",oVe="[".concat(AO,'="true"]');function aVe(e){return e.setAttribute(AO,"true"),function(){return e.removeAttribute(AO)}}function RV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function MV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?RV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var lVe={startHitboxAtPercentageRemainingOfElement:{top:.25,right:.25,bottom:.25,left:.25},maxScrollAtPercentageRemainingOfHitbox:{top:.5,right:.5,bottom:.5,left:.5},timeDampeningDurationMs:400,maxMainAxisHitboxSize:180},cVe={standard:900,fast:1500};function dae(e){var t;return MV(MV({},lVe),{},{maxPixelScrollPerSecond:cVe[(t=e==null?void 0:e.maxScrollSpeed)!==null&&t!==void 0?t:"standard"]})}var uVe={top:function(t){return t.scrollTop>0},right:function(t){return Math.ceil(t.scrollLeft)+t.clientWidth<t.scrollWidth},bottom:function(t){return Math.ceil(t.scrollTop)+t.clientHeight<t.scrollHeight},left:function(t){return t.scrollLeft>0}},dVe=["top","right","bottom","left"],fVe={top:"vertical",right:"horizontal",bottom:"vertical",left:"horizontal"},PV={start:"top",end:"bottom",point:"y",size:"height"},IV={start:"left",end:"right",point:"x",size:"width"},fae={vertical:{mainAxis:PV,crossAxis:IV},horizontal:{mainAxis:IV,crossAxis:PV}},t$={top:"start",right:"end",bottom:"end",left:"start"};function AC(e){var t=e.edge,n=e.axis;return function(i){var s=i.clientRect,o=i.config,a=fae[n],l=a.mainAxis,u=a.crossAxis,f=t$[t],h=Math.min(o.startHitboxAtPercentageRemainingOfElement[t]*s[l.size],o.maxMainAxisHitboxSize);return DOMRect.fromRect(dl(dl(dl(dl({},l.point,f==="start"?s[l.point]:s[l.point]+s[l.size]-h),u.point,s[u.point]),l.size,h),u.size,s[u.size]))}}var hVe={top:AC({axis:"vertical",edge:"top"}),right:AC({axis:"horizontal",edge:"right"}),bottom:AC({axis:"vertical",edge:"bottom"}),left:AC({axis:"horizontal",edge:"left"})};function jO(e){var t=e.startOfRange,n=e.endOfRange,r=e.value,i=t<n;if(!i||r<t)return 0;if(r>n)return 1;var s=n-t;return(r-t)/s}function pVe(e){var t=e.timeSinceLastFrame,n=e.config,r=n.maxPixelScrollPerSecond/1e3,i=Math.ceil(r*t),s=n.maxPixelScrollPerSecond/60;return Math.min(i,s)}function mVe(e){var t=e.client,n=e.axis,r=e.edge,i=e.hitbox,s=e.config,o=fae[n].mainAxis,a=t$[r],l=i[o.size]*s.maxScrollAtPercentageRemainingOfHitbox[r];if(a==="end")return jO({startOfRange:i[o.start],endOfRange:i[o.end]-l,value:t[o.point]});var u=jO({startOfRange:i[o.start]+l,endOfRange:i[o.end],value:t[o.point]});return 1-u}function jC(e){var t=e.client,n=e.timeSinceLastFrame,r=e.engagement,i=e.axis,s=e.hitbox,o=e.edge,a=e.isDistanceDampeningEnabled,l=e.config,u=pVe({timeSinceLastFrame:n,config:l}),f=a?mVe({client:t,edge:o,hitbox:s,axis:i,config:l}):1,h=jO({startOfRange:r.timeOfEngagementStart,endOfRange:r.timeOfEngagementStart+l.timeDampeningDurationMs,value:Date.now()}),m=f*h,g=Math.max(u*m,1),v=t$[o];return v==="end"?g:-1*g}function gVe(e,t){return t==="all"||e===t}function vVe(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function bVe(e){return e.getBoundingClientRect()}function hae(e){var t=e.element,n=e.input,r=e.timeSinceLastFrame,i=e.engagement,s=e.config,o=e.allowedAxis,a=e.getRect,l=a===void 0?bVe:a,u={x:n.clientX,y:n.clientY},f=l(t),h=dVe.reduce(function(v,x){var y=hVe[x]({clientRect:f,config:s}),w=fVe[x];return!gVe(w,o)||!vVe({client:u,clientRect:y})||!uVe[x](t)||v.set(x,{edge:x,hitbox:y}),v},new Map),m=(function(){var v="horizontal",x=h.get("left");if(x)return jC({client:u,edge:x.edge,hitbox:x.hitbox,axis:v,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:s});var y=h.get("right");return y?jC({client:u,edge:y.edge,hitbox:y.hitbox,axis:v,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:s}):0})(),g=(function(){var v="vertical",x=h.get("bottom");if(x)return jC({client:u,edge:x.edge,hitbox:x.hitbox,axis:v,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:s});var y=h.get("top");return y?jC({client:u,edge:y.edge,hitbox:y.hitbox,axis:v,timeSinceLastFrame:r,engagement:i,isDistanceDampeningEnabled:!0,config:s}):0})();return{left:m,top:g}}function xVe(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=yVe(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2831
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return o=u.done,u},e:function(u){a=!0,s=u},f:function(){try{o||n.return==null||n.return()}finally{if(a)throw s}}}}function yVe(e,t){if(e){if(typeof e=="string")return OV(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?OV(e,t):void 0}}function OV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function pae(e){return!!(e.top||e.left)}function mae(e){var t,n,r,i=e.target,s=e.input,o=e.source,a=e.findEntry,l=e.timeSinceLastFrame,u=e.available,f=u===void 0?{top:!0,left:!0}:u;if(!pae(f)||!i)return f;var h=i.closest(oVe);if(!h)return f;var m=a(h);if(!m)return f;function g(){var E;return mae({target:(E=h==null?void 0:h.parentElement)!==null&&E!==void 0?E:null,findEntry:a,source:o,timeSinceLastFrame:l,input:s,available:f})}var v={input:s,source:o,element:h};if(m.canScroll&&!m.canScroll(v))return g();var x=uae(h),y=dae((t=m.getConfiguration)===null||t===void 0?void 0:t.call(m,v)),w=(n=(r=m.getAllowedAxis)===null||r===void 0?void 0:r.call(m,v))!==null&&n!==void 0?n:"all",C=hae({element:h,engagement:x,input:s,timeSinceLastFrame:l,allowedAxis:w,config:y}),k={top:0,left:0};return f.top&&C.top!==0&&(k.top=C.top,f.top=!1),f.left&&C.left!==0&&(k.left=C.left,f.left=!1),(k.top!==0||k.left!==0)&&h.scrollBy(k),g()}function _Ve(e){var t=e.input,n=e.timeSinceLastFrame,r=e.available,i=e.source,s=e.entries,o=document.documentElement,a={input:t,source:i,element:o},l=xVe(s),u;try{for(l.s();!(u=l.n()).done;){var f,h,m,g=u.value;if(!(g.canScroll&&!g.canScroll(a))){var v=uae(o),x=dae((f=g.getConfiguration)===null||f===void 0?void 0:f.call(g,a)),y=(h=(m=g.getAllowedAxis)===null||m===void 0?void 0:m.call(g,a))!==null&&h!==void 0?h:"all",w=hae({element:o,engagement:v,input:t,config:x,allowedAxis:y,getRect:function(E){return DOMRect.fromRect({y:0,x:0,width:E.clientWidth,height:E.clientHeight})},timeSinceLastFrame:n}),C={top:r.top?w.top:0,left:r.left?w.left:0};(C.top!==0||C.left!==0)&&o.scrollBy(C);break}}}catch(k){l.e(k)}finally{l.f()}}function SVe(e){var t=e.input,n=e.findEntry,r=e.timeSinceLastFrame,i=e.source,s=e.getWindowScrollEntries,o=e.underUsersPointer,a=mae({target:o,timeSinceLastFrame:r,input:t,source:i,findEntry:n});pae(a)&&_Ve({input:t,source:i,entries:s(),timeSinceLastFrame:r,available:a})}function DV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function wVe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?DV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function CVe(e){var t=e.monitor,n=new Map,r=new Set;function i(u){n.set(u.element,u);var f=Pb(aVe(u.element),function(){return n.delete(u.element)});return Gu(f)}function s(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},f=wVe({},u);r.add(f);function h(){r.delete(f)}return Gu(h)}function o(u){var f;return(f=n.get(u))!==null&&f!==void 0?f:null}function a(){return Array.from(r)}function l(u){var f=u.latestArgs,h=u.underUsersPointer,m=u.timeSinceLastFrame;SVe({input:f.location.current.input,source:f.source,findEntry:o,underUsersPointer:h,timeSinceLastFrame:m,getWindowScrollEntries:a})}return iVe(t).onFrame(l),{autoScroll:i,autoScrollWindow:s}}var kVe=CVe({monitor:eVe}),gae=kVe.autoScroll;function LV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $V(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?LV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var EVe={top:function(t,n){return Math.abs(n.y-t.top)},right:function(t,n){return Math.abs(t.right-n.x)},bottom:function(t,n){return Math.abs(t.bottom-n.y)},left:function(t,n){return Math.abs(n.x-t.left)}},vae=Symbol("closestEdge");function bae(e,t){var n,r,i=t.element,s=t.input,o=t.allowedEdges,a={x:s.clientX,y:s.clientY},l=i.getBoundingClientRect(),u=o.map(function(h){return{edge:h,value:EVe[h](l,a)}}),f=(n=(r=u.sort(function(h,m){return h.value-m.value})[0])===null||r===void 0?void 0:r.edge)!==null&&n!==void 0?n:null;return $V($V({},e),{},dl({},vae,f))}function xae(e){var t;return(t=e[vae])!==null&&t!==void 0?t:null}const NVe={timer:Jn};function sT(e=1e3,t){const{timer:n}=NVe,[r,i]=_.useState(()=>Date.now()),s=_.useRef(e);return _.useLayoutEffect(()=>{s.current=e}),_.useEffect(()=>{const o=n.setInterval(()=>{i(Date.now())},s.current);return()=>n.clearInterval(o)},[n]),r}function P1(e,t){return`${String(e)} ${t}${e===1?"":"s"}`}function TVe(e){return e.nextFireAt===null?{tone:"muted",label:"Scheduled",clock:null}:{tone:"muted",label:"Runs in",clock:{kind:"countdown",until:e.nextFireAt}}}function AVe(e){const{activity:t}=e,n=zE(e),r=e.stateEnteredAt===void 0?null:{kind:"elapsed",since:e.stateEnteredAt};if((n==null?void 0:n.tone)==="destructive")return{tone:"destructive",label:n.label,clock:null};if(t.lastRunFailure){const{code:i}=t.lastRunFailure;return{tone:"destructive",label:i===null?"Agent failed":`Agent failed — ${i}`,clock:null}}if((n==null?void 0:n.tone)==="info"||t.awaitingAnswer)return{tone:"info",label:(n==null?void 0:n.label)??kf("waiting_for_user"),clock:r};if(t.workflow){const{name:i,agentCount:s}=t.workflow;return{tone:"warning",label:`${i??"Workflow"} · ${P1(s,"agent")}`,clock:r}}if(t.loop){const{done:i,total:s}=t.loop;return{tone:"warning",label:`Loop · ${String(i)}/${String(s)}`,clock:r}}return t.agents>0?{tone:"warning",label:P1(t.agents,"agent"),clock:r}:(n==null?void 0:n.tone)==="warning"?{tone:"warning",label:n.label,clock:r}:t.backgroundTasks>0?{tone:"warning",label:P1(t.backgroundTasks,"background task"),clock:r}:t.cron&&!t.cron.paused?TVe(t.cron):n?{tone:n.tone,label:n.label,clock:null}:null}function jVe(e,t){const n=e.flatMap(i=>{const s=t[i];return s?[{chatId:i,chat:s}]:[]});if(n.length===0)return null;for(const{chatId:i,chat:s}of n){const o=AVe(s);if(o)return{chatId:i,...o,linkedCount:n.length}}const r=n[0];return r?{chatId:r.chatId,tone:null,label:P1(n.length,"chat"),linkedCount:n.length,clock:null}:null}function RVe(e,t,n){var u,f,h,m;const r=e.cards[n.columnId];if(!r)return null;const i=r.filter(g=>g.id!==t),s=n.beforeCardId===null?i.length:i.findIndex(g=>g.id===n.beforeCardId);if(s<0)return null;const o=((u=i[s-1])==null?void 0:u.id)??null,a=((f=i[s])==null?void 0:f.id)??null,l=MVe(e,t);if(l&&l.columnId===n.columnId){const g=((h=l.cards[l.index-1])==null?void 0:h.id)??null,v=((m=l.cards[l.index+1])==null?void 0:m.id)??null;if(g===o&&v===a)return null}return{cardId:t,toColumnId:n.columnId,aboveCardId:o,belowCardId:a}}function MVe(e,t){for(const[n,r]of Object.entries(e.cards)){const i=r.findIndex(s=>s.id===t);if(i>=0)return{columnId:n,index:i,cards:r}}return null}function PVe(e,t,n){var a,l;const r=e.findIndex(u=>u.id===t);if(r<0)return null;const i=e.filter(u=>u.id!==t),s=n===null?i.length:i.findIndex(u=>u.id===n);if(s<0)return null;const o=((a=i[s-1])==null?void 0:a.id)??null;return(((l=e[r-1])==null?void 0:l.id)??null)===o?null:{columnId:t,afterColumnId:o}}function IVe(e,t,n){var i;const r=e.findIndex(s=>s.id===t);return r<0?null:n==="top"?t:((i=e[r+1])==null?void 0:i.id)??null}function OVe(e,t,n){var i;const r=e.findIndex(s=>s.id===t);return r<0?null:n==="left"?t:((i=e[r+1])==null?void 0:i.id)??null}function DVe(e,t){const n=t.text.trim().toLowerCase(),r=t.labels;return!n&&r.length===0?e:e.filter(i=>{if(n&&!i.title.toLowerCase().includes(n))return!1;if(r.length>0){const s=i.content.labels,o=(s==null?void 0:s.kind)==="label"?s.values:[];if(!r.some(a=>o.includes(a)))return!1}return!0})}function yae(e,t){return t!==null&&e.createdAt>t}function LVe(e,t){return t===null?0:e.filter(n=>yae(n,t)).length}const Jo=Yt()(e=>({draggingCardId:null,cardDrop:null,draggingColumnId:null,columnDropBeforeId:null,columnDropActive:!1,startCardDrag:t=>e({draggingCardId:t,cardDrop:null}),setCardDrop:t=>e({cardDrop:t}),startColumnDrag:t=>e({draggingColumnId:t,columnDropBeforeId:null,columnDropActive:!1}),setColumnDrop:(t,n)=>e({columnDropBeforeId:t,columnDropActive:n}),endDrag:()=>e({draggingCardId:null,cardDrop:null,draggingColumnId:null,columnDropBeforeId:null,columnDropActive:!1})}));function $Ve(e,t){return n=>{var r;return((r=n.cardDrop)==null?void 0:r.columnId)===e&&n.cardDrop.beforeCardId===t}}function BVe(e){return t=>{var n;return((n=t.cardDrop)==null?void 0:n.columnId)===e&&t.cardDrop.beforeCardId===null}}const RO={text:"",labels:[]},I1=Yt(e=>({filterByBoard:{},setText:(t,n)=>e(r=>({filterByBoard:{...r.filterByBoard,[t]:{...r.filterByBoard[t]??RO,text:n}}})),setLabels:(t,n)=>e(r=>({filterByBoard:{...r.filterByBoard,[t]:{...r.filterByBoard[t]??RO,labels:n}}})),clear:t=>e(n=>{const{[t]:r,...i}=n.filterByBoard;return{filterByBoard:i}})}));function _ae(e){return t=>t.filterByBoard[e]??RO}function FVe({boardId:e}){const t=I1(_ae(e)),n=_.useCallback(s=>{I1.getState().setText(e,s.currentTarget.value)},[e]),r=_.useCallback(()=>{I1.getState().clear(e)},[e]),i=t.text.length>0||t.labels.length>0;return c.jsxs("div",{className:"flex items-center gap-1 px-1 pb-1.5",children:[c.jsx("input",{value:t.text,onChange:n,placeholder:"Filter…","aria-label":"Filter cards",className:ce("min-w-0 flex-1 rounded-md bg-transparent px-2 py-1 text-xs text-foreground","placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none")}),i?c.jsx("button",{type:"button",onClick:r,"aria-label":"Clear filter",className:"shrink-0 rounded-md p-1 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:c.jsx(xi,{"aria-hidden":!0,className:"size-3"})}):null]})}const BV={title:"",semantic:null,colorToken:null,wipLimit:null},nu=Yt()(e=>({openColumnId:null,draft:BV,open:(t,n)=>e({openColumnId:t,draft:n}),close:()=>e({openColumnId:null,draft:BV}),setTitle:t=>e(n=>({draft:{...n.draft,title:t}})),setSemantic:t=>e(n=>({draft:{...n.draft,semantic:UWe(t)?t:null}})),setColorToken:t=>e(n=>({draft:{...n.draft,colorToken:Xoe(t)?t:null}})),setWipLimit:t=>e(n=>{const r=Number.parseInt(t.trim(),10);return{draft:{...n.draft,wipLimit:Number.isInteger(r)&&r>0?r:null}}})})),FV=[{value:"",label:"No role",hint:"Nothing routes here automatically."},{value:"start",label:"Incoming",hint:"Pulled issues land here."},{value:"active",label:"In progress",hint:"Start work moves a card here."},{value:"review",label:"In review",hint:"No automatic behaviour yet."},{value:"done",label:"Done",hint:"Closes the issue, and asks about the worktree."}];function zVe({columnId:e,value:t,canDelete:n,onSave:r,onDelete:i}){var x;const s=nu(y=>y.openColumnId===e),o=nu(y=>y.draft),a=_.useCallback(y=>{const w=nu.getState();y?w.open(e,t):w.close()},[e,t]),l=_.useCallback(y=>{nu.getState().setTitle(y.currentTarget.value)},[]),u=_.useCallback(y=>{nu.getState().setWipLimit(y.currentTarget.value)},[]),f=_.useCallback(y=>{nu.getState().setSemantic(y.currentTarget.value)},[]),h=_.useCallback(y=>{nu.getState().setColorToken(y.currentTarget.value)},[]),m=_.useCallback(()=>{const y=nu.getState();y.draft.title.trim()!==""&&(r(e,{...y.draft,title:y.draft.title.trim()}),y.close())},[e,r]),g=_.useCallback(()=>{i(e),nu.getState().close()},[e,i]),v=(x=FV.find(y=>(y.value===""?null:y.value)===o.semantic))==null?void 0:x.hint;return c.jsxs(_c,{open:s,onOpenChange:a,children:[c.jsx(Sc,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":`Column settings: ${t.title}`,className:"rounded-md p-0.5 text-muted-foreground hover:bg-secondary hover:text-foreground",children:c.jsx(Pp,{"aria-hidden":!0,className:"size-4"})})}),c.jsxs(Nl,{align:"end",className:"w-72 space-y-4 p-3",children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:`column-title-${e}`,children:"Name"}),c.jsx(Bt,{id:`column-title-${e}`,value:o.title,onChange:l})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:`column-role-${e}`,children:"Role"}),c.jsx("select",{id:`column-role-${e}`,value:o.semantic??"",onChange:f,className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-13 text-foreground",children:FV.map(y=>c.jsx("option",{value:y.value,children:y.label},y.label))}),v?c.jsx("p",{className:"text-13 text-muted-foreground",children:v}):null]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Dot"}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(cE,{token:null,label:"No dot",selected:o.colorToken===null,onSelect:h}),X3.map(y=>c.jsx(cE,{token:y,label:y,selected:o.colorToken===y,onSelect:h},y))]})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:`column-wip-${e}`,children:"WIP limit"}),c.jsx(Bt,{id:`column-wip-${e}`,value:o.wipLimit===null?"":String(o.wipLimit),onChange:u,inputMode:"numeric",placeholder:"None",className:"tabular-nums"}),c.jsx("p",{className:"text-13 text-muted-foreground",children:"Advisory. Going over is shown, never blocked."})]}),c.jsxs("div",{className:"flex items-center gap-2 border-t border-border pt-3",children:[c.jsx(Ee,{size:"sm",onClick:m,disabled:o.title.trim()==="",children:"Save"}),c.jsx(Ee,{variant:"ghost",size:"sm",className:"ml-auto text-destructive-text",onClick:g,disabled:!n,children:"Delete"})]}),n?null:c.jsx("p",{className:"text-13 text-muted-foreground",children:"Move or archive its cards before deleting it."})]})]})}const RC=Yt()(e=>({draft:"",setDraft:t=>e({draft:t}),clear:()=>e({draft:""})})),MC=Yt()(e=>({draftByColumn:{},setDraft:(t,n)=>e(r=>({draftByColumn:{...r.draftByColumn,[t]:n}})),clear:t=>e(n=>{if(!(t in n.draftByColumn))return n;const r={...n.draftByColumn};return delete r[t],{draftByColumn:r}})}));function UVe(e){return t=>t.draftByColumn[e]??""}const MO="kanna-board-card",zV="kanna-board-column",Sae={current:[]};function HVe(e){const{view:t,onCardMove:n,onColumnMove:r}=e,i=_.useRef(null),s=_.useRef(t);_.useLayoutEffect(()=>{s.current=t,Sae.current=t.columns});const o=t.board.id,a=I1(_ae(o)),l=_.useCallback(f=>{const h=Jo.getState().cardDrop;if(Jo.getState().endDrag(),!h)return;const m=RVe(s.current,f,h);m&&n(m)},[n]),u=_.useCallback(f=>{const{columnDropBeforeId:h,columnDropActive:m}=Jo.getState();if(Jo.getState().endDrag(),!m)return;const g=PVe(s.current.columns,f,h);g&&r(g.columnId,g.afterColumnId)},[r]);return _.useEffect(()=>{const f=i.current;if(f)return gae({element:f})},[]),c.jsxs("div",{ref:i,className:"kanna-board flex h-full w-full items-stretch gap-0 overflow-x-auto bg-background p-4",children:[t.columns.map(f=>{const h=t.cards[f.id]??WVe,m=f.semantic==="start",g=m?DVe(h,a):h;return c.jsx(qVe,{column:f,cards:g,total:t.counts[f.id]??h.length,newSince:m?t.newSince??null:null,chatLinksByCard:t.chatLinksByCard??KVe,chatFacts:e.chatFacts??GVe,onCardDrop:l,onColumnDrop:u,onOpenCard:e.onOpenCard,onLoadMore:e.onLoadMore,onColumnSave:e.onColumnSave,onColumnDelete:e.onColumnDelete,onCardAdd:e.onCardAdd,onMoveToTop:e.onMoveToTop},f.id)}),c.jsx(eKe,{onAdd:e.onColumnAdd,isFirst:t.columns.length===0})]})}const WVe=[],VVe=[],KVe={},GVe={};function qVe({column:e,cards:t,total:n,newSince:r,chatLinksByCard:i,chatFacts:s,onOpenCard:o,onLoadMore:a,onColumnSave:l,onColumnDelete:u,onCardAdd:f,onCardDrop:h,onColumnDrop:m,onMoveToTop:g}){const v=_.useRef(null),x=_.useRef(null),y=e.id,w=Jo(M=>M.draggingColumnId===y),C=Jo(M=>M.columnDropActive&&M.columnDropBeforeId===y),k=Jo(BVe(y));_.useEffect(()=>{const M=v.current,P=x.current;if(!M||!P)return;const B=Jo.getState(),U=M.querySelector("[data-column-handle]")??void 0;return Pb(cae({element:M,dragHandle:U,getInitialData:()=>({[zV]:!0,columnId:y}),onDragStart:()=>{B.startColumnDrag(y)},onDrop:()=>{m(y)}}),TO({element:M,canDrop:({source:D})=>D.data[zV]===!0,getData:({input:D,element:$})=>bae({columnId:y},{input:D,element:$,allowedEdges:["left","right"]}),onDragEnter:({self:D})=>{UV(D.data,y)},onDrag:({self:D})=>{UV(D.data,y)}}),TO({element:P,canDrop:({source:D})=>D.data[MO]===!0,getData:()=>({columnId:y}),onDragEnter:()=>{B.setCardDrop({columnId:y,beforeCardId:null})},onDragLeave:()=>{B.setCardDrop(null)}}),gae({element:P}))},[y,m]);const E=sWe(n,e.wipLimit),N=_.useMemo(()=>({title:e.title,semantic:e.semantic,colorToken:e.colorToken,wipLimit:e.wipLimit}),[e.colorToken,e.semantic,e.title,e.wipLimit]),T=e.semantic==="start",R=r!==null?LVe(t,r):0;return c.jsxs("div",{ref:v,className:ce("relative flex h-full w-[300px] shrink-0 flex-col border-r border-border px-3",w&&"opacity-40"),children:[C?c.jsx(QVe,{}):null,c.jsxs("div",{"data-column-handle":!0,className:"flex cursor-grab items-center gap-2 px-1 pb-2 pt-1",children:[e.colorToken?c.jsx("span",{"aria-hidden":!0,className:ce("size-1.5 shrink-0 rounded-full",nT[e.colorToken])}):null,c.jsx("span",{className:"truncate text-[0.9375rem] font-semibold leading-tight text-foreground",children:e.title}),c.jsx("span",{className:ce("ml-auto font-mono text-xs tabular-nums",E?"text-warning":"text-muted-foreground"),children:T&&R>0?c.jsxs(c.Fragment,{children:[n,c.jsxs("span",{className:"text-info",children:[" · ",R," new"]})]}):n}),c.jsx(zVe,{columnId:y,value:N,canDelete:n===0,onSave:l,onDelete:u})]}),T?c.jsx(FVe,{boardId:e.boardId}):null,c.jsxs("div",{ref:x,className:"min-h-0 flex-1 space-y-2 overflow-y-auto px-1 py-2",children:[t.map(M=>c.jsx(YVe,{card:M,columnId:y,cards:t,chatIds:i[M.id]??VVe,chatFacts:s,newSince:r,onOpen:o,onCardDrop:h,onMoveToTop:g},M.id)),k?c.jsx(wae,{}):null,n>t.length?c.jsx(JVe,{columnId:y,onLoadMore:a}):null]}),c.jsx(ZVe,{columnId:y,onAdd:f})]})}function UV(e,t){const n=xae(e);if(n!=="left"&&n!=="right")return;const r=OVe(Sae.current,t,n);Jo.getState().setColumnDrop(r,!0)}function YVe({card:e,columnId:t,cards:n,chatIds:r,chatFacts:i,newSince:s,onOpen:o,onCardDrop:a,onMoveToTop:l}){const u=_.useRef(null),f=e.id,h=Jo(C=>C.draggingCardId===f),m=Jo($Ve(t,f)),g=_.useRef(n);_.useLayoutEffect(()=>{g.current=n}),_.useEffect(()=>{const C=u.current;if(!C)return;const k=Jo.getState();return Pb(cae({element:C,getInitialData:()=>({[MO]:!0,cardId:f}),onDragStart:()=>{k.startCardDrag(f)},onDrop:()=>{a(f)}}),TO({element:C,canDrop:({source:E})=>E.data[MO]===!0,getData:({input:E,element:N})=>bae({cardId:f},{input:E,element:N,allowedEdges:["top","bottom"]}),onDragEnter:({self:E})=>{HV(E.data,t,f,g.current)},onDrag:({self:E})=>{HV(E.data,t,f,g.current)}}))},[f,t,a]);const v=_.useCallback(()=>{o(f)},[f,o]),x=_.useCallback(()=>{l(f)},[f,l]),y=jVe(r,i),w=yae(e,s);return c.jsxs("div",{ref:u,className:"relative",children:[m?c.jsx(wae,{}):null,c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:c.jsxs("button",{type:"button",onClick:v,className:ce("w-full cursor-grab rounded-lg border border-border bg-card px-3 py-2 text-left","transition-colors duration-150 hover:bg-secondary","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",h&&"opacity-40"),children:[c.jsx("span",{className:"line-clamp-2 text-sm font-medium leading-snug text-foreground [text-wrap:pretty]",children:e.title}),w?c.jsxs("span",{className:"mt-1 flex items-center gap-1 text-xs text-info",children:[c.jsx("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-info"}),c.jsx("span",{children:"New"})]}):null,y?c.jsxs("span",{className:ce("mt-1.5 flex items-center gap-1.5 text-xs",lX(y.tone)),children:[y.tone?c.jsx("span",{"aria-hidden":!0,className:ce("size-1.5 shrink-0 rounded-full",UE(y.tone))}):c.jsx(oq,{"aria-hidden":!0,className:"size-3 shrink-0"}),c.jsx("span",{children:y.label}),y.clock===null?null:c.jsx(XVe,{clock:y.clock})]}):null]})}),c.jsx(Xu,{children:c.jsx(Xn,{onSelect:x,children:"Move to top"})})]})]})}function XVe({clock:e}){const t=sT(1e3),n=e.kind==="elapsed"?Pu(Math.max(0,t-e.since)):h0e(e.until-t);return c.jsx("span",{className:"tabular-nums",children:n})}function HV(e,t,n,r){const i=xae(e);if(i!=="top"&&i!=="bottom")return;const s=IVe(r,n,i);Jo.getState().setCardDrop({columnId:t,beforeCardId:s})}function wae(){return c.jsx("div",{"aria-hidden":!0,className:"pointer-events-none h-px w-full rounded-full bg-primary"})}function QVe(){return c.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 left-0 w-px bg-primary"})}function JVe({columnId:e,onLoadMore:t}){const n=_.useRef(null);return _.useEffect(()=>{const r=n.current;if(!r)return;const i=new IntersectionObserver(s=>{s.some(o=>o.isIntersecting)&&t(e)});return i.observe(r),()=>{i.disconnect()}},[e,t]),c.jsxs("div",{ref:n,className:"space-y-2","aria-hidden":!0,children:[c.jsx("div",{className:"h-14 w-full animate-pulse rounded-lg border border-border bg-secondary"}),c.jsx("div",{className:"h-14 w-full animate-pulse rounded-lg border border-border bg-secondary"})]})}function ZVe({columnId:e,onAdd:t}){const n=MC(UVe(e)),r=_.useCallback(s=>{MC.getState().setDraft(e,s.currentTarget.value)},[e]),i=_.useCallback(s=>{s.preventDefault();const o=(MC.getState().draftByColumn[e]??"").trim();o!==""&&(MC.getState().clear(e),t(e,o))},[e,t]);return c.jsx("form",{onSubmit:i,className:"shrink-0 px-1 pb-1 pt-2",children:c.jsx("input",{value:n,onChange:r,placeholder:"Add a card","aria-label":"Add a card",className:"w-full rounded-md bg-transparent px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none"})})}function eKe({onAdd:e,isFirst:t}){const n=RC(s=>s.draft),r=_.useCallback(s=>{RC.getState().setDraft(s.currentTarget.value)},[]),i=_.useCallback(s=>{s.preventDefault();const o=RC.getState().draft.trim();o!==""&&(RC.getState().clear(),e(o))},[e]);return c.jsxs("form",{onSubmit:i,className:"w-64 shrink-0 px-3 pt-1",children:[t?c.jsx("p",{className:"mb-2 px-1 text-sm text-muted-foreground [text-wrap:pretty]",children:"No columns yet. Name your first one to start tracking work your agents can pick up."}):null,c.jsx("input",{value:n,onChange:r,placeholder:t?"Name your first column":"Add a column","aria-label":"Add a column",className:"w-full rounded-md bg-transparent px-1 py-1 text-[0.9375rem] text-foreground placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none"})]})}function tKe(e,t){const n=nKe(e,t.cardId);if(n===null||!(t.toColumnId in e.cards))return e;const r=(e.cards[n]??[]).find(a=>a.id===t.cardId);if(!r)return e;const i={...e.cards};i[n]=(i[n]??[]).filter(a=>a.id!==t.cardId);const s=t.toColumnId===n?[...i[n]??[]]:[...i[t.toColumnId]??[]];s.splice(rKe(s,t),0,{...r,columnId:t.toColumnId}),i[t.toColumnId]=s;const o={...e.counts};return t.toColumnId!==n&&(o[n]=Math.max(0,(o[n]??1)-1),o[t.toColumnId]=(o[t.toColumnId]??0)+1),{...e,cards:i,counts:o}}function nKe(e,t){for(const[n,r]of Object.entries(e.cards))if(r.some(i=>i.id===t))return n;return null}function rKe(e,t){if(t.aboveCardId!==null){const n=e.findIndex(r=>r.id===t.aboveCardId);if(n!==-1)return n+1}if(t.belowCardId!==null){const n=e.findIndex(r=>r.id===t.belowCardId);if(n!==-1)return n}return t.aboveCardId!==null?e.length:0}function iKe(e,t,n){const r=e.columns.find(o=>o.id===t);if(!r||n!==null&&!e.columns.some(o=>o.id===n))return e;const i=e.columns.filter(o=>o.id!==t),s=n===null?0:i.findIndex(o=>o.id===n)+1;return{...e,columns:[...i.slice(0,s),r,...i.slice(s)]}}function sKe({boardId:e,socket:t,chatFacts:n,onOpenCard:r,onOpenBoards:i}){const s=Fi(i7e(e)),o=Fi(s7e(e));_.useEffect(()=>t.subscribe({type:"board",boardId:e,pageSize:o},F=>{Fi.getState().setBoardView(F.boardId,F.view)}),[e,o,t]);const a=_.useCallback(F=>{const O=Fi.getState().viewByBoard[e];O&&Fi.getState().setBoardView(e,tKe(O,F)),t.command({type:"board.card.move",cardId:F.cardId,toColumnId:F.toColumnId,aboveCardId:F.aboveCardId,belowCardId:F.belowCardId}).catch(()=>{})},[e,t]),l=Tr(F=>F.openCardId),u=_.useCallback(F=>{Tr.getState().openCard(F),r==null||r(F)},[r]),f=_.useCallback(()=>{Tr.getState().closeCard()},[]),h=Tr(F=>F.syncPanelOpen),m=_.useCallback(()=>{Tr.getState().openSyncPanel()},[]),g=_.useCallback(()=>{Tr.getState().closeSyncPanel()},[]),v=Tr(F=>F.schemaPanelOpen),x=_.useCallback(()=>{const F=Fi.getState().viewByBoard[e];F&&(vu.getState().open(F.board.cardFields),Tr.getState().openSchemaPanel())},[e]),y=_.useCallback(()=>{Tr.getState().closeSchemaPanel()},[]),w=Tr(F=>F.syncingBoardId===e),C=Tr(F=>F.messageByBoard[e]??null),k=_.useCallback(()=>{const F=Tr.getState();F.startSync(e),t.command({type:"board.sync.pull",boardId:e}).then(O=>{const X=O.conflicts>0?`, ${String(O.conflicts)} conflicts`:"";F.finishSync(e,`Synced · ${String(O.created)} new, ${String(O.updated)} updated${X}`)}).catch(O=>{F.finishSync(e,hi(O))})},[e,t]),E=_.useCallback((F,O)=>{const X=Fi.getState().viewByBoard[e];X&&Fi.getState().setBoardView(e,iKe(X,F,O)),t.command({type:"board.column.move",columnId:F,afterColumnId:O}).catch(()=>{})},[e,t]),N=_.useCallback((F,O)=>{t.command({type:"board.column.update",columnId:F,title:O.title,semantic:O.semantic,colorToken:O.colorToken,wipLimit:O.wipLimit}).catch(X=>{Tr.getState().finishSync(e,hi(X))})},[e,t]),T=_.useCallback(F=>{t.command({type:"board.column.delete",columnId:F}).catch(O=>{Tr.getState().finishSync(e,hi(O))})},[e,t]),R=_.useCallback(F=>{var te;const O=Fi.getState().viewByBoard[e],X=((te=O==null?void 0:O.columns.at(-1))==null?void 0:te.id)??null;t.command({type:"board.column.create",boardId:e,title:F,afterColumnId:X}).catch(ie=>{Tr.getState().finishSync(e,hi(ie))})},[e,t]),M=_.useCallback(F=>{const O=Fi.getState().viewByBoard[e];if(!O)return;const X=Object.values(O.cards).flat().find(ue=>ue.id===F);if(!X)return;const ie=(O.cards[X.columnId]??[])[0];(ie==null?void 0:ie.id)!==F&&t.command({type:"board.card.move",cardId:F,toColumnId:X.columnId,aboveCardId:null,belowCardId:(ie==null?void 0:ie.id)??null}).catch(()=>{})},[e,t]),P=_.useCallback((F,O)=>{var ie,ue;const X=Fi.getState().viewByBoard[e],te=((ue=(ie=X==null?void 0:X.cards[F])==null?void 0:ie.at(-1))==null?void 0:ue.id)??null;t.command({type:"board.card.create",boardId:e,columnId:F,title:O,afterCardId:te}).catch(se=>{Tr.getState().finishSync(e,hi(se))})},[e,t]),B=Tr(F=>F.renamingBoardId===e),U=Tr(F=>F.titleDraft),D=_.useCallback(()=>{const F=Fi.getState().viewByBoard[e];F&&Tr.getState().startRenameBoard(e,F.board.title)},[e]),$=_.useCallback(F=>{Tr.getState().setTitleDraft(F.currentTarget.value)},[]),I=_.useCallback(()=>{const{titleDraft:F}=Tr.getState(),O=Fi.getState().viewByBoard[e];Tr.getState().stopRenameBoard();const X=F.trim();X===""||X===(O==null?void 0:O.board.title)||t.command({type:"board.update",boardId:e,title:X}).catch(te=>{Tr.getState().finishSync(e,hi(te))})},[e,t]),V=_.useCallback(F=>{F.key==="Enter"&&I(),F.key==="Escape"&&Tr.getState().stopRenameBoard()},[I]),z=_.useCallback(F=>{F==null||F.select()},[]),H=_.useCallback(()=>{Fi.getState().growPage(e)},[e]),W=s&&s.board.ownerKind==="project"&&i?s.board.ownerId:null,Y=_.useCallback(()=>{W&&(i==null||i(W))},[i,W]);return s?c.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-background",children:[c.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5",children:[W?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",onClick:Y,className:"shrink-0 rounded-md px-1.5 py-0.5 text-13 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Boards"}),c.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-13 text-muted-foreground",children:"/"})]}):null,B?c.jsx("input",{ref:z,value:U,onChange:$,onKeyDown:V,onBlur:I,"aria-label":"Board name",className:"min-w-0 flex-1 rounded-md bg-secondary px-1.5 py-0.5 text-15 font-semibold text-foreground focus:outline-none"}):c.jsx("button",{type:"button",onClick:D,className:"min-w-0 truncate rounded-md px-1.5 py-0.5 text-left text-15 font-semibold text-foreground hover:bg-secondary",children:s.board.title}),C?c.jsx("span",{className:"truncate font-mono text-xs tabular-nums text-muted-foreground",children:C}):null,c.jsxs(Ee,{variant:"secondary",size:"sm",className:"ml-auto",onClick:k,disabled:w,children:[c.jsx(u0,{"aria-hidden":!0,className:ce("size-3.5",w&&"animate-spin")}),w?"Syncing…":"Sync"]}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:x,"aria-label":"Card fields",children:c.jsx(_D,{"aria-hidden":!0,className:"size-3.5"})}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:m,"aria-label":"Sync settings",children:c.jsx(fq,{"aria-hidden":!0,className:"size-3.5"})})]}),c.jsxs("div",{className:"relative min-h-0 flex-1",children:[h?c.jsx(BWe,{boardId:e,socket:t,onClose:g}):null,v?c.jsx(o9e,{boardId:e,socket:t,onClose:y}):null,l?c.jsx(CWe,{cardId:l,socket:t,chatFacts:n,cardFields:s.board.cardFields,onClose:f}):null,c.jsx(HVe,{view:s,chatFacts:n,onCardMove:a,onColumnMove:E,onOpenCard:u,onLoadMore:H,onColumnSave:N,onColumnDelete:T,onColumnAdd:R,onCardAdd:P,onMoveToTop:M})]})]}):c.jsx("div",{className:"flex h-full items-center justify-center bg-background p-8",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading board…"})})}const oKe=_.forwardRef((e,t)=>c.jsx(Ee,{ref:t,variant:"ghost",size:"none","aria-label":"Public link",...e,className:e.className??"border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",children:c.jsx(Cme,{strokeWidth:2,className:"h-4.5"})})),PO=Xt("SharePopoverBody",()=>e=>({busy:!1,setBusy:t=>e({busy:t})}));function aKe(e,t){const n=e-t;if(n<=0)return"Expired";const r=Math.round(n/36e5);return r<1?"Expires in <1h":r<48?`Expires in ${r}h`:`Expires in ${Math.round(r/24)}d`}function lKe(e){const t=e.clipboard??aa,n=PO.useScopedStore(l=>l.busy),r=PO.useScopedStore(l=>l.setBusy),i=e.shares.filter(l=>!l.revoked),{onMint:s,chatId:o}=e,a=_.useCallback(async()=>{r(!0);try{await s(o)}catch{}finally{r(!1)}},[s,o,r]);return c.jsxs(c.Fragment,{children:[c.jsx(Ee,{variant:"default",disabled:n,"data-share-mint":"",onClick:()=>{a()},children:n?"Creating…":"Create share link"}),i.length===0?c.jsx("p",{className:"text-xs text-muted-foreground",children:"No active share links for this chat."}):c.jsx("ul",{className:"space-y-2",children:i.map(l=>c.jsxs("li",{className:"flex flex-col gap-1 rounded border border-border/40 p-2 text-xs",children:[c.jsx("code",{className:"break-all",children:l.url}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ee,{size:"sm",variant:"ghost",onClick:()=>{t.writeText(l.url)},children:[c.jsx(na,{className:"h-3.5 w-3.5 mr-1"}),"Copy"]}),c.jsxs(Ee,{size:"sm",variant:"ghost","data-share-revoke":"",onClick:()=>{e.onRevoke(l.tokenId)},children:[c.jsx(Sme,{className:"h-3.5 w-3.5 mr-1"}),"Revoke"]}),c.jsx("span",{className:"ml-auto text-muted-foreground",children:aKe(l.expiresAt,e.now)})]})]},l.tokenId))})]})}function cKe(e){return c.jsx(PO.Provider,{init:void 0,children:c.jsx(lKe,{...e})})}function uKe(e){const t=_.useMemo(()=>Date.now(),[e.open]);return c.jsxs(gi,{children:[c.jsxs(_c,{open:e.open,onOpenChange:e.onOpenChange,children:[c.jsx(vi,{asChild:!0,children:c.jsx(Sc,{asChild:!0,children:e.trigger})}),c.jsx(Nl,{align:"end",className:"w-96 p-4 space-y-3",children:c.jsx(cKe,{chatId:e.chatId,shares:e.shares,now:t,onMint:e.onMint,onRevoke:e.onRevoke})})]}),c.jsx(si,{side:"bottom",children:"Mint a public read-only link"})]})}function dKe({bindings:e,provider:t,onOpenPath:n}){return e.length<=1?null:c.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-0.5",children:[e.map(r=>{const i=r.worktreePath.split("/").pop()??r.worktreePath,s=r.role==="primary",o=r.projectStatus==="missing";return c.jsxs("div",{role:"button",tabIndex:0,className:"flex items-center gap-1 cursor-pointer",onClick:()=>n(r.worktreePath),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),n(r.worktreePath))},children:[s?c.jsx("span",{className:"text-emerald-500",children:"●"}):c.jsx("span",{className:"text-muted-foreground",children:"○"}),c.jsx("span",{className:`font-mono tabular-nums text-xs${o?" line-through text-muted-foreground":""}`,children:i})]},r.projectId)}),t==="codex"&&c.jsx("span",{className:"font-mono text-xs text-muted-foreground ml-2",children:"codex: cwd-only"})]})}function WV(e){return e.replace(/[/\\]+$/,"")}function fKe(e,t){const n=WV(e);if(!t)return n.split(/[/\\]/).filter(Boolean).pop()??"";const r=WV(t);if(n===r)return"~";for(const i of["/","\\"])if(n.startsWith(r+i))return`~/${n.slice(r.length+1).replace(/\\/g,"/")}`;return n}function hKe({hasGitRepo:e=!0,gitStatus:t="unknown",localPath:n,branchName:r,homeDir:i}){if(!e)return"Setup Git";if(t==="unknown")return null;const s=n?fKe(n,i):"",o=r??"Detached HEAD";return s?`${s} · ${o}`:o}const IO=Xt("OpenExternalSelect",({initialValue:e})=>t=>({lastValue:e,setLastValue:n=>t({lastValue:n})})),oT=[{value:"cursor",label:"Cursor"},{value:"xcode",label:"Xcode"},{value:"windsurf",label:"Windsurf"},{value:"custom",label:"Custom"}],_f={cursor:"/editor-icons/cursor.png",defaultApp:"/editor-icons/default-app.png",finder:"/editor-icons/finder.png",preview:"/editor-icons/preview.png",xcode:"/editor-icons/xcode.png",terminal:"/editor-icons/terminal.png",windsurf:"/editor-icons/windsurf.png",custom:"/editor-icons/custom.png"};function Sf({src:e,className:t}){return c.jsx("img",{src:e,alt:"","aria-hidden":"true",draggable:!1,className:t})}function Cae({preset:e,className:t}){switch(e){case"xcode":return c.jsx(Sf,{src:_f.xcode,className:t});case"windsurf":return c.jsx(Sf,{src:_f.windsurf,className:t});case"custom":return c.jsx(Sf,{src:_f.custom,className:t});case"cursor":case"vscode":default:return c.jsx(Sf,{src:_f.cursor,className:t})}}function pKe({className:e}){return c.jsx(Sf,{src:_f.finder,className:e})}function mKe({className:e}){return c.jsx(Sf,{src:_f.preview,className:e})}function gKe({className:e}){return c.jsx(Sf,{src:_f.defaultApp,className:e})}function vKe({className:e}){return c.jsx(yE,{className:e})}function bKe({className:e}){return c.jsx(Sf,{src:_f.terminal,className:e})}const VV="kanna:last-open-external",kae="py-2 pl-2 pr-8",xKe="rounded-md text-sm font-normal focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground",yKe="flex items-center gap-3",_Ke="h-5 w-5 shrink-0";function Eae({value:e,label:t,isMac:n}){return c.jsxs("span",{className:yKe,children:[c.jsx(Nae,{value:e,isMac:n,className:_Ke}),c.jsx("span",{children:t})]})}function SKe(e,t){return{preset:e,commandTemplate:e==="custom"&&(t==null?void 0:t.trim())||Zv(e)}}function wKe(e,t){var r;if(e==="finder")return t?"Finder":"Folder";if(e==="terminal")return"Terminal";if(e==="preview")return"Preview";if(e==="default")return"Default App";const n=e.slice(7);return n==="vscode"?"VS Code":((r=oT.find(i=>i.value===n))==null?void 0:r.label)??"Editor"}function Nae({value:e,isMac:t,className:n}){var s;if(e==="finder")return t?c.jsx(pKe,{className:n}):c.jsx(vKe,{className:n});if(e==="terminal")return c.jsx(bKe,{className:n});if(e==="preview")return c.jsx(mKe,{className:n});if(e==="default")return c.jsx(gKe,{className:n});const r=e.slice(7),i=((s=oT.find(o=>o.value===r))==null?void 0:s.value)??"vscode";return c.jsx(Cae,{preset:i,className:n})}function KV(e,t){if(e==="finder"||e==="terminal"||e==="preview"||e==="default")return e;if(e!=null&&e.startsWith("editor:")){const n=e.slice(7);if(zQ(n))return`editor:${n}`}return t}function Tae({editorPreset:e,isMac:t,includeFinder:n=!0,includeTerminal:r=!1,includePreview:i=!1,includeDefault:s=!1,menuKind:o="context"}){const a={value:"finder",label:t?"Finder":"Folder"},l={value:"terminal",label:"Terminal"},u={value:"preview",label:"Preview"},f={value:"default",label:"Default App"},m=[{value:"editor:cursor",label:"Cursor"},{value:"editor:xcode",label:"Xcode"},{value:"editor:windsurf",label:"Windsurf"},...e==="custom"?[{value:"editor:custom",label:"Custom"}]:[]],g=`editor:${e}`,v=[...m.filter(x=>x.value===g),...m.filter(x=>x.value!==g)];return o==="navbar"?[...v.filter(x=>x.value===g),...n?[a]:[],...r?[l]:[],...v.filter(x=>x.value!==g)]:[...v,...i&&t?[u]:[],...n?[a]:[],...r?[l]:[],...s?[f]:[]]}function Aae(e){var r;if(e.value==="finder"){e.onOpenExternal("open_finder");return}if(e.value==="terminal"){e.onOpenExternal("open_terminal");return}if(e.value==="preview"){e.onOpenExternal("open_preview");return}if(e.value==="default"){e.onOpenExternal("open_default");return}const t=e.value.slice(7),n=((r=oT.find(i=>i.value===t))==null?void 0:r.value)??"vscode";e.onOpenExternal("open_editor",SKe(n,e.editorCommandTemplate))}function CKe({isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:s,ports:o}){const a=(o==null?void 0:o.storage)??Tl,l=`editor:${t}`,u=IO.useScopedStore(v=>v.lastValue),f=IO.useScopedStore(v=>v.setLastValue);_.useEffect(()=>{f(KV(a.getItem(VV),l))},[l,f,a]);const h=_.useMemo(()=>Tae({editorPreset:t,isMac:e,includeFinder:!0,includeTerminal:!0,menuKind:"navbar"}),[t,e]);function m(v){f(v),a.setItem(VV,v),Aae({value:v,editorCommandTemplate:n,onOpenExternal:s})}let g;return u==="finder"?g=r:u===`editor:${t}`?g=i:g=void 0,c.jsxs("div",{className:"grid grid-cols-[1fr_auto]",children:[c.jsxs(K1,{children:[c.jsx(G1,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:()=>m(u),title:`Open in ${wKe(u,e)}`,className:"border-0 !pl-2.5 !pr-1 hover:!border-border/0 hover:!bg-transparent",children:c.jsx(Nae,{value:u,isMac:e,className:"size-6"})})}),c.jsx(Qy,{side:"bottom",shortcut:g})]}),c.jsxs(yo,{value:void 0,onValueChange:v=>m(KV(v,u)),children:[c.jsx(Qs,{"aria-label":"Choose open destination",className:"!pl-1 !pr-2.5 border-0 bg-transparent hover:bg-transparent focus:ring-0 focus:ring-offset-0 [&>svg]:hidden",children:c.jsx("span",{className:"flex items-center justify-center",children:c.jsx(Vf,{className:"h-4 w-4 opacity-60"})})}),c.jsx(Js,{align:"end",children:c.jsx(Bh,{children:h.map(v=>c.jsx(Br,{value:v.value,className:kae,children:c.jsx(Eae,{value:v.value,label:v.label,isMac:e})},v.value))})})]})]})}function kKe({isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:s,ports:o}){const a=`editor:${t}`;return c.jsx(IO.Provider,{init:{initialValue:a},children:c.jsx(CKe,{isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:s,ports:o})})}function EKe({isMac:e,editorPreset:t,editorCommandTemplate:n,includeFinder:r=!0,includeTerminal:i=!1,includePreview:s=!1,includeDefault:o=!1,onOpenExternal:a}){const l=Tae({editorPreset:t,isMac:e,includeFinder:r,includeTerminal:i,includePreview:s,includeDefault:o}),u=_.useCallback((f,h)=>{f.preventDefault(),Aae({value:h,editorCommandTemplate:n,onOpenExternal:a})},[n,a]);return c.jsx(Xu,{className:"rounded-lg p-1",children:l.map(f=>c.jsx(Xn,{className:`${kae} ${xKe}`,onSelect:h=>u(h,f.value),children:c.jsx(Eae,{value:f.value,label:f.label,isMac:e})},f.value))})}const OO=Xt("PtyInstanceRow",()=>e=>({confirmKill:!1,setConfirmKill:t=>e({confirmKill:t})})),rb={spawning:"var(--warning)","trust-dialog":"var(--warning)",ready:"var(--success, oklch(0.72 0.16 145))",streaming:"var(--primary)",cancelling:"var(--warning)",exited:"var(--muted-foreground)"},NKe={spawning:"spawning","trust-dialog":"trust",ready:"ready",streaming:"streaming",cancelling:"cancelling",exited:"exited"};function TKe(e){return e.length<=40?e:`…${e.slice(-39)}`}function AKe(e){return e.length>8?e.slice(0,8):e}function jKe(e,t){return a0e(e,t??Date.now())}function GV(e){if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${t.toFixed(0)} KB`;const n=t/1024;return n<1024?`${n.toFixed(0)} MB`:`${(n/1024).toFixed(1)} GB`}function qV(e){return e>=100?`${e.toFixed(0)}%`:e>=10?`${e.toFixed(1)}%`:`${e.toFixed(1)}%`}function RKe({phase:e}){return c.jsxs("span",{className:"inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-10 font-mono uppercase tracking-wide tabular-nums",style:{background:"color-mix(in oklch, var(--muted) 60%, transparent)"},children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-[6px] h-[6px] rounded-full",style:{backgroundColor:rb[e]}}),c.jsx("span",{style:{color:rb[e]},children:NKe[e]})]})}function MKe({instance:e,onOpenChat:t,onCancel:n,onKill:r}){return c.jsx(OO.Provider,{init:void 0,children:c.jsx(PKe,{instance:e,onOpenChat:t,onCancel:n,onKill:r})})}function PKe({instance:e,onOpenChat:t,onCancel:n,onKill:r}){const i=OO.useScopedStore(a=>a.confirmKill),s=OO.useScopedStoreApi(),o=_.useCallback(()=>{const a=s.getState();a.confirmKill?(r(e.chatId),a.setConfirmKill(!1)):a.setConfirmKill(!0)},[s,e.chatId,r]);return c.jsxs("div",{className:"group border border-border/60 rounded-lg p-3 flex flex-col gap-2 hover:border-border transition-colors",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("button",{type:"button",onClick:()=>t(e.chatId),className:"text-xs font-mono font-medium text-foreground hover:text-primary transition-colors text-left truncate flex-1 min-w-0",children:AKe(e.chatId)}),c.jsx(RKe,{phase:e.phase})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 text-11 text-muted-foreground font-mono tabular-nums",children:[c.jsxs(hu,{tooltip:e.cwd,children:[c.jsx("span",{className:"text-foreground/40",children:"cwd"})," ",TKe(e.cwd)]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"pid"})," ",e.pid??"—"]}),c.jsxs(hu,{tooltip:e.model,children:[c.jsx("span",{className:"text-foreground/40",children:"model"})," ",e.model||"—"]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"up"})," ",jKe(e.startedAt,e.exitedAt)]}),e.accountLabel?c.jsxs(hu,{className:"col-span-2",tooltip:e.accountLabel,children:[c.jsx("span",{className:"text-foreground/40",children:"acct"})," ",e.accountLabel,e.oauthMasked?c.jsxs("span",{className:"text-foreground/30",children:[" · ",e.oauthMasked]}):null]}):null,e.planMode!==null?c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"plan"})," ",e.planMode?"on":"off"]}):null,e.smokeTest?c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"smoke"})," ",c.jsx("span",{style:{color:e.smokeTest==="pass"?rb.ready:rb.exited},children:e.smokeTest})]}):null,e.rssBytes!==null?c.jsxs(hu,{className:"col-span-2",tooltip:"Resident memory (current · peak across session)",children:[c.jsx("span",{className:"text-foreground/40",children:"mem"})," ",GV(e.rssBytes),e.rssPeakBytes!==null&&e.rssPeakBytes>e.rssBytes?c.jsxs("span",{className:"text-foreground/30",children:[" · peak ",GV(e.rssPeakBytes)]}):null]}):null,e.cpuPercent!==null?c.jsxs(hu,{className:"col-span-2",tooltip:"CPU usage % across process tree (current · peak; >100% = multi-core)",children:[c.jsx("span",{className:"text-foreground/40",children:"cpu"})," ",qV(e.cpuPercent),e.cpuPeakPercent!==null&&e.cpuPeakPercent>e.cpuPercent?c.jsxs("span",{className:"text-foreground/30",children:[" · peak ",qV(e.cpuPeakPercent)]}):null]}):null]}),e.phase!=="exited"?c.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[c.jsx("button",{type:"button",onClick:()=>t(e.chatId),className:"text-10 font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors",children:"open"}),c.jsx("button",{type:"button",onClick:()=>n(e.chatId),className:"text-10 font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors",children:"cancel"}),c.jsx("button",{type:"button",onClick:o,onBlur:()=>s.getState().setConfirmKill(!1),className:"text-10 font-mono px-2 py-1 rounded-md border transition-colors ml-auto",style:{borderColor:i?"var(--destructive)":"var(--border)",color:i?"var(--destructive)":void 0},"aria-label":i?"Confirm kill":"Kill PTY process",children:i?"confirm kill?":"kill"})]}):c.jsxs("div",{className:"text-10 font-mono text-muted-foreground pt-1",children:["exited",e.exitCode!==null?` · code ${e.exitCode}`:""]})]})}function IKe({instances:e,liveCount:t,open:n,onOpenChange:r,onOpenChat:i,onCancel:s,onKill:o}){const a=t>0,l=a?`${t} claude PTY instance${t===1?"":"s"}`:"No live PTY instances";return c.jsxs(_c,{open:n,onOpenChange:r,children:[c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsx(Sc,{asChild:!0,children:c.jsxs("button",{type:"button","aria-label":l,className:"inline-flex items-center gap-1.5 px-1.5 h-9 rounded-md hover:bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-[7px] h-[7px] rounded-full flex-shrink-0",style:{backgroundColor:a?rb.ready:"var(--muted-foreground)"}}),c.jsxs("span",{className:"text-xs font-mono font-medium tabular-nums leading-none",style:{color:a?rb.ready:"var(--muted-foreground)"},children:["pty ",t]})]})})}),c.jsx(si,{side:"bottom",children:l})]}),c.jsxs(Nl,{align:"end",sideOffset:8,className:"w-[420px] p-3",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsx("h3",{className:"text-xs font-mono uppercase tracking-wider text-foreground/60",children:"claude pty instances"}),c.jsxs("span",{className:"text-10 font-mono text-muted-foreground tabular-nums",children:[t," live"]})]}),e.length===0?c.jsx("div",{className:"text-xs text-muted-foreground text-center py-6 font-mono",children:"no instances yet"}):c.jsx("div",{className:"flex flex-col gap-2 max-h-[60vh] overflow-y-auto",children:e.map(u=>c.jsx(MKe,{instance:u,onOpenChat:i,onCancel:s,onKill:o},u.chatId))})]})]})}function OKe({socket:e,onOpenChat:t}){const n=RBe(),r=MBe(),i=PBe(),s=_.useCallback(f=>{const h=wu.getState();f?h.openPopover():h.closePopover()},[]),o=_.useCallback(f=>{wu.getState().closePopover(),t==null||t(f)},[t]),a=_.useCallback(f=>{if(!e)return;const h={type:"pty.cancel",chatId:f};e.command(h).catch(()=>{})},[e]),l=_.useCallback(f=>{if(!e)return;const h={type:"pty.kill",chatId:f};e.command(h).catch(()=>{})},[e]),u=_.useMemo(()=>n,[n]);return c.jsx(IKe,{instances:u,liveCount:r,open:i,onOpenChange:s,onOpenChat:o,onCancel:a,onKill:l})}function DKe(e,t){e.preventDefault(),e.stopPropagation();const n=e.currentTarget.getBoundingClientRect();t.dispatchContextMenuEvent(e.currentTarget,n.left+n.width/2,n.bottom)}function LKe({showOnDesktop:e,onToggleEmbeddedTerminal:t,dom:n}){return t?c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:r=>DKe(r,n),title:"More actions",className:ce("border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",e?"flex":"flex md:hidden"),children:c.jsx(Pp,{strokeWidth:2,className:"h-4.5"})})}),c.jsx(Xu,{children:t?c.jsxs(Xn,{onSelect:r=>{r.preventDefault(),t()},children:[c.jsx(SE,{strokeWidth:2,className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Toggle Terminal"})]}):null})]}):null}function $Ke({chatId:e}){return Qie(OBe(e))?c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsxs("span",{className:"inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-10 font-mono uppercase tracking-wide flex-shrink-0",style:{background:"color-mix(in oklch, var(--muted) 60%, transparent)"},children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-[6px] h-[6px] rounded-full",style:{backgroundColor:"var(--warning)"}}),c.jsx("span",{style:{color:"var(--warning)"},children:"following"})]})}),c.jsx(si,{side:"bottom",children:"Live view of an external Claude session. Sending a message takes over and stops following."})]}):null}function BKe({sidebarCollapsed:e,onOpenSidebar:t,onExpandSidebar:n,onNewChat:r,localPath:i,embeddedTerminalVisible:s=!1,onToggleEmbeddedTerminal:o,rightSidebarVisible:a=!1,onToggleRightSidebar:l,onOpenExternal:u,editorPreset:f="cursor",editorCommandTemplate:h,platform:m="darwin",finderShortcut:g,editorShortcut:v,terminalShortcut:x,rightSidebarShortcut:y,branchName:w,homeDir:C,hasGitRepo:k=!0,gitStatus:E="unknown",timings:N,status:T,resolvedBindings:R,provider:M,onOpenPath:P=()=>{},socket:B,onOpenPtyChat:U,currentChatId:D,shareShares:$,onShareMint:I,onShareRevoke:V,silent:z,onToggleSilent:H,dom:W}){const Y=W??Et,F=hKe({hasGitRepo:k,gitStatus:E,localPath:i,branchName:w,homeDir:C}),O=yr.useScopedStore(ie=>ie.sharePopoverOpen),X=yr.useScopedStore(ie=>ie.setSharePopoverOpen),te=m==="darwin";return c.jsxs(YD,{className:ce("absolute top-0 left-0 right-0 z-10 md:pt-3 px-3 border-border/0 md:pb-0 flex items-center justify-center"," bg-gradient-to-b from-background/70"),children:[c.jsxs("div",{className:"relative flex items-center gap-2 w-full",children:[c.jsxs("div",{className:`flex items-center gap-1 flex-shrink-0 border border-border/0 rounded-2xl ${e?"px-1.5 border-border":""} p-1`,children:[c.jsx(Ee,{variant:"ghost",size:"icon-mobile",className:"md:hidden",onClick:t,"aria-label":"Open sidebar",children:c.jsx(SD,{className:"size-4.5"})}),e&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center justify-center w-[36px] h-[36px]",children:c.jsx(Cf,{className:"h-4 w-4 sm:h-5 sm:w-5 text-logo ml-1 hidden md:block"})}),c.jsx(Ee,{variant:"ghost",size:"icon",className:"hidden md:flex",onClick:n,title:"Expand sidebar","aria-label":"Expand sidebar",children:c.jsx(lM,{className:"size-4.5"})})]}),c.jsx(Ee,{variant:"ghost",size:"icon",className:"hover:!border-border/0 hover:!bg-transparent",onClick:r,title:"Compose","aria-label":"New chat",children:c.jsx(ED,{className:"size-4.5"})})]}),N&&T?c.jsx("div",{className:"flex-1 min-w-0 flex items-center justify-center select-none",children:c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-2 cursor-default",children:[c.jsxs("span",{className:"flex md:hidden items-center gap-1",children:[c.jsx("span",{className:ce("text-xs font-medium",Jy(R6(T))),children:"●"}),c.jsx("span",{className:"text-xs font-medium text-foreground",children:kf(T)}),c.jsx("span",{className:"text-xs font-mono tabular-nums text-foreground/80",children:Pu(N.derivedAtMs-N.stateEnteredAt)})]}),c.jsxs("span",{className:"hidden md:flex items-center gap-2",children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx("span",{className:ce("text-xs",Jy(R6(T))),children:"●"}),c.jsx("span",{className:"text-xs font-medium text-foreground",children:kf(T)})]}),c.jsx("span",{className:"text-xs font-mono tabular-nums text-foreground/80",children:Pu(N.derivedAtMs-N.stateEnteredAt)}),c.jsx("span",{className:"h-3 w-px bg-border/60","aria-hidden":!0}),c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:xo(N.derivedAtMs-N.activeSessionStartedAt)}),N.lastTurnDurationMs!=null?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"h-3 w-px bg-border/60","aria-hidden":!0}),c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:xo(N.lastTurnDurationMs)})]}):null]})]})}),c.jsx(si,{side:"bottom",className:"text-left",children:c.jsxs("div",{className:"space-y-0.5 text-xs",children:[c.jsxs("div",{children:["Chat created ",xo(N.derivedAtMs-N.chatCreatedAt)," ago"]}),c.jsxs("div",{children:["Idle ",xo(N.cumulativeMs.idle)]}),c.jsxs("div",{children:["Running ",xo(N.cumulativeMs.running)]}),c.jsxs("div",{children:["Waiting ",xo(N.cumulativeMs.waiting_for_user)]})]})})]})}):c.jsx("div",{className:"flex-1 min-w-0"}),c.jsx($Ke,{chatId:D}),c.jsxs("div",{className:"flex items-center flex-shrink-0 border border-border rounded-2xl",children:[c.jsx(OKe,{socket:B,onOpenChat:U}),H!=null?c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:H,"aria-pressed":z??!1,"aria-label":z?"Unsilence notifications":"Silence notifications",className:ce("border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",z&&"text-muted-foreground"),children:z?c.jsx(XG,{strokeWidth:2,className:"h-4.5"}):c.jsx(Bhe,{strokeWidth:2,className:"h-4.5"})})}),c.jsx(si,{side:"bottom",children:z?"Unsilence notifications":"Silence notifications"})]}):null]}),i&&(u||o||l)?c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u?c.jsx("div",{className:"hidden py-0.5 md:block border border-border rounded-2xl",children:c.jsx(kKe,{isMac:te,editorPreset:f,editorCommandTemplate:h,finderShortcut:g,editorShortcut:v,onOpenExternal:u})}):null,o||l?c.jsxs("div",{className:"flex items-center border border-border rounded-2xl px-2 py-0.5",children:[c.jsx(LKe,{showOnDesktop:a,onToggleEmbeddedTerminal:o,dom:Y}),o?c.jsxs(K1,{children:[c.jsx(G1,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:o,"aria-label":"Toggle terminal","aria-pressed":s,className:ce(a?"hidden":"hidden md:flex","border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",s&&"text-foreground"),children:c.jsx(SE,{strokeWidth:2,className:"h-4.5"})})}),c.jsx(Qy,{side:"bottom",shortcut:x})]}):null,D&&I&&V?c.jsx(uKe,{chatId:D,shares:$??[],open:O,onOpenChange:X,trigger:c.jsx(oKe,{}),onMint:I,onRevoke:V}):null,l?c.jsxs(K1,{children:[c.jsx(G1,{asChild:!0,children:c.jsxs(Ee,{variant:"ghost",onClick:l,className:ce("border flex flex-row items-center gap-1.5 h-9 border-border/0 pl-1.5 pr-2 hover:!border-border/0 hover:!bg-transparent",a&&"text-foreground"),children:[a?c.jsx(Vme,{strokeWidth:2.25,className:"h-4"}):c.jsx(xu,{strokeWidth:2.25,className:"h-4"}),F&&!a?c.jsx("div",{className:"text-13 font-mono max-w-[280px] truncate hidden md:block",children:F}):null]})}),c.jsx(Qy,{side:"bottom",shortcut:y})]}):null]}):null]}):null]}),R&&R.length>1&&c.jsx(dKe,{bindings:R,provider:M??null,onOpenPath:P})]})}function jae(e,t,n){const r=typeof e.maxTokens=="number"&&Number.isFinite(e.maxTokens)?e.maxTokens:null,i=r&&r>0?Math.min(100,e.usedTokens/r*100):null,s=r!==null?Math.max(0,Math.round(r-e.usedTokens)):null,o=i!==null?Math.max(0,100-i):null;return{...e,compactsAutomatically:e.compactsAutomatically||n,maxTokens:r??void 0,remainingTokens:s,usedPercentage:i,remainingPercentage:o,updatedAt:t}}function FKe(e){const t=e.some(n=>n.kind==="compact_boundary"||n.kind==="compact_summary"||n.kind==="context_cleared");for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r&&!(r.kind!=="context_window_updated"||r.usage.usedTokens<=0))return jae(r.usage,new Date(r.createdAt).toISOString(),t)}return null}function zKe(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:jae({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function Hd(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function UKe(e,t){let n=0,r=0,i=0,s=0;for(const a of e){if(a.kind!=="result")continue;const l=a.usage;l&&(n+=Hd(l.inputTokens),r+=Hd(l.outputTokens),i+=Hd(l.cachedInputTokens)),s+=Hd(a.costUsd??(l==null?void 0:l.costUsd))}for(const a of t){const l=a.usage;l&&(n+=Hd(l.inputTokens),r+=Hd(l.outputTokens),i+=Hd(l.cachedInputTokens),s+=Hd(l.costUsd))}if(n===0&&r===0&&i===0&&s===0)return null;const o=n>0?i/n*100:null;return{inputTokens:n,outputTokens:r,cachedTokens:i,costUsd:s,cacheHitPercentage:o}}function HKe(e){return!Number.isFinite(e)||e<=0?"$0.00":e<.01?"<$0.01":`$${e.toFixed(2)}`}function _o(e){return e==null||!Number.isFinite(e)?"0":e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}const WKe=350,VKe={dom:Et,timer:Jn};function KKe({rootRef:e,fallbackRef:t,enabled:n,canCancel:r,ports:i=VKe}){const{dom:s,timer:o}=i;_.useEffect(()=>{if(!n)return;let a=0,l=null;const u=C=>{const k=C instanceof Element?C:null,E=e.current,N=t.current;if(p6({trigger:"pointer",activeElement:s.getActiveElement(),pointerStartTarget:l,pointerEndTarget:k,root:E,fallback:N,hasActiveOverlay:s.hasFocusOverlay(),hasActiveSelection:Ixe(s.getSelection())})!=="restore"){l=null;return}N==null||N.focus({preventScroll:!0}),l=null},f=C=>{o.cancelAnimationFrame(a),l=C.target instanceof Element?C.target:null},h=C=>{o.cancelAnimationFrame(a),a=o.requestAnimationFrame(()=>{u(C.target)})},m=()=>{l=null;const C=t.current;!C||C.disabled||C.focus({preventScroll:!0})},g=C=>{if(C.key!=="Escape")return;const k=t.current;p6({trigger:"escape",activeElement:s.getActiveElement(),fallback:k,hasActiveOverlay:s.hasFocusOverlay(),canCancel:r,defaultPrevented:C.defaultPrevented})==="escape-focus"&&(C.preventDefault(),k==null||k.focus({preventScroll:!0}))},v=s.addWindowCaptureListener("pointerdown",f),x=s.addWindowCaptureListener("pointerup",h),y=s.addWindowCaptureListener("keydown",g),w=s.addWindowCustomListener(DD,m);return()=>{o.cancelAnimationFrame(a),v(),x(),y(),w()}},[r,s,n,t,e,o])}function GKe(e){return e.visibilityState==="visible"?e.activeChatId:null}function qKe(e){e.socket.setFocusedChat(GKe({activeChatId:e.activeChatId,visibilityState:e.visibilityState}))}function YKe({socket:e,activeChatId:t,ports:n}){const r=(n==null?void 0:n.dom)??Et;_.useEffect(()=>{const i=()=>{qKe({socket:e,activeChatId:t,visibilityState:r.getVisibilityState()})};i();const s=r.addDocumentListener("visibilitychange",i),o=r.addWindowListener("pagehide",i),a=r.addWindowListener("pageshow",i);return()=>{s(),o(),a(),e.setFocusedChat(null)}},[e,t,r])}const DO=Xt("KannaTranscript",()=>e=>({toolGroupExpanded:{},setToolGroupExpanded:(t,n)=>e(r=>r.toolGroupExpanded[t]===n?r:{toolGroupExpanded:{...r.toolGroupExpanded,[t]:n}})})),Rae=_.memo(({message:e})=>c.jsx("div",{className:"text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4",children:W$e(e.text)})),Mae=_.memo(({message:e})=>c.jsx("div",{className:"px-0.5 w-full max-w-[70ch]",children:c.jsx(KN,{content:e.text})})),nS=({children:e,className:t,animate:n=!0,shimmerWidth:r,...i})=>c.jsx("span",{className:ce("mx-auto max-w-md text-foreground/60",n&&"animate-shiny-pulse",t),...i,children:e});function XKe(e){const t=e.split(`
|
|
2831
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return o=u.done,u},e:function(u){a=!0,s=u},f:function(){try{o||n.return==null||n.return()}finally{if(a)throw s}}}}function yVe(e,t){if(e){if(typeof e=="string")return OV(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?OV(e,t):void 0}}function OV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function pae(e){return!!(e.top||e.left)}function mae(e){var t,n,r,i=e.target,s=e.input,o=e.source,a=e.findEntry,l=e.timeSinceLastFrame,u=e.available,f=u===void 0?{top:!0,left:!0}:u;if(!pae(f)||!i)return f;var h=i.closest(oVe);if(!h)return f;var m=a(h);if(!m)return f;function g(){var E;return mae({target:(E=h==null?void 0:h.parentElement)!==null&&E!==void 0?E:null,findEntry:a,source:o,timeSinceLastFrame:l,input:s,available:f})}var v={input:s,source:o,element:h};if(m.canScroll&&!m.canScroll(v))return g();var x=uae(h),y=dae((t=m.getConfiguration)===null||t===void 0?void 0:t.call(m,v)),w=(n=(r=m.getAllowedAxis)===null||r===void 0?void 0:r.call(m,v))!==null&&n!==void 0?n:"all",C=hae({element:h,engagement:x,input:s,timeSinceLastFrame:l,allowedAxis:w,config:y}),k={top:0,left:0};return f.top&&C.top!==0&&(k.top=C.top,f.top=!1),f.left&&C.left!==0&&(k.left=C.left,f.left=!1),(k.top!==0||k.left!==0)&&h.scrollBy(k),g()}function _Ve(e){var t=e.input,n=e.timeSinceLastFrame,r=e.available,i=e.source,s=e.entries,o=document.documentElement,a={input:t,source:i,element:o},l=xVe(s),u;try{for(l.s();!(u=l.n()).done;){var f,h,m,g=u.value;if(!(g.canScroll&&!g.canScroll(a))){var v=uae(o),x=dae((f=g.getConfiguration)===null||f===void 0?void 0:f.call(g,a)),y=(h=(m=g.getAllowedAxis)===null||m===void 0?void 0:m.call(g,a))!==null&&h!==void 0?h:"all",w=hae({element:o,engagement:v,input:t,config:x,allowedAxis:y,getRect:function(E){return DOMRect.fromRect({y:0,x:0,width:E.clientWidth,height:E.clientHeight})},timeSinceLastFrame:n}),C={top:r.top?w.top:0,left:r.left?w.left:0};(C.top!==0||C.left!==0)&&o.scrollBy(C);break}}}catch(k){l.e(k)}finally{l.f()}}function SVe(e){var t=e.input,n=e.findEntry,r=e.timeSinceLastFrame,i=e.source,s=e.getWindowScrollEntries,o=e.underUsersPointer,a=mae({target:o,timeSinceLastFrame:r,input:t,source:i,findEntry:n});pae(a)&&_Ve({input:t,source:i,entries:s(),timeSinceLastFrame:r,available:a})}function DV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function wVe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?DV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function CVe(e){var t=e.monitor,n=new Map,r=new Set;function i(u){n.set(u.element,u);var f=Pb(aVe(u.element),function(){return n.delete(u.element)});return Gu(f)}function s(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},f=wVe({},u);r.add(f);function h(){r.delete(f)}return Gu(h)}function o(u){var f;return(f=n.get(u))!==null&&f!==void 0?f:null}function a(){return Array.from(r)}function l(u){var f=u.latestArgs,h=u.underUsersPointer,m=u.timeSinceLastFrame;SVe({input:f.location.current.input,source:f.source,findEntry:o,underUsersPointer:h,timeSinceLastFrame:m,getWindowScrollEntries:a})}return iVe(t).onFrame(l),{autoScroll:i,autoScrollWindow:s}}var kVe=CVe({monitor:eVe}),gae=kVe.autoScroll;function LV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $V(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?LV(Object(n),!0).forEach(function(r){dl(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LV(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var EVe={top:function(t,n){return Math.abs(n.y-t.top)},right:function(t,n){return Math.abs(t.right-n.x)},bottom:function(t,n){return Math.abs(t.bottom-n.y)},left:function(t,n){return Math.abs(n.x-t.left)}},vae=Symbol("closestEdge");function bae(e,t){var n,r,i=t.element,s=t.input,o=t.allowedEdges,a={x:s.clientX,y:s.clientY},l=i.getBoundingClientRect(),u=o.map(function(h){return{edge:h,value:EVe[h](l,a)}}),f=(n=(r=u.sort(function(h,m){return h.value-m.value})[0])===null||r===void 0?void 0:r.edge)!==null&&n!==void 0?n:null;return $V($V({},e),{},dl({},vae,f))}function xae(e){var t;return(t=e[vae])!==null&&t!==void 0?t:null}const NVe={timer:Jn};function sT(e=1e3,t){const{timer:n}=NVe,[r,i]=_.useState(()=>Date.now()),s=_.useRef(e);return _.useLayoutEffect(()=>{s.current=e}),_.useEffect(()=>{const o=n.setInterval(()=>{i(Date.now())},s.current);return()=>n.clearInterval(o)},[n]),r}function P1(e,t){return`${String(e)} ${t}${e===1?"":"s"}`}function TVe(e){return e.nextFireAt===null?{tone:"muted",label:"Scheduled",clock:null}:{tone:"muted",label:"Runs in",clock:{kind:"countdown",until:e.nextFireAt}}}function AVe(e){const{activity:t}=e,n=zE(e),r=e.stateEnteredAt===void 0?null:{kind:"elapsed",since:e.stateEnteredAt};if((n==null?void 0:n.tone)==="destructive")return{tone:"destructive",label:n.label,clock:null};if(t.lastRunFailure){const{code:i}=t.lastRunFailure;return{tone:"destructive",label:i===null?"Agent failed":`Agent failed — ${i}`,clock:null}}if((n==null?void 0:n.tone)==="info"||t.awaitingAnswer)return{tone:"info",label:(n==null?void 0:n.label)??kf("waiting_for_user"),clock:r};if(t.workflow){const{name:i,agentCount:s}=t.workflow;return{tone:"warning",label:`${i??"Workflow"} · ${P1(s,"agent")}`,clock:r}}if(t.loop){const{done:i,total:s}=t.loop;return{tone:"warning",label:`Loop · ${String(i)}/${String(s)}`,clock:r}}return t.agents>0?{tone:"warning",label:P1(t.agents,"agent"),clock:r}:(n==null?void 0:n.tone)==="warning"?{tone:"warning",label:n.label,clock:r}:t.backgroundTasks>0?{tone:"warning",label:P1(t.backgroundTasks,"background task"),clock:r}:t.cron&&!t.cron.paused?TVe(t.cron):n?{tone:n.tone,label:n.label,clock:null}:null}function jVe(e,t){const n=e.flatMap(i=>{const s=t[i];return s?[{chatId:i,chat:s}]:[]});if(n.length===0)return null;for(const{chatId:i,chat:s}of n){const o=AVe(s);if(o)return{chatId:i,...o,linkedCount:n.length}}const r=n[0];return r?{chatId:r.chatId,tone:null,label:P1(n.length,"chat"),linkedCount:n.length,clock:null}:null}function RVe(e,t,n){var u,f,h,m;const r=e.cards[n.columnId];if(!r)return null;const i=r.filter(g=>g.id!==t),s=n.beforeCardId===null?i.length:i.findIndex(g=>g.id===n.beforeCardId);if(s<0)return null;const o=((u=i[s-1])==null?void 0:u.id)??null,a=((f=i[s])==null?void 0:f.id)??null,l=MVe(e,t);if(l&&l.columnId===n.columnId){const g=((h=l.cards[l.index-1])==null?void 0:h.id)??null,v=((m=l.cards[l.index+1])==null?void 0:m.id)??null;if(g===o&&v===a)return null}return{cardId:t,toColumnId:n.columnId,aboveCardId:o,belowCardId:a}}function MVe(e,t){for(const[n,r]of Object.entries(e.cards)){const i=r.findIndex(s=>s.id===t);if(i>=0)return{columnId:n,index:i,cards:r}}return null}function PVe(e,t,n){var a,l;const r=e.findIndex(u=>u.id===t);if(r<0)return null;const i=e.filter(u=>u.id!==t),s=n===null?i.length:i.findIndex(u=>u.id===n);if(s<0)return null;const o=((a=i[s-1])==null?void 0:a.id)??null;return(((l=e[r-1])==null?void 0:l.id)??null)===o?null:{columnId:t,afterColumnId:o}}function IVe(e,t,n){var i;const r=e.findIndex(s=>s.id===t);return r<0?null:n==="top"?t:((i=e[r+1])==null?void 0:i.id)??null}function OVe(e,t,n){var i;const r=e.findIndex(s=>s.id===t);return r<0?null:n==="left"?t:((i=e[r+1])==null?void 0:i.id)??null}function DVe(e,t){const n=t.text.trim().toLowerCase(),r=t.labels;return!n&&r.length===0?e:e.filter(i=>{if(n&&!i.title.toLowerCase().includes(n))return!1;if(r.length>0){const s=i.content.labels,o=(s==null?void 0:s.kind)==="label"?s.values:[];if(!r.some(a=>o.includes(a)))return!1}return!0})}function yae(e,t){return t!==null&&e.createdAt>t}function LVe(e,t){return t===null?0:e.filter(n=>yae(n,t)).length}const Jo=Yt()(e=>({draggingCardId:null,cardDrop:null,draggingColumnId:null,columnDropBeforeId:null,columnDropActive:!1,startCardDrag:t=>e({draggingCardId:t,cardDrop:null}),setCardDrop:t=>e({cardDrop:t}),startColumnDrag:t=>e({draggingColumnId:t,columnDropBeforeId:null,columnDropActive:!1}),setColumnDrop:(t,n)=>e({columnDropBeforeId:t,columnDropActive:n}),endDrag:()=>e({draggingCardId:null,cardDrop:null,draggingColumnId:null,columnDropBeforeId:null,columnDropActive:!1})}));function $Ve(e,t){return n=>{var r;return((r=n.cardDrop)==null?void 0:r.columnId)===e&&n.cardDrop.beforeCardId===t}}function BVe(e){return t=>{var n;return((n=t.cardDrop)==null?void 0:n.columnId)===e&&t.cardDrop.beforeCardId===null}}const RO={text:"",labels:[]},I1=Yt(e=>({filterByBoard:{},setText:(t,n)=>e(r=>({filterByBoard:{...r.filterByBoard,[t]:{...r.filterByBoard[t]??RO,text:n}}})),setLabels:(t,n)=>e(r=>({filterByBoard:{...r.filterByBoard,[t]:{...r.filterByBoard[t]??RO,labels:n}}})),clear:t=>e(n=>{const{[t]:r,...i}=n.filterByBoard;return{filterByBoard:i}})}));function _ae(e){return t=>t.filterByBoard[e]??RO}function FVe({boardId:e}){const t=I1(_ae(e)),n=_.useCallback(s=>{I1.getState().setText(e,s.currentTarget.value)},[e]),r=_.useCallback(()=>{I1.getState().clear(e)},[e]),i=t.text.length>0||t.labels.length>0;return c.jsxs("div",{className:"flex items-center gap-1 px-1 pb-1.5",children:[c.jsx("input",{value:t.text,onChange:n,placeholder:"Filter…","aria-label":"Filter cards",className:ce("min-w-0 flex-1 rounded-md bg-transparent px-2 py-1 text-xs text-foreground","placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none")}),i?c.jsx("button",{type:"button",onClick:r,"aria-label":"Clear filter",className:"shrink-0 rounded-md p-1 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:c.jsx(xi,{"aria-hidden":!0,className:"size-3"})}):null]})}const BV={title:"",semantic:null,colorToken:null,wipLimit:null},nu=Yt()(e=>({openColumnId:null,draft:BV,open:(t,n)=>e({openColumnId:t,draft:n}),close:()=>e({openColumnId:null,draft:BV}),setTitle:t=>e(n=>({draft:{...n.draft,title:t}})),setSemantic:t=>e(n=>({draft:{...n.draft,semantic:UWe(t)?t:null}})),setColorToken:t=>e(n=>({draft:{...n.draft,colorToken:Xoe(t)?t:null}})),setWipLimit:t=>e(n=>{const r=Number.parseInt(t.trim(),10);return{draft:{...n.draft,wipLimit:Number.isInteger(r)&&r>0?r:null}}})})),FV=[{value:"",label:"No role",hint:"Nothing routes here automatically."},{value:"start",label:"Incoming",hint:"Pulled issues land here."},{value:"active",label:"In progress",hint:"Start work moves a card here."},{value:"review",label:"In review",hint:"No automatic behaviour yet."},{value:"done",label:"Done",hint:"Closes the issue, and asks about the worktree."}];function zVe({columnId:e,value:t,canDelete:n,onSave:r,onDelete:i}){var x;const s=nu(y=>y.openColumnId===e),o=nu(y=>y.draft),a=_.useCallback(y=>{const w=nu.getState();y?w.open(e,t):w.close()},[e,t]),l=_.useCallback(y=>{nu.getState().setTitle(y.currentTarget.value)},[]),u=_.useCallback(y=>{nu.getState().setWipLimit(y.currentTarget.value)},[]),f=_.useCallback(y=>{nu.getState().setSemantic(y.currentTarget.value)},[]),h=_.useCallback(y=>{nu.getState().setColorToken(y.currentTarget.value)},[]),m=_.useCallback(()=>{const y=nu.getState();y.draft.title.trim()!==""&&(r(e,{...y.draft,title:y.draft.title.trim()}),y.close())},[e,r]),g=_.useCallback(()=>{i(e),nu.getState().close()},[e,i]),v=(x=FV.find(y=>(y.value===""?null:y.value)===o.semantic))==null?void 0:x.hint;return c.jsxs(_c,{open:s,onOpenChange:a,children:[c.jsx(Sc,{asChild:!0,children:c.jsx("button",{type:"button","aria-label":`Column settings: ${t.title}`,className:"rounded-md p-0.5 text-muted-foreground hover:bg-secondary hover:text-foreground",children:c.jsx(Pp,{"aria-hidden":!0,className:"size-4"})})}),c.jsxs(Nl,{align:"end",className:"w-72 space-y-4 p-3",children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:`column-title-${e}`,children:"Name"}),c.jsx(Bt,{id:`column-title-${e}`,value:o.title,onChange:l})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:`column-role-${e}`,children:"Role"}),c.jsx("select",{id:`column-role-${e}`,value:o.semantic??"",onChange:f,className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-13 text-foreground",children:FV.map(y=>c.jsx("option",{value:y.value,children:y.label},y.label))}),v?c.jsx("p",{className:"text-13 text-muted-foreground",children:v}):null]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Dot"}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(cE,{token:null,label:"No dot",selected:o.colorToken===null,onSelect:h}),X3.map(y=>c.jsx(cE,{token:y,label:y,selected:o.colorToken===y,onSelect:h},y))]})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:`column-wip-${e}`,children:"WIP limit"}),c.jsx(Bt,{id:`column-wip-${e}`,value:o.wipLimit===null?"":String(o.wipLimit),onChange:u,inputMode:"numeric",placeholder:"None",className:"tabular-nums"}),c.jsx("p",{className:"text-13 text-muted-foreground",children:"Advisory. Going over is shown, never blocked."})]}),c.jsxs("div",{className:"flex items-center gap-2 border-t border-border pt-3",children:[c.jsx(Ee,{size:"sm",onClick:m,disabled:o.title.trim()==="",children:"Save"}),c.jsx(Ee,{variant:"ghost",size:"sm",className:"ml-auto text-destructive-text",onClick:g,disabled:!n,children:"Delete"})]}),n?null:c.jsx("p",{className:"text-13 text-muted-foreground",children:"Move or archive its cards before deleting it."})]})]})}const RC=Yt()(e=>({draft:"",setDraft:t=>e({draft:t}),clear:()=>e({draft:""})})),MC=Yt()(e=>({draftByColumn:{},setDraft:(t,n)=>e(r=>({draftByColumn:{...r.draftByColumn,[t]:n}})),clear:t=>e(n=>{if(!(t in n.draftByColumn))return n;const r={...n.draftByColumn};return delete r[t],{draftByColumn:r}})}));function UVe(e){return t=>t.draftByColumn[e]??""}const MO="kanna-board-card",zV="kanna-board-column",Sae={current:[]};function HVe(e){const{view:t,onCardMove:n,onColumnMove:r}=e,i=_.useRef(null),s=_.useRef(t);_.useLayoutEffect(()=>{s.current=t,Sae.current=t.columns});const o=t.board.id,a=I1(_ae(o)),l=_.useCallback(f=>{const h=Jo.getState().cardDrop;if(Jo.getState().endDrag(),!h)return;const m=RVe(s.current,f,h);m&&n(m)},[n]),u=_.useCallback(f=>{const{columnDropBeforeId:h,columnDropActive:m}=Jo.getState();if(Jo.getState().endDrag(),!m)return;const g=PVe(s.current.columns,f,h);g&&r(g.columnId,g.afterColumnId)},[r]);return _.useEffect(()=>{const f=i.current;if(f)return gae({element:f})},[]),c.jsxs("div",{ref:i,className:"kanna-board flex h-full w-full items-stretch gap-0 overflow-x-auto bg-background p-4",children:[t.columns.map(f=>{const h=t.cards[f.id]??WVe,m=f.semantic==="start",g=m?DVe(h,a):h;return c.jsx(qVe,{column:f,cards:g,total:t.counts[f.id]??h.length,newSince:m?t.newSince??null:null,chatLinksByCard:t.chatLinksByCard??KVe,chatFacts:e.chatFacts??GVe,onCardDrop:l,onColumnDrop:u,onOpenCard:e.onOpenCard,onLoadMore:e.onLoadMore,onColumnSave:e.onColumnSave,onColumnDelete:e.onColumnDelete,onCardAdd:e.onCardAdd,onMoveToTop:e.onMoveToTop},f.id)}),c.jsx(eKe,{onAdd:e.onColumnAdd,isFirst:t.columns.length===0})]})}const WVe=[],VVe=[],KVe={},GVe={};function qVe({column:e,cards:t,total:n,newSince:r,chatLinksByCard:i,chatFacts:s,onOpenCard:o,onLoadMore:a,onColumnSave:l,onColumnDelete:u,onCardAdd:f,onCardDrop:h,onColumnDrop:m,onMoveToTop:g}){const v=_.useRef(null),x=_.useRef(null),y=e.id,w=Jo(M=>M.draggingColumnId===y),C=Jo(M=>M.columnDropActive&&M.columnDropBeforeId===y),k=Jo(BVe(y));_.useEffect(()=>{const M=v.current,P=x.current;if(!M||!P)return;const B=Jo.getState(),U=M.querySelector("[data-column-handle]")??void 0;return Pb(cae({element:M,dragHandle:U,getInitialData:()=>({[zV]:!0,columnId:y}),onDragStart:()=>{B.startColumnDrag(y)},onDrop:()=>{m(y)}}),TO({element:M,canDrop:({source:D})=>D.data[zV]===!0,getData:({input:D,element:$})=>bae({columnId:y},{input:D,element:$,allowedEdges:["left","right"]}),onDragEnter:({self:D})=>{UV(D.data,y)},onDrag:({self:D})=>{UV(D.data,y)}}),TO({element:P,canDrop:({source:D})=>D.data[MO]===!0,getData:()=>({columnId:y}),onDragEnter:()=>{B.setCardDrop({columnId:y,beforeCardId:null})},onDragLeave:()=>{B.setCardDrop(null)}}),gae({element:P}))},[y,m]);const E=sWe(n,e.wipLimit),N=_.useMemo(()=>({title:e.title,semantic:e.semantic,colorToken:e.colorToken,wipLimit:e.wipLimit}),[e.colorToken,e.semantic,e.title,e.wipLimit]),T=e.semantic==="start",R=r!==null?LVe(t,r):0;return c.jsxs("div",{ref:v,className:ce("relative flex h-full w-[300px] shrink-0 flex-col border-r border-border px-3",w&&"opacity-40"),children:[C?c.jsx(QVe,{}):null,c.jsxs("div",{"data-column-handle":!0,className:"flex cursor-grab items-center gap-2 px-1 pb-2 pt-1",children:[e.colorToken?c.jsx("span",{"aria-hidden":!0,className:ce("size-1.5 shrink-0 rounded-full",nT[e.colorToken])}):null,c.jsx("span",{className:"truncate text-[0.9375rem] font-semibold leading-tight text-foreground",children:e.title}),c.jsx("span",{className:ce("ml-auto font-mono text-xs tabular-nums",E?"text-warning":"text-muted-foreground"),children:T&&R>0?c.jsxs(c.Fragment,{children:[n,c.jsxs("span",{className:"text-info",children:[" · ",R," new"]})]}):n}),c.jsx(zVe,{columnId:y,value:N,canDelete:n===0,onSave:l,onDelete:u})]}),T?c.jsx(FVe,{boardId:e.boardId}):null,c.jsxs("div",{ref:x,className:"min-h-0 flex-1 space-y-2 overflow-y-auto px-1 py-2",children:[t.map(M=>c.jsx(YVe,{card:M,columnId:y,cards:t,chatIds:i[M.id]??VVe,chatFacts:s,newSince:r,onOpen:o,onCardDrop:h,onMoveToTop:g},M.id)),k?c.jsx(wae,{}):null,n>t.length?c.jsx(JVe,{columnId:y,onLoadMore:a}):null]}),c.jsx(ZVe,{columnId:y,onAdd:f})]})}function UV(e,t){const n=xae(e);if(n!=="left"&&n!=="right")return;const r=OVe(Sae.current,t,n);Jo.getState().setColumnDrop(r,!0)}function YVe({card:e,columnId:t,cards:n,chatIds:r,chatFacts:i,newSince:s,onOpen:o,onCardDrop:a,onMoveToTop:l}){const u=_.useRef(null),f=e.id,h=Jo(C=>C.draggingCardId===f),m=Jo($Ve(t,f)),g=_.useRef(n);_.useLayoutEffect(()=>{g.current=n}),_.useEffect(()=>{const C=u.current;if(!C)return;const k=Jo.getState();return Pb(cae({element:C,getInitialData:()=>({[MO]:!0,cardId:f}),onDragStart:()=>{k.startCardDrag(f)},onDrop:()=>{a(f)}}),TO({element:C,canDrop:({source:E})=>E.data[MO]===!0,getData:({input:E,element:N})=>bae({cardId:f},{input:E,element:N,allowedEdges:["top","bottom"]}),onDragEnter:({self:E})=>{HV(E.data,t,f,g.current)},onDrag:({self:E})=>{HV(E.data,t,f,g.current)}}))},[f,t,a]);const v=_.useCallback(()=>{o(f)},[f,o]),x=_.useCallback(()=>{l(f)},[f,l]),y=jVe(r,i),w=yae(e,s);return c.jsxs("div",{ref:u,className:"relative",children:[m?c.jsx(wae,{}):null,c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:c.jsxs("button",{type:"button",onClick:v,className:ce("w-full cursor-grab rounded-lg border border-border bg-card px-3 py-2 text-left","transition-colors duration-150 hover:bg-secondary","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",h&&"opacity-40"),children:[c.jsx("span",{className:"line-clamp-2 text-sm font-medium leading-snug text-foreground [text-wrap:pretty]",children:e.title}),w?c.jsxs("span",{className:"mt-1 flex items-center gap-1 text-xs text-info",children:[c.jsx("span",{"aria-hidden":!0,className:"size-1.5 shrink-0 rounded-full bg-info"}),c.jsx("span",{children:"New"})]}):null,y?c.jsxs("span",{className:ce("mt-1.5 flex items-center gap-1.5 text-xs",lX(y.tone)),children:[y.tone?c.jsx("span",{"aria-hidden":!0,className:ce("size-1.5 shrink-0 rounded-full",UE(y.tone))}):c.jsx(oq,{"aria-hidden":!0,className:"size-3 shrink-0"}),c.jsx("span",{children:y.label}),y.clock===null?null:c.jsx(XVe,{clock:y.clock})]}):null]})}),c.jsx(Xu,{children:c.jsx(Xn,{onSelect:x,children:"Move to top"})})]})]})}function XVe({clock:e}){const t=sT(1e3),n=e.kind==="elapsed"?Pu(Math.max(0,t-e.since)):h0e(e.until-t);return c.jsx("span",{className:"tabular-nums",children:n})}function HV(e,t,n,r){const i=xae(e);if(i!=="top"&&i!=="bottom")return;const s=IVe(r,n,i);Jo.getState().setCardDrop({columnId:t,beforeCardId:s})}function wae(){return c.jsx("div",{"aria-hidden":!0,className:"pointer-events-none h-px w-full rounded-full bg-primary"})}function QVe(){return c.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 left-0 w-px bg-primary"})}function JVe({columnId:e,onLoadMore:t}){const n=_.useRef(null);return _.useEffect(()=>{const r=n.current;if(!r)return;const i=new IntersectionObserver(s=>{s.some(o=>o.isIntersecting)&&t(e)});return i.observe(r),()=>{i.disconnect()}},[e,t]),c.jsxs("div",{ref:n,className:"space-y-2","aria-hidden":!0,children:[c.jsx("div",{className:"h-14 w-full animate-pulse rounded-lg border border-border bg-secondary"}),c.jsx("div",{className:"h-14 w-full animate-pulse rounded-lg border border-border bg-secondary"})]})}function ZVe({columnId:e,onAdd:t}){const n=MC(UVe(e)),r=_.useCallback(s=>{MC.getState().setDraft(e,s.currentTarget.value)},[e]),i=_.useCallback(s=>{s.preventDefault();const o=(MC.getState().draftByColumn[e]??"").trim();o!==""&&(MC.getState().clear(e),t(e,o))},[e,t]);return c.jsx("form",{onSubmit:i,className:"shrink-0 px-1 pb-1 pt-2",children:c.jsx("input",{value:n,onChange:r,placeholder:"Add a card","aria-label":"Add a card",className:"w-full rounded-md bg-transparent px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none"})})}function eKe({onAdd:e,isFirst:t}){const n=RC(s=>s.draft),r=_.useCallback(s=>{RC.getState().setDraft(s.currentTarget.value)},[]),i=_.useCallback(s=>{s.preventDefault();const o=RC.getState().draft.trim();o!==""&&(RC.getState().clear(),e(o))},[e]);return c.jsxs("form",{onSubmit:i,className:"w-64 shrink-0 px-3 pt-1",children:[t?c.jsx("p",{className:"mb-2 px-1 text-sm text-muted-foreground [text-wrap:pretty]",children:"No columns yet. Name your first one to start tracking work your agents can pick up."}):null,c.jsx("input",{value:n,onChange:r,placeholder:t?"Name your first column":"Add a column","aria-label":"Add a column",className:"w-full rounded-md bg-transparent px-1 py-1 text-[0.9375rem] text-foreground placeholder:text-muted-foreground hover:bg-secondary focus:bg-secondary focus:outline-none"})]})}function tKe(e,t){const n=nKe(e,t.cardId);if(n===null||!(t.toColumnId in e.cards))return e;const r=(e.cards[n]??[]).find(a=>a.id===t.cardId);if(!r)return e;const i={...e.cards};i[n]=(i[n]??[]).filter(a=>a.id!==t.cardId);const s=t.toColumnId===n?[...i[n]??[]]:[...i[t.toColumnId]??[]];s.splice(rKe(s,t),0,{...r,columnId:t.toColumnId}),i[t.toColumnId]=s;const o={...e.counts};return t.toColumnId!==n&&(o[n]=Math.max(0,(o[n]??1)-1),o[t.toColumnId]=(o[t.toColumnId]??0)+1),{...e,cards:i,counts:o}}function nKe(e,t){for(const[n,r]of Object.entries(e.cards))if(r.some(i=>i.id===t))return n;return null}function rKe(e,t){if(t.aboveCardId!==null){const n=e.findIndex(r=>r.id===t.aboveCardId);if(n!==-1)return n+1}if(t.belowCardId!==null){const n=e.findIndex(r=>r.id===t.belowCardId);if(n!==-1)return n}return t.aboveCardId!==null?e.length:0}function iKe(e,t,n){const r=e.columns.find(o=>o.id===t);if(!r||n!==null&&!e.columns.some(o=>o.id===n))return e;const i=e.columns.filter(o=>o.id!==t),s=n===null?0:i.findIndex(o=>o.id===n)+1;return{...e,columns:[...i.slice(0,s),r,...i.slice(s)]}}function sKe({boardId:e,socket:t,chatFacts:n,onOpenCard:r,onOpenBoards:i}){const s=Fi(i7e(e)),o=Fi(s7e(e));_.useEffect(()=>t.subscribe({type:"board",boardId:e,pageSize:o},F=>{Fi.getState().setBoardView(F.boardId,F.view)}),[e,o,t]);const a=_.useCallback(F=>{const O=Fi.getState().viewByBoard[e];O&&Fi.getState().setBoardView(e,tKe(O,F)),t.command({type:"board.card.move",cardId:F.cardId,toColumnId:F.toColumnId,aboveCardId:F.aboveCardId,belowCardId:F.belowCardId}).catch(()=>{})},[e,t]),l=Tr(F=>F.openCardId),u=_.useCallback(F=>{Tr.getState().openCard(F),r==null||r(F)},[r]),f=_.useCallback(()=>{Tr.getState().closeCard()},[]),h=Tr(F=>F.syncPanelOpen),m=_.useCallback(()=>{Tr.getState().openSyncPanel()},[]),g=_.useCallback(()=>{Tr.getState().closeSyncPanel()},[]),v=Tr(F=>F.schemaPanelOpen),x=_.useCallback(()=>{const F=Fi.getState().viewByBoard[e];F&&(vu.getState().open(F.board.cardFields),Tr.getState().openSchemaPanel())},[e]),y=_.useCallback(()=>{Tr.getState().closeSchemaPanel()},[]),w=Tr(F=>F.syncingBoardId===e),C=Tr(F=>F.messageByBoard[e]??null),k=_.useCallback(()=>{const F=Tr.getState();F.startSync(e),t.command({type:"board.sync.pull",boardId:e}).then(O=>{const X=O.conflicts>0?`, ${String(O.conflicts)} conflicts`:"";F.finishSync(e,`Synced · ${String(O.created)} new, ${String(O.updated)} updated${X}`)}).catch(O=>{F.finishSync(e,hi(O))})},[e,t]),E=_.useCallback((F,O)=>{const X=Fi.getState().viewByBoard[e];X&&Fi.getState().setBoardView(e,iKe(X,F,O)),t.command({type:"board.column.move",columnId:F,afterColumnId:O}).catch(()=>{})},[e,t]),N=_.useCallback((F,O)=>{t.command({type:"board.column.update",columnId:F,title:O.title,semantic:O.semantic,colorToken:O.colorToken,wipLimit:O.wipLimit}).catch(X=>{Tr.getState().finishSync(e,hi(X))})},[e,t]),T=_.useCallback(F=>{t.command({type:"board.column.delete",columnId:F}).catch(O=>{Tr.getState().finishSync(e,hi(O))})},[e,t]),R=_.useCallback(F=>{var te;const O=Fi.getState().viewByBoard[e],X=((te=O==null?void 0:O.columns.at(-1))==null?void 0:te.id)??null;t.command({type:"board.column.create",boardId:e,title:F,afterColumnId:X}).catch(ie=>{Tr.getState().finishSync(e,hi(ie))})},[e,t]),M=_.useCallback(F=>{const O=Fi.getState().viewByBoard[e];if(!O)return;const X=Object.values(O.cards).flat().find(ue=>ue.id===F);if(!X)return;const ie=(O.cards[X.columnId]??[])[0];(ie==null?void 0:ie.id)!==F&&t.command({type:"board.card.move",cardId:F,toColumnId:X.columnId,aboveCardId:null,belowCardId:(ie==null?void 0:ie.id)??null}).catch(()=>{})},[e,t]),P=_.useCallback((F,O)=>{var ie,ue;const X=Fi.getState().viewByBoard[e],te=((ue=(ie=X==null?void 0:X.cards[F])==null?void 0:ie.at(-1))==null?void 0:ue.id)??null;t.command({type:"board.card.create",boardId:e,columnId:F,title:O,afterCardId:te}).catch(se=>{Tr.getState().finishSync(e,hi(se))})},[e,t]),B=Tr(F=>F.renamingBoardId===e),U=Tr(F=>F.titleDraft),D=_.useCallback(()=>{const F=Fi.getState().viewByBoard[e];F&&Tr.getState().startRenameBoard(e,F.board.title)},[e]),$=_.useCallback(F=>{Tr.getState().setTitleDraft(F.currentTarget.value)},[]),I=_.useCallback(()=>{const{titleDraft:F}=Tr.getState(),O=Fi.getState().viewByBoard[e];Tr.getState().stopRenameBoard();const X=F.trim();X===""||X===(O==null?void 0:O.board.title)||t.command({type:"board.update",boardId:e,title:X}).catch(te=>{Tr.getState().finishSync(e,hi(te))})},[e,t]),V=_.useCallback(F=>{F.key==="Enter"&&I(),F.key==="Escape"&&Tr.getState().stopRenameBoard()},[I]),z=_.useCallback(F=>{F==null||F.select()},[]),H=_.useCallback(()=>{Fi.getState().growPage(e)},[e]),W=s&&s.board.ownerKind==="project"&&i?s.board.ownerId:null,Y=_.useCallback(()=>{W&&(i==null||i(W))},[i,W]);return s?c.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-background",children:[c.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5",children:[W?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",onClick:Y,className:"shrink-0 rounded-md px-1.5 py-0.5 text-13 text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Boards"}),c.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-13 text-muted-foreground",children:"/"})]}):null,B?c.jsx("input",{ref:z,value:U,onChange:$,onKeyDown:V,onBlur:I,"aria-label":"Board name",className:"min-w-0 flex-1 rounded-md bg-secondary px-1.5 py-0.5 text-15 font-semibold text-foreground focus:outline-none"}):c.jsx("button",{type:"button",onClick:D,className:"min-w-0 truncate rounded-md px-1.5 py-0.5 text-left text-15 font-semibold text-foreground hover:bg-secondary",children:s.board.title}),C?c.jsx("span",{className:"truncate font-mono text-xs tabular-nums text-muted-foreground",children:C}):null,c.jsxs(Ee,{variant:"secondary",size:"sm",className:"ml-auto",onClick:k,disabled:w,children:[c.jsx(u0,{"aria-hidden":!0,className:ce("size-3.5",w&&"animate-spin")}),w?"Syncing…":"Sync"]}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:x,"aria-label":"Card fields",children:c.jsx(_D,{"aria-hidden":!0,className:"size-3.5"})}),c.jsx(Ee,{variant:"ghost",size:"sm",onClick:m,"aria-label":"Sync settings",children:c.jsx(fq,{"aria-hidden":!0,className:"size-3.5"})})]}),c.jsxs("div",{className:"relative min-h-0 flex-1",children:[h?c.jsx(BWe,{boardId:e,socket:t,onClose:g}):null,v?c.jsx(o9e,{boardId:e,socket:t,onClose:y}):null,l?c.jsx(CWe,{cardId:l,socket:t,chatFacts:n,cardFields:s.board.cardFields,onClose:f}):null,c.jsx(HVe,{view:s,chatFacts:n,onCardMove:a,onColumnMove:E,onOpenCard:u,onLoadMore:H,onColumnSave:N,onColumnDelete:T,onColumnAdd:R,onCardAdd:P,onMoveToTop:M})]})]}):c.jsx("div",{className:"flex h-full items-center justify-center bg-background p-8",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading board…"})})}const oKe=_.forwardRef((e,t)=>c.jsx(Ee,{ref:t,variant:"ghost",size:"none","aria-label":"Public link",...e,className:e.className??"border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",children:c.jsx(Cme,{strokeWidth:2,className:"h-4.5"})})),PO=Xt("SharePopoverBody",()=>e=>({busy:!1,setBusy:t=>e({busy:t})}));function aKe(e,t){const n=e-t;if(n<=0)return"Expired";const r=Math.round(n/36e5);return r<1?"Expires in <1h":r<48?`Expires in ${r}h`:`Expires in ${Math.round(r/24)}d`}function lKe(e){const t=e.clipboard??aa,n=PO.useScopedStore(l=>l.busy),r=PO.useScopedStore(l=>l.setBusy),i=e.shares.filter(l=>!l.revoked),{onMint:s,chatId:o}=e,a=_.useCallback(async()=>{r(!0);try{await s(o)}catch{}finally{r(!1)}},[s,o,r]);return c.jsxs(c.Fragment,{children:[c.jsx(Ee,{variant:"default",disabled:n,"data-share-mint":"",onClick:()=>{a()},children:n?"Creating…":"Create share link"}),i.length===0?c.jsx("p",{className:"text-xs text-muted-foreground",children:"No active share links for this chat."}):c.jsx("ul",{className:"space-y-2",children:i.map(l=>c.jsxs("li",{className:"flex flex-col gap-1 rounded border border-border/40 p-2 text-xs",children:[c.jsx("code",{className:"break-all",children:l.url}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ee,{size:"sm",variant:"ghost",onClick:()=>{t.writeText(l.url)},children:[c.jsx(na,{className:"h-3.5 w-3.5 mr-1"}),"Copy"]}),c.jsxs(Ee,{size:"sm",variant:"ghost","data-share-revoke":"",onClick:()=>{e.onRevoke(l.tokenId)},children:[c.jsx(Sme,{className:"h-3.5 w-3.5 mr-1"}),"Revoke"]}),c.jsx("span",{className:"ml-auto text-muted-foreground",children:aKe(l.expiresAt,e.now)})]})]},l.tokenId))})]})}function cKe(e){return c.jsx(PO.Provider,{init:void 0,children:c.jsx(lKe,{...e})})}function uKe(e){const t=_.useMemo(()=>Date.now(),[e.open]);return c.jsxs(gi,{children:[c.jsxs(_c,{open:e.open,onOpenChange:e.onOpenChange,children:[c.jsx(vi,{asChild:!0,children:c.jsx(Sc,{asChild:!0,children:e.trigger})}),c.jsx(Nl,{align:"end",className:"w-96 p-4 space-y-3",children:c.jsx(cKe,{chatId:e.chatId,shares:e.shares,now:t,onMint:e.onMint,onRevoke:e.onRevoke})})]}),c.jsx(si,{side:"bottom",children:"Mint a public read-only link"})]})}function dKe({bindings:e,provider:t,onOpenPath:n}){return e.length<=1?null:c.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-0.5",children:[e.map(r=>{const i=r.worktreePath.split("/").pop()??r.worktreePath,s=r.role==="primary",o=r.projectStatus==="missing";return c.jsxs("div",{role:"button",tabIndex:0,className:"flex items-center gap-1 cursor-pointer",onClick:()=>n(r.worktreePath),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),n(r.worktreePath))},children:[s?c.jsx("span",{className:"text-emerald-500",children:"●"}):c.jsx("span",{className:"text-muted-foreground",children:"○"}),c.jsx("span",{className:`font-mono tabular-nums text-xs${o?" line-through text-muted-foreground":""}`,children:i})]},r.projectId)}),t==="codex"&&c.jsx("span",{className:"font-mono text-xs text-muted-foreground ml-2",children:"codex: cwd-only"})]})}function WV(e){return e.replace(/[/\\]+$/,"")}function fKe(e,t){const n=WV(e);if(!t)return n.split(/[/\\]/).filter(Boolean).pop()??"";const r=WV(t);if(n===r)return"~";for(const i of["/","\\"])if(n.startsWith(r+i))return`~/${n.slice(r.length+1).replace(/\\/g,"/")}`;return n}function hKe({hasGitRepo:e=!0,gitStatus:t="unknown",localPath:n,branchName:r,homeDir:i}){if(!e)return"Setup Git";if(t==="unknown")return null;const s=n?fKe(n,i):"",o=r??"Detached HEAD";return s?`${s} · ${o}`:o}const IO=Xt("OpenExternalSelect",({initialValue:e})=>t=>({lastValue:e,setLastValue:n=>t({lastValue:n})})),oT=[{value:"cursor",label:"Cursor"},{value:"xcode",label:"Xcode"},{value:"windsurf",label:"Windsurf"},{value:"custom",label:"Custom"}],_f={cursor:"/editor-icons/cursor.png",defaultApp:"/editor-icons/default-app.png",finder:"/editor-icons/finder.png",preview:"/editor-icons/preview.png",xcode:"/editor-icons/xcode.png",terminal:"/editor-icons/terminal.png",windsurf:"/editor-icons/windsurf.png",custom:"/editor-icons/custom.png"};function Sf({src:e,className:t}){return c.jsx("img",{src:e,alt:"","aria-hidden":"true",draggable:!1,className:t})}function Cae({preset:e,className:t}){switch(e){case"xcode":return c.jsx(Sf,{src:_f.xcode,className:t});case"windsurf":return c.jsx(Sf,{src:_f.windsurf,className:t});case"custom":return c.jsx(Sf,{src:_f.custom,className:t});case"cursor":case"vscode":default:return c.jsx(Sf,{src:_f.cursor,className:t})}}function pKe({className:e}){return c.jsx(Sf,{src:_f.finder,className:e})}function mKe({className:e}){return c.jsx(Sf,{src:_f.preview,className:e})}function gKe({className:e}){return c.jsx(Sf,{src:_f.defaultApp,className:e})}function vKe({className:e}){return c.jsx(yE,{className:e})}function bKe({className:e}){return c.jsx(Sf,{src:_f.terminal,className:e})}const VV="kanna:last-open-external",kae="py-2 pl-2 pr-8",xKe="rounded-md text-sm font-normal focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground",yKe="flex items-center gap-3",_Ke="h-5 w-5 shrink-0";function Eae({value:e,label:t,isMac:n}){return c.jsxs("span",{className:yKe,children:[c.jsx(Nae,{value:e,isMac:n,className:_Ke}),c.jsx("span",{children:t})]})}function SKe(e,t){return{preset:e,commandTemplate:e==="custom"&&(t==null?void 0:t.trim())||Zv(e)}}function wKe(e,t){var r;if(e==="finder")return t?"Finder":"Folder";if(e==="terminal")return"Terminal";if(e==="preview")return"Preview";if(e==="default")return"Default App";const n=e.slice(7);return n==="vscode"?"VS Code":((r=oT.find(i=>i.value===n))==null?void 0:r.label)??"Editor"}function Nae({value:e,isMac:t,className:n}){var s;if(e==="finder")return t?c.jsx(pKe,{className:n}):c.jsx(vKe,{className:n});if(e==="terminal")return c.jsx(bKe,{className:n});if(e==="preview")return c.jsx(mKe,{className:n});if(e==="default")return c.jsx(gKe,{className:n});const r=e.slice(7),i=((s=oT.find(o=>o.value===r))==null?void 0:s.value)??"vscode";return c.jsx(Cae,{preset:i,className:n})}function KV(e,t){if(e==="finder"||e==="terminal"||e==="preview"||e==="default")return e;if(e!=null&&e.startsWith("editor:")){const n=e.slice(7);if(zQ(n))return`editor:${n}`}return t}function Tae({editorPreset:e,isMac:t,includeFinder:n=!0,includeTerminal:r=!1,includePreview:i=!1,includeDefault:s=!1,menuKind:o="context"}){const a={value:"finder",label:t?"Finder":"Folder"},l={value:"terminal",label:"Terminal"},u={value:"preview",label:"Preview"},f={value:"default",label:"Default App"},m=[{value:"editor:cursor",label:"Cursor"},{value:"editor:xcode",label:"Xcode"},{value:"editor:windsurf",label:"Windsurf"},...e==="custom"?[{value:"editor:custom",label:"Custom"}]:[]],g=`editor:${e}`,v=[...m.filter(x=>x.value===g),...m.filter(x=>x.value!==g)];return o==="navbar"?[...v.filter(x=>x.value===g),...n?[a]:[],...r?[l]:[],...v.filter(x=>x.value!==g)]:[...v,...i&&t?[u]:[],...n?[a]:[],...r?[l]:[],...s?[f]:[]]}function Aae(e){var r;if(e.value==="finder"){e.onOpenExternal("open_finder");return}if(e.value==="terminal"){e.onOpenExternal("open_terminal");return}if(e.value==="preview"){e.onOpenExternal("open_preview");return}if(e.value==="default"){e.onOpenExternal("open_default");return}const t=e.value.slice(7),n=((r=oT.find(i=>i.value===t))==null?void 0:r.value)??"vscode";e.onOpenExternal("open_editor",SKe(n,e.editorCommandTemplate))}function CKe({isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:s,ports:o}){const a=(o==null?void 0:o.storage)??Tl,l=`editor:${t}`,u=IO.useScopedStore(v=>v.lastValue),f=IO.useScopedStore(v=>v.setLastValue);_.useEffect(()=>{f(KV(a.getItem(VV),l))},[l,f,a]);const h=_.useMemo(()=>Tae({editorPreset:t,isMac:e,includeFinder:!0,includeTerminal:!0,menuKind:"navbar"}),[t,e]);function m(v){f(v),a.setItem(VV,v),Aae({value:v,editorCommandTemplate:n,onOpenExternal:s})}let g;return u==="finder"?g=r:u===`editor:${t}`?g=i:g=void 0,c.jsxs("div",{className:"grid grid-cols-[1fr_auto]",children:[c.jsxs(K1,{children:[c.jsx(G1,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:()=>m(u),title:`Open in ${wKe(u,e)}`,className:"border-0 !pl-2.5 !pr-1 hover:!border-border/0 hover:!bg-transparent",children:c.jsx(Nae,{value:u,isMac:e,className:"size-6"})})}),c.jsx(Qy,{side:"bottom",shortcut:g})]}),c.jsxs(yo,{value:void 0,onValueChange:v=>m(KV(v,u)),children:[c.jsx(Qs,{"aria-label":"Choose open destination",className:"!pl-1 !pr-2.5 border-0 bg-transparent hover:bg-transparent focus:ring-0 focus:ring-offset-0 [&>svg]:hidden",children:c.jsx("span",{className:"flex items-center justify-center",children:c.jsx(Vf,{className:"h-4 w-4 opacity-60"})})}),c.jsx(Js,{align:"end",children:c.jsx(Bh,{children:h.map(v=>c.jsx(Br,{value:v.value,className:kae,children:c.jsx(Eae,{value:v.value,label:v.label,isMac:e})},v.value))})})]})]})}function kKe({isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:s,ports:o}){const a=`editor:${t}`;return c.jsx(IO.Provider,{init:{initialValue:a},children:c.jsx(CKe,{isMac:e,editorPreset:t,editorCommandTemplate:n,finderShortcut:r,editorShortcut:i,onOpenExternal:s,ports:o})})}function EKe({isMac:e,editorPreset:t,editorCommandTemplate:n,includeFinder:r=!0,includeTerminal:i=!1,includePreview:s=!1,includeDefault:o=!1,onOpenExternal:a}){const l=Tae({editorPreset:t,isMac:e,includeFinder:r,includeTerminal:i,includePreview:s,includeDefault:o}),u=_.useCallback((f,h)=>{f.preventDefault(),Aae({value:h,editorCommandTemplate:n,onOpenExternal:a})},[n,a]);return c.jsx(Xu,{className:"rounded-lg p-1",children:l.map(f=>c.jsx(Xn,{className:`${kae} ${xKe}`,onSelect:h=>u(h,f.value),children:c.jsx(Eae,{value:f.value,label:f.label,isMac:e})},f.value))})}const OO=Xt("PtyInstanceRow",()=>e=>({confirmKill:!1,setConfirmKill:t=>e({confirmKill:t})})),rb={spawning:"var(--warning)","trust-dialog":"var(--warning)",ready:"var(--success, oklch(0.72 0.16 145))",streaming:"var(--primary)",cancelling:"var(--warning)",exited:"var(--muted-foreground)"},NKe={spawning:"spawning","trust-dialog":"trust",ready:"ready",streaming:"streaming",cancelling:"cancelling",exited:"exited"};function TKe(e){return e.length<=40?e:`…${e.slice(-39)}`}function AKe(e){return e.length>8?e.slice(0,8):e}function jKe(e,t){return a0e(e,t??Date.now())}function GV(e){if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${t.toFixed(0)} KB`;const n=t/1024;return n<1024?`${n.toFixed(0)} MB`:`${(n/1024).toFixed(1)} GB`}function qV(e){return e>=100?`${e.toFixed(0)}%`:e>=10?`${e.toFixed(1)}%`:`${e.toFixed(1)}%`}function RKe({phase:e}){return c.jsxs("span",{className:"inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-10 font-mono uppercase tracking-wide tabular-nums",style:{background:"color-mix(in oklch, var(--muted) 60%, transparent)"},children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-[6px] h-[6px] rounded-full",style:{backgroundColor:rb[e]}}),c.jsx("span",{style:{color:rb[e]},children:NKe[e]})]})}function MKe({instance:e,onOpenChat:t,onCancel:n,onKill:r}){return c.jsx(OO.Provider,{init:void 0,children:c.jsx(PKe,{instance:e,onOpenChat:t,onCancel:n,onKill:r})})}function PKe({instance:e,onOpenChat:t,onCancel:n,onKill:r}){const i=OO.useScopedStore(a=>a.confirmKill),s=OO.useScopedStoreApi(),o=_.useCallback(()=>{const a=s.getState();a.confirmKill?(r(e.chatId),a.setConfirmKill(!1)):a.setConfirmKill(!0)},[s,e.chatId,r]);return c.jsxs("div",{className:"group border border-border/60 rounded-lg p-3 flex flex-col gap-2 hover:border-border transition-colors",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("button",{type:"button",onClick:()=>t(e.chatId),className:"text-xs font-mono font-medium text-foreground hover:text-primary transition-colors text-left truncate flex-1 min-w-0",children:AKe(e.chatId)}),c.jsx(RKe,{phase:e.phase})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 text-11 text-muted-foreground font-mono tabular-nums",children:[c.jsxs(hu,{tooltip:e.cwd,children:[c.jsx("span",{className:"text-foreground/40",children:"cwd"})," ",TKe(e.cwd)]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"pid"})," ",e.pid??"—"]}),c.jsxs(hu,{tooltip:e.model,children:[c.jsx("span",{className:"text-foreground/40",children:"model"})," ",e.model||"—"]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"up"})," ",jKe(e.startedAt,e.exitedAt)]}),e.accountLabel?c.jsxs(hu,{className:"col-span-2",tooltip:e.accountLabel,children:[c.jsx("span",{className:"text-foreground/40",children:"acct"})," ",e.accountLabel,e.oauthMasked?c.jsxs("span",{className:"text-foreground/30",children:[" · ",e.oauthMasked]}):null]}):null,e.planMode!==null?c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"plan"})," ",e.planMode?"on":"off"]}):null,e.smokeTest?c.jsxs("div",{children:[c.jsx("span",{className:"text-foreground/40",children:"smoke"})," ",c.jsx("span",{style:{color:e.smokeTest==="pass"?rb.ready:rb.exited},children:e.smokeTest})]}):null,e.rssBytes!==null?c.jsxs(hu,{className:"col-span-2",tooltip:"Resident memory (current · peak across session)",children:[c.jsx("span",{className:"text-foreground/40",children:"mem"})," ",GV(e.rssBytes),e.rssPeakBytes!==null&&e.rssPeakBytes>e.rssBytes?c.jsxs("span",{className:"text-foreground/30",children:[" · peak ",GV(e.rssPeakBytes)]}):null]}):null,e.cpuPercent!==null?c.jsxs(hu,{className:"col-span-2",tooltip:"CPU usage % across process tree (current · peak; >100% = multi-core)",children:[c.jsx("span",{className:"text-foreground/40",children:"cpu"})," ",qV(e.cpuPercent),e.cpuPeakPercent!==null&&e.cpuPeakPercent>e.cpuPercent?c.jsxs("span",{className:"text-foreground/30",children:[" · peak ",qV(e.cpuPeakPercent)]}):null]}):null]}),e.phase!=="exited"?c.jsxs("div",{className:"flex items-center gap-1.5 pt-1",children:[c.jsx("button",{type:"button",onClick:()=>t(e.chatId),className:"text-10 font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors",children:"open"}),c.jsx("button",{type:"button",onClick:()=>n(e.chatId),className:"text-10 font-mono px-2 py-1 rounded-md border border-border/60 hover:bg-muted/40 transition-colors",children:"cancel"}),c.jsx("button",{type:"button",onClick:o,onBlur:()=>s.getState().setConfirmKill(!1),className:"text-10 font-mono px-2 py-1 rounded-md border transition-colors ml-auto",style:{borderColor:i?"var(--destructive)":"var(--border)",color:i?"var(--destructive)":void 0},"aria-label":i?"Confirm kill":"Kill PTY process",children:i?"confirm kill?":"kill"})]}):c.jsxs("div",{className:"text-10 font-mono text-muted-foreground pt-1",children:["exited",e.exitCode!==null?` · code ${e.exitCode}`:""]})]})}function IKe({instances:e,liveCount:t,open:n,onOpenChange:r,onOpenChat:i,onCancel:s,onKill:o}){const a=t>0,l=a?`${t} claude PTY instance${t===1?"":"s"}`:"No live PTY instances";return c.jsxs(_c,{open:n,onOpenChange:r,children:[c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsx(Sc,{asChild:!0,children:c.jsxs("button",{type:"button","aria-label":l,className:"inline-flex items-center gap-1.5 px-1.5 h-9 rounded-md hover:bg-transparent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-[7px] h-[7px] rounded-full flex-shrink-0",style:{backgroundColor:a?rb.ready:"var(--muted-foreground)"}}),c.jsxs("span",{className:"text-xs font-mono font-medium tabular-nums leading-none",style:{color:a?rb.ready:"var(--muted-foreground)"},children:["pty ",t]})]})})}),c.jsx(si,{side:"bottom",children:l})]}),c.jsxs(Nl,{align:"end",sideOffset:8,className:"w-[420px] p-3",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsx("h3",{className:"text-xs font-mono uppercase tracking-wider text-foreground/60",children:"claude pty instances"}),c.jsxs("span",{className:"text-10 font-mono text-muted-foreground tabular-nums",children:[t," live"]})]}),e.length===0?c.jsx("div",{className:"text-xs text-muted-foreground text-center py-6 font-mono",children:"no instances yet"}):c.jsx("div",{className:"flex flex-col gap-2 max-h-[60vh] overflow-y-auto",children:e.map(u=>c.jsx(MKe,{instance:u,onOpenChat:i,onCancel:s,onKill:o},u.chatId))})]})]})}function OKe({socket:e,onOpenChat:t}){const n=RBe(),r=MBe(),i=PBe(),s=_.useCallback(f=>{const h=wu.getState();f?h.openPopover():h.closePopover()},[]),o=_.useCallback(f=>{wu.getState().closePopover(),t==null||t(f)},[t]),a=_.useCallback(f=>{if(!e)return;const h={type:"pty.cancel",chatId:f};e.command(h).catch(()=>{})},[e]),l=_.useCallback(f=>{if(!e)return;const h={type:"pty.kill",chatId:f};e.command(h).catch(()=>{})},[e]),u=_.useMemo(()=>n,[n]);return c.jsx(IKe,{instances:u,liveCount:r,open:i,onOpenChange:s,onOpenChat:o,onCancel:a,onKill:l})}function DKe(e,t){e.preventDefault(),e.stopPropagation();const n=e.currentTarget.getBoundingClientRect();t.dispatchContextMenuEvent(e.currentTarget,n.left+n.width/2,n.bottom)}function LKe({showOnDesktop:e,onToggleEmbeddedTerminal:t,dom:n}){return t?c.jsxs(qf,{children:[c.jsx(Yf,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:r=>DKe(r,n),title:"More actions",className:ce("border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",e?"flex":"flex md:hidden"),children:c.jsx(Pp,{strokeWidth:2,className:"h-4.5"})})}),c.jsx(Xu,{children:t?c.jsxs(Xn,{onSelect:r=>{r.preventDefault(),t()},children:[c.jsx(SE,{strokeWidth:2,className:"h-3.5 w-3.5"}),c.jsx("span",{className:"text-xs font-medium",children:"Toggle Terminal"})]}):null})]}):null}function $Ke({chatId:e}){return Qie(OBe(e))?c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsxs("span",{className:"inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded-full text-10 font-mono uppercase tracking-wide flex-shrink-0",style:{background:"color-mix(in oklch, var(--muted) 60%, transparent)"},children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-[6px] h-[6px] rounded-full",style:{backgroundColor:"var(--warning)"}}),c.jsx("span",{style:{color:"var(--warning)"},children:"following"})]})}),c.jsx(si,{side:"bottom",children:"Live view of an external Claude session. Sending a message takes over and stops following."})]}):null}function BKe({sidebarCollapsed:e,onOpenSidebar:t,onExpandSidebar:n,onNewChat:r,localPath:i,embeddedTerminalVisible:s=!1,onToggleEmbeddedTerminal:o,rightSidebarVisible:a=!1,onToggleRightSidebar:l,onOpenExternal:u,editorPreset:f="cursor",editorCommandTemplate:h,platform:m="darwin",finderShortcut:g,editorShortcut:v,terminalShortcut:x,rightSidebarShortcut:y,branchName:w,homeDir:C,hasGitRepo:k=!0,gitStatus:E="unknown",timings:N,status:T,resolvedBindings:R,provider:M,onOpenPath:P=()=>{},socket:B,onOpenPtyChat:U,currentChatId:D,shareShares:$,onShareMint:I,onShareRevoke:V,silent:z,onToggleSilent:H,dom:W}){const Y=W??Et,F=hKe({hasGitRepo:k,gitStatus:E,localPath:i,branchName:w,homeDir:C}),O=yr.useScopedStore(ie=>ie.sharePopoverOpen),X=yr.useScopedStore(ie=>ie.setSharePopoverOpen),te=m==="darwin";return c.jsxs(YD,{className:ce("absolute top-0 left-0 right-0 z-10 md:pt-3 px-3 border-border/0 md:pb-0 flex items-center justify-center"," bg-gradient-to-b from-background/70"),children:[c.jsxs("div",{className:"relative flex items-center gap-2 w-full",children:[c.jsxs("div",{className:`flex items-center gap-1 flex-shrink-0 border border-border/0 rounded-2xl ${e?"px-1.5 border-border":""} p-1`,children:[c.jsx(Ee,{variant:"ghost",size:"icon-mobile",className:"md:hidden",onClick:t,"aria-label":"Open sidebar",children:c.jsx(SD,{className:"size-4.5"})}),e&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center justify-center w-[36px] h-[36px]",children:c.jsx(Cf,{className:"h-4 w-4 sm:h-5 sm:w-5 text-logo ml-1 hidden md:block"})}),c.jsx(Ee,{variant:"ghost",size:"icon",className:"hidden md:flex",onClick:n,title:"Expand sidebar","aria-label":"Expand sidebar",children:c.jsx(lM,{className:"size-4.5"})})]}),c.jsx(Ee,{variant:"ghost",size:"icon",className:"hover:!border-border/0 hover:!bg-transparent",onClick:r,title:"Compose","aria-label":"New chat",children:c.jsx(ED,{className:"size-4.5"})})]}),N&&T?c.jsx("div",{className:"flex-1 min-w-0 flex items-center justify-center select-none",children:c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-2 cursor-default min-w-0",children:[c.jsxs("span",{className:"flex md:hidden items-center gap-1",children:[c.jsx("span",{className:ce("text-xs font-medium",Jy(R6(T))),children:"●"}),c.jsx("span",{className:"text-xs font-medium text-foreground",children:kf(T)}),c.jsx("span",{className:"text-xs font-mono tabular-nums text-foreground/80",children:Pu(N.derivedAtMs-N.stateEnteredAt)})]}),c.jsxs("span",{className:"hidden md:flex items-center gap-2",children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx("span",{className:ce("text-xs",Jy(R6(T))),children:"●"}),c.jsx("span",{className:"text-xs font-medium text-foreground",children:kf(T)})]}),c.jsx("span",{className:"text-xs font-mono tabular-nums text-foreground/80",children:Pu(N.derivedAtMs-N.stateEnteredAt)}),c.jsx("span",{className:"h-3 w-px bg-border/60","aria-hidden":!0}),c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:xo(N.derivedAtMs-N.activeSessionStartedAt)}),N.lastTurnDurationMs!=null?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"h-3 w-px bg-border/60","aria-hidden":!0}),c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:xo(N.lastTurnDurationMs)})]}):null]})]})}),c.jsx(si,{side:"bottom",className:"text-left",children:c.jsxs("div",{className:"space-y-0.5 text-xs",children:[c.jsxs("div",{children:["Chat created ",xo(N.derivedAtMs-N.chatCreatedAt)," ago"]}),c.jsxs("div",{children:["Idle ",xo(N.cumulativeMs.idle)]}),c.jsxs("div",{children:["Running ",xo(N.cumulativeMs.running)]}),c.jsxs("div",{children:["Waiting ",xo(N.cumulativeMs.waiting_for_user)]})]})})]})}):c.jsx("div",{className:"flex-1 min-w-0"}),c.jsx($Ke,{chatId:D}),c.jsxs("div",{className:"flex items-center flex-shrink-0 border border-border rounded-2xl",children:[c.jsx(OKe,{socket:B,onOpenChat:U}),H!=null?c.jsxs(gi,{children:[c.jsx(vi,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:H,"aria-pressed":z??!1,"aria-label":z?"Unsilence notifications":"Silence notifications",className:ce("border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",z&&"text-muted-foreground"),children:z?c.jsx(XG,{strokeWidth:2,className:"size-4.5"}):c.jsx(Bhe,{strokeWidth:2,className:"size-4.5"})})}),c.jsx(si,{side:"bottom",children:z?"Unsilence notifications":"Silence notifications"})]}):null]}),i&&(u||o||l)?c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u?c.jsx("div",{className:"hidden py-0.5 md:block border border-border rounded-2xl",children:c.jsx(kKe,{isMac:te,editorPreset:f,editorCommandTemplate:h,finderShortcut:g,editorShortcut:v,onOpenExternal:u})}):null,o||l?c.jsxs("div",{className:"flex items-center border border-border rounded-2xl px-2 py-0.5",children:[c.jsx(LKe,{showOnDesktop:a,onToggleEmbeddedTerminal:o,dom:Y}),o?c.jsxs(K1,{children:[c.jsx(G1,{asChild:!0,children:c.jsx(Ee,{variant:"ghost",size:"none",onClick:o,"aria-label":"Toggle terminal","aria-pressed":s,className:ce(a?"hidden":"hidden md:flex","border border-border/0 hover:!border-border/0 px-1.5 h-9 hover:!bg-transparent",s&&"text-foreground"),children:c.jsx(SE,{strokeWidth:2,className:"h-4.5"})})}),c.jsx(Qy,{side:"bottom",shortcut:x})]}):null,D&&I&&V?c.jsx(uKe,{chatId:D,shares:$??[],open:O,onOpenChange:X,trigger:c.jsx(oKe,{}),onMint:I,onRevoke:V}):null,l?c.jsxs(K1,{children:[c.jsx(G1,{asChild:!0,children:c.jsxs(Ee,{variant:"ghost",onClick:l,className:ce("border flex flex-row items-center gap-1.5 h-9 border-border/0 pl-1.5 pr-2 hover:!border-border/0 hover:!bg-transparent",a&&"text-foreground"),children:[a?c.jsx(Vme,{strokeWidth:2.25,className:"h-4"}):c.jsx(xu,{strokeWidth:2.25,className:"h-4"}),F&&!a?c.jsx("div",{className:"text-13 font-mono max-w-[280px] truncate hidden md:block",children:F}):null]})}),c.jsx(Qy,{side:"bottom",shortcut:y})]}):null]}):null]}):null]}),R&&R.length>1&&c.jsx(dKe,{bindings:R,provider:M??null,onOpenPath:P})]})}function jae(e,t,n){const r=typeof e.maxTokens=="number"&&Number.isFinite(e.maxTokens)?e.maxTokens:null,i=r&&r>0?Math.min(100,e.usedTokens/r*100):null,s=r!==null?Math.max(0,Math.round(r-e.usedTokens)):null,o=i!==null?Math.max(0,100-i):null;return{...e,compactsAutomatically:e.compactsAutomatically||n,maxTokens:r??void 0,remainingTokens:s,usedPercentage:i,remainingPercentage:o,updatedAt:t}}function FKe(e){const t=e.some(n=>n.kind==="compact_boundary"||n.kind==="compact_summary"||n.kind==="context_cleared");for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r&&!(r.kind!=="context_window_updated"||r.usage.usedTokens<=0))return jae(r.usage,new Date(r.createdAt).toISOString(),t)}return null}function zKe(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:jae({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function Hd(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function UKe(e,t){let n=0,r=0,i=0,s=0;for(const a of e){if(a.kind!=="result")continue;const l=a.usage;l&&(n+=Hd(l.inputTokens),r+=Hd(l.outputTokens),i+=Hd(l.cachedInputTokens)),s+=Hd(a.costUsd??(l==null?void 0:l.costUsd))}for(const a of t){const l=a.usage;l&&(n+=Hd(l.inputTokens),r+=Hd(l.outputTokens),i+=Hd(l.cachedInputTokens),s+=Hd(l.costUsd))}if(n===0&&r===0&&i===0&&s===0)return null;const o=n>0?i/n*100:null;return{inputTokens:n,outputTokens:r,cachedTokens:i,costUsd:s,cacheHitPercentage:o}}function HKe(e){return!Number.isFinite(e)||e<=0?"$0.00":e<.01?"<$0.01":`$${e.toFixed(2)}`}function _o(e){return e==null||!Number.isFinite(e)?"0":e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}m`}const WKe=350,VKe={dom:Et,timer:Jn};function KKe({rootRef:e,fallbackRef:t,enabled:n,canCancel:r,ports:i=VKe}){const{dom:s,timer:o}=i;_.useEffect(()=>{if(!n)return;let a=0,l=null;const u=C=>{const k=C instanceof Element?C:null,E=e.current,N=t.current;if(p6({trigger:"pointer",activeElement:s.getActiveElement(),pointerStartTarget:l,pointerEndTarget:k,root:E,fallback:N,hasActiveOverlay:s.hasFocusOverlay(),hasActiveSelection:Ixe(s.getSelection())})!=="restore"){l=null;return}N==null||N.focus({preventScroll:!0}),l=null},f=C=>{o.cancelAnimationFrame(a),l=C.target instanceof Element?C.target:null},h=C=>{o.cancelAnimationFrame(a),a=o.requestAnimationFrame(()=>{u(C.target)})},m=()=>{l=null;const C=t.current;!C||C.disabled||C.focus({preventScroll:!0})},g=C=>{if(C.key!=="Escape")return;const k=t.current;p6({trigger:"escape",activeElement:s.getActiveElement(),fallback:k,hasActiveOverlay:s.hasFocusOverlay(),canCancel:r,defaultPrevented:C.defaultPrevented})==="escape-focus"&&(C.preventDefault(),k==null||k.focus({preventScroll:!0}))},v=s.addWindowCaptureListener("pointerdown",f),x=s.addWindowCaptureListener("pointerup",h),y=s.addWindowCaptureListener("keydown",g),w=s.addWindowCustomListener(DD,m);return()=>{o.cancelAnimationFrame(a),v(),x(),y(),w()}},[r,s,n,t,e,o])}function GKe(e){return e.visibilityState==="visible"?e.activeChatId:null}function qKe(e){e.socket.setFocusedChat(GKe({activeChatId:e.activeChatId,visibilityState:e.visibilityState}))}function YKe({socket:e,activeChatId:t,ports:n}){const r=(n==null?void 0:n.dom)??Et;_.useEffect(()=>{const i=()=>{qKe({socket:e,activeChatId:t,visibilityState:r.getVisibilityState()})};i();const s=r.addDocumentListener("visibilitychange",i),o=r.addWindowListener("pagehide",i),a=r.addWindowListener("pageshow",i);return()=>{s(),o(),a(),e.setFocusedChat(null)}},[e,t,r])}const DO=Xt("KannaTranscript",()=>e=>({toolGroupExpanded:{},setToolGroupExpanded:(t,n)=>e(r=>r.toolGroupExpanded[t]===n?r:{toolGroupExpanded:{...r.toolGroupExpanded,[t]:n}})})),Rae=_.memo(({message:e})=>c.jsx("div",{className:"text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4",children:W$e(e.text)})),Mae=_.memo(({message:e})=>c.jsx("div",{className:"px-0.5 w-full max-w-[70ch]",children:c.jsx(KN,{content:e.text})})),nS=({children:e,className:t,animate:n=!0,shimmerWidth:r,...i})=>c.jsx("span",{className:ce("mx-auto max-w-md text-foreground/60",n&&"animate-shiny-pulse",t),...i,children:e});function XKe(e){const t=e.split(`
|
|
2832
2832
|
`),n=/^\s*(\d+)→(.*)$/;return t.map(r=>{const i=r.match(n);return i?{lineNumber:parseInt(i[1],10),content:i[2]}:{lineNumber:null,content:r}})}function QKe(e){return e.replace(/<[^>]+>/g,"")}function JKe(e,t){const n=e.split(`
|
|
2833
2833
|
`),r=t.split(`
|
|
2834
2834
|
`),i=ZKe(n,r),s=eGe(n,r,i);return tGe(s)}function ZKe(e,t){const n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let s=1;s<=n;s++)for(let o=1;o<=r;o++)i[s][o]=e[s-1]===t[o-1]?i[s-1][o-1]+1:Math.max(i[s-1][o],i[s][o-1]);return i}function eGe(e,t,n){const r=[];let i=e.length,s=t.length;for(;i>0||s>0;)i>0&&s>0&&e[i-1]===t[s-1]?(r.push({type:"context",text:e[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:t[s-1],oldIdx:i,newIdx:s}),s--):(r.push({type:"removed",text:e[i-1],oldIdx:i,newIdx:s}),i--);return r.reverse()}function tGe(e){return e.map(t=>{let n;return t.type==="removed"?n="-":t.type==="added"?n="+":n=" ",{type:t.type,content:`${n}${t.text}`}})}function PC({content:e,isDiff:t=!1,oldString:n,newString:r}){const i=_.useMemo(()=>t&&n!==void 0&&r!==void 0?JKe(n,r):[],[t,n,r]),s=_.useMemo(()=>t?[]:XKe(e),[e,t]),o=_.useMemo(()=>s.some(a=>a.lineNumber!==null),[s]);return t&&i.length>0?c.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:c.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:c.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:c.jsx("tbody",{children:i.map((a,l)=>{let u;a.type==="removed"?u="bg-destructive/10 dark:bg-destructive/15":a.type==="added"?u="bg-success/10 dark:bg-success/15":u="";let f;a.type==="removed"?f="text-destructive":a.type==="added"?f="text-success":f="text-foreground";let h;a.type==="removed"?h="text-destructive/50":a.type==="added"?h="text-success/50":h="text-muted-foreground/50";let m;return a.type==="removed"?m="-":a.type==="added"?m="+":m=" ",c.jsxs("tr",{className:u,children:[c.jsx("td",{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${h}`,children:m}),c.jsx("td",{className:`px-2 py-0 whitespace-pre select-all ${f}`,children:a.content.slice(1)})]},l)})})})})}):c.jsx("div",{className:"my-1 rounded-lg border border-border overflow-hidden",children:c.jsx("div",{className:"overflow-auto max-h-64 md:max-h-[50vh]",children:c.jsx("table",{className:"w-full border-collapse text-xs font-mono",children:c.jsx("tbody",{children:s.map((a,l)=>c.jsxs("tr",{children:[o&&c.jsx("td",{className:"px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right",children:a.lineNumber!==null?a.lineNumber:""}),c.jsx("td",{className:"px-2 py-0 whitespace-pre select-all text-foreground",children:QKe(a.content)})]},l))})})})})}function Pae({tone:e,label:t,pulse:n=!1}){return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-10 font-medium uppercase tracking-wide",children:[c.jsx("span",{"aria-hidden":!0,className:ce("inline-block size-1.5 rounded-full",oX(e),n&&"animate-pulse")}),c.jsx("span",{className:Jy(e),children:t})]})}function n$({status:e,pulse:t=!1}){return c.jsx(Pae,{tone:aX(e),label:p0e(e),pulse:t&&e==="running"})}function nGe(){return c.jsx("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-10 font-medium uppercase tracking-wide text-muted-foreground",children:"started…"})}function rGe({name:e,description:t,run:n}){const r=e??"Workflow";return c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(xu,{className:"size-4 text-muted-icon shrink-0"}),c.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[c.jsx("span",{className:"font-medium text-foreground/80 text-sm truncate",children:r}),t&&c.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t}),n?c.jsxs(c.Fragment,{children:[c.jsx(n$,{status:n.status}),n.agentCount!=null&&n.agentCount>0&&c.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[n.agentCount," agents"]})]}):c.jsx(nGe,{})]})]})}const Iae=_.createContext(null);function Oae({children:e,value:t}){return c.jsx(Iae.Provider,{value:t,children:e})}function iGe(){return _.useContext(Iae)}const sGe=[],nl=Xt("SubagentTaskMessage",()=>e=>({expanded:!1,loading:!1,loaded:!1,children:sGe,error:null,setExpanded:t=>e({expanded:t}),setLoading:t=>e({loading:t}),setLoaded:t=>e({loaded:t}),setChildren:t=>e({children:t}),setError:t=>e({error:t})}));function oGe(e,t){return t||e==="failed"||e==="error"?"destructive":e==="in_progress"||e==="running"?"active":"muted"}function aGe(e){if(!e)return"";const t=[],n=(r,i,s)=>{r&&r>0&&t.push(`${r} ${r===1?i:s}`)};return n(e.readCount,"read","reads"),n(e.editFileCount,"edit","edits"),n(e.bashCount,"cmd","cmds"),n(e.searchCount,"search","searches"),n(e.otherToolCount,"tool","tools"),t.join(" · ")}function lGe({subagentType:e,result:t,isError:n,localPath:r}){const i=e||"Agent",s=oGe(t==null?void 0:t.status,n),o=aGe(t==null?void 0:t.toolStats),a=iGe(),l=t==null?void 0:t.agentId,u=!!(a&&l),f=nl.useScopedStore(T=>T.expanded),h=nl.useScopedStore(T=>T.loading),m=nl.useScopedStore(T=>T.loaded),g=nl.useScopedStore(T=>T.children),v=nl.useScopedStore(T=>T.error),x=nl.useScopedStore(T=>T.setExpanded),y=nl.useScopedStore(T=>T.setLoading),w=nl.useScopedStore(T=>T.setLoaded),C=nl.useScopedStore(T=>T.setChildren),k=nl.useScopedStore(T=>T.setError),E=_.useCallback(()=>{if(!a||!l)return;const T=!f;x(T),T&&!m&&!h&&(y(!0),k(null),a(l).then(R=>{C(eT(R)),w(!0)}).catch(R=>k(R instanceof Error?R.message:"Failed to load subagent transcript")).finally(()=>y(!1)))},[a,l,f,m,h,x,y,k,C,w]),N=c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[u?c.jsx(Da,{className:ce("size-4 text-muted-icon shrink-0 transition-transform",f&&"rotate-90"),"aria-hidden":!0}):c.jsx(wE,{className:"size-4 text-muted-icon shrink-0"}),c.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0 overflow-hidden",children:[c.jsx("span",{className:"font-medium text-foreground/80 text-sm truncate",children:i}),(t==null?void 0:t.status)&&c.jsx(Pae,{tone:s,label:t.status}),(t==null?void 0:t.totalTokens)!=null&&t.totalTokens>0&&c.jsxs("span",{className:"inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums",children:[c.jsx(Gy,{className:"size-3","aria-hidden":!0}),_o(t.totalTokens)," tokens"]}),(t==null?void 0:t.totalDurationMs)!=null&&t.totalDurationMs>0&&c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:xo(t.totalDurationMs)}),o&&c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums truncate",children:o}),h&&c.jsx(jn,{className:"size-3 animate-spin text-muted-foreground","aria-label":"Loading"})]})]});return u?c.jsxs("div",{className:"min-w-0",children:[c.jsx("button",{type:"button",onClick:E,"aria-expanded":f,className:"w-full text-left cursor-pointer",children:N}),f&&c.jsxs("div",{className:"mt-2 ml-2 border-l-2 border-muted-foreground/20 pl-3 space-y-2",children:[v&&c.jsx("div",{className:"text-xs text-destructive",children:v}),!v&&m&&g.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground",children:"No subagent activity recorded."}),g.map(T=>c.jsx(r$,{message:T,localPath:r??""},T.id))]})]}):N}function cGe({subagentType:e,result:t,isError:n,localPath:r}){return c.jsx(nl.Provider,{init:void 0,children:c.jsx(lGe,{subagentType:e,result:t,isError:n,localPath:r})})}function YV(e){let t;return Mr(e)&&Array.isArray(e.content)?t=e.content:Array.isArray(e)?t=e:t=[],t.flatMap(n=>!n||typeof n!="object"||!("type"in n)||n.type!=="image"?[]:"data"in n&&typeof n.data=="string"?[{type:"image",data:n.data,mimeType:"mimeType"in n&&typeof n.mimeType=="string"?n.mimeType:void 0}]:"source"in n&&n.source&&typeof n.source=="object"&&"type"in n.source&&n.source.type==="base64"&&"data"in n.source&&typeof n.source.data=="string"?[{type:"image",data:n.source.data,mimeType:"media_type"in n.source&&typeof n.source.media_type=="string"?n.source.media_type:void 0}]:[])}function uGe({images:e}){return c.jsx("div",{className:"flex flex-col gap-3",children:e.map((t,n)=>{const r=t.mimeType||"image/png";return c.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-muted/20",children:c.jsx("img",{src:`data:${r};base64,${t.data}`,alt:`Read result ${n+1}`,className:"max-h-[50vh] w-full object-contain bg-background"})},`${r}:${n}`)})})}function dE({message:e,isLoading:t=!1,localPath:n,chatId:r=""}){var N;const i=e.result!==void 0,s=!i&&t,o=tT(Ap(G3(r))),a=_.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill;if(e.toolKind==="glob")return`Search files ${e.input.pattern==="**/*"?"in all directories":`matching ${e.input.pattern}`}`;if(e.toolKind==="grep"){const T=e.input.pattern,R=e.input.outputMode;return R==="count"?`Count \`${T}\` occurrences`:R==="content"?`Find \`${T}\` in text`:`Find \`${T}\` in files`}return e.toolKind==="bash"?e.input.description||(e.input.command?iX(e.input.command):"Bash"):e.toolKind==="web_search"?e.input.query||"Web Search":e.toolKind==="read_file"?`Read ${bf(e.input.filePath,n)}`:e.toolKind==="write_file"?`Write ${bf(e.input.filePath,n)}`:e.toolKind==="edit_file"?`Edit ${bf(e.input.filePath,n)}`:e.toolKind==="delete_file"?`Delete ${bf(e.input.filePath,n)}`:e.toolKind==="mcp_generic"?`${xM(e.input.tool)} from ${xM(e.input.server)}`:e.toolKind==="subagent_task"?e.input.subagentType||e.toolName:e.toolKind==="workflow"?e.input.name??"Workflow":e.toolName},[e.input,e.toolKind,e.toolName,n]),l=_.useMemo(()=>e.toolKind==="subagent_task",[e.toolKind]),u=_.useMemo(()=>{if(e.toolKind==="skill")return e.input.skill},[e.input,e.toolKind]),f=e.toolKind==="bash",h=e.toolKind==="write_file",m=e.toolKind==="edit_file",g=e.toolKind==="delete_file",v=e.toolKind==="read_file",x=_.useMemo(()=>{if(typeof e.result=="string")return e.result;if(!e.result)return"";if(Mr(e.result)){const T=e.result.content;if(typeof T=="string")return T}return JSON.stringify(e.result,null,2)},[e.result]),y=_.useMemo(()=>{if(!v)return[];if(Mr(e.result)){const T=e.result.blocks;if(Array.isArray(T)){const R=YV(T);if(R.length>0)return R}}return YV(e.rawResult)},[v,e.rawResult,e.result]),w=_.useMemo(()=>{switch(e.toolKind){case"bash":return e.input.command;case"write_file":case"delete_file":return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]);let C;f?C=c.jsxs("span",{className:"flex items-center gap-2 w-full",children:[c.jsx("span",{children:"Command"}),!!e.input.timeoutMs&&c.jsxs("span",{className:"text-muted-foreground",children:["timeout: ",String(e.input.timeoutMs),"ms"]}),!!e.input.runInBackground&&c.jsx("span",{className:"text-muted-foreground",children:"background"})]}):h?C="Contents":C="Input";let k;m?k=c.jsx(PC,{content:"",isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):g?k=c.jsx(PC,{content:e.input.content}):!v&&!h?k=c.jsx(fP,{label:C,copyText:w,children:w}):k=null;let E;if(e.toolKind==="workflow"&&!e.isError){const T=Mr(e.result)&&typeof e.result.text=="string"?{taskId:typeof e.result.taskId=="string"?e.result.taskId:void 0,text:e.result.text}:void 0,R=T==null?void 0:T.taskId,M=R?o.find(P=>P.taskId===R):void 0;E=c.jsx(rGe,{name:e.input.name,description:e.input.description,run:M})}else e.toolKind==="subagent_task"&&e.result?E=c.jsx(cGe,{subagentType:e.input.subagentType,result:e.result,isError:e.isError,localPath:n}):E=c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:e.isError?c.jsx(xi,{className:"size-4 text-destructive"}):l?c.jsx(wE,{className:"size-4 text-muted-icon"}):e.toolKind==="workflow"?c.jsx(xu,{className:"size-4 text-muted-icon"}):c.jsx(Cee,{icon:wee(e.toolName),className:"size-4 text-muted-icon"})}),c.jsx(zp,{className:"text-left transition-opacity duration-200 truncate",children:c.jsx(nS,{animate:s,shimmerWidth:Math.max(20,(((N=u||a)==null?void 0:N.length)??33)*3),children:u||a})})]});return c.jsx(Ju,{className:"w-full",children:c.jsx(b5,{expandedContent:c.jsx(gN,{className:"my-4 text-sm",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[k,i&&v&&!e.isError&&(y.length>0?c.jsxs("div",{children:[c.jsx("span",{className:"font-medium text-muted-foreground",children:"Image"}),c.jsx("div",{className:"mt-1",children:c.jsx(uGe,{images:y})})]}):c.jsx(PC,{content:x})),h&&!e.isError&&c.jsx(PC,{content:e.input.content}),i&&!v&&!(h&&!e.isError)&&!(m&&!e.isError)&&!(g&&!e.isError)&&c.jsx(fP,{label:e.isError?"Error":"Result",copyText:x,children:x})]})}),children:E})})}const Dae={serverOverloaded:"transient",internalServerError:"transient",httpConnectionFailed:"transient",responseStreamConnectionFailed:"transient",responseStreamDisconnected:"transient",responseTooManyFailedAttempts:"transient",usageLimitExceeded:"quota",sessionBudgetExceeded:"quota",unauthorized:"auth",contextWindowExceeded:"fatal",badRequest:"fatal",cyberPolicy:"fatal",sandboxError:"fatal",threadRollbackFailed:"fatal",activeTurnNotSteerable:"fatal",other:"unknown"},XV=new Set(["httpConnectionFailed","responseStreamConnectionFailed","responseStreamDisconnected","responseTooManyFailedAttempts","activeTurnNotSteerable"]);function LO(e){return e in Dae}function dGe(e){if(e==null)return null;if(typeof e=="string")return LO(e)&&!XV.has(e)?e:null;if(typeof e!="object")return null;const t=Object.keys(e);if(t.length!==1)return null;const[n]=t;return XV.has(n)&&LO(n)?n:null}function Lae(e){return typeof e=="string"?LO(e)?e:null:dGe(e)}function fGe(e){const t=Lae(e);return t===null?"unknown":Dae[t]}function hGe(e){return fGe(e)==="transient"}const pGe={serverOverloaded:e=>`${e} is temporarily at capacity. Retry, or switch to another model.`,internalServerError:e=>`${e} hit a server-side error. Retrying usually clears it.`,httpConnectionFailed:()=>"Could not reach the model provider. Check your connection, then retry.",responseStreamConnectionFailed:()=>"The response stream failed to connect. Retry to start a new stream.",responseStreamDisconnected:()=>"The response stream disconnected mid-turn. Retry to pick up from where it stopped.",responseTooManyFailedAttempts:e=>`${e} failed repeatedly while streaming. Retry, or switch to another model.`,usageLimitExceeded:()=>"You have reached your Codex usage limit. Access returns when the limit window resets.",sessionBudgetExceeded:()=>"This session reached its configured token budget.",unauthorized:()=>"Codex rejected the credentials for this request. Re-authenticate with `codex login`.",contextWindowExceeded:e=>`The conversation no longer fits in ${e}'s context window. Start a new chat or compact this one.`,badRequest:()=>"Codex rejected the request as malformed.",cyberPolicy:()=>"Codex declined this request under its usage policy.",sandboxError:()=>"The Codex sandbox failed to run the requested command.",threadRollbackFailed:()=>"Codex could not roll the conversation back to the requested point.",activeTurnNotSteerable:()=>"The running turn cannot accept new input. Wait for it to finish, or stop it."},mGe="The selected model";function gGe(e,t){const n=Lae(e);if(n===null)return null;const r=pGe[n];return r===void 0?null:r(mGe)}const O1=Xt("TranscriptActionCard",()=>e=>({busyId:null,actionError:null,setBusyId:t=>e({busyId:t}),setActionError:t=>e({actionError:t})})),vGe={neutral:"border-border bg-card",muted:"border-border/50 bg-card/50 opacity-75",success:"border-emerald-500/30 bg-emerald-500/5",error:"border-destructive/40 bg-destructive/5"},bGe={primary:"default",secondary:"secondary",ghost:"ghost",destructive:"destructive"};function Yl(e){return c.jsx(O1.Provider,{init:void 0,children:c.jsx(xGe,{...e})})}function xGe({title:e,description:t,body:n,errorMessage:r,tone:i="neutral",actions:s=[]}){const o=O1.useScopedStore(h=>h.busyId),a=O1.useScopedStore(h=>h.actionError),l=O1.useScopedStoreApi(),u=_.useCallback(async h=>{const m=l.getState();if(m.busyId)return;m.setActionError(null);let g;try{g=h.onClick()}catch(v){Os.error("[transcript-action-card] sync click threw",String(v)),l.getState().setActionError(v instanceof Error?v.message:String(v));return}if(g instanceof Promise){m.setBusyId(h.id);try{await g}catch(v){Os.error("[transcript-action-card] async click rejected",String(v)),l.getState().setActionError(v instanceof Error?v.message:String(v))}finally{l.getState().setBusyId(null)}}},[l]),f=o!==null;return c.jsxs("div",{"data-focus-fallback-ignore":!0,className:ce("rounded-lg border px-4 py-3 text-sm space-y-2 transition-colors",vGe[i]),children:[c.jsx("div",{className:"flex items-start justify-between gap-3",children:c.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[c.jsx("div",{className:"font-medium leading-tight",children:e}),t?c.jsx("div",{className:"text-muted-foreground text-xs leading-snug",children:t}):null]})}),n?c.jsx("div",{className:"text-xs leading-snug",children:n}):null,r?c.jsx("div",{className:"text-destructive text-xs leading-snug",children:r}):null,a?c.jsx("div",{className:"text-destructive text-xs leading-snug",role:"alert",children:a}):null,s.length>0?c.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:s.map(h=>{const m=o===h.id;return c.jsxs(Ee,{type:"button",size:"sm",variant:bGe[h.variant??"ghost"],disabled:h.disabled||f&&!m,onClick:()=>{u(h)},className:"gap-1.5",children:[m?c.jsx(jn,{className:"size-3.5 animate-spin"}):null,h.label]},h.id)})}):null]})}function yGe(e){if(e<1e3)return`${e}ms`;const t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h${r>0?` ${r}m`:""}`:r>0?`${r}m${i>0?` ${i}s`:""}`:`${i}s`}function QV({durationMs:e,prefix:t="Worked for"}){return e<=0?null:c.jsxs(OPe,{children:[t," ",yGe(e)]})}const SR=/\[([^\]]+)\]\(\/chat\/([0-9a-fA-F][0-9a-fA-F-]{7,})\)/g;function $ae(e,t){const n=[];let r=0,i=0;SR.lastIndex=0;for(let s=SR.exec(e);s!==null;s=SR.exec(e))s.index>r&&n.push(e.slice(r,s.index)),n.push(c.jsx(a0,{to:`/chat/${s[2]}`,className:"underline decoration-destructive/40 hover:decoration-destructive",children:s[1]},`chat-link-${i++}`)),r=s.index+s[0].length;return r<e.length&&n.push(e.slice(r)),n.length===0?e:n}function _Ge({resultMessageId:e,body:t,onRetry:n}){const i=[{id:"retry",label:"Retry",variant:"primary",onClick:_.useCallback(()=>n(e),[n,e])}];return c.jsx("div",{className:"mx-2 my-1",children:c.jsx(Yl,{title:"Turn failed",tone:"error",body:t,actions:i})})}function Bae({message:e,onRetry:t}){if(!e.success){const n=e.codexErrorInfo,r=(n?gGe(n):null)??e.result??"",i=r.trim().length>0,s=n!==void 0&&hGe(n);let o=null;return s&&t?o=c.jsx(_Ge,{resultMessageId:e.id,body:r,onRetry:t}):i&&(o=c.jsx("div",{className:"px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm whitespace-pre-wrap",children:$ae(r)})),c.jsxs(c.Fragment,{children:[o,e.durationMs>0?c.jsx(QV,{durationMs:e.durationMs,prefix:"Failed after"}):null]})}return c.jsx(QV,{durationMs:e.durationMs})}function SGe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function wGe(e){return typeof e=="string"?e:JSON.stringify(e,null,2)}function CGe(e){return e.replace(/<persisted-output>\n?/g,"").replace(/\n?<\/persisted-output>/g,"")}function r$({message:e,localPath:t,isRunning:n=!1}){if(e.kind==="tool"&&e.persisted){const i=CGe(wGe(e.rawResult??""));return c.jsxs("div",{className:"animate-in fade-in-0 duration-200 rounded-md border border-border bg-muted/30 p-2 space-y-1 text-xs",children:[c.jsxs("div",{className:"font-medium",children:[e.toolName,": output too large (",SGe(e.persisted.originalSize),") — saved to disk"]}),c.jsx("pre",{className:"text-11 whitespace-pre-wrap overflow-hidden max-h-48",children:i}),c.jsxs("a",{href:eie(e.persisted.filePath),className:"text-blue-500 hover:underline break-all",target:"_blank",rel:"noreferrer",children:["View full output (",e.persisted.filePath,")"]})]})}let r;switch(e.kind){case"assistant_text":r=c.jsx(Rae,{message:e});break;case"assistant_thinking":r=c.jsx(Mae,{message:e});break;case"tool":r=c.jsx(dE,{message:e,isLoading:n,localPath:t});break;case"result":r=c.jsx(Bae,{message:e});break;default:return null}return c.jsx("div",{className:"animate-in fade-in-0 duration-200",children:r})}function kGe(e){switch(e){case"AUTH_REQUIRED":return"Auth required";case"UNKNOWN_SUBAGENT":return"Unknown subagent";case"MANUAL_ONLY":return"Manual only";case"LOOP_DETECTED":return"Loop detected";case"DEPTH_EXCEEDED":return"Depth exceeded";case"TIMEOUT":return"Timeout";case"PROVIDER_ERROR":return"Provider error";case"INTERRUPTED":return"Interrupted";case"USER_CANCELLED":return"Cancelled by you";default:return"Error"}}function EGe({error:e,runId:t,onRetry:n,onOpenSettings:r}){const i=e.code==="TIMEOUT"||e.code==="PROVIDER_ERROR",s=e.code==="AUTH_REQUIRED";return c.jsxs("div",{"data-testid":`subagent-error:${t}`,className:"rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2 font-medium text-destructive",children:[c.jsx(Mf,{className:"h-4 w-4"}),c.jsx("span",{children:kGe(e.code)})]}),c.jsx("p",{className:"mt-1 text-foreground",children:e.message}),c.jsxs("div",{className:"mt-2 flex gap-2",children:[s&&r&&c.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 text-xs underline",children:[c.jsx(iq,{className:"h-3 w-3"})," Open settings"]}),i&&n&&c.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1 text-xs underline",children:[c.jsx(hge,{className:"h-3 w-3"})," Retry"]})]})]})}const Fae={readonly:!1,localLinkMode:"open",askUserQuestionSurface:"inline"},zae=_.createContext(Fae);function $O({children:e,value:t}){const n=_.useMemo(()=>({...Fae,...t}),[t]);return c.jsx(zae.Provider,{value:n,children:e})}function i$(){return _.useContext(zae)}const Wh=Xt("AskUserQuestionInteractive",()=>e=>({currentIndex:0,answers:{},customInputs:{},setCurrentIndex:t=>e({currentIndex:t}),setAnswers:t=>e({answers:t}),setCustomInputs:t=>e({customInputs:t})}));function NGe({question:e,header:t,currentIndex:n,totalQuestions:r,onBack:i,children:s}){const o=i&&n>0,a=o||r>1||!!t;let l;return o?l=c.jsx("button",{onClick:i,className:"text-muted-foreground hover:opacity-60 transition-all flex items-center",children:c.jsx(npe,{className:"h-4 w-4 -ml-0.5",strokeWidth:3})}):r>1?l=c.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground whitespace-nowrap",children:[n+1," of ",r]}):l=null,c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("div",{className:"relative",children:[c.jsxs("div",{className:"p-3 px-4 bg-card border-b border-border",children:[a&&c.jsxs("div",{className:"flex flex-row items-center gap-2 mb-1",children:[l,t?c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground text-pretty",children:t}):null]}),c.jsx("h3",{className:"font-medium text-foreground text-sm text-pretty",children:e})]}),r>1&&c.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-border",children:c.jsx("div",{className:"h-full bg-muted-foreground/40 transition-all duration-300",style:{width:`${n/r*100}%`}})})]}),s]})}function JV({label:e,description:t}){return c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-foreground text-sm",children:e}),t&&c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t})]})}function Uae({selected:e,multiSelect:t,onClick:n}){const r=ce("flex-shrink-0 w-5 h-5 border-1 flex items-center justify-center",t?"rounded":"rounded-full",e?"border-transparent bg-foreground":"border-muted-foreground/50 bg-background",n&&e&&"cursor-pointer"),i=e?c.jsx(Cs,{strokeWidth:3,className:"translate-y-[0.5px] h-3 w-3 text-white dark:text-background"}):null;return n?c.jsx("button",{type:"button",onClick:n,className:r,children:i}):c.jsx("div",{"aria-hidden":!0,className:r,children:i})}function TGe({option:e,selected:t,multiSelect:n,onClick:r,isLast:i}){const s="w-full text-left p-3 pt-2.5 pl-4 pr-5 bg-background",o=i?"":"border-b border-border";return r?c.jsx("button",{onClick:r,className:ce(s,o,"transition-all cursor-pointer"),children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("div",{className:"flex-1 min-w-0",children:c.jsx(JV,{label:e.label,description:e.description})}),c.jsx(Uae,{selected:t,multiSelect:n})]})}):c.jsx("div",{className:ce(s,o),children:c.jsx(JV,{label:e.label,description:e.description})})}function AGe({questions:e,onSubmit:t,onCancel:n,ports:r={}}){var U;const i=r.timer??Jn,s=Wh.useScopedStore(D=>D.currentIndex),o=Wh.useScopedStore(D=>D.answers),a=Wh.useScopedStore(D=>D.customInputs),l=Wh.useScopedStore(D=>D.setCurrentIndex),u=Wh.useScopedStore(D=>D.setAnswers),f=Wh.useScopedStore(D=>D.setCustomInputs);if(e.length===0)return null;const h=D=>D.id||D.question,m=(D,$)=>{var W;const I=(W=a[D])==null?void 0:W.trim(),V=o[D]||"",z=$||e.find(Y=>h(Y)===D);if(z!=null&&z.multiSelect)return[V,I].filter(Boolean).flatMap(Y=>Y.split(", ").filter(Boolean));const H=I||V;return H?[H]:[]},g=D=>{const $=o[h(D)]||"";return D.multiSelect?$.split(", ").filter(Boolean):[$]},v=(D,$)=>{const I=h(D);if(D.multiSelect){const V=o[I]?o[I].split(", ").filter(Boolean):[],z=V.includes($)?V.filter(H=>H!==$):[...V,$];u({...o,[I]:z.join(", ")})}else u({...o,[I]:$}),f({...a,[I]:""}),s<e.length-1&&i.setTimeout(()=>l(s+1),150)},x=(D,$)=>{const I=h(D);f({...a,[I]:$}),$&&!D.multiSelect&&u({...o,[I]:""})},y=D=>{const $=h(D);D.multiSelect&&a[$]&&f({...a,[$]:""})},w=e.every(D=>m(h(D),D).length>0),C=e[Math.min(s,e.length-1)],k=s>=e.length-1,E=m(h(C),C).length>0,N=()=>{s<e.length-1&&l(s+1)},T=()=>{s>0&&l(s-1)},R=()=>{if(!w)return;const D={};for(const $ of e){const I=h($);D[I]=m(I,$)}t(D)},M=D=>{if(D.key==="Enter"&&E){if(D.preventDefault(),k){R();return}N()}},P=g(C),B=a[h(C)]||"";return c.jsxs("div",{className:"w-full space-y-3",children:[c.jsxs(NGe,{question:C.question,header:C.header,currentIndex:s,totalQuestions:e.length,onBack:s>0?T:void 0,children:[(U=C.options)==null?void 0:U.map(D=>c.jsx(TGe,{option:D,selected:P.includes(D.label),multiSelect:C.multiSelect,onClick:()=>v(C,D.label)},D.label)),c.jsx("div",{className:"transition-all bg-background",children:c.jsxs("div",{className:"flex pr-5 items-center justify-between gap-3",children:[c.jsx("input",{type:"text",value:B,onChange:D=>x(C,D.target.value),onKeyDown:M,placeholder:"Other...",className:"flex-1 px-3 !py-1 pl-4 min-h-[55px] min-w-0 text-sm bg-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-md text-foreground placeholder:text-muted-foreground"}),c.jsx(Uae,{selected:!!B,multiSelect:C.multiSelect,onClick:C.multiSelect&&B?()=>y(C):void 0})]})})]}),c.jsxs("div",{className:"flex items-center mx-2",children:[n?c.jsx(Ee,{size:"sm",variant:"outline",className:"rounded-full",onClick:n,children:"Cancel"}):null,c.jsxs("div",{className:"ml-auto flex gap-2",children:[!k&&E&&(C.multiSelect||!!B)&&c.jsx(Ee,{size:"sm",onClick:N,children:"Next"}),k&&c.jsx(Ee,{size:"sm",onClick:R,disabled:!w,className:ce(!w&&"opacity-50 cursor-not-allowed","rounded-full"),children:"Submit"})]})]})]})}function Hae({questions:e,onSubmit:t,onCancel:n,ports:r}){return c.jsx(Wh.Provider,{init:void 0,children:c.jsx(AGe,{questions:e,onSubmit:t,onCancel:n,ports:r})})}function jGe({savedAnswers:e,isComplete:t}){return n=>({submittedAnswers:e??null,isSubmitted:t,submitError:null,markSubmitted:r=>n({submittedAnswers:r,isSubmitted:!0,submitError:null}),markSubmitFailed:r=>n(i=>i.isSubmitted||i.submitError!==r?{isSubmitted:!1,submitError:r}:i)})}const Og=Xt("AskUserQuestionMessage",jGe);function Wae(e){return e==null?void 0:e.answers}function BO(e){return e.id||e.question}function ZV({questions:e,statusLabel:t,testId:n}){return c.jsx("div",{className:"w-full","data-testid":n,children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.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 gap-3",children:[c.jsxs("p",{children:["Question",e.length!==1?"s":""]}),c.jsx("p",{className:"text-muted-foreground",children:t})]}),e.map((r,i)=>{var s;return c.jsxs("div",{className:ce("w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-start justify-between gap-3",i<e.length-1&&"border-b border-border"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[r.header&&c.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground text-pretty",children:r.header}),c.jsx("div",{className:"text-sm text-pretty",children:r.question})]}),c.jsx("div",{className:"max-w-[50%] text-right text-xs text-muted-foreground text-pretty",children:((s=r.options)==null?void 0:s.map(o=>o.label).join(", "))||"Freeform response"})]},BO(r))})]})})}function RGe({message:e,onSubmit:t,isLatest:n}){var v;const r=i$(),i=e.input.questions,s=!!e.result,o=Wae(e.result),a=((v=e.result)==null?void 0:v.discarded)===!0,l=Og.useScopedStore(x=>x.submittedAnswers),u=Og.useScopedStore(x=>x.isSubmitted),f=Og.useScopedStore(x=>x.markSubmitted),h=Og.useScopedStore(x=>x.markSubmitFailed),m=Og.useScopedStore(x=>x.submitError),g=_.useCallback(x=>{f(x);try{const y=t(e.toolId,i,x);y&&typeof y.then=="function"&&y.catch(w=>{h(hi(w))})}catch(y){h(hi(y))}},[f,h,t,e.toolId,i]);if(u||s){const x=o||l||{};return c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.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:[c.jsxs("p",{children:["Question",i.length!==1?"s":""]}),c.jsx("p",{className:"",children:a?"Discarded":"Answers"})]}),i.map((y,w)=>{const C=x[BO(y)]||x[y.question]||[],k=w===i.length-1,E=y.options?C.map(N=>{var T,R;return(R=(T=y.options)==null?void 0:T.find(M=>M.label===N))==null?void 0:R.description}).filter(N=>!!N):[];return c.jsxs("div",{className:ce("w-full p-3 pt-2.5 pl-4 pr-5 bg-background flex items-start justify-between gap-3",!k&&"border-b border-border"),children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[y.header&&c.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground text-pretty",children:y.header}),c.jsx("div",{className:"text-sm text-pretty",children:y.question})]}),c.jsx("div",{className:"max-w-[50%] text-right",children:C.length>0?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"text-sm font-medium text-pretty",children:C.join(", ")}),E.length>0&&c.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 text-pretty",children:E.join(" · ")})]}):c.jsx("div",{className:"text-sm font-medium italic",children:a?"Discarded":"No Response"})})]},BO(y))})]})})}return r.readonly?c.jsx(ZV,{questions:i,statusLabel:"Awaiting response"}):n?r.askUserQuestionSurface==="footer"?c.jsx(ZV,{questions:i,statusLabel:"Answer below",testId:`ask-user-question-moved:${e.toolId}`}):c.jsxs("div",{className:"w-full",children:[m?c.jsx("div",{className:"mb-2 rounded-xl border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive whitespace-pre-wrap","data-testid":`ask-user-question-error:${e.toolId}`,children:m}):null,c.jsx(Hae,{questions:i,onSubmit:g})]}):c.jsx("div",{className:"w-full py-2",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(wD,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Questions pending (newer question active)"})]})})}function s$({message:e,onSubmit:t,isLatest:n}){const r=Wae(e.result)??null,i=!!e.result;return c.jsx(Og.Provider,{init:{savedAnswers:r,isComplete:i},children:c.jsx(RGe,{message:e,onSubmit:t,isLatest:n})})}function MGe(){return e=>({expanded:!1,copied:!1,showEditInput:!1,editMessage:"",setExpanded:t=>e({expanded:t}),setCopied:t=>e({copied:t}),setEditMessage:t=>e({editMessage:t}),openEdit:()=>e({showEditInput:!0}),cancelEdit:()=>e(t=>t.showEditInput||t.editMessage!==""?{showEditInput:!1,editMessage:""}:t)})}const Bl=Xt("ExitPlanModeMessage",MGe);function PGe({message:e,onConfirm:t,isLatest:n,ports:r={}}){const i=i$(),s=r.clipboard??aa,o=r.timer??Jn,a=!!e.result,l=Bl.useScopedStore(P=>P.expanded),u=Bl.useScopedStore(P=>P.copied),f=Bl.useScopedStore(P=>P.showEditInput),h=Bl.useScopedStore(P=>P.editMessage),m=Bl.useScopedStore(P=>P.setExpanded),g=Bl.useScopedStore(P=>P.setCopied),v=Bl.useScopedStore(P=>P.setEditMessage),x=Bl.useScopedStore(P=>P.openEdit),y=Bl.useScopedStore(P=>P.cancelEdit),w=_.useRef(null),C=_.useCallback(P=>{P.key==="Enter"&&!P.shiftKey&&h.trim()&&(P.preventDefault(),t(e.toolId,!1,void 0,h.trim())),P.key==="Escape"&&y()},[h,t,e.toolId,y]),k=e.input;_.useEffect(()=>{f&&w.current&&w.current.focus()},[f]);const E=async()=>{k!=null&&k.plan&&(await s.writeText(k.plan),g(!0),o.setTimeout(()=>g(!1),2e3))},N=a?e.result:null,T=(N==null?void 0:N.discarded)===!0;let R;T?R="Discarded":N!=null&&N.clearContext?R="Approved & Cleared Context":N!=null&&N.confirmed?R="Approved":N!=null&&N.message?R=`Adjusted: "${N.message}"`:R="Adjusted Plan";let M;return a?M=c.jsx("div",{className:"flex justify-end mx-2",children:c.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:[c.jsx("em",{children:R}),c.jsx(_pe,{className:"inline h-4 w-4 ml-1.5 -mt-0.5"})]})}):n?i.readonly?M=c.jsx("div",{className:"flex justify-end mx-2",children:c.jsx("span",{className:"inline text-sm text-muted-foreground italic",children:"Plan pending in original session"})}):M=c.jsxs("div",{className:"flex flex-col gap-3",children:[!f&&c.jsxs("div",{className:"flex flex-col md:flex-row items-stretch md:items-center justify-end gap-2 mx-2",children:[c.jsxs(Ee,{size:"sm",onClick:()=>t(e.toolId,!0,!0),className:"rounded-full bg-primary text-background pr-4 md:order-last",children:[c.jsx(Xhe,{className:"h-4 w-4 mr-1.5"}),"Approve & Clear"]}),c.jsxs("div",{className:"flex items-stretch md:items-center gap-2 md:contents",children:[c.jsxs(Ee,{size:"sm",variant:"outline",onClick:x,className:"rounded-full border-border flex-1 md:flex-initial md:order-first",children:[c.jsx(om,{className:"h-4 w-4 mr-1.5"}),"Suggest Edits"]}),c.jsxs(Ee,{size:"sm",variant:"outline",onClick:()=>t(e.toolId,!0),className:"rounded-full border-border flex-1 md:flex-initial",children:[c.jsx(Cs,{className:"h-4 w-4 mr-1.5"}),"Approve"]})]})]}),f&&c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("textarea",{ref:w,value:h,onChange:P=>v(P.target.value),onKeyDown:C,placeholder:"Describe what you'd like to change...",rows:3,className:"w-full rounded-2xl border border-border bg-muted dark:bg-card px-4 py-3 text-sm text-foreground placeholder:text-muted-foreground resize-none outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"}),c.jsxs("div",{className:"flex items-center justify-end gap-2 mx-2",children:[c.jsx(Ee,{size:"sm",variant:"ghost",onClick:y,className:"rounded-full text-muted-foreground",children:"Cancel"}),c.jsxs(Ee,{size:"sm",disabled:!h.trim(),onClick:()=>t(e.toolId,!1,void 0,h.trim()),className:"rounded-full bg-primary text-background disabled:opacity-50 disabled:pointer-events-none",children:[c.jsx(Sge,{className:"h-4 w-4 mr-1.5"}),"Adjust Plan"]})]})]})]}):M=c.jsx("div",{className:"flex justify-end mx-2",children:c.jsx("span",{className:"inline text-sm text-muted-foreground italic",children:"Plan pending (newer prompt active)"})}),c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsxs("div",{className:"relative rounded-2xl border border-border overflow-hidden group/plan",children:[(k==null?void 0:k.plan)&&c.jsx(Ee,{variant:"ghost",size:"icon","aria-label":u?"Copied":"Copy plan",className:ce("absolute top-2 right-2 z-10 h-11 w-11 md:h-8 md:w-8 rounded-md text-muted-foreground opacity-100 md:opacity-0 md:group-hover/plan:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100",!u&&"hover:text-foreground",u&&"hover:!bg-transparent hover:!border-transparent"),onClick:E,children:u?c.jsx(Cs,{className:"h-4 w-4 text-success"}):c.jsx(na,{className:"h-4 w-4"})}),c.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",a&&!l?"max-h-[min(400px,40vh)] ":"",a?"hover:!pb-[32px]":""),children:[a&&c.jsxs(Ee,{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 bg-background hover:text-foreground opacity-0 group-hover/plan:opacity-100 transition-all rounded-full border border-border",onClick:()=>m(!l),children:[l?"Show Less":"Show More",c.jsx(Vf,{className:`size-3.5 transition-transform ${l?"rotate-180":""}`})]}),k!=null&&k.plan?c.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:[oie(k.plan),c.jsx("div",{className:"mt-5"})]}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No plan provided"})]})]}),M]})}function Vae({message:e,onConfirm:t,isLatest:n,ports:r}){return c.jsx(Bl.Provider,{init:void 0,children:c.jsx(PGe,{message:e,onConfirm:t,isLatest:n,ports:r})})}function Kae({pendingTool:e,onAskUserQuestionSubmit:t,onExitPlanModeSubmit:n}){if(e.toolKind==="ask_user_question"){const r=e.input.questions,i=Array.isArray(r)?r.filter(o=>Mr(o)):[],s={id:e.toolUseId,kind:"tool",toolKind:"ask_user_question",toolName:"AskUserQuestion",toolId:e.toolUseId,input:{questions:i},timestamp:new Date(e.requestedAt).toISOString()};return c.jsxs("div",{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[c.jsx("div",{className:"text-10 uppercase tracking-wide text-muted-foreground mb-1",children:"awaiting your response"}),c.jsx(s$,{message:s,onSubmit:t,isLatest:!0})]})}if(e.toolKind==="exit_plan_mode"){const r=e.input,i={id:e.toolUseId,kind:"tool",toolKind:"exit_plan_mode",toolName:"ExitPlanMode",toolId:e.toolUseId,input:{plan:typeof r.plan=="string"?r.plan:void 0,summary:typeof r.summary=="string"?r.summary:void 0},timestamp:new Date(e.requestedAt).toISOString()};return c.jsxs("div",{"data-testid":`subagent-pending-tool:${e.toolUseId}`,children:[c.jsx("div",{className:"text-10 uppercase tracking-wide text-muted-foreground mb-1",children:"awaiting your response"}),c.jsx(Vae,{message:i,onConfirm:(s,o,a,l)=>n(s,{confirmed:o,clearContext:a,message:l}),isLatest:!0})]})}return null}const IGe=40;function _a(e){return sX(e,IGe)}function OGe(e,t){switch(e.toolKind){case"bash":{const n=e.input.description||(e.input.command?iX(e.input.command):"");return n?`$ ${_a(n)}`:"running bash..."}case"read_file":{const n=bf(e.input.filePath,t);return n?`reading ${_a(n)}`:"reading file..."}case"write_file":{const n=bf(e.input.filePath,t);return n?`writing ${_a(n)}`:"writing file..."}case"edit_file":{const n=bf(e.input.filePath,t);return n?`editing ${_a(n)}`:"editing file..."}case"delete_file":{const n=bf(e.input.filePath,t);return n?`deleting ${_a(n)}`:"deleting file..."}case"glob":return e.input.pattern?`globbing ${_a(e.input.pattern)}`:"globbing...";case"grep":return e.input.pattern?`grepping ${_a(e.input.pattern)}`:"grepping...";case"web_search":return e.input.query?`searching: ${_a(e.input.query)}`:"searching web...";case"skill":return e.input.skill?`skill ${_a(e.input.skill)}`:"running skill...";case"todo_write":return"updating todos...";case"subagent_task":return e.input.subagentType?`delegating ${_a(e.input.subagentType)}`:"delegating...";case"ask_user_question":return"asking...";case"exit_plan_mode":return"presenting plan...";case"offer_download":return"preparing download...";case"image_generation":return"generating image...";case"mcp_generic":return _a(`${e.input.server}.${e.input.tool}`);case"unknown_tool":return`running ${_a(e.toolName)}`;default:return"running..."}}function DGe(e,t){if(e.pendingTool)return"waiting for input...";const n=e.entries,r=new Set;for(let s=n.length-1;s>=0;s--){const o=n[s];if(o.kind==="tool_result")r.add(o.toolId);else if(o.kind==="tool_call"&&!r.has(o.tool.toolId))return OGe(o.tool,t)}const i=n[n.length-1];return(i==null?void 0:i.kind)==="assistant_text"?"streaming...":"running..."}function Gae({run:e,indentDepth:t,localPath:n,onOpenSettings:r,onRetry:i,onSubagentAskUserQuestionSubmit:s,onSubagentExitPlanModeSubmit:o,onCancelSubagentRun:a,suppressPendingTool:l=!1}){var g;const u=eT(e.entries),f=u.some(v=>v.kind==="assistant_text"),h=e.status==="running"&&f,m=e.status==="running"?DGe(e,n):"";return c.jsxs("div",{"data-testid":`subagent-message:${e.runId}`,className:ce("border-l-2 border-accent pl-3 py-2 space-y-2"),style:{marginLeft:`${t*24}px`},[qy]:"",children:[c.jsxs("header",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx(Wf,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:e.subagentName}),c.jsxs("span",{className:"opacity-60",children:[e.provider,e.model?`/${e.model}`:""]}),((g=e.usage)==null?void 0:g.outputTokens)!=null&&c.jsxs("span",{className:"opacity-60",children:["· ",e.usage.inputTokens??0,"↑ ",e.usage.outputTokens,"↓"]}),e.status==="running"&&c.jsx("span",{"data-testid":`subagent-activity:${e.runId}`,className:"ml-auto inline-block animate-pulse",children:m}),a&&e.status==="running"&&c.jsx("button",{type:"button","data-testid":`subagent-cancel:${e.runId}`,"aria-label":"Cancel subagent",onClick:()=>a(e.chatId,e.runId),className:"text-muted-foreground hover:text-foreground",children:c.jsx(xi,{className:"h-3.5 w-3.5"})})]}),u.map(v=>c.jsx(r$,{message:v,localPath:n,isRunning:e.status==="running"},v.id)),!l&&e.pendingTool&&c.jsx(Kae,{pendingTool:e.pendingTool,onAskUserQuestionSubmit:(v,x,y)=>s==null?void 0:s(e.runId,v,x,y),onExitPlanModeSubmit:(v,x)=>o==null?void 0:o(e.runId,v,x)}),u.length===0&&e.finalText&&c.jsxs("div",{className:ce("whitespace-pre-wrap text-sm",h&&"text-foreground/80"),children:[e.finalText,h&&c.jsx("span",{className:"ml-0.5 inline-block w-2 animate-pulse",children:"▍"})]}),e.status==="failed"&&e.error&&c.jsx("div",{children:c.jsx(EGe,{error:e.error,runId:e.runId,subagentId:e.subagentId,onOpenSettings:r,onRetry:i})})]})}const FO=Xt("UserMessage",()=>e=>({selectedAttachmentId:null,setSelectedAttachmentId:t=>e({selectedAttachmentId:t})}));function LGe(e){var n;const t=e.match(/^<system-message>\s*([\s\S]*?)\s*<\/system-message>\s*([\s\S]*)$/);return t?{systemMessage:((n=t[1])==null?void 0:n.trim())||null,body:t[2]??""}:{systemMessage:null,body:e}}function $Ge({content:e,attachments:t=[],steered:n=!1,autoContinue:r,ports:i}){const s=(i==null?void 0:i.dom)??Et,o=FO.useScopedStore(y=>y.selectedAttachmentId),a=FO.useScopedStore(y=>y.setSelectedAttachmentId),l=i$(),u=_.useMemo(()=>LGe(e),[e]),f=!l.readonly,h=_.useMemo(()=>t.filter(y=>y.kind==="image"&&y.contentUrl),[t]),m=_.useMemo(()=>t.filter(y=>y.kind!=="image"||!y.contentUrl),[t]),g=t.find(y=>y.id===o)??null,v=g?Ab(g,"user_attachment"):null;function x(y){if(!f||!y.contentUrl)return;if(_b(y).openInNewTab){s.openWindow(new URL(y.contentUrl,s.getBaseURI()||s.getHref()).toString(),"_blank","noopener,noreferrer");return}a(y.id)}return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex flex-col items-end gap-2",children:[h.length>0?c.jsx("div",{className:"flex max-w-[85%] sm:max-w-[80%] flex-wrap justify-end gap-3",children:h.map(y=>c.jsx(vN,{attachment:y,onClick:f?()=>x(y):void 0},y.id))}):null,m.length>0?c.jsx("div",{className:"flex max-w-[85%] sm:max-w-[80%] flex-wrap justify-end gap-2",children:m.map(y=>c.jsx(ea,{attachment:y,onClick:f?()=>x(y):void 0},y.id))}):null,u.body||!u.body&&t.length===0&&e&&!u.systemMessage?c.jsxs("div",{className:"flex max-w-[85%] items-center gap-2 sm:max-w-[80%]",children:[n?c.jsx(fve,{"aria-label":"Sent mid-turn",className:"size-3.5 shrink-0 text-muted-foreground"}):null,c.jsx("div",{className:"min-w-0 flex-1 rounded-[20px] rounded-tr-sm border border-border bg-muted px-3.5 py-1.5 text-primary prose prose-sm prose-invert [&_p]:whitespace-pre-line",children:Yp(u.body)})]}):null,r?c.jsx("span",{className:"text-xs text-muted-foreground opacity-70",children:"auto-sent"}):null]}),c.jsx(Sm,{source:v,open:v!==null,onOpenChange:y=>!y&&a(null)})]})}const BGe=_.memo(({content:e,attachments:t=[],steered:n=!1,autoContinue:r,ports:i})=>c.jsx(FO.Provider,{init:void 0,children:c.jsx($Ge,{content:e,attachments:t,steered:n,autoContinue:r,ports:i})}));function FGe({json:e}){return c.jsx("div",{className:"flex gap-3 justify-start",children:c.jsx("div",{className:"flex-1 max-w-[90%]",children:c.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted rounded-lg p-3 overflow-auto max-h-96",children:e})})})}const o$=e=>Xt(e,()=>t=>({open:!1,setOpen:n=>t({open:n})})),zO=o$("CollapsibleSection"),UO=o$("ExpandableMcpServer"),HO=o$("RawMessageSection");function zGe({title:e,count:t,children:n,badge:r}){const i=zO.useScopedStore(o=>o.open),s=zO.useScopedStore(o=>o.setOpen);return t===0?null:c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[c.jsx(Da,{className:ce("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",i&&"rotate-90")}),c.jsx("span",{className:"text-muted-foreground font-medium",children:e}),c.jsx("span",{className:"text-muted-foreground/60",children:t}),r]}),i&&c.jsx("div",{className:"ml-5",children:n})]})}function qae({title:e,count:t,children:n,badge:r}){return c.jsx(zO.Provider,{init:void 0,children:c.jsx(zGe,{title:e,count:t,badge:r,children:n})})}function wR({title:e,items:t,icon:n,getIcon:r}){return t.length===0?null:c.jsx(qae,{title:e,count:t.length,children:c.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(i=>c.jsx(Eee,{icon:r?r(i):n,children:i},i))})})}function UGe(e){const t=e.match(/^mcp__([^_]+)__(.+)$/);return t?{server:t[1],tool:t[2]}:null}function Yae({status:e}){let t;return e==="connected"?t="bg-success":e==="pending"?t="bg-warning":t="bg-destructive",c.jsx("span",{className:ce("inline-block h-2 w-2 rounded-full shrink-0",t)})}function HGe(e){switch(e){case"connected":return"Connected";case"failed":return"Failed";case"needs-auth":return"Needs auth";case"pending":return"Connecting...";case"disabled":return"Disabled";default:return e}}function WGe({server:e}){const t=UO.useScopedStore(i=>i.open),n=UO.useScopedStore(i=>i.setOpen),r=e.status==="connected";return c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("button",{onClick:()=>r&&e.tools.length>0&&n(!t),className:ce("flex items-center gap-1.5",r&&e.tools.length>0&&"cursor-pointer hover:opacity-60 transition-opacity"),children:[r&&e.tools.length>0&&c.jsx(Da,{className:ce("h-3 w-3 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),c.jsx(Yae,{status:e.status}),c.jsx("span",{className:"text-muted-foreground font-medium",children:xM(e.name)}),r?c.jsxs("span",{className:"text-muted-foreground/50",children:[e.tools.length," tools"]}):c.jsx("span",{className:"text-muted-foreground/50",children:HGe(e.status)})]}),!r&&e.error&&c.jsx("span",{className:"text-destructive ml-5",children:e.error}),t&&e.tools.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 ml-5",children:e.tools.map(i=>c.jsx(Eee,{icon:wee(`mcp__${e.name}__${i}`),children:i},i))})]})}function eK({server:e}){return c.jsx(UO.Provider,{init:void 0,children:c.jsx(WGe,{server:e})})}function VGe({servers:e}){if(e.length===0)return null;const t=e.filter(i=>i.status==="connected"),n=e.filter(i=>i.status!=="connected"),r=n.length>0?c.jsxs("span",{className:"flex items-center gap-1 ml-1",children:[c.jsx(Yae,{status:"failed"}),c.jsxs("span",{className:"text-muted-foreground/60",children:[n.length," disconnected"]})]}):null;return c.jsx(qae,{title:"MCP Servers",count:e.length,badge:r,children:c.jsxs("div",{className:"flex flex-col gap-2",children:[t.map(i=>c.jsx(eK,{server:i},i.name)),n.map(i=>c.jsx(eK,{server:i},i.name))]})})}function KGe({rawJson:e}){const t=HO.useScopedStore(r=>r.open),n=HO.useScopedStore(r=>r.setOpen);return c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsxs("button",{onClick:()=>n(!t),className:"flex items-center gap-1 cursor-pointer group/section hover:opacity-60 transition-opacity",children:[c.jsx(Da,{className:ce("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),c.jsx("span",{className:"text-muted-foreground font-medium",children:"Raw Message"})]}),t&&c.jsx("pre",{className:"ml-5 text-xs whitespace-pre-wrap break-all border border-border rounded-md p-3 overflow-x-auto max-h-96 overflow-y-auto",children:e})]})}function GGe({rawJson:e}){return c.jsx(HO.Provider,{init:void 0,children:c.jsx(KGe,{rawJson:e})})}function qGe({message:e,rawJson:t}){const{coreTools:n,mcpServersWithTools:r}=_.useMemo(()=>{const i=new Map,s=[];for(const a of e.tools){const l=UGe(a);if(l){const u=i.get(l.server)||[];u.push(l.tool),i.set(l.server,u)}else s.push(a)}const o=e.mcpServers.map(a=>({name:a.name,status:a.status,error:a.error,tools:i.get(a.name)||[]}));return{coreTools:s,mcpServersWithTools:o}},[e.tools,e.mcpServers]);return c.jsx(Ju,{children:c.jsxs(b5,{expandedContent:c.jsx(gN,{className:"my-4 text-xs",children:c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsx(IPe,{children:e.model}),c.jsx(wR,{title:"Tools",items:n,getIcon:i=>dP[i]??See}),c.jsx(wR,{title:"Agents",items:e.agents,icon:wE}),c.jsx(wR,{title:"Commands",items:e.slashCommands,icon:Mge}),c.jsx(VGe,{servers:r}),t&&c.jsx(GGe,{rawJson:t})]})}),children:[c.jsx(Phe,{className:"h-5 w-5 text-logo"}),c.jsx(zp,{children:"Session Started"})]})})}const WO=Xt("AccountInfoMessage",()=>e=>({expanded:!1,setExpanded:t=>e({expanded:t})})),YGe={"kanna-oauth-pool":"Pool token","claude-pro":"Claude Pro","claude-max":"Claude Max",openrouter:"OpenRouter"};function XGe(e,t){return e?YGe[e]??e:t?`API key (${t})`:null}function QGe({message:e}){const{organization:t,tokenSource:n,apiKeySource:r,subscriptionType:i,email:s,oauthKeyMasked:o}=e.accountInfo,a=o??t??s??"Unknown account",l=XGe(n,r),u=WO.useScopedStore(h=>h.expanded),f=WO.useScopedStore(h=>h.setExpanded);return c.jsx(Ju,{children:c.jsxs("div",{className:"flex w-full flex-col",children:[c.jsxs("button",{type:"button",onClick:()=>f(!u),"aria-expanded":u,className:"group/account flex w-full items-center gap-2.5 text-left transition-opacity hover:opacity-80 focus-visible:opacity-100",children:[c.jsx("span",{className:"text-12 font-medium text-muted-foreground",children:"Account"}),c.jsx("span",{className:"h-3 w-px bg-border/60","aria-hidden":!0}),c.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-13 font-medium leading-snug text-foreground",children:a}),l?c.jsx("span",{className:"hidden whitespace-nowrap text-11 text-muted-foreground sm:inline",children:l}):null,c.jsx(Da,{className:ce("h-3.5 w-3.5 flex-shrink-0 text-muted-foreground transition-transform duration-200",u&&"rotate-90"),"aria-hidden":!0})]}),l?c.jsx("span",{className:"mt-0.5 text-11 text-muted-foreground sm:hidden",children:l}):null,u?c.jsx(gN,{className:"mt-3 mb-2 text-xs",children:c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsx(fP,{label:"OAuth key",copyText:a,children:c.jsx("code",{className:"block text-xs whitespace-pre-wrap break-all",children:a})}),c.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-5 gap-y-1.5",children:[l?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Source"}),c.jsx("dd",{className:"text-foreground/90",children:l})]}):null,i?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Plan"}),c.jsx("dd",{className:"text-foreground/90",children:i})]}):null,s?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Email"}),c.jsx("dd",{className:"font-mono break-all text-foreground/90",children:s})]}):null,t?c.jsxs(c.Fragment,{children:[c.jsx("dt",{className:"text-muted-foreground",children:"Organization"}),c.jsx("dd",{className:"text-foreground/90",children:t})]}):null]})]})}):null]})})}function JGe({message:e}){return c.jsx(WO.Provider,{init:void 0,children:c.jsx(QGe,{message:e})})}function ZGe({message:e,onRemove:t}){return c.jsx(za.Provider,{init:void 0,children:c.jsx(eqe,{message:e,onRemove:t})})}function eqe({message:e,onRemove:t}){const n=za.useScopedStore(a=>a.copied),r=za.useScopedStore(a=>a.setCopied),i=`/cron ${e.instruction} ${e.mode} ${e.scheduleText}`,s=_.useCallback(async()=>{await aa.writeText(i),r(!0),Jn.setTimeout(()=>r(!1),2e3)},[i,r]),o=e.upcomingFires??(e.nextFireAt!==null?[e.nextFireAt]:[]);return c.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(im,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),c.jsx("div",{className:"min-w-0 flex-1",children:c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Cron job armed"}),c.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.jobId}),c.jsx("span",{className:"rounded-full border border-border px-2 py-0.5 text-xs font-medium text-muted-foreground",children:e.mode==="inline"?"inline · runs in this chat":"spawn · new chat per run"})]})})]}),c.jsx(hu,{tooltip:e.instruction,className:"mt-1.5 text-sm text-foreground/90",children:e.instruction}),c.jsxs("div",{className:"mt-2 space-y-1",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[c.jsxs("span",{children:[e.scheduleHuman,e.scheduleHuman!==e.scheduleText?c.jsx("span",{className:"ml-1.5 font-mono opacity-70",children:e.scheduleText}):null]}),e.model?c.jsx("span",{className:"font-mono",children:e.model}):null,e.mode==="spawn"&&e.cwd?c.jsx(hu,{tooltip:e.cwd,className:"max-w-48",inline:!0,children:c.jsx("span",{className:"font-mono",children:e.cwd})}):null]}),o.length>0?c.jsx("div",{className:"flex flex-col gap-0.5 text-xs tabular-nums text-muted-foreground",children:o.map((a,l)=>c.jsxs("span",{children:[l===0?"next":` ${l+1}.`," ",new Date(a).toLocaleString()]},a))}):null]}),e.mode==="inline"?c.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Context is cleared before every run — this chat becomes a monitoring view."}):null,c.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[c.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-muted/40",onClick:s,children:[n?c.jsx(Cs,{className:"h-3.5 w-3.5 text-success","aria-hidden":"true"}):c.jsx(na,{className:"h-3.5 w-3.5","aria-hidden":"true"}),n?"Copied":"Edit"]}),t?c.jsxs("button",{type:"button","aria-label":`Disarm cron job ${e.jobId}`,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:border-destructive/50 hover:text-destructive",onClick:()=>t(e.jobId),children:[c.jsx(xc,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Disarm"]}):null]})]})}function tqe({message:e}){return c.jsx(za.Provider,{init:void 0,children:c.jsx(nqe,{message:e})})}function nqe({message:e}){const t=za.useScopedStore(s=>s.copied),n=za.useScopedStore(s=>s.setCopied),r=e.suggestion,i=_.useCallback(async()=>{r!==void 0&&(await aa.writeText(r),n(!0),Jn.setTimeout(()=>n(!1),2e3))},[r,n]);return c.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(qhe,{className:"h-4 w-4 shrink-0 text-destructive","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Invalid /cron command"})]}),e.input!==void 0?c.jsx("code",{className:"mt-1.5 block truncate rounded-md border border-border bg-muted/40 px-2.5 py-1.5 font-mono text-xs text-muted-foreground",children:e.input}):null,c.jsx("p",{className:"mt-1.5 text-sm text-foreground/90",children:e.message}),r!==void 0?c.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[c.jsx("code",{className:"min-w-0 flex-1 truncate rounded-md border border-border bg-muted/40 px-2.5 py-1.5 font-mono text-xs text-foreground",children:r}),c.jsxs("button",{type:"button",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-muted/40",onClick:i,children:[t?c.jsx(Cs,{className:"h-3.5 w-3.5 text-success","aria-hidden":"true"}):c.jsx(na,{className:"h-3.5 w-3.5","aria-hidden":"true"}),t?"Copied":"Copy fix"]})]}):null]})}function rqe({message:e}){return c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(im,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),c.jsxs("span",{className:"text-xs",children:["Cron job",c.jsxs("span",{className:"font-mono",children:[" ",e.jobId," "]}),e.change]})]})}function tK(e){return e==="inline"?"runs in this chat, context cleared each cycle":"a new chat per run"}const iqe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function a$(e,t){if(e.type==="interval")return sqe(e.ms);const{second:n,minute:r,hour:i,dom:s,month:o,dow:a}=e;if(o.kind!=="any")return t;const l=s.kind==="any"&&a.kind==="any";if(n!==void 0&&r.kind==="any"&&i.kind==="any"&&l){if(n.kind==="any")return"every second";const g=oqe(n.values);if(g!==null)return g===1?"every second":`every ${g} seconds`;if(n.values.length>1)return t}const u=n===void 0?0:CR(n);if(u===null)return t;const f=u===0?"":`:${qx(u)}`,h=CR(r),m=CR(i);if(r.kind==="any"&&i.kind==="any"&&l)return u===0?"every minute":`every minute at :${qx(u)}`;if(h!==null&&i.kind==="any"&&l)return`hourly at :${qx(h)}${f}`;if(h!==null&&m!==null){const g=`${qx(m)}:${qx(h)}${f}`;if(l)return`daily at ${g}`;if(s.kind==="any"&&a.kind==="values")return`every ${a.values.map(x=>iqe[x]).join(", ")} at ${g}`;if(a.kind==="any"&&s.kind==="values"&&s.values.length===1)return`on day ${s.values[0]} of each month at ${g}`}return t}function sqe(e){const t=Math.round(e/1e3);if(t%3600===0){const n=t/3600;return n===1?"every hour":`every ${n} hours`}if(t%60===0){const n=t/60;return n===1?"every minute":`every ${n} minutes`}return t===1?"every second":`every ${t} seconds`}function CR(e){return e.kind==="values"&&e.values.length===1?e.values[0]:null}function oqe(e){if(e.length<2||e[0]!==0)return null;const t=e[1];if(t<1||60%t!==0||e.length!==60/t)return null;for(let n=1;n<e.length;n++)if(e[n]!==n*t)return null;return t}function qx(e){return String(e).padStart(2,"0")}const aqe={running:"border-warning/40 text-warning-text bg-warning/10",completed:"border-success/40 text-success-text bg-success/10",failed:"border-destructive/40 text-destructive-text bg-destructive/10",skipped:"border-border text-muted-foreground bg-muted/40"};function lqe({message:e,cronJobs:t}){const n=t==null?void 0:t.find(s=>s.jobId===e.jobId),r=n==null?void 0:n.recentRuns.find(s=>s.runId===e.runId),i=(r==null?void 0:r.status)??"running";return c.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(im,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Cron run"}),c.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.jobId}),c.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[c.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:l0e(e.firedAt)}),c.jsx(ib,{status:i})]})]}),c.jsx("p",{className:"mt-1.5 text-sm text-foreground/90",children:e.instruction}),e.spawnedChatId?c.jsxs(a0,{to:`/chat/${e.spawnedChatId}`,className:"mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline",children:[c.jsx(sm,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Open run chat"]}):null]})}const cqe={running:"Running",completed:"Completed",failed:"Failed",skipped:"Skipped"},uqe={running:"bg-warning",completed:"bg-success",failed:"bg-destructive",skipped:"bg-muted-foreground"};function ib({status:e}){return c.jsxs("span",{className:ce("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium",aqe[e]),children:[c.jsx("span",{className:ce("h-1.5 w-1.5 rounded-full",uqe[e])}),cqe[e]]})}function Xae(){return c.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground"}),"Paused"]})}function dqe({message:e,cronJobs:t}){const n=t??[];return c.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(im,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-foreground",children:"Cron jobs"}),c.jsxs("span",{className:"ml-auto text-xs text-muted-foreground tabular-nums",children:[n.length," armed"]})]}),n.length===0?c.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:"No cron jobs armed in this chat."}):c.jsx("div",{className:"mt-2 space-y-2",children:n.map(r=>c.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[c.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:r.jobId}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground/90",children:r.instruction}),c.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[a$(r.schedule,r.scheduleText)," · ",r.mode,r.paused?" · paused":""]}),r.lastRun?c.jsx(ib,{status:r.lastRun.status}):null]},r.jobId))}),e.help?c.jsxs("div",{className:"mt-3 border-t border-border pt-2 font-mono text-xs text-muted-foreground",children:[c.jsx("div",{children:"/cron <instruction> inline|spawn <schedule>"}),c.jsx("div",{children:"/cron list · /cron remove <id> · /cron pause <id> · /cron resume <id>"}),c.jsx("div",{children:"schedules: `0 9 * * 1-5` · `*/30 * * * * *` (leading second) · @hourly @daily @weekly @monthly · every 30s / every 5m / every 2h"}),c.jsxs("div",{className:"mt-1",children:["inline: ",tK("inline"),"; spawn: ",tK("spawn"),". Next-fire times use server-local time."]})]}):null]})}function fqe({message:e}){const t=e.missedCount??1;return c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(jge,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),c.jsxs("span",{className:"text-xs tabular-nums",children:[t===1?"Cron run skipped":`Cron runs skipped ${t}×`,c.jsxs("span",{className:"font-mono",children:[" ",e.jobId]})," — ",hqe(e.reason)]})]})}function hqe(e){switch(e){case"chat_busy":return"chat was busy";case"previous_run_active":return"previous run still running";case"server_offline":return"missed while the server was offline"}}function pqe(e){return e===429?"Rate Limited":e===500?"Internal Server Error":e===502?"Bad Gateway":e===503?"Service Unavailable":e===529?"Overloaded":e>=500?"Server Error":(e>=400,"API Error")}function mqe(e){if(e!==0)return"https://status.claude.com"}function gqe({message:e}){const t=e.status>0?`${e.status} ${pqe(e.status)}`:"API Error",n=mqe(e.status);return c.jsx("div",{className:"w-full max-w-[70ch]",children:c.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2.5 space-y-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-destructive-text",children:[c.jsx(Mf,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"uppercase tracking-wide",children:t})]}),c.jsx("div",{className:"text-sm whitespace-pre-wrap break-words text-foreground/90",children:e.text}),(e.requestId||n)&&c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground pt-0.5",children:[n&&c.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"hover:underline",children:"Check status"}),e.requestId&&c.jsxs("span",{children:["Request ID: ",c.jsx("code",{className:"text-xs",children:e.requestId})]})]})]})})}const vqe="https://www.anthropic.com/legal/aup";function bqe(e){return e.replace(/^API Error:\s*/i,"")}function xqe({message:e}){const t=bqe(e.text);return c.jsx("div",{className:"w-full max-w-[70ch]",children:c.jsxs("div",{className:"rounded-md border border-warning/40 bg-warning/10 px-3 py-2.5 space-y-1.5",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warning",children:[c.jsx(kD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"uppercase tracking-wide",children:"Blocked by Usage Policy"})]}),c.jsx("div",{className:"text-sm whitespace-pre-wrap break-words text-foreground/90",children:t}),c.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground pt-0.5",children:[c.jsx("a",{href:vqe,target:"_blank",rel:"noreferrer",className:"hover:underline",children:"Usage Policy"}),e.requestId&&c.jsxs("span",{children:["Request ID: ",c.jsx("code",{className:"text-xs",children:e.requestId})]})]})]})})}const yqe={completed:{Icon:Cs,iconClass:"text-success",textClass:"text-muted-foreground"},in_progress:{Icon:jn,iconClass:"text-foreground animate-spin",textClass:"text-foreground font-medium"},pending:{Icon:cpe,iconClass:"text-muted-foreground",textClass:"text-muted-foreground"}};function _qe({message:e}){const t=e.input.todos;return t.length?c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.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:[c.jsx(_D,{className:"h-4 w-4 text-muted-foreground"}),"Progress"]}),c.jsx("div",{children:t.map((n,r)=>{const i=r===t.length-1,{Icon:s,iconClass:o,textClass:a}=yqe[n.status];return c.jsxs("div",{className:ce("flex items-center gap-3 px-4 py-2.5 bg-background",!i&&"border-b border-border"),children:[c.jsx(s,{className:ce("h-4 w-4 flex-shrink-0",o)}),c.jsx("span",{className:ce("text-sm",a),children:n.status==="in_progress"?n.activeForm:n.content})]},r)})})]})}):null}const my=Xt("OfferDownloadMessage",()=>e=>({probeState:"idle",previewOpen:!1,setProbeState:t=>e({probeState:t}),setPreviewOpen:t=>e({previewOpen:t})}));function Sqe({message:e}){const t=e.result,n=t==null?void 0:t.contentUrl,r=my.useScopedStore(x=>x.probeState),i=my.useScopedStore(x=>x.previewOpen),s=my.useScopedStore(x=>x.setProbeState),o=my.useScopedStore(x=>x.setPreviewOpen);if(_.useEffect(()=>{if(!n)return;const x=new AbortController;return g5(n,{signal:x.signal}).then(y=>{x.signal.aborted||(y.kind==="ready"?s("ready"):y.kind==="missing"&&s("missing"))}),()=>x.abort()},[n,s]),!t||!n)return null;const a={id:`offer-download-${e.toolId}`,kind:"file",displayName:t.displayName||t.fileName,absolutePath:t.relativePath,relativePath:t.relativePath,contentUrl:n,mimeType:t.mimeType??"application/octet-stream",size:t.size},l=mm(a),u=P0(l,t.mimeType),f=t.size>0?gm(t.size):null,h=c.jsxs(c.Fragment,{children:[u,f?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:f})]}):null]});if(r==="missing")return c.jsx("div",{className:"flex","data-testid":"offer-download-link",children:c.jsx(ea,{attachment:a,disabledReason:"File no longer available"})});if(!_b(a).openInNewTab){const x=`Preview ${a.displayName}, ${u}${f?`, ${f}`:""}`;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex","data-testid":"offer-download-link",children:c.jsx(ea,{attachment:a,onClick:()=>o(!0),meta:h,ariaLabel:x})}),c.jsx(Sm,{source:i?Ab(a,"offer_download"):null,open:i,onOpenChange:o})]})}const v=["Download",a.displayName,u,f].filter(x=>!!x);return c.jsx("div",{className:"flex","data-testid":"offer-download-link",children:c.jsx(ea,{attachment:a,href:n,download:t.fileName||void 0,meta:h,ariaLabel:v.join(", ")})})}function wqe({message:e}){return c.jsx(my.Provider,{init:void 0,children:c.jsx(Sqe,{message:e})})}const gy=Xt("PreviewFileMessage",()=>e=>({probeState:"idle",previewOpen:!1,setProbeState:t=>e({probeState:t}),setPreviewOpen:t=>e({previewOpen:t})}));function Cqe({message:e}){const t=e.result,n=t==null?void 0:t.contentUrl,r=gy.useScopedStore(g=>g.probeState),i=gy.useScopedStore(g=>g.previewOpen),s=gy.useScopedStore(g=>g.setProbeState),o=gy.useScopedStore(g=>g.setPreviewOpen);if(_.useEffect(()=>{if(!n)return;const g=new AbortController;return g5(n,{signal:g.signal}).then(v=>{g.signal.aborted||(v.kind==="ready"?s("ready"):v.kind==="missing"&&s("missing"))}),()=>g.abort()},[n,s]),!t||!n)return null;const a={id:`preview-file-${e.toolId}`,kind:"file",displayName:t.displayName||t.fileName,absolutePath:t.relativePath,relativePath:t.relativePath,contentUrl:n,mimeType:t.mimeType,size:t.size},l=mm(a),u=P0(l,t.mimeType),f=t.size>0?gm(t.size):null,h=c.jsxs(c.Fragment,{children:[u,f?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:f})]}):null]});if(r==="missing")return c.jsx("div",{className:"flex","data-testid":"preview-file-card",children:c.jsx(ea,{attachment:a,disabledReason:"File no longer available"})});const m=`Preview ${a.displayName}, ${u}${f?`, ${f}`:""}`;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex","data-testid":"preview-file-card",children:c.jsx(ea,{attachment:a,onClick:()=>o(!0),meta:h,ariaLabel:m})}),c.jsx(Sm,{source:i?Ab(a,"preview_file"):null,open:i,onOpenChange:o})]})}function kqe({message:e}){return c.jsx(gy.Provider,{init:void 0,children:c.jsx(Cqe,{message:e})})}const Qae=new Map;function nK(e){const t=Qae.get(e);return t!==void 0?t:void 0}function Eqe(e){const{cacheKey:t,enabled:n,ref:r,fetcher:i,rootMargin:s}=e,o=nK(t),a=_.useRef(null);a.current===null&&(a.current=vD(()=>({state:o!==void 0?"ready":"idle",data:o!==void 0?o:null,error:null})));const l=_y(a.current,v=>v.state),u=_y(a.current,v=>v.data),f=_y(a.current,v=>v.error),h=_.useRef(t),m=_.useRef(null),g=_.useRef(t);return g.current=t,_.useEffect(()=>{if(h.current===t)return;h.current=t;const v=nK(t);a.current.setState({state:v!==void 0?"ready":"idle",data:v!==void 0?v:null,error:null})},[t]),_.useEffect(()=>{if(!n||o!==void 0)return;const v=r.current;if(!v||typeof IntersectionObserver>"u")return;let x=!1;const y=t,w=new IntersectionObserver(C=>{for(const k of C){if(!k.isIntersecting)continue;if(w.disconnect(),x)return;const E=new AbortController;m.current=E,a.current.setState({state:"loading"}),i(E.signal).then(N=>{x||g.current!==y||(Qae.set(y,N),a.current.setState({data:N,state:"ready"}))}).catch(N=>{x||E.signal.aborted||g.current!==y||a.current.setState({error:N instanceof Error?N:new Error(String(N)),state:"error"})});break}},{rootMargin:s??"200px"});return w.observe(v),()=>{var C;x=!0,w.disconnect(),(C=m.current)==null||C.abort(),m.current=null}},[o,t,n,r,i,s]),_.useMemo(()=>({state:l,data:u,error:f}),[l,u,f])}function Nqe({source:e,onOpen:t,variant:n}){const r={id:e.id,kind:"file",displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??"",absolutePath:""},i=mm(r),s=P0(i,e.mimeType),o=e.size&&e.size>0?gm(e.size):null;return i==="image"?c.jsx("button",{type:"button",onClick:t,"aria-label":`Preview ${e.displayName}`,className:"overflow-hidden rounded-xl border border-border bg-background",children:c.jsx("img",{src:e.contentUrl,alt:e.altText??e.displayName,loading:"lazy",className:"max-h-64 w-auto max-w-full object-contain"})}):n==="expanded"&&(i==="text"||i==="code"||i==="markdown"||i==="json"||i==="table")?c.jsx(Tqe,{source:e,onOpen:t,friendlyType:s,sizeLabel:o}):c.jsx(ea,{attachment:r,onClick:t,meta:c.jsxs(c.Fragment,{children:[s,o?c.jsxs(c.Fragment,{children:[" · ",c.jsx("span",{className:"tabular-nums",children:o})]}):null]}),ariaLabel:`Preview ${e.displayName}, ${s}${o?`, ${o}`:""}`})}const Tqe=function({source:t,onOpen:n,friendlyType:r,sizeLabel:i}){const s=_.useRef(null),o=t.contentUrl,a=_.useCallback(async f=>{const h=await v5(o,4096);if(f.aborted)throw new Error("aborted");return h.content.slice(0,200)},[o]),l=Eqe({ref:s,enabled:!0,cacheKey:`snippet:${t.id}|${t.contentUrl}|${t.size??0}`,fetcher:a}),u=l.state==="ready"&&typeof l.data=="string"?l.data:"";return c.jsxs("button",{ref:s,type:"button",onClick:n,"aria-label":`Preview ${t.displayName}`,className:"flex w-full max-w-md flex-col items-start gap-1 rounded-xl border border-border bg-background p-3 text-left hover:bg-accent/40",children:[c.jsx("div",{className:"text-sm font-medium text-foreground",children:t.displayName}),c.jsxs("div",{className:"text-11 text-muted-foreground",children:[r,i?` · ${i}`:""]}),u?c.jsx("pre",{className:"line-clamp-3 max-h-16 w-full whitespace-pre-wrap break-words text-11 text-muted-foreground",children:u}):null]})},VO=Xt("ImageGenerationMessage",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function Aqe({message:e}){const{status:t,revisedPrompt:n}=e.input,r=e.result,i=r==null?void 0:r.contentUrl,s=e.isError||t==="failed",o=VO.useScopedStore(u=>u.open),a=VO.useScopedStore(u=>u.setOpen);if(!s&&!r&&t==="in_progress")return c.jsxs("div",{className:"flex flex-col gap-1 rounded-md border border-border/40 bg-muted/30 px-3 py-2 text-sm text-muted-foreground","data-testid":"image-generation-pending",children:[c.jsx("span",{children:"Generating image…"}),n?c.jsx("span",{className:"italic",children:n}):null]});if(s||!r||!i)return c.jsxs("div",{className:"flex flex-col gap-1 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm","data-testid":"image-generation-error",children:[c.jsx("span",{children:"Image generation failed."}),r!=null&&r.relativePath?c.jsx("span",{className:"text-muted-foreground",children:r.relativePath}):null]});const l={id:`image-gen-${e.toolId}`,contentUrl:i,displayName:r.fileName,fileName:r.fileName,relativePath:r.relativePath,mimeType:"image/png",origin:"image_generation",altText:n??void 0};return c.jsxs("figure",{className:"flex flex-col gap-2","data-testid":"image-generation",children:[c.jsx(Nqe,{source:l,onOpen:()=>a(!0),variant:"expanded"}),n?c.jsx("figcaption",{className:"text-xs text-muted-foreground italic",children:n}):null,c.jsx(Sm,{source:o?l:null,open:o,onOpenChange:a})]})}function jqe({message:e}){return c.jsx(VO.Provider,{init:void 0,children:c.jsx(Aqe,{message:e})})}function Rqe({message:e}){return c.jsx("div",{className:"flex items-center justify-end gap-2 text-sm text-muted-foreground",children:c.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:[c.jsx(ape,{className:"h-4 w-4 ml-1.5"}),c.jsx("em",{children:"Interrupted"})]})})}function fE({size:e=4}){return c.jsxs("svg",{className:"flex-1",viewBox:`0 0 100 ${e}`,preserveAspectRatio:"none",style:{height:`${e}px`},children:[c.jsx("pattern",{id:"zigzag",width:e,height:e,patternUnits:"userSpaceOnUse",children:c.jsx("path",{d:`M0 ${e} L${e/2} 0 L${e} ${e}`,fill:"none",stroke:"currentColor",strokeWidth:"0.5",className:"text-muted-foreground/30",style:{stroke:"currentColor"}})}),c.jsx("rect",{width:"100%",height:e,fill:"url(#zigzag)",className:"text-muted-foreground/30"})]})}function Mqe(){return c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(fE,{}),c.jsx("span",{className:"text-11 tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Compacted"}),c.jsx(fE,{})]})}function Pqe(){return c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(fE,{}),c.jsx("span",{className:"text-11 tracking-widest text-muted-foreground uppercase flex-shrink-0",children:"Context Cleared"}),c.jsx(fE,{})]})}function Iqe({message:e}){const t=e.path.lastIndexOf("/"),n=t>=0?e.path.slice(0,t+1):"",r=t>=0?e.path.slice(t+1):e.path;return c.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[c.jsx(c0,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),c.jsx("span",{className:"text-xs",children:"Loaded"}),c.jsxs("span",{className:"min-w-0 truncate font-mono text-xs",children:[n?c.jsx("span",{className:"opacity-60",children:n}):null,c.jsx("span",{className:"text-foreground/70",children:r})]})]})}function Oqe({message:e}){return c.jsx(Ju,{children:c.jsxs(b5,{expandedContent:c.jsx(gN,{className:"my-4 text-xs",children:c.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:Yp(e.summary)})}),children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(aq,{className:"h-4.5 w-4.5 text-muted-foreground"})}),c.jsx(zp,{children:"Summarized"})]})})}const Dqe={compacting:"Compacting..."};function Lqe({message:e}){const t=Dqe[e.status]||e.status;return c.jsxs(Ju,{className:"grid grid-cols-[auto_1fr] items-center gap-1.5 text-sm animate-pulse",children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(aq,{className:"h-4.5 w-4.5 text-muted-foreground"})}),c.jsx(zp,{className:"text-left transition-opacity duration-200 truncate",children:t})]})}function KO(e){return e.kind==="tool"}const $qe={read_file:{key:"read",singular:"read",plural:"reads"},edit_file:{key:"edit",singular:"edit",plural:"edits"},write_file:{key:"write",singular:"write",plural:"writes"},delete_file:{key:"delete",singular:"delete",plural:"deletes"},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"}},Bqe={key:"other",singular:"tool call",plural:"tool calls"};function Fqe(e){return $qe[e]??Bqe}function zqe(e){const t=new Map,n=[];for(const r of e){if(!KO(r))continue;const i=r.toolKind,s=Fqe(i),o=t.get(s.key);o?o.count++:(t.set(s.key,{category:s,count:1}),n.push(s.key))}return n.map(r=>{const{category:i,count:s}=t.get(r);return`${s} ${s===1?i.singular:i.plural}`}).join(", ")}function Uqe({messages:e,isLoading:t,localPath:n,expanded:r,onExpandedChange:i,chatId:s}){const o=_.useMemo(()=>zqe(e),[e]),l=e.some(u=>KO(u)&&u.result===void 0)&&t;return c.jsx(Ju,{className:"w-full",children:c.jsxs("div",{className:"flex flex-col w-full",children:[c.jsx("button",{onClick:()=>i(!r),className:`group cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${!r&&!l?"hover:opacity-60 transition-opacity":""}`,children:c.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(Da,{className:`h-4.5 w-4.5 text-muted-icon transition-all duration-200 ${r?"rotate-90":""}`})}),c.jsx(zp,{className:"text-left",children:c.jsx(nS,{animate:l,children:o})})]})}),r&&c.jsxs("div",{className:"my-4 flex flex-col gap-3",children:[e.filter(KO).map(u=>c.jsx(dE,{message:u,isLoading:t,localPath:n,chatId:s},u.id)),e.length>5&&c.jsx("button",{onClick:()=>i(!1),className:"cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-xs hover:opacity-80 transition-opacity",children:c.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-1.5",children:[c.jsx("div",{className:"w-5 h-5 relative flex items-center justify-center",children:c.jsx(Da,{className:"h-4.5 w-4.5 text-muted-icon -rotate-90"})}),c.jsx(zp,{className:"text-left",children:"Collapse"})]})})]})]})})}function Hqe(e){if(e!=="system")return e}function hE(e,t){const n=Hqe(t),r=new Intl.DateTimeFormat("en-GB",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).formatToParts(new Date(e)),i=o=>{var a;return((a=r.find(l=>l.type===o))==null?void 0:a.value)??"00"};let s=i("hour");return s==="24"&&(s="00"),`${i("day")}/${i("month")}/${i("year")} ${s}:${i("minute")}`}const Wqe=/^(\d{2})\/(\d{2})\/(\d{4}) (\d{2}):(\d{2})$/;function rK(e,t){if(e==="system")return-new Date(t).getTimezoneOffset();const n=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(t)),r=o=>{var a;return Number(((a=n.find(l=>l.type===o))==null?void 0:a.value)??0)};let i=r("hour");i===24&&(i=0);const s=Date.UTC(r("year"),r("month")-1,r("day"),i,r("minute"),r("second"));return Math.round((s-t)/6e4)}function Vqe(e,t){const n=Wqe.exec(e.trim());if(!n)return null;const[,r,i,s,o,a]=n,l=Number(r),u=Number(i),f=Number(s),h=Number(o),m=Number(a);if(u<1||u>12||l<1||l>31||h>23||m>59)return null;const g=Date.UTC(f,u-1,l,h,m),v=rK(t,g),x=g-v*6e4,y=rK(t,x);return x-(y-v)*6e4}const vy=Xt("AutoContinueCard",({initialDraft:e})=>t=>({draft:e,editing:!1,setDraft:n=>t({draft:n}),setEditing:n=>t({editing:n})}));function Kqe({schedule:e,onAccept:t,onReschedule:n,onCancel:r}){const i=hE(e.scheduledAt??e.resetAt,e.tz);return c.jsx(vy.Provider,{init:{initialDraft:i},children:c.jsx(Gqe,{schedule:e,onAccept:t,onReschedule:n,onCancel:r})})}function Gqe({schedule:e,onAccept:t,onReschedule:n,onCancel:r}){const i=vy.useScopedStore(v=>v.draft),s=vy.useScopedStore(v=>v.editing),o=vy.useScopedStore(v=>v.setDraft),a=vy.useScopedStore(v=>v.setEditing),l=_.useMemo(()=>Vqe(i,e.tz),[i,e.tz]),u=l!==null&&l>Date.now();let f;if(l===null?f="Use format dd/mm/yyyy hh:mm":u?f=null:f="Time must be in the future",e.state==="fired"){const v=hE(e.scheduledAt??e.resetAt,e.tz);return c.jsx(Yl,{title:`Auto-continued at ${v}`,tone:"success"})}if(e.state==="cancelled")return c.jsx(Yl,{title:"Auto-continue cancelled",tone:"muted"});if(e.state==="proposed"){const v=e.resetAt<=Date.now(),x=[{id:"schedule",label:"Schedule",variant:"primary",disabled:!u,onClick:()=>{l!==null&&t(l)}},{id:"dismiss",label:"Dismiss",variant:"ghost",onClick:()=>r()}];return c.jsx(Yl,{title:"Rate limit hit — schedule auto-continue?",description:v?"Reset time has passed — accept to continue now.":void 0,body:c.jsxs("div",{className:"space-y-1",children:[c.jsx(Bt,{value:i,onChange:y=>o(y.target.value),placeholder:"dd/mm/yyyy hh:mm"}),f&&c.jsx("div",{className:"text-destructive text-xs",children:f})]}),actions:x})}const h=hE(e.scheduledAt??e.resetAt,e.tz),m=e.tz==="system"?"local":e.tz;if(!s){const v=[{id:"change",label:"Change time",variant:"secondary",onClick:()=>a(!0)},{id:"cancel",label:"Cancel",variant:"ghost",onClick:()=>r()}];return c.jsx(Yl,{title:`Auto-continue at ${h} (${m})`,actions:v})}const g=[{id:"save",label:"Save",variant:"primary",disabled:!u,onClick:()=>{l!==null&&(n(l),a(!1))}},{id:"back",label:"Back",variant:"ghost",onClick:()=>a(!1)}];return c.jsx(Yl,{title:`Auto-continue at ${h} (${m})`,body:c.jsxs("div",{className:"space-y-1",children:[c.jsx(Bt,{value:i,onChange:v=>o(v.target.value),placeholder:"dd/mm/yyyy hh:mm"}),f&&c.jsx("div",{className:"text-destructive text-xs",children:f})]}),actions:g})}function qqe({toolRequestId:e,plan:t,onAnswer:n}){return c.jsxs("div",{className:"rounded-2xl border border-border overflow-hidden",children:[c.jsxs("div",{className:"font-medium text-sm p-3 px-4 bg-muted border-b border-border flex items-center justify-between",children:[c.jsx("span",{children:"Plan"}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"Reconnected — awaiting your response"})]}),c.jsx("div",{className:"bg-background px-4 py-3",children:c.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t})}),c.jsxs("div",{className:"flex justify-end gap-2 px-4 py-3 bg-background border-t border-border",children:[c.jsx(Ee,{size:"sm",variant:"outline",className:"rounded-full",onClick:()=>n(e,{kind:"deny",reason:"user_canceled"}),children:"Edit"}),c.jsx(Ee,{size:"sm",className:"rounded-full",onClick:()=>n(e,{kind:"answer",payload:{confirmed:!0}}),children:"Confirm"})]})]})}function Yqe({toolRequestId:e,toolName:t,args:n,onAnswer:r}){const i=["command","path","url","pattern","query"].find(a=>typeof n[a]=="string"&&String(n[a]).length>0),s=i!==void 0?n[i]:void 0,o=typeof s=="string"?s:JSON.stringify(n);return c.jsxs("div",{className:"rounded-2xl border border-border bg-background px-4 py-3 text-sm",children:[c.jsxs("div",{className:"flex items-baseline gap-2",children:[c.jsx("span",{className:"text-muted-foreground shrink-0",children:"Pending tool:"}),c.jsx("span",{className:"font-mono text-foreground",children:t})]}),o?c.jsx("pre",{className:"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:o}):null,c.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2",children:[c.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>r(e,{kind:"deny",reason:"user_canceled"}),children:"Deny"}),c.jsx(Ee,{variant:"default",size:"sm",onClick:()=>r(e,{kind:"allow"}),children:"Allow"})]})]})}function Xqe({entry:e,onAnswer:t}){const{toolRequestId:n,toolName:r,arguments:i}=e;if(r==="mcp__kanna__ask_user_question"){const o=(Array.isArray(i.questions)?i.questions.filter(Mr):[]).map(a=>{let l;return typeof a.question=="string"?l=a.question:typeof a.text=="string"?l=a.text:l="",{id:typeof a.id=="string"?a.id:void 0,question:l,header:typeof a.header=="string"?a.header:void 0,options:Array.isArray(a.options)?a.options.filter(Mr).filter(u=>typeof u.label=="string"):void 0,multiSelect:typeof a.multiSelect=="boolean"?a.multiSelect:!1}});return c.jsx(Hae,{questions:o,onSubmit:a=>t(n,{kind:"answer",payload:{questions:o,answers:a}}),onCancel:()=>t(n,{kind:"deny",reason:"user_canceled"})})}if(r==="mcp__kanna__exit_plan_mode"){const s=typeof i.plan=="string"?i.plan:"";return c.jsx(qqe,{toolRequestId:n,plan:s,onAnswer:t})}return c.jsx(Yqe,{toolRequestId:n,toolName:r,args:i,onAnswer:t})}const l$="mcp__kanna__delegate_subagent";function Qqe(e){const t=[];for(const n of e){if(n.kind!=="tool"||n.toolKind!=="mcp_generic"||n.toolName!==l$)continue;const r=n.input.payload.subagent_id;typeof r=="string"&&t.push({toolId:n.toolId,subagentId:r})}return t}function Jqe(e,t){const n=new Map;for(const a of t){const l=a.subagentId??"\0null",u=n.get(l)??[];u.push(a),n.set(l,u)}for(const a of n.values())a.sort((l,u)=>l.startedAt-u.startedAt||l.runId.localeCompare(u.runId));const r=new Map,i=new Set,s=new Map;for(const a of e){const l=n.get(a.subagentId);if(!l)continue;const u=s.get(a.subagentId)??0,f=l[u];f&&(r.set(a.toolId,f),i.add(f.runId),s.set(a.subagentId,u+1))}const o=t.filter(a=>!i.has(a.runId));return{matched:r,orphans:o}}function Zqe(e,t){if(e.length===0)return;const n=e.map(i=>`${i.runId} (subagentId=${i.subagentId})`).join(", "),r=`Subagent run placement: ${e.length} orphan top-level run(s) with no delegate_subagent tool call: ${n}`;if(t)throw new Error(r);Os.error(r)}const eYe=new Set(["AskUserQuestion","ExitPlanMode","TodoWrite",l$,u7e]),tYe=new Set(["offer_download","image_generation"]);function nYe(e){return e.kind==="tool"}function iK(e){return!nYe(e)||tYe.has(e.toolKind)?!1:!eYe.has(e.toolName)}function rYe(e,{isFirstSystem:t,isFirstAccount:n,isLatestTodoWrite:r,hideResult:i,isFinalStatus:s}){let o=!e.hidden;if(o)switch(e.kind){case"system_init":o=t;break;case"account_info":o=n;break;case"tool":o=e.toolKind!=="todo_write"||r;break;case"result":o=!i&&(!e.success||e.durationMs>6e4);break;case"context_window_updated":o=!1;break;case"status":o=s;break;default:o=!0;break}return{isFirstSystem:t,isFirstAccount:n,isLatestTodoWrite:r,hideResult:i,isFinalStatus:s,shouldRender:o}}function iYe(e,t){const n=e.findIndex(i=>i.kind==="system_init"),r=e.findIndex(i=>i.kind==="account_info");return e.map((i,s)=>{const o=e[s-1],a=e[s+1];return rYe(i,{isFirstSystem:n===s,isFirstAccount:r===s,isLatestTodoWrite:i.id===t.TodoWrite,hideResult:(a==null?void 0:a.kind)==="context_cleared"||(o==null?void 0:o.kind)==="context_cleared",isFinalStatus:s===e.length-1})})}function sYe(e,t){const n=[];let r=0;for(;r<e.length;){const i=e[r],s=t[r];if(s!=null&&s.shouldRender&&iK(i)){const o=[i],a=r;for(r+=1;r<e.length;){const l=e[r],u=t[r];if(!(u!=null&&u.shouldRender)){r+=1;continue}if(!iK(l))break;o.push(l),r+=1}o.length>=2?n.push({type:"tool-group",messages:o,startIndex:a}):n.push({type:"single",message:i,index:a});continue}n.push({type:"single",message:i,index:r}),r+=1}return n}function sK(e){var n;return e.type==="single"?e.message.id:`tool-group:${((n=e.messages[0])==null?void 0:n.id)??e.startIndex}`}function kR(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function oYe(e,t){return e.id===t.id&&e.kind===t.kind&&e.displayName===t.displayName&&e.absolutePath===t.absolutePath&&e.relativePath===t.relativePath&&e.contentUrl===t.contentUrl&&e.mimeType===t.mimeType&&e.size===t.size}function aYe(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>oYe(n,t[r]))}function sb(e,t){var n,r;if(e===t)return!0;if(e.kind!==t.kind||e.id!==t.id||e.hidden!==t.hidden)return!1;switch(e.kind){case"user_prompt":return e.content===(t.kind==="user_prompt"?t.content:null)&&t.kind==="user_prompt"&&e.steered===t.steered&&((n=e.autoContinue)==null?void 0:n.scheduleId)===((r=t.autoContinue)==null?void 0:r.scheduleId)&&aYe(e.attachments,t.attachments);case"system_init":return t.kind==="system_init"&&e.provider===t.provider&&e.model===t.model&&kR(e.tools,t.tools)&&kR(e.agents,t.agents)&&kR(e.slashCommands,t.slashCommands)&&e.debugRaw===t.debugRaw;case"account_info":return t.kind==="account_info"&&JSON.stringify(e.accountInfo)===JSON.stringify(t.accountInfo);case"assistant_text":return t.kind==="assistant_text"&&e.text===t.text;case"assistant_thinking":return t.kind==="assistant_thinking"&&e.text===t.text;case"api_error":return t.kind==="api_error"&&e.status===t.status&&e.text===t.text&&e.requestId===t.requestId;case"policy_refusal":return t.kind==="policy_refusal"&&e.text===t.text&&e.requestId===t.requestId;case"tool":return t.kind==="tool"&&e.toolKind===t.toolKind&&e.toolName===t.toolName&&e.toolId===t.toolId&&e.isError===t.isError&&JSON.stringify(e.input)===JSON.stringify(t.input)&&JSON.stringify(e.result)===JSON.stringify(t.result)&&JSON.stringify(e.rawResult)===JSON.stringify(t.rawResult);case"result":return t.kind==="result"&&e.success===t.success&&e.cancelled===t.cancelled&&e.result===t.result&&e.durationMs===t.durationMs&&e.costUsd===t.costUsd&&e.codexErrorInfo===t.codexErrorInfo;case"status":return t.kind==="status"&&e.status===t.status;case"compact_summary":return t.kind==="compact_summary"&&e.summary===t.summary;case"context_window_updated":return t.kind==="context_window_updated"&&JSON.stringify(e.usage)===JSON.stringify(t.usage);case"memory_loaded":return t.kind==="memory_loaded"&&e.path===t.path;case"compact_boundary":case"context_cleared":case"interrupted":return!0;case"unknown":return t.kind==="unknown"&&e.json===t.json;case"auto_continue_prompt":return t.kind==="auto_continue_prompt"&&e.scheduleId===t.scheduleId;case"pending_tool_request":return t.kind==="pending_tool_request"&&e.toolRequestId===t.toolRequestId&&e.toolName===t.toolName;case"cron_armed":case"cron_command_error":case"cron_run":case"cron_run_skipped":case"cron_list":case"cron_job_change":return!0}}function lYe(e,t){return e.kind!==t.kind||e.id!==t.id?!1:e.kind==="single"&&t.kind==="single"?e.index===t.index&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.isFirstSystem===t.isFirstSystem&&e.isFirstAccount===t.isFirstAccount&&e.isLatestAskUserQuestion===t.isLatestAskUserQuestion&&e.isLatestExitPlanMode===t.isLatestExitPlanMode&&e.isLatestTodoWrite===t.isLatestTodoWrite&&e.hideResult===t.hideResult&&e.isFinalStatus===t.isFinalStatus&&sb(e.message,t.message):e.kind==="tool-group"&&t.kind==="tool-group"?e.startIndex===t.startIndex&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.messages.length===t.messages.length&&e.messages.every((n,r)=>sb(n,t.messages[r])):!1}function cYe(e,t){const n=new Map;let r=e.length!==t.byId.size;const i=e.map((s,o)=>{const a=t.byId.get(s.id),l=a&&lYe(a,s)?a:s;return n.set(s.id,l),!r&&t.result[o]!==l&&(r=!0),l});return r?{byId:n,result:i}:t}function uYe(e){const t=_.useRef({byId:new Map,result:[]}),n=_.useMemo(()=>cYe(e,t.current),[e]);return _.useLayoutEffect(()=>{t.current=n}),n.result}const Jae=(e,t)=>{},dYe=_.memo(({message:e,index:t,isLoading:n,localPath:r,isFirstSystem:i,isFirstAccount:s,isLatestAskUserQuestion:o,isLatestExitPlanMode:a,isLatestTodoWrite:l,hideResult:u,isFinalStatus:f,onAskUserQuestionSubmit:h,onExitPlanModeConfirm:m,onToolRequestAnswer:g=Jae,schedules:v,cronJobs:x,onAutoContinueAccept:y,onAutoContinueReschedule:w,onAutoContinueCancel:C,onRetryFailedTurn:k,onCronRemove:E,chatId:N})=>{let T=null;if(e.kind==="user_prompt")T=c.jsx(BGe,{content:e.content,attachments:e.attachments,steered:e.steered,autoContinue:e.autoContinue},e.id);else switch(e.kind){case"auto_continue_prompt":{const R=v[e.scheduleId];if(!R){T=c.jsx("div",{className:"rounded border px-3 py-2 text-sm opacity-70",children:"Auto-continue expired"},e.id);break}T=c.jsx(Kqe,{schedule:R,onAccept:M=>y(e.scheduleId,M),onReschedule:M=>w(e.scheduleId,M),onCancel:()=>C(e.scheduleId)},e.id);break}case"unknown":T=c.jsx(FGe,{json:e.json},e.id);break;case"system_init":T=i?c.jsx(qGe,{message:e,rawJson:e.debugRaw},e.id):null;break;case"account_info":T=s?c.jsx(JGe,{message:e},e.id):null;break;case"assistant_text":T=c.jsx(Rae,{message:e},e.id);break;case"assistant_thinking":T=c.jsx(Mae,{message:e},e.id);break;case"api_error":T=c.jsx(gqe,{message:e},e.id);break;case"policy_refusal":T=c.jsx(xqe,{message:e},e.id);break;case"tool":if(e.isError){T=c.jsx(dE,{message:e,isLoading:n,localPath:r,chatId:N},e.id);break}if(e.toolKind==="ask_user_question"){T=c.jsx(s$,{message:e,onSubmit:h,isLatest:o},e.id);break}if(e.toolKind==="exit_plan_mode"){T=c.jsx(Vae,{message:e,onConfirm:m,isLatest:a},e.id);break}if(e.toolKind==="todo_write"){T=l?c.jsx(_qe,{message:e},e.id):null;break}if(e.toolKind==="offer_download"&&e.result){T=c.jsx(wqe,{message:e},e.id);break}if(e.toolKind==="preview_file"&&e.result){T=c.jsx(kqe,{message:e},e.id);break}if(e.toolKind==="image_generation"){T=c.jsx(jqe,{message:e},e.id);break}T=c.jsx(dE,{message:e,isLoading:n,localPath:r,chatId:N},e.id);break;case"result":T=u?null:c.jsx(Bae,{message:e,onRetry:k},e.id);break;case"context_window_updated":T=null;break;case"interrupted":T=c.jsx(Rqe,{message:e},e.id);break;case"compact_boundary":T=c.jsx(Mqe,{},e.id);break;case"context_cleared":T=c.jsx(Pqe,{},e.id);break;case"memory_loaded":T=c.jsx(Iqe,{message:e},e.id);break;case"compact_summary":T=c.jsx(Oqe,{message:e},e.id);break;case"status":T=f?c.jsx(Lqe,{message:e},e.id):null;break;case"pending_tool_request":T=c.jsx(Xqe,{entry:e,onAnswer:g},e.id);break;case"cron_armed":T=c.jsx(ZGe,{message:e,onRemove:E},e.id);break;case"cron_command_error":T=c.jsx(tqe,{message:e},e.id);break;case"cron_run":T=c.jsx(lqe,{message:e,cronJobs:x},e.id);break;case"cron_run_skipped":T=c.jsx(fqe,{message:e},e.id);break;case"cron_list":T=c.jsx(dqe,{message:e,cronJobs:x},e.id);break;case"cron_job_change":T=c.jsx(rqe,{message:e},e.id);break}return T?c.jsx("div",{id:`msg-${e.id}`,className:"group relative","data-index":t,[qy]:"",children:T}):null},(e,t)=>e.index===t.index&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.isFirstSystem===t.isFirstSystem&&e.isFirstAccount===t.isFirstAccount&&e.isLatestAskUserQuestion===t.isLatestAskUserQuestion&&e.isLatestExitPlanMode===t.isLatestExitPlanMode&&e.isLatestTodoWrite===t.isLatestTodoWrite&&e.hideResult===t.hideResult&&e.isFinalStatus===t.isFinalStatus&&e.onAskUserQuestionSubmit===t.onAskUserQuestionSubmit&&e.onExitPlanModeConfirm===t.onExitPlanModeConfirm&&e.onToolRequestAnswer===t.onToolRequestAnswer&&e.schedules===t.schedules&&e.cronJobs===t.cronJobs&&e.onAutoContinueAccept===t.onAutoContinueAccept&&e.onAutoContinueReschedule===t.onAutoContinueReschedule&&e.onAutoContinueCancel===t.onAutoContinueCancel&&e.onCronRemove===t.onCronRemove&&e.chatId===t.chatId&&sb(e.message,t.message)),fYe=_.memo(({id:e,messages:t,isLoading:n,localPath:r,expanded:i,onExpandedChange:s,chatId:o})=>c.jsx("div",{className:"group relative",[qy]:"",children:c.jsx(Uqe,{messages:t,isLoading:n,localPath:r,expanded:i,onExpandedChange:a=>s(e,a),chatId:o})}),(e,t)=>e.id===t.id&&e.startIndex===t.startIndex&&e.isLoading===t.isLoading&&e.localPath===t.localPath&&e.expanded===t.expanded&&e.onExpandedChange===t.onExpandedChange&&e.chatId===t.chatId&&e.messages.length===t.messages.length&&e.messages.every((n,r)=>sb(n,t.messages[r])));function Zae(e,{isLoading:t,localPath:n,latestToolIds:r}){const i=iYe(e,r),s=sYe(e,i),o=[];for(const a of s){if(a.type==="tool-group"){o.push({kind:"tool-group",id:sK(a),startIndex:a.startIndex,messages:a.messages,isLoading:t&&a.messages.some(f=>f.kind==="tool"&&f.result===void 0),localPath:n});continue}const l=i[a.index];if(!l)continue;const u={kind:"single",id:sK(a),message:a.message,index:a.index,isLoading:a.message.kind==="tool"&&a.message.result===void 0&&t,localPath:n,isFirstSystem:l.isFirstSystem,isFirstAccount:l.isFirstAccount,isLatestAskUserQuestion:a.message.id===r.AskUserQuestion,isLatestExitPlanMode:a.message.id===r.ExitPlanMode,isLatestTodoWrite:l.isLatestTodoWrite,hideResult:l.hideResult,isFinalStatus:l.isFinalStatus};l.shouldRender&&o.push(u)}return o}const hYe={};function ele(e,t,n,r,i,s,o){const a=n.get(e.runId)??[];return c.jsxs(Dn.Fragment,{children:[c.jsx(Gae,{run:e,indentDepth:t,localPath:r,onSubagentAskUserQuestionSubmit:i,onSubagentExitPlanModeSubmit:s,onCancelSubagentRun:o}),a.map(l=>ele(l,t+1,n,r,i,s,o))]},e.runId)}const tle=_.memo(({row:e,toolGroupExpanded:t,onToolGroupExpandedChange:n,onAskUserQuestionSubmit:r,onExitPlanModeConfirm:i,onToolRequestAnswer:s,schedules:o,cronJobs:a,onAutoContinueAccept:l,onAutoContinueReschedule:u,onAutoContinueCancel:f,onRetryFailedTurn:h,onCronRemove:m,chatId:g})=>e.kind==="tool-group"?c.jsx(fYe,{id:e.id,startIndex:e.startIndex,messages:e.messages,isLoading:e.isLoading,localPath:e.localPath,expanded:t??!1,onExpandedChange:n,chatId:g}):c.jsx(dYe,{message:e.message,index:e.index,isLoading:e.isLoading,localPath:e.localPath,isFirstSystem:e.isFirstSystem,isFirstAccount:e.isFirstAccount,isLatestAskUserQuestion:e.isLatestAskUserQuestion,isLatestExitPlanMode:e.isLatestExitPlanMode,isLatestTodoWrite:e.isLatestTodoWrite,hideResult:e.hideResult,isFinalStatus:e.isFinalStatus,onAskUserQuestionSubmit:r,onExitPlanModeConfirm:i,onToolRequestAnswer:s,schedules:o,cronJobs:a,onAutoContinueAccept:l,onAutoContinueReschedule:u,onAutoContinueCancel:f,onRetryFailedTurn:h,onCronRemove:m,chatId:g}),(e,t)=>{if(e.toolGroupExpanded!==t.toolGroupExpanded||e.onToolGroupExpandedChange!==t.onToolGroupExpandedChange||e.onAskUserQuestionSubmit!==t.onAskUserQuestionSubmit||e.onExitPlanModeConfirm!==t.onExitPlanModeConfirm||e.onToolRequestAnswer!==t.onToolRequestAnswer||e.schedules!==t.schedules||e.cronJobs!==t.cronJobs||e.onAutoContinueAccept!==t.onAutoContinueAccept||e.onAutoContinueReschedule!==t.onAutoContinueReschedule||e.onAutoContinueCancel!==t.onAutoContinueCancel||e.onRetryFailedTurn!==t.onRetryFailedTurn||e.onCronRemove!==t.onCronRemove||e.chatId!==t.chatId||e.row.kind!==t.row.kind||e.row.id!==t.row.id)return!1;if(e.row.kind==="tool-group"&&t.row.kind==="tool-group"){const n=e.row,r=t.row;return n.startIndex===r.startIndex&&n.isLoading===r.isLoading&&n.localPath===r.localPath&&n.messages.length===r.messages.length&&n.messages.every((i,s)=>sb(i,r.messages[s]))}return e.row.kind==="single"&&t.row.kind==="single"?e.row.index===t.row.index&&e.row.isLoading===t.row.isLoading&&e.row.localPath===t.row.localPath&&e.row.isFirstSystem===t.row.isFirstSystem&&e.row.isFirstAccount===t.row.isFirstAccount&&e.row.isLatestAskUserQuestion===t.row.isLatestAskUserQuestion&&e.row.isLatestExitPlanMode===t.row.isLatestExitPlanMode&&e.row.isLatestTodoWrite===t.row.isLatestTodoWrite&&e.row.hideResult===t.row.hideResult&&e.row.isFinalStatus===t.row.isFinalStatus&&sb(e.row.message,t.row.message):!1}),nle={},pE=[],pYe=(e,t)=>{},mYe=(e,t)=>{},gYe=e=>{};function vYe({messages:e,isLoading:t,localPath:n,latestToolIds:r,onOpenLocalLink:i,chatId:s,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:a,onToolRequestAnswer:l=Jae,schedules:u=nle,cronJobs:f=pE,onAutoContinueAccept:h=pYe,onAutoContinueReschedule:m=mYe,onAutoContinueCancel:g=gYe,onRetryFailedTurn:v,onTunnelAccept:x,onTunnelStop:y,onTunnelRetry:w,subagentRuns:C=hYe,onSubagentAskUserQuestionSubmit:k,onSubagentExitPlanModeSubmit:E,onCancelSubagentRun:N,onCronRemove:T}){const R=DO.useScopedStore($=>$.toolGroupExpanded),M=DO.useScopedStore($=>$.setToolGroupExpanded),P=_.useMemo(()=>Zae(e,{isLoading:t,localPath:n,latestToolIds:r}),[t,r,n,e]),{matchedRunsByToolId:B,childrenByParentRunId:U}=_.useMemo(()=>{const $=[],I=new Map;for(const W of Object.values(C))if(W.parentRunId===null)$.push(W);else{const Y=I.get(W.parentRunId)??[];Y.push(W),I.set(W.parentRunId,Y)}const V=(W,Y)=>W.startedAt-Y.startedAt||W.runId.localeCompare(Y.runId);for(const W of I.values())W.sort(V);const{matched:z,orphans:H}=Jqe(Qqe(e),$);return Zqe(H,!1),{matchedRunsByToolId:z,childrenByParentRunId:I}},[C,e]),D=_.useCallback(($,I)=>{M($,I)},[M]);return c.jsx(_ee,{onOpenLocalLink:i,children:P.map($=>{const I=$.kind==="single"&&$.message.kind==="tool"&&$.message.toolName===l$?$.message.toolId:null,V=I?B.get(I):void 0;return c.jsxs("div",{className:"mx-auto max-w-[800px] pb-5","data-transcript-row-id":$.id,children:[c.jsx(tle,{row:$,toolGroupExpanded:$.kind==="tool-group"?R[$.id]??!1:void 0,onToolGroupExpandedChange:D,onAskUserQuestionSubmit:o,onExitPlanModeConfirm:a,onToolRequestAnswer:l,schedules:u,cronJobs:f,onAutoContinueAccept:h,onAutoContinueReschedule:m,onAutoContinueCancel:g,onRetryFailedTurn:v,onCronRemove:T,chatId:s}),V?ele(V,0,U,n??"",k,E,N):null]},$.id)})})}function bYe(e){return c.jsx(DO.Provider,{init:{},children:c.jsx(vYe,{...e})})}_.memo(bYe);const xYe=[];function yYe(e,t){const n=e.findIndex(r=>r.id===t);if(n<0)return null;for(let r=n-1;r>=0;r-=1){const i=e[r];if((i==null?void 0:i.kind)!=="user_prompt")continue;const s=i.attachments??xYe;if(!(i.content.trim().length===0&&s.length===0))return{content:i.content,attachments:[...s]}}return null}const _Ye=Object.freeze([]),ER=Yt((e,t)=>({sharesByChat:{},listForChat(n){return t().sharesByChat[n]??_Ye},setShares(n,r){e(i=>({sharesByChat:{...i.sharesByChat,[n]:r}}))},addShare(n,r){e(i=>({sharesByChat:{...i.sharesByChat,[n]:[...i.sharesByChat[n]??[],r]}}))},removeShare(n,r){e(i=>({sharesByChat:{...i.sharesByChat,[n]:(i.sharesByChat[n]??[]).filter(s=>s.tokenId!==r)}}))}})),rle=_.createContext(null);function SYe(e,t){return{getTheme:function(){return t??null}}}function $s(){const e=_.useContext(rle);return e==null&&(function(t,...n){const r=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const s of n)i.append("v",s);throw r.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(8),e}const wYe=Ri?_.useLayoutEffect:_.useEffect,IC={tag:av};function CYe({initialConfig:e,children:t}){const n=_.useMemo(()=>{const{theme:r,namespace:i,nodes:s,onError:o,editorState:a,html:l}=e,u=SYe(null,r),f=z5({editable:e.editable,html:l,namespace:i,nodes:s,onError:h=>o(h,f),theme:r});return(function(h,m){if(m!==null){if(m===void 0)h.update(()=>{const g=Mn();if(g.isEmpty()){const v=$t();g.append(v);const x=Ri?document.activeElement:null;(Ue()!==null||x!==null&&x===h.getRootElement())&&v.select()}},IC);else if(m!==null)switch(typeof m){case"string":{const g=h.parseEditorState(m);h.setEditorState(g,IC);break}case"object":h.setEditorState(m,IC);break;case"function":h.update(()=>{Mn().isEmpty()&&m(h)},IC)}}})(f,a),[f,u]},[]);return wYe(()=>{const r=e.editable,[i]=n;i.setEditable(r===void 0||r)},[]),c.jsx(rle.Provider,{value:n,children:t})}const kYe=Ri?_.useLayoutEffect:_.useEffect;function EYe(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function NYe(){return(function(e){const[t]=$s(),n=_.useMemo(()=>e(t),[t,e]),[r,i]=_.useState(()=>n.initialValueFn()),s=_.useRef(r);return kYe(()=>{const{initialValueFn:o,subscribe:a}=n,l=o();return s.current!==l&&(s.current=l,i(l)),a(u=>{s.current=u,i(u)})},[n,e]),r})(EYe)}const TYe={name:"@lexical/react/ReactProvider"};function AYe(){return Mn().getTextContent()}function jYe(e,t=!0){if(e)return!1;let n=AYe();return t&&(n=n.trim()),n===""}function RYe(e){if(!jYe(e,!1))return!1;const t=Mn().getChildren(),n=t.length;if(n>1)return!1;for(let r=0;r<n;r++){const i=t[r];if(bn(i))return!1;if(be(i)){if(!qa(i)||i.__indent!==0)return!1;const s=i.getChildren(),o=s.length;for(let a=0;a<o;a++){const l=s[r];if(!$e(l))return!1}}}return!0}function ile(e){return()=>RYe(e)}function MYe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const i of t)r.append("v",i);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const c$=Ri?_.useLayoutEffect:_.useEffect;function PYe({editor:e,ErrorBoundary:t}){return(function(n,r){const[i,s]=_.useState(()=>n.getDecorators());return c$(()=>n.registerDecoratorListener(o=>{to.flushSync(()=>{s(o)})}),[n]),_.useEffect(()=>{s(n.getDecorators())},[n]),_.useMemo(()=>{const o=[],a=Object.keys(i);for(let l=0;l<a.length;l++){const u=a[l],f=c.jsx(r,{onError:m=>n._onError(m),children:c.jsx(_.Suspense,{fallback:null,children:i[u]})}),h=n.getElementByKey(u);h!==null&&o.push(to.createPortal(f,h,u))}return o},[r,i,n])})(e,t)}function IYe({editor:e,ErrorBoundary:t}){return(function(n){const r=l3.maybeFromEditor(n);if(r&&r.hasExtensionByName(TYe.name)){for(const i of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(i)&&MYe(320,i);return!0}return!1})(e)?null:c.jsx(PYe,{editor:e,ErrorBoundary:t})}function oK(e){return e.getEditorState().read(ile(e.isComposing()))}function OYe({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){const[r]=$s();return(function(i){c$(()=>Pi(kre(i),Sre(i)),[i])})(r),c.jsxs(c.Fragment,{children:[e,c.jsx(DYe,{content:t}),c.jsx(IYe,{editor:r,ErrorBoundary:n})]})}function DYe({content:e}){const[t]=$s(),n=(function(i){const[s,o]=_.useState(()=>oK(i));return c$(()=>{function a(){const l=oK(i);o(l)}return a(),Pi(i.registerUpdateListener(()=>{a()}),i.registerEditableListener(()=>{a()}))},[i]),s})(t),r=NYe();return n?typeof e=="function"?e(r):e:null}const sle=Ri?_.useLayoutEffect:_.useEffect;function LYe({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:s,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:f,ariaOwns:h,ariaRequired:m,autoCapitalize:g,className:v,id:x,role:y="textbox",spellCheck:w=!0,style:C,tabIndex:k,"data-testid":E,...N},T){const[R,M]=_.useState(e.isEditable()),P=_.useCallback(U=>{U&&U.ownerDocument&&U.ownerDocument.defaultView?e.setRootElement(U):e.setRootElement(null)},[e]),B=_.useMemo(()=>(function(...U){return D=>{for(const $ of U)typeof $=="function"?$(D):$!=null&&($.current=D)}})(T,P),[P,T]);return sle(()=>(M(e.isEditable()),e.registerEditableListener(U=>{M(U)})),[e]),c.jsx("div",{"aria-activedescendant":R?t:void 0,"aria-autocomplete":R?n:"none","aria-controls":R?r:void 0,"aria-describedby":i,...s!=null?{"aria-errormessage":s}:{},"aria-expanded":R&&y==="combobox"?!!o:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":u,"aria-multiline":f,"aria-owns":R?h:void 0,"aria-readonly":!R||void 0,"aria-required":m,autoCapitalize:g,className:v,contentEditable:R,"data-testid":E,id:x,ref:B,role:y,spellCheck:w,style:C,tabIndex:k,...N})}const $Ye=_.forwardRef(LYe);function aK(e){return e.getEditorState().read(ile(e.isComposing()))}const BYe=_.forwardRef(FYe);function FYe(e,t){const{placeholder:n,...r}=e,[i]=$s();return c.jsxs(c.Fragment,{children:[c.jsx($Ye,{editor:i,...r,ref:t}),n!=null&&c.jsx(zYe,{editor:i,content:n})]})}function zYe({content:e,editor:t}){const n=(function(o){const[a,l]=_.useState(()=>aK(o));return sle(()=>{function u(){const f=aK(o);l(f)}return u(),Pi(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a})(t),[r,i]=_.useState(t.isEditable());if(_.useLayoutEffect(()=>(i(t.isEditable()),t.registerEditableListener(o=>{i(o)})),[t]),!n)return null;let s=null;return typeof e=="function"?s=e(r):e!==null&&(s=e),s===null?null:c.jsx("div",{"aria-hidden":!0,children:s})}function UYe(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;const s=t._selection,o=e._selection;if(i)return 1;if(!(Ne(s)&&Ne(o)&&o.isCollapsed()&&s.isCollapsed()))return 0;const a=(function(w,C,k){const E=w._nodeMap,N=[];for(const T of C){const R=E.get(T);R!==void 0&&N.push(R)}for(const[T,R]of k){if(!R)continue;const M=E.get(T);M===void 0||Ai(M)||N.push(M)}return N})(t,n,r);if(a.length===0)return 0;if(a.length>1){const w=t._nodeMap,C=w.get(s.anchor.key),k=w.get(o.anchor.key);return C&&k&&!e._nodeMap.has(C.__key)&&$e(C)&&C.__text.length===1&&s.anchor.offset===1?2:0}const l=a[0],u=e._nodeMap.get(l.__key);if(!$e(u)||!$e(l)||u.__mode!==l.__mode)return 0;const f=u.__text,h=l.__text;if(f===h)return 0;const m=s.anchor,g=o.anchor;if(m.key!==g.key||m.type!=="text")return 0;const v=m.offset,x=g.offset,y=h.length-f.length;return y===1&&x===v-1?2:y===-1&&x===v+1?3:y===-1&&x===v?4:0}function HYe(e,t,n){let r=n(),i=0,s=r,o=0,a=null;return(l,u,f,h,m,g)=>{const v=n();if(g.has(mte)&&(s=r,o=i,a=l),g.has(AP))return i=0,r=v,2;g.has(gte)&&a&&(r=s,i=o,l=a);const x=UYe(l,u,h,m,e.isComposing()),y=(()=>{const w=f===null||f.editor===e,C=g.has(jIe);if(!C&&w&&g.has(av))return 0;if(x===1)return 2;if(l===null)return 1;const k=u._selection;if(!(h.size>0||m.size>0))return k!==null?0:2;const E=typeof t=="number"?t:t.peek();return C===!1&&x!==0&&x===i&&v<r+E&&w||h.size===1&&(function(N,T,R){const M=T._nodeMap.get(N),P=R._nodeMap.get(N),B=T._selection,U=R._selection;return!(Ne(B)&&Ne(U)&&B.anchor.type==="element"&&B.focus.type==="element"&&U.anchor.type==="text"&&U.focus.type==="text"||!$e(M)||!$e(P)||M.__parent!==P.__parent)&&JSON.stringify(T.read(()=>M.exportJSON()))===JSON.stringify(R.read(()=>P.exportJSON()))})(Array.from(h)[0],l,u)?0:1})();return r=v,i=x,y}}function lK(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function ole(e,t,n,r=Date.now,i,s=null){const o=HYe(e,n,r),a=()=>{i&&i(t)};return a(),Pi(e.registerCommand(C5,()=>((function(l,u,f){const h=u.redoStack,m=u.undoStack;if(m.length!==0){const g=u.current,v=m.pop();g!==null&&(h.push(g),l.dispatchCommand(Zw,!0)),m.length===0&&l.dispatchCommand(eC,!1),u.current=v||null,f&&f(u),v&&v.editor.setEditorState(v.editorState,{tag:AP})}})(e,t,i),!0),Kt),e.registerCommand(k5,()=>((function(l,u,f){const h=u.redoStack,m=u.undoStack;if(h.length!==0){const g=u.current;g!==null&&(m.push(g),l.dispatchCommand(eC,!0));const v=h.pop();h.length===0&&l.dispatchCommand(Zw,!1),u.current=v||null,f&&f(u),v&&v.editor.setEditorState(v.editorState,{tag:AP})}})(e,t,i),!0),Kt),e.registerCommand(yIe,()=>(lK(t,i),!1),Kt),e.registerCommand(_Ie,()=>(lK(t,i),e.dispatchCommand(Zw,!1),e.dispatchCommand(eC,!1),!0),Kt),e.registerUpdateListener(({editorState:l,prevEditorState:u,dirtyLeaves:f,dirtyElements:h,tags:m})=>{const g=t.current,v=t.redoStack,x=t.undoStack,y=g===null?null:g.editorState;if(g!==null&&l===y)return;const w=o(u,l,g,f,h,m);if(w===1){if(v.length!==0&&(t.redoStack=[],e.dispatchCommand(Zw,!1)),g!==null){x.push({...g});const C=typeof s=="number"||s===null?s:s.peek();C!==null&&x.length>C&&x.splice(0,x.length-C),e.dispatchCommand(eC,!0)}}else if(w===2)return;t.current={editor:e,editorState:l},a()}))}function ale(){return{current:null,redoStack:[],undoStack:[]}}const NR={build:(e,{delay:t,createInitialHistoryState:n,disabled:r,maxDepth:i,now:s},o)=>({...nd({delay:t,disabled:r,historyState:n(e),maxDepth:i,now:s}),...o.getInitResult()}),config:{createInitialHistoryState:ale,delay:300,disabled:typeof window>"u",maxDepth:null,now:Date.now},init:()=>({canRedo:Uu(!1),canUndo:Uu(!1)}),name:"@lexical/history/History",register:(e,t,n)=>{const{canUndo:r,canRedo:i}=n.getInitResult(),s=n.getOutput(),o=a=>s3(()=>{r.value=a!=null&&a.undoStack.length>0,i.value=a!=null&&a.redoStack.length>0});return ws(()=>{if(!s.disabled.value)return ole(e,s.historyState.value,s.delay,()=>s.now.peek()(),o,s.maxDepth);o(null)})}};td(NR,{disabled:!0});function WYe({delay:e,externalHistoryState:t}){const[n]=$s();return(function(r,i,s=1e3){const o=_.useMemo(()=>i||ale(),[i]);_.useEffect(()=>ole(r,o,s),[s,r,o])})(n,t,e),null}const lle=_.forwardRef(({className:e,children:t,...n},r)=>c.jsx("div",{ref:r,className:ce("relative overflow-y-auto overscroll-contain touch-pan-y scrollbar-hide",e),style:{WebkitOverflowScrolling:"touch"},...n,children:t}));lle.displayName="ScrollArea";const cK="(display-mode: standalone)";function VYe(e={dom:Et}){const[t,n]=_.useState(()=>{const r=e.dom.isIOSStandalone(),i=e.dom.matchesMediaQuery(cK);return r||i});return _.useEffect(()=>e.dom.addMediaQueryListener(cK,r=>{n(r||e.dom.isIOSStandalone())}),[e.dom]),t}const GO=Xt("InputPopover",()=>e=>({open:!1,setOpen:t=>e({open:t})}));function KYe(){return e=>({open:!1,query:"",setQuery:t=>e({query:t}),setPopoverOpen:t=>e(t?{open:!0}:{open:!1,query:""}),closeAndClearQuery:()=>e({open:!1,query:""})})}const Dg=Xt("SearchableModelPopover",KYe);function GYe({className:e,...t}){return c.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:ce("shrink-0",e),...t,children:c.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"})})}function qYe({className:e,...t}){return c.jsx("svg",{viewBox:"0 0 158.7128 157.296",fill:"currentColor","aria-hidden":"true",className:ce("shrink-0",e),...t,children:c.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"})})}function YYe({className:e,...t}){return c.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:ce("shrink-0",e),...t,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M6.3 6.3a8 8 0 1 0 11.4 11.4"}),c.jsx("path",{d:"M17.7 6.3a8 8 0 0 1 0 11.4"}),c.jsx("path",{d:"M2 12h4"}),c.jsx("path",{d:"M18 12h4"})]})}const uK={claude:GYe,codex:qYe,openrouter:YYe};function Fl({onClick:e,selected:t,icon:n,label:r,description:i,disabled:s}){return c.jsxs("button",{onClick:e,disabled:s,className:ce("w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity",t?"bg-muted border-border":"hover:opacity-60",s&&"opacity-40 cursor-not-allowed"),children:[n,c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium",children:r}),i?c.jsx("div",{className:"text-xs text-muted-foreground",children:i}):null]})]})}function Tg({trigger:e,triggerClassName:t,disabled:n=!1,children:r}){return n?c.jsx("button",{disabled:!0,className:ce("flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap",t),children:e}):c.jsx(GO.Provider,{init:void 0,children:c.jsx(XYe,{trigger:e,triggerClassName:t,children:r})})}function XYe({trigger:e,triggerClassName:t,children:n}){const r=GO.useScopedStore(s=>s.open),i=GO.useScopedStore(s=>s.setOpen);return c.jsxs(_c,{open:r,onOpenChange:i,children:[c.jsx(Sc,{asChild:!0,children:c.jsx("button",{type:"button",className:ce("flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap","hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),children:e})}),c.jsx(Nl,{align:"center",className:"w-64 p-1",children:c.jsx("div",{className:"space-y-1",children:typeof n=="function"?n(()=>i(!1)):n})})]})}function QYe({models:e,selectedModel:t,onSelect:n,ModelIcon:r}){return c.jsx(Dg.Provider,{init:void 0,children:c.jsx(JYe,{models:e,selectedModel:t,onSelect:n,ModelIcon:r})})}function JYe({models:e,selectedModel:t,onSelect:n,ModelIcon:r}){var g;const i=Dg.useScopedStore(v=>v.open),s=Dg.useScopedStore(v=>v.query),o=Dg.useScopedStore(v=>v.setPopoverOpen),a=Dg.useScopedStore(v=>v.setQuery),l=Dg.useScopedStore(v=>v.closeAndClearQuery),u=_.useCallback(v=>{n(v),l()},[n,l]),f=((g=e.find(v=>v.id===t))==null?void 0:g.label)??t,h=_.useMemo(()=>{const v=s.trim().toLowerCase();return v?e.filter(x=>x.id.toLowerCase().includes(v)||x.label.toLowerCase().includes(v)):e},[e,s]);let m;return e.length===0?m=c.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground text-center",children:"Loading models… verify OpenRouter API key in Settings."}):h.length===0?m=c.jsx("div",{className:"px-2 py-3 text-xs text-muted-foreground text-center",children:"No matches"}):m=h.map(v=>c.jsx(Fl,{onClick:()=>u(v.id),selected:t===v.id,icon:c.jsx(sM,{className:"h-4 w-4 text-muted-foreground"}),label:v.label,description:v.id},v.id)),c.jsxs(_c,{open:i,onOpenChange:o,children:[c.jsx(Sc,{asChild:!0,children:c.jsxs("button",{type:"button",className:ce("flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap","hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[c.jsx(r,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"max-w-[200px] truncate",children:f})]})}),c.jsxs(Nl,{align:"center",className:"w-80 p-1",children:[c.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 border-b border-border/50",children:[c.jsx(Yg,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),c.jsx("input",{type:"text",value:s,onChange:v=>a(v.target.value),placeholder:"Search models...",autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),c.jsx("div",{className:"max-h-72 overflow-y-auto py-1 space-y-1",children:m})]})]})}function qO({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,showCodexCliRequirementHints:r=!1,model:i,modelOptions:s,onProviderChange:o,onModelChange:a,onModelOptionChange:l,planMode:u=!1,onPlanModeChange:f,includePlanMode:h=!0,className:m}){var P,B,U,D,$;const g=pr(X0),v=e.find(I=>I.id===t)??e[0],x=uK[t],y=sM,w=h&&(v==null?void 0:v.supportsPlanMode)&&f,C=t==="claude"&&"contextWindow"in s?s:null,k=t==="codex"&&"fastMode"in s?s:null,E=((P=v.models.find(I=>I.id===i))==null?void 0:P.contextWindowOptions)??[],N=(C==null?void 0:C.contextWindow)??ip[0].id,T=N==="1m"?Vz:Kz,R=((B=v.models.find(I=>I.id===i))==null?void 0:B.label)??i,M=t==="openrouter"?c.jsx(QYe,{models:v.models,selectedModel:i,onSelect:I=>a==null?void 0:a(t,I),ModelIcon:y}):c.jsx(Tg,{trigger:c.jsxs(c.Fragment,{children:[c.jsx(y,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:R})]}),children:I=>v.models.map(V=>{const z=sM;return c.jsx(Fl,{onClick:()=>{a==null||a(t,V.id),I()},selected:i===V.id,icon:c.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),label:r&&t==="codex"&&V.id==="gpt-5.5"?c.jsxs(c.Fragment,{children:[V.label," ",c.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"codex-cli >= 0.124"})]}):V.label},V.id)})});return c.jsxs("div",{className:ce("flex md:justify-center items-center gap-0.5",m),children:[n?c.jsx(Tg,{disabled:!o,trigger:c.jsxs(c.Fragment,{children:[c.jsx(x,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:(v==null?void 0:v.label)??t})]}),children:I=>e.map(V=>{const z=uK[V.id];return c.jsx(Fl,{onClick:()=>{o==null||o(V.id),I()},selected:t===V.id,icon:c.jsx(z,{className:"h-4 w-4 text-muted-foreground"}),label:V.label},V.id)})}):null,a==null?c.jsx(ia,{label:"Model is locked while a cron job is running — pause or remove the cron job to change it",side:"top",children:c.jsxs("span",{"aria-disabled":"true",className:"flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap",children:[c.jsx(sq,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:R})]})}):M,t!=="openrouter"?c.jsx(Tg,{trigger:c.jsxs(c.Fragment,{children:[c.jsx(BC,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:t==="claude"?((U=i_.find(I=>I.id===s.reasoningEffort))==null?void 0:U.label)??s.reasoningEffort:((D=ek.find(I=>I.id===s.reasoningEffort))==null?void 0:D.label)??s.reasoningEffort})]}),children:I=>t==="claude"?i_.map(V=>c.jsx(Fl,{onClick:()=>{l({type:"claudeReasoningEffort",effort:V.id}),I()},selected:s.reasoningEffort===V.id,icon:c.jsx(BC,{className:"h-4 w-4 text-muted-foreground"}),label:V.label,disabled:V.id==="max"&&!BQ(i,g)},V.id)):ek.map(V=>c.jsx(Fl,{onClick:()=>{l({type:"codexReasoningEffort",effort:V.id}),I()},selected:s.reasoningEffort===V.id,icon:c.jsx(BC,{className:"h-4 w-4 text-muted-foreground"}),label:V.label},V.id))}):null,t==="claude"&&E.length>1?c.jsx(Tg,{trigger:c.jsxs(c.Fragment,{children:[c.jsx(T,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:(($=E.find(I=>I.id===N))==null?void 0:$.label)??N})]}),children:I=>E.map(V=>c.jsx(Fl,{onClick:()=>{l({type:"contextWindow",contextWindow:V.id}),I()},selected:N===V.id,icon:V.id==="1m"?c.jsx(Vz,{className:"h-4 w-4 text-muted-foreground"}):c.jsx(Kz,{className:"h-4 w-4 text-muted-foreground"}),label:V.label,description:V.id==="1m"?"Expanded context window":"Standard context window"},V.id))}):null,t==="codex"?c.jsx(Tg,{trigger:c.jsxs(c.Fragment,{children:[k!=null&&k.fastMode?c.jsx(pw,{className:"h-3.5 w-3.5"}):c.jsx(pw,{className:"h-3.5 w-3.5 -scale-x-100"}),c.jsx("span",{children:k!=null&&k.fastMode?"Fast Mode":"Standard"})]}),triggerClassName:k!=null&&k.fastMode?"text-success":void 0,children:I=>c.jsxs(c.Fragment,{children:[c.jsx(Fl,{onClick:()=>{l({type:"fastMode",fastMode:!1}),I()},selected:!(k!=null&&k.fastMode),icon:c.jsx(pw,{className:"h-4 w-4 text-muted-foreground -scale-x-100"}),label:"Standard"}),c.jsx(Fl,{onClick:()=>{l({type:"fastMode",fastMode:!0}),I()},selected:!!(k!=null&&k.fastMode),icon:c.jsx(pw,{className:"h-4 w-4 text-muted-foreground"}),label:"Fast Mode"})]})}):null,w?c.jsx(Tg,{trigger:c.jsxs(c.Fragment,{children:[u?c.jsx($1,{className:"h-3.5 w-3.5"}):c.jsx(zz,{className:"h-3.5 w-3.5"}),c.jsx("span",{children:u?"Plan Mode":"Full Access"})]}),triggerClassName:u?"text-info":void 0,children:I=>c.jsxs(c.Fragment,{children:[c.jsx(Fl,{onClick:()=>{f(!1),I()},selected:!u,icon:c.jsx(zz,{className:"h-4 w-4 text-muted-foreground"}),label:"Full Access",description:"Execution without approval"}),c.jsx(Fl,{onClick:()=>{f(!0),I()},selected:u,icon:c.jsx($1,{className:"h-4 w-4 text-muted-foreground"}),label:"Plan Mode",description:"Review a plan before execution"})]})}):null]})}function ZYe(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,"")}%`:`${Math.round(e)}%`}function dK({usage:e}){const t=ZYe(e.usedPercentage),n=Math.max(0,Math.min(100,e.usedPercentage??0)),r=9.75,i=2*Math.PI*r,s=i-n/100*i;return c.jsxs(_c,{children:[c.jsx(Sc,{asChild:!0,children:c.jsx("button",{type:"button",className:"group inline-flex h-9 w-9 cursor-pointer touch-manipulation items-center justify-center rounded-full transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e.maxTokens!==void 0&&t?`Context window ${t} used`:`Context window ${_o(e.usedTokens)} tokens used`,children:c.jsxs("span",{className:"relative flex h-6 w-6 items-center justify-center",children:[c.jsxs("svg",{viewBox:"0 0 24 24",className:"-rotate-90 absolute inset-0 h-full w-full transform-gpu","aria-hidden":"true",children:[c.jsx("circle",{cx:"12",cy:"12",r,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-muted-foreground/20"}),c.jsx("circle",{cx:"12",cy:"12",r,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:s,className:"text-muted-foreground transition-[stroke-dashoffset] duration-500 ease-out"})]}),c.jsx("span",{className:ce("relative flex h-[15px] w-[15px] items-center justify-center rounded-full bg-background text-9 font-medium","text-muted-foreground"),children:e.usedPercentage!==null?Math.round(e.usedPercentage):_o(e.usedTokens)})]})})}),c.jsx(Nl,{side:"top",align:"center",className:"w-max max-w-none px-3 py-2",children:c.jsx("div",{className:"space-y-1.5 leading-tight",children:e.maxTokens!==void 0&&t?c.jsxs("div",{className:"whitespace-nowrap text-xs font-medium text-foreground",children:[c.jsx("span",{children:t}),c.jsx("span",{className:"mx-1",children:"·"}),c.jsx("span",{children:_o(e.usedTokens)}),c.jsx("span",{children:"/"}),c.jsxs("span",{children:[_o(e.maxTokens)," context used"]})]}):c.jsxs("div",{className:"text-sm text-foreground",children:[_o(e.usedTokens)," tokens used so far"]})})})]})}function fK({totals:e,className:t}){if(!e)return null;const n=e.cacheHitPercentage===null?null:eXe(e.cacheHitPercentage),i=e.costUsd>0?HKe(e.costUsd):null;return c.jsxs(_c,{children:[c.jsx(Sc,{asChild:!0,children:c.jsxs("button",{type:"button","aria-label":tXe(e,n,i),className:ce("inline-flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 rounded-md bg-muted/30 px-2.5 py-1.5 text-xs tabular-nums text-muted-foreground transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),children:[c.jsx(TR,{label:"in",value:_o(e.inputTokens)}),c.jsx(AR,{}),c.jsx(TR,{label:"out",value:_o(e.outputTokens)}),n!==null?c.jsxs(c.Fragment,{children:[c.jsx(AR,{}),c.jsx(TR,{label:"cache",value:n})]}):null,i!==null?c.jsxs(c.Fragment,{children:[c.jsx(AR,{}),c.jsx("span",{className:"tabular-nums",children:i})]}):null]})}),c.jsx(Nl,{side:"top",align:"center",className:"w-max max-w-none px-3 py-2",children:c.jsxs("div",{className:"space-y-1 text-xs leading-tight",children:[c.jsx(Yx,{label:"Input",value:_o(e.inputTokens)}),c.jsx(Yx,{label:"Output",value:_o(e.outputTokens)}),c.jsx(Yx,{label:"Cache read",value:_o(e.cachedTokens)}),n!==null?c.jsx(Yx,{label:"Cache hit",value:n}):null,i!==null?c.jsx(Yx,{label:"Cost",value:i}):null]})})]})}function TR({label:e,value:t}){return c.jsxs("span",{className:"inline-flex items-baseline gap-1 tabular-nums",children:[c.jsx("span",{className:"font-medium text-foreground",children:t}),c.jsx("span",{children:e})]})}function AR(){return c.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50",children:"·"})}function Yx({label:e,value:t}){return c.jsxs("div",{className:"flex items-baseline justify-between gap-6 whitespace-nowrap",children:[c.jsx("span",{className:"text-muted-foreground",children:e}),c.jsx("span",{className:"font-medium tabular-nums text-foreground",children:t})]})}function eXe(e){const t=Math.max(0,Math.min(100,e));return t<10?`${t.toFixed(1).replace(/\.0$/,"")}%`:`${Math.round(t)}%`}function tXe(e,t,n){const r=[`Input ${_o(e.inputTokens)}`,`Output ${_o(e.outputTokens)}`,`Cache ${_o(e.cachedTokens)}`];return t!==null&&r.push(`hit ${t}`),n!==null&&r.push(`cost ${n}`),`Session tokens: ${r.join(", ")}`}class cle extends Error{constructor(){super("Upload aborted"),this.name="UploadAbortedError"}}const nXe=80;function u$(e){const t=e.XHR??XMLHttpRequest,n=new t;let r=!1,i=0,s=-1;return{promise:new Promise((a,l)=>{function u(h,m,g=!1){const v=m>0?m:e.file.size,x=v>0?Math.floor(h/v*100):0,y=Date.now(),w=y-i>=nXe;!g&&!w&&!(x!==s)||(i=y,s=x,e.onProgress({loaded:h,total:v}))}n.upload.addEventListener("progress",h=>{u(h.loaded,h.lengthComputable?h.total:e.file.size)}),n.upload.addEventListener("load",()=>{u(e.file.size,e.file.size,!0)}),n.addEventListener("load",()=>{if(r)return;let h;try{h=n.responseText?JSON.parse(n.responseText):null}catch{h=null}if(n.status>=200&&n.status<300){const g=h==null?void 0:h.attachments;if(!Array.isArray(g)){l(new Error("Upload failed: malformed response"));return}a({attachments:g});return}const m=h==null?void 0:h.error;l(new Error(typeof m=="string"?m:"Upload failed"))}),n.addEventListener("error",()=>{r||l(new Error("Upload failed"))}),n.addEventListener("abort",()=>{l(new cle)});const f=new FormData;f.append("files",e.file),n.open("POST",`/api/projects/${encodeURIComponent(e.projectId)}/uploads`),n.send(f)}),abort:()=>{if(!r){r=!0;try{n.abort()}catch{}}}}}const rXe="(^|[\\s\\n\\t])@agent/([a-z0-9_-]+)";function iXe(){return new RegExp(rXe,"gi")}const sXe=Ri?_.useLayoutEffect:_.useEffect;class ule{constructor(t){K(this,"key");K(this,"ref");K(this,"icon");K(this,"title");this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const hK=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function pK(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top>=r.top-6&&n.top<=r.bottom+6}function oXe(e,t,n,r){const[i]=$s();_.useEffect(()=>{if(t!=null&&e!=null){const s=i.getRootElement(),o=s!=null?(function(h){let m=getComputedStyle(h);const g=m.position==="absolute",v=/(auto|scroll)/;if(m.position==="fixed")return document.body;for(let x=h;x=x.parentElement;)if(m=getComputedStyle(x),(!g||m.position!=="static")&&v.test(m.overflow+m.overflowY+m.overflowX))return x;return document.body})(s):document.body;let a=!1,l=pK(t,o);const u=function(){a||(window.requestAnimationFrame(function(){n(),a=!1}),a=!0);const h=pK(t,o);h!==l&&(l=h,r!=null&&r(h))},f=new ResizeObserver(n);return window.addEventListener("resize",n),document.addEventListener("scroll",u,{capture:!0,passive:!0}),f.observe(t),()=>{f.unobserve(t),window.removeEventListener("resize",n),document.removeEventListener("scroll",u,!0)}}},[t,i,r,n,e])}const mK=yt("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function aXe({index:e,isSelected:t,onClick:n,onMouseEnter:r,option:i}){let s="item";return t&&(s+=" selected"),c.jsxs("li",{tabIndex:-1,className:s,ref:i.setRefElement,role:"option","aria-selected":t,id:"typeahead-item-"+e,onMouseEnter:r,onClick:n,children:[i.icon,c.jsx("span",{className:"text",children:i.title})]},i.key)}function lXe({close:e,editor:t,anchorElementRef:n,resolution:r,options:i,menuRenderFn:s,onSelectOption:o,shouldSplitNodeWithQuery:a=!1,commandPriority:l=Aa,preselectFirstItem:u=!0}){const[f,h]=_.useState(null),m=f!==null?Math.min(i.length-1,f):null,g=r.match&&r.match.matchingString;_.useEffect(()=>{u&&h(0)},[g,u]);const v=_.useCallback(C=>{t.update(()=>{const k=r.match!=null&&a?(function(E){const N=Ue();if(!Ne(N)||!N.isCollapsed())return null;const T=N.anchor;if(T.type!=="text")return null;const R=T.getNode();if(!R.isSimpleText())return null;const M=T.offset,P=R.getTextContent().slice(0,M),B=E.replaceableString.length,U=M-(function($,I,V){let z=V;for(let H=z;H<=I.length;H++)$.slice(-H)===I.substring(0,H)&&(z=H);return z})(P,E.matchingString,B);if(U<0)return null;let D;return U===0?[D]=R.splitText(M):[,D]=R.splitText(U,M),D})(r.match):null;o(C,k,e,r.match?r.match.matchingString:"")})},[t,a,r.match,o,e]),x=_.useCallback(C=>{const k=t.getRootElement();k!==null&&(k.setAttribute("aria-activedescendant","typeahead-item-"+C),h(C))},[t]),y=_.useCallback(()=>n.current&&i.length?PG.createPortal(c.jsx("div",{className:"typeahead-popover mentions-menu",children:c.jsx("ul",{children:i.map((C,k)=>c.jsx(aXe,{index:k,isSelected:m===k,onClick:()=>{h(k),v(C)},onMouseEnter:()=>{h(k)},option:C},C.key))})}),n.current):null,[n,i,m,v,h]);_.useEffect(()=>()=>{const C=t.getRootElement();C!==null&&C.removeAttribute("aria-activedescendant")},[t]),sXe(()=>{i===null?h(null):m===null&&u&&x(0)},[i,m,x,u]),_.useEffect(()=>Pi(t.registerCommand(mK,({option:C})=>!(!C.ref||C.ref.current==null)&&(hK(C.ref.current),!0),l)),[t,x,l]),_.useEffect(()=>Pi(t.registerCommand(_N,C=>{const k=C;if(i!==null&&i.length){const E=m===null?0:m!==i.length-1?m+1:0;x(E);const N=i[E];if(!N)return x(-1),k.preventDefault(),k.stopImmediatePropagation(),!0;N.ref&&N.ref.current&&t.dispatchCommand(mK,{index:E,option:N}),k.preventDefault(),k.stopImmediatePropagation()}return!0},l),t.registerCommand(yN,C=>{const k=C;if(i!==null&&i.length){const E=m===null?i.length-1:m!==0?m-1:i.length-1;x(E);const N=i[E];if(!N)return x(-1),k.preventDefault(),k.stopImmediatePropagation(),!0;N.ref&&N.ref.current&&hK(N.ref.current),k.preventDefault(),k.stopImmediatePropagation()}return!0},l),t.registerCommand(SN,C=>{const k=C;return k.preventDefault(),k.stopImmediatePropagation(),e(),!0},l),t.registerCommand($0,C=>{const k=C;return i!==null&&m!==null&&i[m]!=null&&(k.preventDefault(),k.stopImmediatePropagation(),v(i[m]),!0)},l),t.registerCommand(Wp,C=>!(i===null||m===null||i[m]==null||C&&C.shiftKey)&&(C!==null&&(C.preventDefault(),C.stopImmediatePropagation()),v(i[m]),!0),l)),[v,e,t,i,m,x,l]);const w=_.useMemo(()=>({options:i,selectOptionAndCleanUp:v,selectedIndex:m,setHighlightedIndex:h}),[v,m,i]);return s!=null?s(n,w,r.match?r.match.matchingString:""):y()}function gK(e,t){t!=null&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}const vK="startTransition";function dle({options:e,onQueryChange:t,onSelectOption:n,onOpen:r,onClose:i,menuRenderFn:s,triggerFn:o,anchorClassName:a,commandPriority:l=Aa,parent:u,preselectFirstItem:f=!0,ignoreEntityBoundary:h=!1}){const[m]=$s(),[g,v]=_.useState(null),x=(function(C,k,E,N=Ri?document.body:void 0,T=!0){const[R]=$s(),M=Ri?document.createElement("div"):null,P=_.useRef(M),B=_.useCallback(()=>{if(P.current===null||N===void 0)return;P.current.style.top=P.current.style.bottom;const D=R.getRootElement(),$=P.current,I=$.firstChild;if(D!==null&&C!==null){const{left:V,top:z,width:H,height:W}=C.getRect(),Y=P.current.offsetHeight;if($.style.top=`${z+Y+3+(T?window.pageYOffset:0)}px`,$.style.left=`${V+window.pageXOffset}px`,$.style.height=`${W}px`,$.style.width=`${H}px`,I!==null){I.style.top=`${z}`;const F=I.getBoundingClientRect(),O=F.height,X=F.width,te=D.getBoundingClientRect();V+X>te.right&&($.style.left=`${te.right-X+window.pageXOffset}px`),(z+O>window.innerHeight||z+O>te.bottom)&&z-te.top>O+W&&($.style.top=`${z-O-W+(T?window.pageYOffset:0)}px`)}$.isConnected||(gK($,E),N.append($)),$.setAttribute("id","typeahead-menu"),D.setAttribute("aria-controls","typeahead-menu")}},[R,C,T,E,N]);_.useEffect(()=>{const D=R.getRootElement();return C!==null&&B(),()=>{D!==null&&D.removeAttribute("aria-controls");const $=P.current;$!==null&&$.isConnected&&($.remove(),$.removeAttribute("id"))}},[R,B,C]);const U=_.useCallback(D=>{C!==null&&(D||k(null))},[C,k]);return oXe(C,P.current,B,U),M!=null&&M===P.current&&(gK(M,E),N!=null&&N.append(M)),P})(g,v,a,u),y=_.useCallback(()=>{if(g===null)return;const C=()=>{v(null)};let k;try{k=i&&i()}finally{k?k.then(C,C):C()}},[i,g]),w=_.useCallback(C=>{v(C),r!=null&&g===null&&r(C)},[r,g]);return _.useEffect(()=>{const C=m.registerUpdateListener(()=>{m.getEditorState().read(()=>{if(!m.isEditable())return void y();if(m.isComposing())return;const k=m._window||window,E=k.document.createRange(),N=Ue(),T=(function(P){let B=null;return P.getEditorState().read(()=>{const U=Ue();Ne(U)&&(B=(function(D){const $=D.anchor;if($.type!=="text")return null;const I=$.getNode();if(!I.isSimpleText())return null;const V=$.offset;return I.getTextContent().slice(0,V)})(U))}),B})(m);if(!Ne(N)||!N.isCollapsed()||T===null||E===null)return void y();const R=o(T,m);if(t(R?R.matchingString:null),R!==null&&(h||!(function(P,B){return B===0&&P.getEditorState().read(()=>{const U=Ue();if(Ne(U)){const D=U.anchor.getNode().getPreviousSibling();return $e(D)&&D.isTextEntity()}return!1})})(m,R.leadOffset))&&(function(B,U,D){const $=ss(D);if($===null||!$.isCollapsed)return!1;const I=$.anchorNode,V=B,z=$.anchorOffset;if(I==null||z==null)return!1;try{U.setStart(I,V),U.setEnd(I,z)}catch{return!1}return!0})(R.leadOffset,E,k)!==null)return M=()=>w({getRect:()=>E.getBoundingClientRect(),match:R}),void(vK in Dn?Dn[vK](M):M());var M;y()})});return()=>{C()}},[m,o,t,g,y,w,h]),_.useEffect(()=>m.registerEditableListener(C=>{C||y()}),[m,y]),g===null||m===null||x.current===null?null:c.jsx(lXe,{close:y,resolution:g,editor:m,anchorElementRef:x,options:e,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:n,commandPriority:l,preselectFirstItem:f})}async function cXe(e,t,n={}){const r=n.http??wc,i=new URLSearchParams({query:t});try{const s=await r.getJson(`/api/projects/${encodeURIComponent(e)}/paths?${i.toString()}`,{signal:n.signal});return s.ok?s.data.paths??[]:[]}catch{return[]}}const uXe=120,dXe={http:wc,timer:Jn},fXe={items:[],loading:!1,error:null};function hXe(e){const{http:t,timer:n}=e.ports??dXe,r=yr.useScopedStore(l=>l.mentionSuggestions),i=yr.useScopedStore(l=>l.setMentionSuggestions),s=yr.useScopedStoreApi(),o=_.useRef(null),a=_.useRef(null);return _.useEffect(()=>{var u;if(!e.enabled||!e.projectId){i(fXe);return}o.current!==null&&n.clearTimeout(o.current),(u=a.current)==null||u.abort(),i({items:s.getState().mentionSuggestions.items,loading:!0,error:null});const l=new AbortController;return a.current=l,o.current=n.setTimeout(()=>{cXe(e.projectId,e.query,{signal:l.signal,http:t}).then(f=>{l.signal.aborted||i({items:f,loading:!1,error:null})})},uXe),()=>{o.current!==null&&n.clearTimeout(o.current),l.abort()}},[e.enabled,e.projectId,e.query,t,n,i,s]),r}const pXe=[];function mXe(e,t){const n=t.toLowerCase();if(n&&!("agent/".startsWith(n)||n.startsWith("agent/")))return[];const r=n.startsWith("agent/")?n.slice(6):"";return e.filter(i=>i.name.toLowerCase().includes(r)).sort((i,s)=>i.name.localeCompare(s.name)).map(i=>({kind:"agent",subagent:i}))}function gXe(e){const t=pr(n=>{var r;return((r=n.settings)==null?void 0:r.subagents)??pXe});return _.useMemo(()=>({items:e.enabled?mXe(t,e.query):[]}),[e.enabled,e.query,t])}const vXe=/(?:^|\s)(@((?:[^@\s]){0,200}))$/;function bXe(){return _.useCallback((e,t)=>{const n=vXe.exec(e);return n===null?null:{leadOffset:n.index+(n[0].length-n[1].length),matchingString:n[2]??"",replaceableString:n[1]}},[])}class bK extends ule{constructor(n){const r=n.kind==="agent"?`agent:${n.subagent.id}`:`path:${n.path.kind}:${n.path.path}`;super(r);K(this,"data");this.data=n}}function xXe({projectId:e}){const t=yr.useScopedStore(h=>h.mentionQuery),n=yr.useScopedStore(h=>h.setMentionQuery),r=bXe(),i=t!==null,s=hXe({projectId:e,query:t??"",enabled:i}),o=gXe({query:t??"",enabled:i}),a=_.useMemo(()=>{const h=o.items.map(g=>new bK({kind:"agent",subagent:g.subagent})),m=s.items.map(g=>new bK({kind:"path",path:g}));return[...h,...m]},[o.items,s.items]),l=_.useCallback(h=>{n(h)},[n]),u=_.useCallback((h,m,g)=>{const v=h.data,x=v.kind==="agent"?bI({mentionKind:"agent",value:v.subagent.name,label:v.subagent.name}):bI({mentionKind:"path",value:v.path.path,label:v.path.path});m!==null?m.replace(x):z0([x]);const y=zn(" ");x.insertAfter(y),y.select(),g()},[]),f=_.useCallback((h,{selectedIndex:m,selectOptionAndCleanUp:g,setHighlightedIndex:v,options:x})=>{if(h.current==null||x.length===0&&!s.loading)return null;const y=(w,C)=>{w.preventDefault(),g(C)};return c.jsx("ul",{role:"listbox","data-kanna-typeahead-menu":"mention",className:"absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl max-h-64 overflow-auto rounded-md border border-border bg-popover shadow-md",children:s.loading&&x.length===0?Array.from({length:4}).map((w,C)=>c.jsxs("li",{className:"flex items-center gap-2 px-3 py-1.5","aria-hidden":"true",children:[c.jsx("span",{className:"h-3.5 w-3.5 rounded bg-muted animate-pulse"}),c.jsx("span",{className:"h-3 w-40 max-w-full rounded bg-muted animate-pulse"})]},C)):x.map((w,C)=>{const k=C===m,E=w.data,N=E.kind==="path"?E.path:null,T=(N==null?void 0:N.kind)==="dir"?tq:c0;let R;return E.kind==="agent"?R=c.jsxs(c.Fragment,{children:[c.jsx(Wf,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsxs("span",{className:"font-mono truncate",children:["agent/",E.subagent.name]}),E.subagent.description?c.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:E.subagent.description}):null]}):N?R=c.jsxs(c.Fragment,{children:[c.jsx(T,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"font-mono truncate",children:N.path})]}):R=null,c.jsxs("li",{ref:w.setRefElement,role:"option","aria-selected":k,onMouseDown:M=>y(M,w),onMouseEnter:()=>v(C),className:ce("flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm",k&&"bg-accent text-accent-foreground"),children:[c.jsx(Ohe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),R]},w.key)})})},[s.loading]);return c.jsx(dle,{options:a,onQueryChange:l,onSelectOption:u,triggerFn:r,menuRenderFn:f})}const xK=[];function yXe(e,t){return t?e.byProjectId[t]??xK:xK}function _Xe(e){return lse(t=>yXe(t,e))}function YO(e){return e.replace(/^\/+/,"")}const yK={project:0,personal:0,builtin:1,plugin:2};function jR(e,t){const n=(yK[e.scope??""]??1)-(yK[t.scope??""]??1);return n!==0?n:e.name.localeCompare(t.name)}function SXe(e,t){return t!=="codex"?e:e.filter(n=>n.scope==="builtin")}function wXe(e,t){if(t==="")return[...e].sort(jR);const n=t.toLowerCase(),r=[],i=[];for(const s of e){const o=s.name.toLowerCase();o.startsWith(n)?r.push(s):o.includes(n)&&i.push(s)}return[...r.sort(jR),...i.sort(jR)]}const CXe=/(?:^|\s)(\/(\S*))$/;function kXe(){return _.useCallback((e,t)=>{const n=CXe.exec(e);return n===null?null:{leadOffset:n.index+(n[0].length-n[1].length),matchingString:n[2]??"",replaceableString:n[1]}},[])}class EXe extends ule{constructor(n){super(n.name);K(this,"command");this.command=n}}function NXe(e){const t=new Set,n=[];for(const r of e){const i=YO(r.name);t.has(i)||(t.add(i),n.push(r))}return n}function TXe({projectId:e,provider:t}){const n=yr.useScopedStore(f=>f.slashQuery),r=yr.useScopedStore(f=>f.setSlashQuery),i=_Xe(e),s=kXe(),o=_.useMemo(()=>{const f=SXe(i,t),h=wXe(f,n??"");return NXe(h).map(m=>new EXe(m))},[t,i,n]),a=_.useCallback(f=>{r(f)},[r]),l=_.useCallback((f,h,m)=>{const g=f.command,v=Qre({commandName:YO(g.name),hasArgument:!!g.argumentHint});h!==null?h.replace(v):z0([v]);const x=zn(" ");v.insertAfter(x),x.select(),m()},[]),u=_.useCallback((f,{selectedIndex:h,selectOptionAndCleanUp:m,setHighlightedIndex:g,options:v})=>{if(f.current==null||v.length===0)return null;const x=(y,w)=>{y.preventDefault(),m(w)};return c.jsx("ul",{role:"listbox","data-kanna-typeahead-menu":"slash",className:"absolute bottom-full left-0 mb-2 w-full max-w-md md:max-w-xl max-h-64 overflow-auto rounded-md border border-border bg-popover shadow-md",children:v.map((y,w)=>{const C=w===h,k=y.command;return c.jsxs("li",{ref:y.setRefElement,role:"option","aria-selected":C,onMouseDown:E=>x(E,y),onMouseEnter:()=>g(w),className:ce("flex flex-col gap-0.5 px-3 py-1.5 cursor-pointer text-sm sm:flex-row sm:items-center sm:gap-3",C&&"bg-accent text-accent-foreground"),children:[c.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[c.jsxs("span",{className:"font-mono break-all sm:whitespace-nowrap sm:break-normal",children:["/",YO(k.name)]}),k.kind==="skill"?c.jsx("span",{className:"shrink-0 rounded-sm border border-border bg-muted px-1 py-px text-10 font-medium uppercase tracking-wide text-muted-foreground",children:"skill"}):null,k.argumentHint?c.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground whitespace-nowrap",children:k.argumentHint}):null]}),k.description?c.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground sm:text-right",children:d0e(k.description)}):null]},y.key)})})},[]);return c.jsx(dle,{options:o,onQueryChange:a,onSelectOption:l,triggerFn:s,menuRenderFn:u})}const AXe=50,jXe=3,RXe={"image/gif":"gif","image/jpeg":"jpg","image/png":"png","image/webp":"webp"};function fle(e){return RXe[e.type]??"bin"}function MXe(e){const t=e.name.trim().toLowerCase();if(!t)return!0;const n=fle(e);return t===`image.${n}`||t==="image.png"}function PXe(e,t,n){if(e.name&&!MXe(e))return e;const r=fle(e),i=t===0?"":`-${t}`,s=`clipboard-${n}${i}.${r}`;return Object.defineProperty(e,"name",{configurable:!0,value:s}),e}function IXe(e,t){const n=[];for(const r of e){if(r.kind!=="file"||!r.type.startsWith("image/"))continue;const i=r.getAsFile();i&&n.push(PXe(i,n.length,t))}return n}function OXe(e){return e?e.types.includes("text/plain")||e.types.includes("text/html"):!1}async function DXe(e,t,n,r,i){if(e.length===0||e.length>AXe)return;let s=0;async function o(){if(s>=e.length)return;const l=e[s++];try{const u=r({projectId:n,file:l,onProgress:()=>{}}),{attachments:f}=await u.promise,h=f[0];if(!h){i==null||i("Upload failed: no attachment returned");return}t.update(()=>{z0([g3(h)])})}catch(u){if(u instanceof Error&&u.name==="UploadAbortedError")return;i==null||i(u instanceof Error?u.message:String(u))}await o()}const a=[];for(let l=0;l<Math.min(jXe,e.length);l++)a.push(o());await Promise.all(a)}function LXe({projectId:e,onUploadError:t,uploadFileFn:n=u$}){const[r]=$s();return _.useEffect(()=>r.registerCommand(L0,i=>{if(!(i instanceof ClipboardEvent))return!1;const s=i.clipboardData,o=IXe((s==null?void 0:s.items)??[],Date.now());if(o.length===0)return!1;const a=OXe(s);return e&&DXe(o,r,e,n,t),!a},js),[r,e,t,n]),null}const $Xe=50,BXe=3;async function FXe(e,t,n,r,i){if(e.length===0||e.length>$Xe)return;let s=0;async function o(){if(s>=e.length)return;const l=e[s++];try{const u=r({projectId:n,file:l,onProgress:()=>{}}),{attachments:f}=await u.promise,h=f[0];if(!h){i==null||i("Upload failed: no attachment returned");return}t.update(()=>{z0([g3(h)])})}catch(u){if(u instanceof Error&&u.name==="UploadAbortedError")return;i==null||i(u instanceof Error?u.message:String(u))}await o()}const a=[];for(let l=0;l<Math.min(BXe,e.length);l++)a.push(o());await Promise.all(a)}function _K(e){var i,s;const t=(i=e.dataTransfer)==null?void 0:i.items;if(t){const o=[];for(let a=0;a<t.length;a++){const l=t[a];if(l&&l.kind==="file"){const u=l.getAsFile();u&&o.push(u)}}return o}const n=(s=e.dataTransfer)==null?void 0:s.files;if(!n)return[];const r=[];for(let o=0;o<n.length;o++){const a=n[o];a&&r.push(a)}return r}function zXe({projectId:e,onUploadError:t,uploadFileFn:n=u$}){const[r]=$s();return _.useEffect(()=>{const i=r.registerCommand(R5,o=>_K(o).length===0?!1:(o.preventDefault(),!0),js),s=r.registerCommand(j5,o=>{const a=_K(o);return a.length===0?!1:(o.preventDefault(),e&&FXe(a,r,e,n,t),!0)},js);return()=>{i(),s()}},[r,e,t,n]),null}function hle(e){if($e(e))return e.getTextContent();if(bi(e))return`
|