@hellcoder/companion 0.124.1 → 0.125.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentsPage-Byq8wvdn.js → AgentsPage-0Fi6tbQN.js} +1 -1
- package/dist/assets/{CronManager-Bq2lOMbZ.js → CronManager-DNN709nr.js} +1 -1
- package/dist/assets/{DashboardPage-V77HIt8S.js → DashboardPage-6cNRrqGQ.js} +1 -1
- package/dist/assets/{IntegrationsPage-C3aW9cDI.js → IntegrationsPage-DrE-8KPE.js} +1 -1
- package/dist/assets/{LinearOAuthSettingsPage-_eAbciJN.js → LinearOAuthSettingsPage-Czi_NsX1.js} +1 -1
- package/dist/assets/{LinearSettingsPage-DDHFHt7j.js → LinearSettingsPage-C1RHlPwX.js} +1 -1
- package/dist/assets/{MagicUIDashboard-Cl18AKjV.js → MagicUIDashboard-BOZc4rKn.js} +1 -1
- package/dist/assets/{MagicUIView-C0aiMTet.js → MagicUIView-BVM8CqGg.js} +1 -1
- package/dist/assets/{Playground-CvoHRMBd.js → Playground-DWAal5bL.js} +1 -1
- package/dist/assets/{PromptsPage-CzTs1_Se.js → PromptsPage-D2YI_-95.js} +1 -1
- package/dist/assets/{RunsPage-B7xru-Xy.js → RunsPage-dn5rSkPu.js} +1 -1
- package/dist/assets/{SandboxManager-C3tFkiWz.js → SandboxManager-vWbQKeLT.js} +1 -1
- package/dist/assets/{SettingsPage-BZ2fBrHD.js → SettingsPage-CrV1Tb8F.js} +1 -1
- package/dist/assets/{TailscalePage-DFRiFKcb.js → TailscalePage-ba0g8QT1.js} +1 -1
- package/dist/assets/{index-C7nK12tB.js → index-e4RnFbra.js} +4 -4
- package/dist/assets/{sw-register-Dc72vh_Y.js → sw-register-BBun0drK.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/server/settings-manager.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Playground-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Playground-DWAal5bL.js","assets/MagicUIDashboard-BOZc4rKn.js","assets/MagicUIView-BVM8CqGg.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var i4=Object.defineProperty;var r4=(e,t,n)=>t in e?i4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var w_=(e,t,n)=>r4(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const u of o.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();const a4="modulepreload",l4=function(e){return"/"+e},S_={},Zn=function(t,n,i){let a=Promise.resolve();if(n&&n.length>0){let u=function(p){return Promise.all(p.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),f=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));a=u(n.map(p=>{if(p=l4(p),p in S_)return;S_[p]=!0;const g=p.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${v}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":a4,g||(b.as="script"),b.crossOrigin="",b.href=p,f&&b.setAttribute("nonce",f),document.head.appendChild(b),g)return new Promise((y,_)=>{b.addEventListener("load",y),b.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${p}`)))})}))}function o(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return a.then(u=>{for(const h of u||[])h.status==="rejected"&&o(h.reason);return t().catch(o)})};function wx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jm={exports:{}},Bc={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -102,7 +102,7 @@ Details: ${t}`:`Error: ${t}`}function DT(e,t){const n=Su.get(e)||[];n.push(t),Su
|
|
|
102
102
|
`),g=l.jsxs("div",{className:"relative rounded-lg bg-cc-code-bg overflow-hidden",children:[l.jsx(Af,{text:e,label:"Copy output",className:"absolute top-1 right-1 z-10 bg-cc-code-bg/80 backdrop-blur-sm"}),l.jsx("pre",{className:`text-[12px] font-mono-code px-3 py-2 whitespace-pre-wrap leading-relaxed ${t?"text-cc-error":"text-cc-code-fg/60"}`,children:p}),i&&l.jsxs("div",{className:"px-3 pb-1.5 flex items-center justify-between",children:[l.jsx("span",{className:`text-[10px] ${t?"text-cc-error/50":"text-cc-muted/40"}`,children:a?`${n.length} lines`:`last 20 of ${n.length}`}),l.jsx("button",{onClick:()=>o(!a),className:"text-[10px] text-cc-muted/40 hover:text-cc-muted/70 transition-colors cursor-pointer",children:a?"Show tail":"Show all"})]})]});return u?l.jsxs("div",{children:[l.jsx(_f,{open:h,onToggle:()=>f(!h),marker:"›",label:t?"Error output":"Output",meta:iC(n.length),labelClassName:t?"text-cc-error/70":""}),h&&l.jsx("div",{className:"mt-1",children:g})]}):g}function o9({content:e,isError:t}){const n=va(),[i,a]=k.useState(!1),o=l.jsxs("div",{className:"relative rounded-lg bg-cc-code-bg overflow-hidden",children:[l.jsx(Af,{text:e,label:"Copy output",className:"absolute top-1 right-1 z-10 bg-cc-code-bg/80 backdrop-blur-sm"}),l.jsx("pre",{className:`text-[12px] font-mono-code px-3 py-2 whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto ${t?"text-cc-error":"text-cc-code-fg/60"}`,children:e})]});return n?l.jsxs("div",{children:[l.jsx(_f,{open:i,onToggle:()=>a(!i),marker:"›",label:t?"Error result":"Result",meta:iC(e.split(/\r?\n/).length),labelClassName:t?"text-cc-error/70":""}),i&&l.jsx("div",{className:"mt-1",children:o})]}):o}function c9({name:e,items:t}){const[n,i]=k.useState(!1),a=Lo(e),o=Hi(e);return l.jsxs("div",{className:"border border-cc-border rounded-[10px] overflow-hidden bg-cc-card tool-card",children:[l.jsxs("button",{onClick:()=>i(!n),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${n?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx(ol,{type:a}),l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:o}),l.jsx("span",{className:"text-[10px] text-cc-muted bg-cc-hover rounded-full px-1.5 py-0.5 tabular-nums",children:t.length})]}),n&&l.jsx("div",{className:"border-t border-cc-border px-3 py-1.5",children:t.map((u,h)=>{const f=wo(u.name,u.input);return l.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-cc-muted font-mono-code truncate",children:[l.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-muted/40 shrink-0"}),l.jsx("span",{className:"truncate",children:f||JSON.stringify(u.input).slice(0,80)})]},u.id||h)})})]})}function rC({text:e}){const t=e.trim(),n=va(),[i,a]=k.useState(!1),o=t.split(`
|
|
103
103
|
`),u=n?2:8,h=n?200:600,f=o.length>u||t.length>h,p=f&&!i?o.slice(0,u).join(`
|
|
104
104
|
`):t;return n&&!t?null:l.jsxs("div",{children:[l.jsx("div",{className:"markdown-body text-[13px] text-cc-fg/40 leading-relaxed italic",children:l.jsx(mv,{remarkPlugins:[wv],components:{p:({children:g})=>l.jsx("p",{className:"mb-2 last:mb-0",children:g}),ul:({children:g})=>l.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:g}),ol:({children:g})=>l.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:g}),li:({children:g})=>l.jsx("li",{children:g}),code:({children:g})=>l.jsx("code",{className:"px-1 py-0.5 rounded bg-cc-fg/[0.03] text-cc-fg/40 font-mono-code text-[12px] not-italic",children:g})},children:p||"No thinking text captured."})}),f&&!i&&l.jsx("button",{onClick:()=>a(!0),className:"text-[11px] text-cc-muted/40 hover:text-cc-muted/70 cursor-pointer transition-colors",children:"Show more"})]})}function ru(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function po(e){const t=Math.floor(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function $2(e){try{const t=new Date(e).getTime()-Date.now();return Number.isFinite(t)?t<=0?"now":u9(t):"N/A"}catch{return"N/A"}}function vx(e){const n=(e>0&&e<1e12?e*1e3:e)-Date.now();if(n<=0)return"now";const i=Math.floor(n/864e5),a=Math.floor(n%864e5/36e5),o=Math.floor(n%36e5/6e4);return i>0?`${i}d ${a}h`:a>0?`${a}h${o}m`:`${o}m`}function P2(e){return e>=1440?`${Math.round(e/1440)}d`:e>=60?`${Math.round(e/60)}h`:`${e}m`}function u9(e){const t=Math.floor(e/864e5),n=Math.floor(e%864e5/36e5),i=Math.floor(e%36e5/6e4);return t>0?`${t}d ${n}h${i}m`:n>0?`${n}h${i}m`:`${i}m`}function d9({tools:e}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono-code pl-10 py-1.5 animate-[fadeSlideIn_0.3s_ease-out]",role:"status","aria-label":`${e.length} tool${e.length>1?"s":""} running`,children:e.map((t,n)=>l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsxs("span",{className:"relative flex items-center justify-center w-3.5 h-3.5",children:[l.jsx(ol,{type:Lo(t.toolName)}),l.jsx("span",{className:"absolute inset-0 rounded-full bg-cc-primary/20 animate-[typing-breathe_1.5s_ease-in-out_infinite]"})]}),l.jsx("span",{className:"text-cc-fg/70",children:Hi(t.toolName)}),l.jsxs("span",{className:"text-cc-muted/50 tabular-nums",children:[t.elapsedSeconds,"s"]})]},n))})}function h9({entries:e}){const[t,n]=k.useState(!1),i=k.useMemo(()=>{const a=e.reduce((f,p)=>f+p.elapsedSeconds,0),o=Math.max(...e.map(f=>f.elapsedSeconds),.1),u=e.filter(f=>f.isError).length,h=e.filter(f=>!f.completedAt).length;return{totalTime:a,maxTime:o,errorCount:u,running:h}},[e]);return e.length===0?null:l.jsxs("div",{className:"pl-10 pr-4 animate-[fadeSlideIn_0.3s_ease-out]",children:[l.jsxs("button",{onClick:()=>n(!t),className:"group flex items-center gap-2 text-[11px] text-cc-muted hover:text-cc-fg/80 transition-colors cursor-pointer py-1 w-full","aria-expanded":t,"aria-label":`${e.length} tools executed in ${i.totalTime.toFixed(1)}s`,children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 transition-transform duration-200 shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsxs("span",{className:"font-mono-code flex items-center gap-1.5",children:[l.jsxs("span",{className:"text-cc-fg/60 font-medium",children:[e.length," tool",e.length>1?"s":""]}),l.jsx("span",{className:"text-cc-muted/40",children:"·"}),l.jsxs("span",{className:"tabular-nums",children:[i.totalTime.toFixed(1),"s"]}),i.errorCount>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/40",children:"·"}),l.jsxs("span",{className:"text-cc-error",children:[i.errorCount," error",i.errorCount>1?"s":""]})]}),i.running>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/40",children:"·"}),l.jsxs("span",{className:"text-cc-primary",children:[i.running," running"]})]})]}),!t&&e.length>1&&l.jsx("span",{className:"hidden sm:flex items-center gap-px ml-auto flex-shrink-0 h-1.5 max-w-[120px]",children:e.map(a=>l.jsx("span",{className:`h-full rounded-full ${a.isError?"bg-cc-error/40":a.completedAt?"bg-cc-success/30":"bg-cc-primary/40 animate-[typing-breathe_1.5s_ease-in-out_infinite]"}`,style:{width:`${Math.max(4,a.elapsedSeconds/i.maxTime*100)}%`,minWidth:"3px"},title:`${Hi(a.toolName)} ${a.elapsedSeconds}s`},a.toolUseId))})]}),t&&l.jsx("div",{className:"mt-1 mb-2 space-y-1 animate-[fadeSlideIn_0.2s_ease-out]",children:e.map(a=>l.jsx(f9,{entry:a,maxTime:i.maxTime},a.toolUseId))})]})}function f9({entry:e,maxTime:t}){const n=Math.max(3,e.elapsedSeconds/t*100),i=!e.completedAt;return l.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-mono-code group",children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${e.isError?"bg-cc-error":i?"bg-cc-primary animate-[typing-breathe_1.5s_ease-in-out_infinite]":"bg-cc-success/60"}`}),l.jsxs("span",{className:"flex items-center gap-1 shrink-0 w-[100px]",children:[l.jsx(ol,{type:Lo(e.toolName)}),l.jsx("span",{className:"text-cc-fg/70 truncate",children:Hi(e.toolName)})]}),l.jsx("span",{className:"flex-1 h-1 bg-cc-border/30 rounded-full overflow-hidden min-w-[40px]",children:l.jsx("span",{className:`block h-full rounded-full transition-all duration-500 ${e.isError?"bg-cc-error/50":i?"bg-cc-primary/50 animate-[typing-breathe_1.5s_ease-in-out_infinite]":"bg-cc-success/30"}`,style:{width:`${n}%`}})}),l.jsxs("span",{className:"text-cc-muted/60 tabular-nums shrink-0 w-[40px] text-right",children:[e.elapsedSeconds.toFixed(1),"s"]}),e.preview&&l.jsx("span",{className:"text-cc-muted/40 truncate max-w-[200px] hidden lg:inline",children:e.preview})]})}function p9(e){var n;const t=e.contentBlocks;return t&&t.length>0?t.some(i=>i.type==="text"&&i.text.trim().length>0):!!((n=e.content)!=null&&n.trim())}function m9(e){if(e.kind!=="message")return!1;const t=e.msg;if(t.role==="user")return!0;if(t.role==="system")return!!t.meta;if(t.isStreaming)return!0;if(t.stopReason==="tool_use")return!1;const n=t.contentBlocks;return n!=null&&n.some(i=>i.type==="tool_use")?!1:p9(t)}function g9(e){switch(e.kind){case"message":return e.msg.id;case"tool_msg_group":return e.firstId;case"subagent":return e.taskToolUseId;case"activity_run":return e.key}}function x9(e){if(e.length>=2)return!0;const t=e[0];return!(t.kind==="message"&&t.msg.role==="system")}function v9(e){const t=[];let n=[];const i=()=>{n.length!==0&&(x9(n)?t.push({kind:"activity_run",key:g9(n[0]),children:n}):t.push(...n),n=[])};for(const a of e)a.kind==="activity_run"||m9(a)?(i(),t.push(a)):n.push(a);return i(),t}const B2=160;function bx(e){const t=e.split(`
|
|
105
|
-
`).map(n=>n.trim()).find(n=>n.length>0);return t?t.length>B2?`${t.slice(0,B2)}…`:t:""}function aC(e,t){const n=wo(e,t);return{label:n?`${Hi(e)} · ${n}`:Hi(e),toolName:e}}function b9(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.type==="tool_use")return aC(n.name,n.input);if(n.type==="text"&&n.text.trim())return{label:bx(n.text),italic:!0};if(n.type==="thinking"&&n.thinking.trim())return{label:bx(n.thinking),italic:!0}}return null}function y9(e){var t;switch(e.kind){case"subagent":return{label:`Subagent · ${e.description||"Subagent"}`,toolName:"Task"};case"tool_msg_group":{const n=e.items[e.items.length-1];return n?aC(n.name,n.input):null}case"activity_run":return Rf(e).latest;case"message":{const n=e.msg;if(n.role==="system")return{label:n.content,italic:!0};const i=n.contentBlocks;return i&&i.length>0?b9(i)??{label:"Thinking…",italic:!0}:(t=n.content)!=null&&t.trim()?{label:bx(n.content),italic:!0}:{label:"Thinking…",italic:!0}}}}function lC(e){switch(e.kind){case"message":return[e.msg.timestamp,e.msg.timestamp];case"tool_msg_group":return[e.startedAt,e.endedAt];case"subagent":{let t=null,n=null;for(const i of e.children){const[a,o]=lC(i);a!==null&&(t===null||a<t)&&(t=a),o!==null&&(n===null||o>n)&&(n=o)}return[t,n]}case"activity_run":{const t=Rf(e);return[t.startedAt,t.endedAt]}}}function Rf(e,t){let n=0,i=0,a=0,o=null,u=null;for(const f of e.children){if(f.kind==="subagent")i++;else if(f.kind==="tool_msg_group")n+=f.items.length;else if(f.kind==="message")for(const v of f.msg.contentBlocks??[])v.type==="tool_use"&&n++,v.type==="tool_result"&&v.is_error&&a++;else{const v=Rf(f);n+=v.toolCalls,i+=v.subagents,a+=v.errors}const[p,g]=lC(f);p!==null&&(o===null||p<o)&&(o=p),g!==null&&(u===null||g>u)&&(u=g)}t!==void 0&&o!==null&&(u=Math.max(u??t,t));const h=e.children[e.children.length-1];return{toolCalls:n,subagents:i,errors:a,steps:e.children.length,startedAt:o,endedAt:u,latest:h?y9(h):null}}function _9({run:e,live:t,children:n}){const[i,a]=k.useState(!1),o=t?Date.now():void 0,u=k.useMemo(()=>Rf(e,o),[e,o]),h=u.startedAt!==null&&u.endedAt!==null?Math.max(0,u.endedAt-u.startedAt):null,f=[];u.toolCalls>0&&f.push(`${u.toolCalls} tool call${u.toolCalls===1?"":"s"}`),u.subagents>0&&f.push(`${u.subagents} subagent${u.subagents===1?"":"s"}`),u.errors>0&&f.push(l.jsxs("span",{className:"text-cc-error",children:[u.errors," error",u.errors===1?"":"s"]},"err")),h!==null&&h>=1e3&&f.push(po(h));const p=t?"Working":"Worked",g=`${u.steps} step${u.steps===1?"":"s"}`,v=u.latest;return l.jsxs("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]","data-activity-run":e.key,children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(Uh,{}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("button",{type:"button",onClick:()=>a(b=>!b),"aria-expanded":i,"aria-label":`${p}: ${g}, ${i?"collapse":"expand"} details`,className:"w-full flex items-center gap-1.5 py-0.5 text-left group cursor-pointer min-w-0",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:`w-2.5 h-2.5 shrink-0 text-cc-muted/40 group-hover:text-cc-muted/70 transition-transform duration-200 ${i?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx("span",{"aria-hidden":"true",className:`w-1.5 h-1.5 rounded-full shrink-0 ${t?"bg-cc-primary animate-[typing-breathe_1.5s_ease-in-out_infinite]":"bg-cc-success/60"}`}),l.jsx("span",{className:"text-[11px] font-medium text-cc-fg/70 shrink-0",children:p}),f.length>0&&l.jsx("span",{className:"text-[11px] text-cc-muted/60 font-mono-code truncate min-w-0 tabular-nums",children:f.map((b,y)=>l.jsxs("span",{children:[l.jsx("span",{className:"text-cc-muted/35",children:" · "}),b]},y))}),l.jsx("span",{className:"ml-auto text-[10px] text-cc-muted/40 group-hover:text-cc-muted/70 shrink-0 tabular-nums",children:i?"hide":g})]}),!i&&v&&l.jsxs("div",{role:"status",className:"flex items-center gap-1.5 pl-4 py-0.5 text-[11px] min-w-0",children:[v.toolName&&l.jsx(ol,{type:Lo(v.toolName)}),l.jsx("span",{className:`truncate min-w-0 ${v.italic?"italic text-cc-muted/60":"font-mono-code text-cc-muted/70"}`,children:v.label})]})]})]}),i&&l.jsx("div",{className:"mt-4 space-y-5 sm:space-y-7 animate-[fadeSlideIn_0.2s_ease-out]",children:n})]})}const Nh=100,w9=40,S9=120,F2=1e4,k9=15*6e4,g0=new Map,j9=[],N9=[];function C9(e){const t=e.split("/").filter(Boolean);return t.length===0?e:t.slice(-2).join("/")}function E9(e){if(e.role!=="assistant")return null;const t=e.contentBlocks;if(!t||t.length===0)return null;let n=null;for(const i of t){if(i.type==="text"&&i.text.trim()||i.type==="thinking")return null;if(i.type==="tool_use"){if(n===null)n=i.name;else if(n!==i.name)return null}}return n}function I2(e){return(e.contentBlocks||[]).filter(n=>n.type==="tool_use").map(n=>({id:n.id,name:n.name,input:n.input}))}function T9(e){return e.kind==="message"?(e.msg.contentBlocks||[]).filter(n=>n.type==="tool_use").filter(n=>n.name==="Task").map(n=>n.id):e.kind==="tool_msg_group"&&e.toolName==="Task"?e.items.map(t=>t.id):[]}function oC(e){const t=[];for(const n of e){const i=E9(n);if(i){const a=t[t.length-1];if((a==null?void 0:a.kind)==="tool_msg_group"&&a.toolName===i){a.items.push(...I2(n)),a.endedAt=Math.max(a.endedAt,n.timestamp);continue}t.push({kind:"tool_msg_group",toolName:i,items:I2(n),firstId:n.id,startedAt:n.timestamp,endedAt:n.timestamp})}else t.push({kind:"message",msg:n})}return t}function cC(e,t,n){const i=oC(e),a=[];for(const o of i){a.push(o);const u=T9(o);for(const h of u){const f=n.get(h);if(f&&f.length>0){const p=t.get(h)||{description:"Subagent",agentType:""},g=cC(f,t,n);a.push({kind:"subagent",taskToolUseId:h,description:p.description,agentType:p.agentType,backend:p.backend,status:p.status,receiverCount:p.receiverCount,senderThreadId:p.senderThreadId,receiverThreadIds:p.receiverThreadIds,children:g})}}}return a}function M9(e){const t=new Map;for(const a of e)if(a.contentBlocks){for(const o of a.contentBlocks)if(o.type==="tool_use"&&o.name==="Task"){const{input:u,id:h}=o,f=Array.isArray(u==null?void 0:u.receiver_thread_ids)?u.receiver_thread_ids.filter(b=>typeof b=="string"&&b.length>0):void 0,p=f&&f.length>0?f.length:void 0,g=typeof(u==null?void 0:u.sender_thread_id)=="string"&&u.sender_thread_id.length>0?u.sender_thread_id:void 0,v=typeof(u==null?void 0:u.codex_status)=="string"||g!==void 0||p!==void 0;t.set(h,{description:String((u==null?void 0:u.description)||"Subagent"),agentType:String((u==null?void 0:u.subagent_type)||""),backend:v?"codex":"claude",status:typeof(u==null?void 0:u.codex_status)=="string"?u.codex_status:void 0,receiverCount:p,senderThreadId:g,receiverThreadIds:f})}}if(t.size===0)return oC(e);const n=new Map,i=[];for(const a of e)if(a.parentToolUseId&&t.has(a.parentToolUseId)){let o=n.get(a.parentToolUseId);o||(o=[],n.set(a.parentToolUseId,o)),o.push(a)}else i.push(a);return cC(i,t,n)}function A9({group:e}){const[t,n]=k.useState(!1),i=Lo(e.toolName),a=Hi(e.toolName),o=e.items.length;if(o===1){const u=e.items[0];return l.jsx("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(U2,{}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"border border-cc-border rounded-[10px] overflow-hidden bg-cc-card tool-card",children:[l.jsxs("button",{onClick:()=>n(!t),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx(ol,{type:i}),l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:a}),l.jsx("span",{className:"text-xs text-cc-muted truncate flex-1 font-mono-code",children:wo(u.name,u.input)})]}),t&&l.jsx("div",{className:"px-3 pb-3 pt-0 border-t border-cc-border mt-0",children:l.jsx("pre",{className:"mt-2 text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto",children:JSON.stringify(u.input,null,2)})})]})})]})})}return l.jsx("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(U2,{}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"border border-cc-border rounded-[10px] overflow-hidden bg-cc-card tool-card",children:[l.jsxs("button",{onClick:()=>n(!t),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx(ol,{type:i}),l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:a}),l.jsx("span",{className:"text-[10px] text-cc-muted bg-cc-hover rounded-full px-1.5 py-0.5 tabular-nums font-medium",children:o})]}),t&&l.jsx("div",{className:"border-t border-cc-border px-3 py-1.5",children:e.items.map((u,h)=>{const f=wo(u.name,u.input);return l.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-cc-muted font-mono-code truncate",children:[l.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-muted/40 shrink-0"}),l.jsx("span",{className:"truncate",children:f||JSON.stringify(u.input).slice(0,80)})]},u.id||h)})})]})})]})})}function kv({entries:e,toolActivity:t,liveRunKey:n}){return l.jsx(l.Fragment,{children:e.map((i,a)=>{if(i.kind==="activity_run")return l.jsx(_9,{run:i,live:i.key===n,children:l.jsx(kv,{entries:i.children,toolActivity:t})},i.key);if(i.kind==="tool_msg_group")return l.jsx(A9,{group:i},i.firstId||a);if(i.kind==="subagent")return l.jsx(L9,{group:i},i.taskToolUseId);const o=i.msg,u=R9(o),h=t&&u.length>0?t.filter(p=>u.includes(p.toolUseId)):[],f=h.length>0&&h.every(p=>p.completedAt);return l.jsxs("div",{children:[l.jsx(e9,{message:o}),f&&l.jsx(h9,{entries:h})]},o.id)})})}function R9(e){var t;return(t=e.contentBlocks)!=null&&t.length?e.contentBlocks.filter(n=>n.type==="tool_use").map(n=>n.id):[]}function O9(e){if(!e)return null;const t=e.trim().toLowerCase();return t?t==="completed"?{label:"completed",summaryLabel:"completed",className:"text-green-600 bg-green-500/15"}:t==="failed"||t==="error"||t==="errored"?{label:"failed",summaryLabel:"failed",className:"text-cc-error bg-cc-error/10"}:t==="pending"||t==="pendinginit"||t==="pending_init"?{label:"pending",summaryLabel:"pending",className:"text-amber-700 bg-amber-500/15"}:t==="running"||t==="inprogress"||t==="in_progress"||t==="started"?{label:"running",summaryLabel:"running",className:"text-blue-600 bg-blue-500/15"}:{label:e,summaryLabel:"running",className:"text-amber-700 bg-amber-500/15"}:null}function L9({group:e}){const[t,n]=k.useState(!1),i=e.description||"Subagent",a=e.agentType,o=e.children.length,u=O9(e.status),h=e.receiverCount,f=e.senderThreadId,p=e.receiverThreadIds||[],g=e.backend||"claude",v=e.children[e.children.length-1],b=k.useMemo(()=>{var y,_;if(!v)return"";if(v.kind==="tool_msg_group")return`${Hi(v.toolName)}${v.items.length>1?` ×${v.items.length}`:""}`;if(v.kind==="message"&&v.msg.role==="assistant"){const j=(y=v.msg.content)==null?void 0:y.trim();if(j)return j.length>60?j.slice(0,60)+"...":j;const N=(_=v.msg.contentBlocks)==null?void 0:_.find(S=>S.type==="tool_use");if(N)return Hi(N.name)}return""},[v]);return l.jsx("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]",children:l.jsxs("div",{className:"ml-10 border-l border-cc-border/50 pl-4",children:[l.jsxs("button",{type:"button",onClick:()=>n(!t),className:"relative z-10 flex items-center gap-1.5 py-1 text-left cursor-pointer group w-full",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/40 group-hover:text-cc-muted/70 transition-transform shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx("span",{className:"text-[11px] font-medium text-cc-primary/70",children:i}),a&&l.jsx("span",{className:"text-[10px] text-cc-muted/50",children:a}),l.jsx("span",{className:"text-[10px] text-cc-muted/40",children:g==="codex"?"Codex":"Claude"}),u&&l.jsx("span",{className:`text-[10px] ${u.className}`,children:u.label}),h!==void 0&&l.jsxs("span",{className:"text-[10px] text-cc-muted/40",children:[h," agent",h===1?"":"s"]}),!t&&b&&l.jsx("span",{className:"text-[11px] text-cc-muted/40 truncate ml-1 font-mono-code",children:b}),l.jsx("span",{className:"text-[10px] text-cc-muted/40 tabular-nums shrink-0 ml-auto",children:o})]}),t&&l.jsxs("div",{className:"space-y-3 pb-2 mt-1",children:[(f||p.length>0)&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-cc-muted/50 pl-4",children:[f&&l.jsxs("span",{className:"font-mono-code",children:["sender: ",f]}),p.length>0&&l.jsxs("span",{children:["receivers: ",p.map(y=>l.jsx("span",{className:"font-mono-code ml-1",children:y},y))]})]}),l.jsx(kv,{entries:e.children})]})]})})}function U2(){return l.jsx("div",{className:"w-7 h-7 rounded-full avatar-ring flex items-center justify-center shrink-0 mt-0.5",children:l.jsx("div",{className:"avatar-inner w-full h-full rounded-full flex items-center justify-center",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-primary",children:l.jsx("path",{d:"M8 2L10.5 6.5L15 8L10.5 9.5L8 14L5.5 9.5L1 8L5.5 6.5L8 2Z"})})})})}function D9({sessionId:e}){var Zt;const t=W(ie=>ie.messages.get(e)??j9),n=W(ie=>(ie.sdkSessions||N9).find(ke=>ke.sessionId===e)),i=W(ie=>ie.streamingStartedAt.get(e)),a=W(ie=>ie.streamingOutputTokens.get(e)),o=W(ie=>ie.sessionStatus.get(e)),u=W(ie=>ie.lastActivityAt.get(e)),h=W(ie=>ie.sessionProcesses.get(e)),f=W(ie=>ie.toolProgress.get(e)),p=W(ie=>ie.toolActivity.get(e)),g=k.useRef(null),v=k.useRef(null),b=k.useRef(!0),[y,_]=k.useState(0),[j,N]=k.useState(Nh),[S,C]=k.useState([]),[E,R]=k.useState(0),[A,O]=k.useState(!1),[P,z]=k.useState(!1),[Z,I]=k.useState(!1),[q,L]=k.useState(""),de=k.useRef(new Set),Q=W(ie=>ie.chatTabReentryTickBySession.get(e)??0),V=k.useMemo(()=>t.some(ie=>ie.role==="assistant"&&ie.isStreaming),[t]),G=k.useMemo(()=>(h??[]).filter(ie=>ie.status==="running"),[h]),H=G.length>0,ae=k.useMemo(()=>{const ie=p??[];for(let ke=ie.length-1;ke>=0;ke--)if(!ie[ke].completedAt)return ie[ke]},[p]),ye=k.useMemo(()=>G.length>0?Math.min(...G.map(ie=>ie.startedAt)):null,[G]),T=k.useMemo(()=>(n==null?void 0:n.backendType)==="codex"?"":((n==null?void 0:n.resumeSessionAt)||"").trim(),[n==null?void 0:n.backendType,n==null?void 0:n.resumeSessionAt]),Ne=T.length>0,Ce=n!=null&&n.forkSession?"Forked from":"Continuing from",$=k.useMemo(()=>{if(S.length===0)return t;const ie=[],ke=new Set;for(const Qe of S)ke.has(Qe.id)||(ke.add(Qe.id),ie.push(Qe));for(const Qe of t)ke.has(Qe.id)||(ke.add(Qe.id),ie.push(Qe));return ie},[S,t]),B=k.useMemo(()=>M9($),[$]);k.useEffect(()=>{N(Nh),C([]),R(0),O(!1),z(!1),I(!1),L(""),de.current=new Set},[e,T]);const oe=B.length,be=oe>j,je=k.useMemo(()=>be?B.slice(oe-j):B,[B,be,oe,j]),Ee=oe-je.length,Be=va(),Oe=k.useMemo(()=>Be?v9(je):je,[Be,je]),Te=Oe[Oe.length-1],Re=o==="running"&&(Te==null?void 0:Te.kind)==="activity_run"?Te.key:void 0,Ft=k.useCallback(()=>{const ie=v.current,ke=(ie==null?void 0:ie.scrollHeight)??0;N(Qe=>Qe+Nh),requestAnimationFrame(()=>{if(ie){const Qe=ie.scrollHeight;ie.scrollTop+=Qe-ke}})},[]),vn=k.useCallback(async(ie={})=>{if(!Ne||!T||Z)return;const ke=v.current,Qe=(ke==null?void 0:ke.scrollHeight)??0,nt=P?E:0;I(!0),L("");try{const Kt=await we.getClaudeSessionHistory(T,{cursor:nt,limit:w9}),It=Kt.messages.map(U=>({id:U.id,role:U.role,content:U.content,contentBlocks:U.role==="assistant"?U.contentBlocks:void 0,timestamp:U.timestamp||Date.now(),model:U.role==="assistant"?U.model:void 0,stopReason:U.role==="assistant"?U.stopReason:void 0})),ce=[];for(const U of It)de.current.has(U.id)||(de.current.add(U.id),ce.push(U));C(U=>[...ce,...U]),R(Kt.nextCursor),O(Kt.hasMore),z(!0),ce.length>0&&N(U=>U+ce.length),ie.preserveScroll!==!1&&ke&&requestAnimationFrame(()=>{const U=ke.scrollHeight;ke.scrollTop+=U-Qe})}catch(Kt){const It=Kt instanceof Error?Kt.message:String(Kt);L(It||"Failed to load previous history"),P||(C([]),R(0),O(!1))}finally{I(!1)}},[Ne,T,Z,P,E]);k.useEffect(()=>{if(!i&&o!=="running"&&!H){_(0);return}const ie=i||Date.now();_(Date.now()-ie);const ke=setInterval(()=>_(Date.now()-ie),1e3);return()=>clearInterval(ke)},[i,o,H]);function Vt(){const ie=v.current;if(!ie)return;b.current=ie.scrollHeight-ie.scrollTop-ie.clientHeight<120;const ke=Math.max(0,ie.scrollHeight-ie.clientHeight-ie.scrollTop);g0.set(e,ke),Ne&&P&&A&&!Z&&ie.scrollTop<=S9&&vn({preserveScroll:!0})}const St=k.useCallback(()=>{const ie=v.current;if(!ie)return;const ke=ie.style.scrollBehavior;ie.style.scrollBehavior="auto",ie.scrollTop=ie.scrollHeight,ie.style.scrollBehavior=ke},[]),wt=k.useCallback(()=>{const ie=v.current;if(!ie)return;const ke=ie.style.scrollBehavior;ie.style.scrollBehavior="auto";const Qe=g0.get(e);typeof Qe=="number"?ie.scrollTop=Math.max(0,ie.scrollHeight-ie.clientHeight-Qe):ie.scrollTop=ie.scrollHeight,ie.style.scrollBehavior=ke},[e]);if(k.useEffect(()=>{requestAnimationFrame(()=>wt())},[e,wt]),k.useEffect(()=>()=>{const ie=v.current;if(!ie)return;const ke=Math.max(0,ie.scrollHeight-ie.clientHeight-ie.scrollTop);g0.set(e,ke)},[e]),k.useEffect(()=>{Q&&requestAnimationFrame(()=>St())},[Q,St]),k.useEffect(()=>{var ie;b.current&&((ie=g.current)==null||ie.scrollIntoView({behavior:"smooth"}))},[t]),$.length===0)return l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 select-none px-6",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-cc-primary/10 to-cc-primary/5 border border-cc-primary/15 flex items-center justify-center shadow-[0_4px_20px_rgba(217,119,87,0.08)]",children:l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-7 h-7 text-cc-primary",children:[l.jsx("polyline",{points:"4 17 10 11 4 5"}),l.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),l.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary/40 animate-[gentle-bounce_2s_ease-in-out_infinite]",children:l.jsx("path",{d:"M8 2L10.5 6.5L15 8L10.5 9.5L8 14L5.5 9.5L1 8L5.5 6.5L8 2Z"})})})]}),l.jsx("div",{className:"text-center max-w-xs",children:Ne?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-cc-fg font-medium mb-1.5",children:"This session has prior context"}),l.jsxs("p",{className:"text-xs text-cc-muted leading-relaxed mb-4",children:[Ce," ",l.jsx("span",{className:"font-mono-code text-cc-fg/70",children:T.slice(0,8)}),". Load earlier messages when needed."]}),l.jsxs("button",{onClick:()=>void vn({preserveScroll:!1}),disabled:Z,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium text-cc-fg bg-cc-card border border-cc-border rounded-xl hover:bg-cc-hover hover:border-cc-primary/20 transition-all disabled:opacity-60 disabled:cursor-not-allowed cursor-pointer shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M8 2v12M3 9l5 5 5-5",strokeLinecap:"round",strokeLinejoin:"round"})}),Z?"Loading...":"Load previous history"]}),q&&l.jsx("p",{className:"text-xs text-cc-error mt-2",children:q})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[15px] text-cc-fg font-medium mb-1.5",children:"Start a conversation"}),l.jsx("p",{className:"text-xs text-cc-muted leading-relaxed",children:"Send a message to begin working with The Companion."})]})})]});const We=o==="running"&&u!=null?Math.max(0,Date.now()-u):0,xt=H&&(o!=="running"||We>=F2)?"background":We>=k9&&!ae?"stalled":We>=F2?"quiet":"active";return l.jsxs("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:[l.jsx("div",{className:"pointer-events-none absolute top-0 inset-x-0 h-6 bg-gradient-to-b from-cc-bg to-transparent z-10"}),l.jsx("div",{ref:v,onScroll:Vt,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-4 sm:px-6 py-5 sm:py-8",children:l.jsxs("div",{className:"max-w-3xl mx-auto space-y-5 sm:space-y-7",children:[Ne&&!P&&l.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs font-medium text-cc-fg",children:[Ce," existing Claude thread"]}),l.jsxs("p",{className:"text-[11px] text-cc-muted mt-1",children:[T," ",n!=null&&n.cwd?`· ${C9(n.cwd)}`:""]})]}),l.jsx("button",{onClick:()=>void vn({preserveScroll:!0}),disabled:Z,className:"shrink-0 inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-cc-fg bg-cc-card border border-cc-border rounded-lg hover:bg-cc-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed cursor-pointer",children:Z?"Loading...":"Load previous history"})]}),q&&l.jsx("p",{className:"text-xs text-cc-error mt-2",children:q})]}),Ne&&P&&l.jsx("div",{className:"flex justify-center",children:l.jsx("p",{className:"text-[11px] text-cc-muted",children:A?Z?"Loading older transcript...":"Scroll to top to load older transcript":"Loaded all available prior transcript"})}),be&&l.jsx("div",{className:"flex justify-center pb-3",children:l.jsxs("button",{onClick:Ft,className:"flex items-center gap-2 px-4 py-2 text-xs font-medium text-cc-muted hover:text-cc-fg bg-cc-card border border-cc-border rounded-xl hover:bg-cc-hover hover:border-cc-primary/20 transition-all cursor-pointer shadow-[0_2px_6px_rgba(0,0,0,0.03)]",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M8 3v10M3 8l5-5 5 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Load ",Math.min(Nh,Ee)," more",l.jsxs("span",{className:"text-cc-muted/50 tabular-nums",children:["(",Ee," hidden)"]})]})}),l.jsx(kv,{entries:Oe,toolActivity:p,liveRunKey:Re}),f&&f.size>0&&!V&&l.jsx(d9,{tools:Array.from(f.values())}),o==="compacting"&&l.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-cc-warning font-mono-code pl-10 py-1",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6",opacity:"0.2"}),l.jsx("path",{d:"M8 2a6 6 0 0 1 6 6",strokeLinecap:"round"})]}),l.jsx("span",{children:"Compacting context..."})]}),(o==="running"||H)&&y>=0&&l.jsxs("div",{"data-testid":"activity-indicator","data-activity-tier":xt,className:`flex items-center gap-2 text-[11px] font-mono-code pl-10 stats-glow py-1 ${xt==="stalled"?"text-cc-warning":"text-cc-muted"}`,children:[l.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${xt==="stalled"?"bg-cc-warning animate-[typing-breathe_1.5s_ease-in-out_infinite]":"bg-cc-primary animate-[typing-breathe_1.5s_ease-in-out_infinite]"}`}),xt==="background"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-fg/70",children:G.length===1?"Background process running":`${G.length} background processes running`}),ye!=null&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"tabular-nums",children:po(Math.max(0,Date.now()-ye))})]}),((Zt=G[0])==null?void 0:Zt.description)&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"truncate max-w-[24ch]",children:G[0].description})]})]}):xt==="stalled"?l.jsxs("span",{children:["No activity for ",po(We)," — the agent may be stuck"]}):xt==="quiet"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-fg/70",children:ae?`Running ${ae.toolName}`:"Still working…"}),l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"tabular-nums",children:ae?po(Math.max(0,Date.now()-ae.startedAt)):`no update for ${po(We)}`}),(ae==null?void 0:ae.preview)&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"truncate max-w-[32ch]",children:ae.preview})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-fg/70",children:"Generating"}),l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"tabular-nums",children:po(y)}),(a??0)>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsxs("span",{className:"tabular-nums",children:[ru(a)," tokens"]})]})]})]}),l.jsx("div",{ref:g})]})})]})}const z9={codex:"✳",xhigh:"★",max:"■",mini:"⚡"};function $9(e,t){for(const[i,a]of Object.entries(z9))if(e.includes(i))return a;const n=["◆","●","◕","✦"];return n[t%n.length]}function P9(e){return e.map((t,n)=>({value:t.value,label:t.label||t.value,icon:$9(t.value,n)}))}const uC=[{value:"claude-opus-5-5",label:"Opus 5.5",icon:""},{value:"claude-opus-5",label:"Opus 5",icon:""},{value:"claude-opus-4-8",label:"Opus 4.8",icon:""},{value:"claude-fable-5-1",label:"Fable 5.1",icon:"★"},{value:"claude-fable-5",label:"Fable 5",icon:"★"},{value:"claude-opus-4-7",label:"Opus 4.7",icon:""},{value:"claude-opus-4-6",label:"Opus 4.6",icon:""},{value:"claude-sonnet-5-5",label:"Sonnet 5.5",icon:""},{value:"claude-sonnet-5",label:"Sonnet 5",icon:""},{value:"claude-haiku-4-5-20251001",label:"Haiku 4.5",icon:""}],dC=[{value:"gpt-6-astra",label:"GPT-6-Astra",icon:"✦"},{value:"gpt-5.6-sol",label:"GPT-5.6-Sol",icon:"■"},{value:"gpt-5.6-terra",label:"GPT-5.6-Terra",icon:"✳"},{value:"gpt-5.6-luna",label:"GPT-5.6-Luna",icon:"⚡"},{value:"gpt-5.5",label:"GPT-5.5",icon:"◆"},{value:"gpt-5.2",label:"GPT-5.2",icon:"●"}],jv=[{value:"bypassPermissions",label:"Agent"},{value:"plan",label:"Plan"}],Nv=[{value:"bypassPermissions",label:"Auto"},{value:"plan",label:"Plan"}],B9=[{value:"",label:"Default"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"xHigh"},{value:"max",label:"Max"}],hC=[{value:"bypassPermissions",label:"Full Auto"},{value:"acceptEdits",label:"Auto-Edit"},{value:"default",label:"Supervised"}],fC=[{value:"bypassPermissions",label:"Full Auto"},{value:"default",label:"Supervised"}];function pC(e){return e==="codex"?dC:uC}function H2(e){return e==="codex"?Nv:jv}function hF(e){return e==="codex"?fC:hC}function q2(e){return e==="codex"?dC[0].value:uC[0].value}function V2(e){return e==="codex"?Nv[0].value:jv[0].value}function fF(e){return e==="codex"?fC[0].value:hC[0].value}function F9(e){return e==="codex"?[]:B9}function G2({sessionId:e}){const[t,n]=k.useState(!1),i=k.useRef(null),a=W(b=>b.sdkSessions.find(y=>y.sessionId===e)||null),o=W(b=>b.sessions.get(e)),u=W(b=>b.cliConnected.get(e)??!1),h=(a==null?void 0:a.backendType)??(o==null?void 0:o.backend_type)??"claude",f=(o==null?void 0:o.model)??(a==null?void 0:a.model)??"",p=pC(h),g=p.find(b=>b.value===f)||(f?{label:f,icon:"?"}:null),v=k.useCallback(b=>{if(n(!1),b===f)return;Xn(e,{type:"set_model",model:b});const{sdkSessions:y,setSdkSessions:_}=W.getState();_(y.map(j=>j.sessionId===e?{...j,model:b}:j))},[e,f]);return k.useEffect(()=>{if(!t)return;const b=y=>{i.current&&!i.current.contains(y.target)&&n(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[t]),k.useEffect(()=>{if(!t)return;const b=y=>{y.key==="Escape"&&n(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]),!u||!g?null:l.jsxs("div",{ref:i,className:"relative shrink-0",children:[l.jsxs("button",{onClick:()=>n(b=>!b),className:`flex items-center gap-1 h-8 px-2 rounded-md text-[12px] font-medium transition-colors cursor-pointer ${t?"text-cc-fg bg-cc-active":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,title:`Current model: ${g.label}`,"aria-label":"Switch model","aria-expanded":t,"aria-haspopup":"listbox",children:[g.icon&&l.jsx("span",{className:"text-[13px] leading-none",children:g.icon}),l.jsx("span",{children:g.label}),l.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor",className:"w-2.5 h-2.5 opacity-50",children:l.jsx("path",{d:"M6 8L1.5 3.5h9L6 8z"})})]}),t&&l.jsx("div",{className:"absolute right-0 bottom-full mb-1 z-50 min-w-[160px] rounded-lg border border-cc-separator bg-cc-bg shadow-lg overflow-hidden",role:"listbox","aria-label":"Select model",children:p.map(b=>l.jsxs("button",{onClick:()=>v(b.value),className:`w-full flex items-center gap-2 px-3 min-h-[44px] text-[13px] transition-colors cursor-pointer ${b.value===f?"text-cc-fg bg-cc-active font-medium":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,role:"option","aria-selected":b.value===f,children:[b.icon&&l.jsx("span",{className:"text-[14px] leading-none w-5 text-center",children:b.icon}),l.jsx("span",{className:"flex-1 text-left",children:b.label}),b.value===f&&l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-primary shrink-0",children:l.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})]},b.value))})]})}function mC({open:e,loading:t,prompts:n,selectedIndex:i,onSelect:a,menuRef:o,className:u=""}){return e?l.jsx("div",{ref:o,className:`max-h-[240px] overflow-y-auto bg-cc-card border border-cc-border rounded-[10px] shadow-lg z-20 py-1 ${u}`,children:t?l.jsx("div",{className:"px-3 py-2 text-[12px] text-cc-muted",children:"Searching prompts..."}):n.length>0?n.map((h,f)=>l.jsxs("button",{"data-prompt-index":f,onClick:()=>a(h),className:`w-full px-3 py-2 text-left flex items-center gap-2.5 transition-colors cursor-pointer ${f===i?"bg-cc-hover":"hover:bg-cc-hover/50"}`,children:[l.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-cc-hover text-cc-muted shrink-0",children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[l.jsx("path",{d:"M2.5 8a5.5 5.5 0 1111 0v3a2.5 2.5 0 01-2.5 2.5h-1",strokeLinecap:"round"}),l.jsx("circle",{cx:"8",cy:"8",r:"1.75",fill:"currentColor",stroke:"none"})]})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-[13px] font-medium text-cc-fg truncate",children:["@",h.name]}),l.jsx("div",{className:"text-[11px] text-cc-muted truncate",children:h.content})]}),l.jsx("span",{className:"text-[10px] text-cc-muted shrink-0",children:h.scope})]},h.id)):l.jsx("div",{className:"px-3 py-2 text-[12px] text-cc-muted",children:"No prompts found."})}):null}function gC({text:e,caretPos:t,cwd:n,enabled:i=!0}){const[a,o]=k.useState(!1),[u,h]=k.useState(0),[f,p]=k.useState([]),[g,v]=k.useState(!1),b=k.useRef(null),y=k.useCallback(async()=>{v(!0);try{const S=await we.listPrompts(n);p(S.filter(C=>!!C.name.trim()))}catch{p([])}finally{v(!1)}},[n]);k.useEffect(()=>{y()},[y]);const _=k.useMemo(()=>{const S=e.slice(0,t),C=S.match(/(^|\s)@([^\s@]*)$/);if(!C||C.index===void 0)return null;const E=S.length-C[0].length+C[1].length;return{query:C[2]||"",start:E,end:t}},[e,t]),j=k.useMemo(()=>{if(!a||!_)return[];const S=_.query.toLowerCase();if(!S)return f;const C=f.filter(R=>R.name.toLowerCase().startsWith(S)),E=f.filter(R=>!R.name.toLowerCase().startsWith(S)&&R.name.toLowerCase().includes(S));return[...C,...E]},[a,_,f]);k.useEffect(()=>{const S=i&&!!_;S&&!a?(o(!0),h(0)):!S&&a&&o(!1)},[i,_,a]),k.useEffect(()=>{u>=j.length&&h(Math.max(0,j.length-1))},[j.length,u]),k.useEffect(()=>{if(!b.current||!a)return;const C=b.current.querySelectorAll("[data-prompt-index]")[u];C&&C.scrollIntoView({block:"nearest"})},[u,a]);const N=k.useCallback(S=>{if(!_)return{nextText:e,nextCursor:t};const C=`${S.content} `,E=`${e.slice(0,_.start)}${C}${e.slice(_.end)}`,R=_.start+C.length;return{nextText:E,nextCursor:R}},[_,e,t]);return{mentionMenuOpen:a,setMentionMenuOpen:o,mentionMenuIndex:u,setMentionMenuIndex:h,mentionContext:_,filteredPrompts:j,promptsLoading:g,savedPrompts:f,selectPrompt:N,refreshPrompts:y,mentionMenuRef:b}}const I9=[];function Y2({isPlan:e,isConnected:t,onToggle:n,modeLabel:i,size:a}){const o=a==="desktop",u=o?"px-2.5 py-1.5":"px-2 py-1",h=o?"text-cc-primary border-cc-primary/30 bg-cc-primary/8 hover:bg-cc-primary/12 cursor-pointer":"text-cc-primary border-cc-primary/30 bg-cc-primary/8",f=o?"text-cc-muted border-cc-border hover:text-cc-fg hover:bg-cc-hover cursor-pointer":"text-cc-muted border-cc-border";return l.jsxs("button",{onClick:n,disabled:!t,className:`flex items-center gap-1.5 ${u} rounded-md text-[12px] font-semibold transition-all border select-none shrink-0 ${t?e?h:f:"opacity-30 cursor-not-allowed text-cc-muted border-transparent"}`,title:"Toggle mode (Shift+Tab)",children:[e?l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[l.jsx("rect",{x:"3",y:"3",width:"3.5",height:"10",rx:"0.75"}),l.jsx("rect",{x:"9.5",y:"3",width:"3.5",height:"10",rx:"0.75"})]}):l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[l.jsx("path",{d:"M2.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),l.jsx("path",{d:"M8.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}),l.jsx("span",{children:i})]})}function Ch({onClick:e,disabled:t,active:n,title:i,children:a}){return l.jsx("button",{onClick:e,disabled:t,className:`flex items-center justify-center w-8 h-8 rounded-md transition-colors ${n?"text-cc-muted hover:text-cc-fg hover:bg-cc-hover cursor-pointer":"text-cc-muted opacity-30 cursor-not-allowed"}`,title:i,children:a})}function X2(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:l.jsx("path",{d:"M4 2.75h8A1.25 1.25 0 0113.25 4v9.25L8 10.5l-5.25 2.75V4A1.25 1.25 0 014 2.75z"})})}function Q2({isRunning:e,canSend:t,onSend:n,onInterrupt:i,size:a}){const o=a==="desktop",u=o?"w-9 h-9":"w-10 h-10",h=o?"bg-cc-primary hover:bg-cc-primary-hover hover:scale-105 text-white cursor-pointer shadow-[0_4px_16px_rgba(217,119,87,0.25)]":"bg-cc-primary hover:bg-cc-primary-hover active:scale-95 text-white cursor-pointer shadow-[0_4px_16px_rgba(217,119,87,0.25)]";return e?l.jsx("button",{onClick:i,className:`flex items-center justify-center ${u} rounded-lg bg-cc-error/10 hover:bg-cc-error/20 text-cc-error transition-colors cursor-pointer`,title:"Stop generation",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}):l.jsx("button",{onClick:n,disabled:!t,className:`flex items-center justify-center ${u} rounded-full transition-all duration-200 ${t?h:"bg-cc-hover text-cc-muted cursor-not-allowed"}`,title:"Send message",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M3 2l11 6-11 6V9.5l7-1.5-7-1.5V2z"})})})}function U9({sessionId:e}){var It,ce;const[t,n]=k.useState(""),[i,a]=k.useState([]),[o,u]=k.useState(null),[h,f]=k.useState(!1),[p,g]=k.useState(!1),[v,b]=k.useState(0),[y,_]=k.useState(!1),[j,N]=k.useState(""),[S,C]=k.useState("global"),[E,R]=k.useState(null),[A,O]=k.useState(0),P=k.useRef(null),z=k.useRef(null),Z=k.useRef(null),I=k.useRef(null),q=W(U=>U.cliConnected),L=W(U=>U.sessions.get(e)),de=W(U=>U.previousPermissionMode.get(e)||"acceptEdits"),Q=q.get(e)??!1,V=(L==null?void 0:L.permissionMode)||"acceptEdits",G=V==="plan",H=(L==null?void 0:L.backend_type)==="codex",ye=((ce=(It=(H?Nv:jv).find(U=>U.value===V))==null?void 0:It.label)==null?void 0:ce.toLowerCase())||V,T=gC({text:t,caretPos:A,cwd:L==null?void 0:L.cwd,enabled:!p}),Ne=k.useMemo(()=>{const U=[];if(L!=null&&L.slash_commands)for(const fe of L.slash_commands)U.push({name:fe,type:"command"});if(L!=null&&L.skills)for(const fe of L.skills)U.push({name:fe,type:"skill"});return U},[L==null?void 0:L.slash_commands,L==null?void 0:L.skills]),Ce=k.useMemo(()=>{if(!p)return[];const U=t.match(/^\/(\S*)$/);if(!U)return[];const fe=U[1].toLowerCase();return fe===""?Ne:Ne.filter(Ae=>Ae.name.toLowerCase().includes(fe))},[t,p,Ne]);k.useEffect(()=>{const U=t.startsWith("/")&&/^\/\S*$/.test(t)&&Ne.length>0;U&&!p?(g(!0),b(0)):!U&&p&&g(!1)},[t,Ne.length,p]),k.useEffect(()=>{v>=Ce.length&&b(Math.max(0,Ce.length-1))},[Ce.length,v]),k.useEffect(()=>{if(!Z.current||!p)return;const fe=Z.current.querySelectorAll("[data-cmd-index]")[v];fe&&fe.scrollIntoView({block:"nearest"})},[v,p]),k.useEffect(()=>{if(I.current===null||!P.current)return;const U=I.current;P.current.setSelectionRange(U,U),I.current=null},[t]);const $=k.useCallback(U=>{var fe;n(`/${U.name} `),g(!1),(fe=P.current)==null||fe.focus()},[]),B=k.useCallback(U=>{var Ae;const fe=T.selectPrompt(U);I.current=fe.nextCursor,n(fe.nextText),T.setMentionMenuOpen(!1),O(fe.nextCursor),(Ae=P.current)==null||Ae.focus(),P.current&&(P.current.style.height="auto",P.current.style.height=Math.min(P.current.scrollHeight,200)+"px")},[T]);function oe(){var ze;const U=t.trim();if(!U||!Q)return;const fe=k0(),Ae=i.length>0?i.map(st=>({name:st.name,media_type:st.mediaType,data:st.base64,size:st.size})):void 0;Xn(e,{type:"user_message",content:U,session_id:e,attachments:Ae,client_msg_id:fe});const tt=W.getState();tt.appendMessage(e,{id:fe,role:"user",content:U,attachments:Ae,timestamp:Date.now()}),tt.setSessionStatus(e,"running"),tt.setLastActivity(e,Date.now()),tt.streamingStartedAt.has(e)||tt.setStreamingStats(e,{startedAt:Date.now()}),n(""),a([]),u(null),g(!1),T.setMentionMenuOpen(!1),P.current&&(P.current.style.height="auto"),(ze=P.current)==null||ze.focus()}function be(U){if(p&&Ce.length>0){if(U.key==="ArrowDown"){U.preventDefault(),b(fe=>(fe+1)%Ce.length);return}if(U.key==="ArrowUp"){U.preventDefault(),b(fe=>(fe-1+Ce.length)%Ce.length);return}if(U.key==="Tab"&&!U.shiftKey){U.preventDefault(),$(Ce[v]);return}if(U.key==="Enter"&&!U.shiftKey){U.preventDefault(),$(Ce[v]);return}if(U.key==="Escape"){U.preventDefault(),g(!1);return}}if(T.mentionMenuOpen&&U.key==="Escape"){U.preventDefault(),T.setMentionMenuOpen(!1);return}if(T.mentionMenuOpen&&T.filteredPrompts.length>0){if(U.key==="ArrowDown"){U.preventDefault(),T.setMentionMenuIndex(fe=>(fe+1)%T.filteredPrompts.length);return}if(U.key==="ArrowUp"){U.preventDefault(),T.setMentionMenuIndex(fe=>(fe-1+T.filteredPrompts.length)%T.filteredPrompts.length);return}if(U.key==="Tab"&&!U.shiftKey||U.key==="Enter"&&!U.shiftKey){U.preventDefault(),B(T.filteredPrompts[T.mentionMenuIndex]);return}}if(T.mentionMenuOpen&&T.filteredPrompts.length===0&&(U.key==="Enter"&&!U.shiftKey||U.key==="Tab"&&!U.shiftKey)){U.preventDefault();return}if(U.key==="Tab"&&U.shiftKey){U.preventDefault(),We();return}U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),oe())}function je(U){n(U.target.value),O(U.target.selectionStart??U.target.value.length);const fe=U.target;fe.style.height="auto",fe.style.height=Math.min(fe.scrollHeight,200)+"px"}function Ee(){P.current&&O(P.current.selectionStart??0)}function Be(){Xn(e,{type:"interrupt"})}async function Oe(U){if(U.length===0)return;const fe=[],Ae=[];let tt=i.reduce((ze,st)=>ze+st.size,0);for(const ze of U){if(ze.size>vf){Ae.push(`${ze.name} is too large (${pa(ze.size)}, max ${pa(vf)})`);continue}if(tt+ze.size>bf){Ae.push(`${ze.name} would exceed the per-message limit (${pa(bf)})`);continue}const{base64:st,mediaType:rn}=await eC(ze);fe.push({name:ze.name,base64:st,mediaType:rn,size:ze.size}),tt+=ze.size}fe.length>0&&a(ze=>[...ze,...fe]),u(Ae.length>0?Ae.join("; "):null)}async function Te(U){const fe=U.target.files;fe&&(await Oe(Array.from(fe)),U.target.value="")}function Re(U){a(fe=>fe.filter((Ae,tt)=>tt!==U))}async function Ft(U){var tt;const fe=(tt=U.clipboardData)==null?void 0:tt.items;if(!fe)return;const Ae=[];for(const ze of Array.from(fe)){if(ze.kind!=="file")continue;const st=ze.getAsFile();if(!st)continue;const rn=st.name&&st.name.length>0?st.name:`pasted-${Date.now()}.${(st.type.split("/")[1]||"bin").replace(/[^a-zA-Z0-9]/g,"")}`;Ae.push(new File([st],rn,{type:st.type,lastModified:st.lastModified}))}Ae.length>0&&(U.preventDefault(),await Oe(Ae))}function vn(U){U.dataTransfer.types.includes("Files")&&(U.preventDefault(),U.stopPropagation(),f(!0))}function Vt(U){U.currentTarget===U.target&&f(!1)}async function St(U){if(!U.dataTransfer.types.includes("Files"))return;U.preventDefault(),U.stopPropagation(),f(!1);const fe=Array.from(U.dataTransfer.files);fe.length>0&&await Oe(fe)}function wt(){const U=t.trim().slice(0,32);N(U||""),R(null),_(fe=>!fe)}function We(){if(!Q)return;const U=W.getState();if(!G)U.setPreviousPermissionMode(e,V),Xn(e,{type:"set_permission_mode",mode:"plan"}),U.updateSession(e,{permissionMode:"plan"});else{const fe=de||(H?"bypassPermissions":"acceptEdits");Xn(e,{type:"set_permission_mode",mode:fe}),U.updateSession(e,{permissionMode:fe})}}async function xt(){const U=t.trim(),fe=j.trim();if(!U||!fe)return;if(S==="project"&&!(L!=null&&L.cwd)){R("No project folder available for this session");return}const Ae={name:fe,content:U,scope:S};S==="project"&&(Ae.projectPaths=[L.cwd]);try{await we.createPrompt(Ae),await T.refreshPrompts(),_(!1),N(""),C("global"),R(null)}catch(tt){const ze=tt instanceof Error&&tt.message?tt.message:"Could not save prompt.";R(ze)}}const ie=W(U=>U.promptSuggestions.get(e))??I9,ke=W(U=>U.clearPromptSuggestions),nt=W(U=>U.sessionStatus).get(e)==="running",Kt=t.trim().length>0&&Q;return l.jsx("div",{className:`shrink-0 px-0 sm:px-6 pt-0 sm:pt-3 pb-5 sm:pb-4 bg-cc-input-bg sm:bg-transparent relative ${h?"ring-2 ring-cc-primary/40 rounded-2xl":""}`,onDragOver:vn,onDragLeave:Vt,onDrop:St,children:l.jsxs("div",{className:"max-w-3xl mx-auto",children:[h&&l.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none rounded-2xl bg-cc-primary/5 border-2 border-dashed border-cc-primary/40",children:l.jsx("span",{className:"text-sm text-cc-primary font-medium",children:"Drop files to attach"})}),i.length>0&&l.jsx("div",{className:"flex items-center gap-2 mb-2 px-3 sm:px-0 flex-wrap",children:i.map((U,fe)=>l.jsx(sC,{name:U.name,mediaType:U.mediaType,base64:U.base64,size:U.size,onRemove:()=>Re(fe)},fe))}),o&&l.jsx("div",{className:"mb-2 px-3 sm:px-0 text-[11px] text-cc-error",children:o}),l.jsx("input",{ref:z,type:"file",multiple:!0,onChange:Te,className:"hidden","aria-label":"Attach files"}),ie.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 px-2 sm:px-4 pb-2",children:ie.map((U,fe)=>l.jsx("button",{onClick:()=>{if(!Q||nt)return;const Ae=k0();Xn(e,{type:"user_message",content:U,session_id:e,client_msg_id:Ae}),W.getState().appendMessage(e,{id:Ae,role:"user",content:U,timestamp:Date.now()}),ke(e)},disabled:!Q||nt,className:"text-xs px-2.5 py-1.5 rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg border border-cc-border transition-colors cursor-pointer truncate max-w-[280px]",title:U,children:U},fe))}),l.jsxs("div",{className:`relative overflow-visible transition-all duration-200 border-t border-cc-separator sm:border sm:border-cc-border sm:bg-cc-input-bg/95 sm:rounded-[16px] sm:backdrop-blur-sm composer-card ${G?"sm:border-cc-primary/40 sm:shadow-[0_10px_30px_rgba(217,119,87,0.08)]":"sm:focus-within:border-cc-primary/25"}`,children:[p&&Ce.length>0&&l.jsx("div",{ref:Z,className:"absolute left-2 right-2 bottom-full mb-1 max-h-[240px] overflow-y-auto bg-cc-card border border-cc-border rounded-[10px] shadow-lg z-20 py-1",children:Ce.map((U,fe)=>l.jsxs("button",{"data-cmd-index":fe,onClick:()=>$(U),className:`w-full px-3 py-2 text-left flex items-center gap-2.5 transition-colors cursor-pointer ${fe===v?"bg-cc-hover":"hover:bg-cc-hover/50"}`,children:[l.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-cc-hover text-cc-muted shrink-0",children:U.type==="skill"?l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M8 1l1.796 3.64L14 5.255l-3 2.924.708 4.126L8 10.5l-3.708 1.805L5 8.18 2 5.255l4.204-.615L8 1z"})}):l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M5 12L10 4",strokeLinecap:"round"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("span",{className:"text-[13px] font-medium text-cc-fg",children:["/",U.name]}),l.jsx("span",{className:"ml-2 text-[11px] text-cc-muted",children:U.type})]})]},`${U.type}-${U.name}`))}),l.jsx(mC,{open:T.mentionMenuOpen,loading:T.promptsLoading,prompts:T.filteredPrompts,selectedIndex:T.mentionMenuIndex,onSelect:B,menuRef:T.mentionMenuRef,className:"absolute left-2 right-2 bottom-full mb-1"}),y&&l.jsxs("div",{className:"absolute left-2 right-2 bottom-full mb-1 bg-cc-card border border-cc-border rounded-[10px] shadow-lg z-20 p-3 space-y-2",children:[l.jsx("div",{className:"text-xs font-semibold text-cc-fg",children:"Save prompt"}),l.jsx("input",{value:j,onChange:U=>{N(U.target.value),E&&R(null)},placeholder:"Prompt title","aria-label":"Prompt title",className:"w-full px-2 py-1.5 text-sm bg-cc-input-bg border border-cc-border rounded-md text-cc-fg focus:outline-none focus:border-cc-primary/40"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button","aria-pressed":S==="global",onClick:()=>C("global"),className:`px-2 py-0.5 text-[11px] rounded border transition-colors cursor-pointer ${S==="global"?"border-cc-primary/40 text-cc-primary bg-cc-primary/8":"border-cc-border text-cc-muted hover:text-cc-fg"}`,children:"Global"}),l.jsx("button",{type:"button","aria-pressed":S==="project",onClick:()=>C("project"),className:`px-2 py-0.5 text-[11px] rounded border transition-colors cursor-pointer ${S==="project"?"border-cc-primary/40 text-cc-primary bg-cc-primary/8":"border-cc-border text-cc-muted hover:text-cc-fg"}`,children:"This project"})]}),S==="project"&&(L==null?void 0:L.cwd)&&l.jsx("div",{className:"text-[10px] text-cc-muted font-mono-code truncate",title:L.cwd,children:L.cwd}),E?l.jsx("div",{className:"text-[11px] text-cc-error",children:E}):null,l.jsxs("div",{className:"flex items-center gap-1.5 justify-end",children:[l.jsx("button",{onClick:()=>{_(!1),C("global"),R(null)},className:"px-2 py-1 text-[11px] rounded-md border border-cc-border text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:xt,disabled:!j.trim()||!t.trim(),className:`px-2 py-1 text-[11px] rounded-md border ${j.trim()&&t.trim()?"border-cc-primary/40 text-cc-primary bg-cc-primary/8 cursor-pointer":"border-cc-border text-cc-muted cursor-not-allowed"}`,children:"Save"})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 px-3 pt-1.5 pb-0.5 sm:hidden",children:[l.jsx(Y2,{isPlan:G,isConnected:Q,onToggle:We,modeLabel:ye,size:"mobile"}),l.jsx(G2,{sessionId:e}),l.jsx("div",{className:"flex-1"}),l.jsx(Ch,{onClick:wt,disabled:!Q||!t.trim(),active:Q&&!!t.trim(),title:"Save as prompt",children:l.jsx(X2,{})}),l.jsx(Ch,{onClick:()=>{var U;return(U=z.current)==null?void 0:U.click()},disabled:!Q,active:Q,title:"Attach file",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:l.jsx("path",{d:"M11.5 6.5L7 11a2 2 0 1 1-2.83-2.83l5-5a3.25 3.25 0 1 1 4.6 4.6l-5.7 5.7a4.5 4.5 0 0 1-6.36-6.36L7 2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),l.jsx("div",{className:"px-3 sm:px-3 pt-1 sm:pt-2.5",children:l.jsx("textarea",{ref:P,value:t,onChange:je,onKeyDown:be,onClick:Ee,onKeyUp:Ee,onPaste:Ft,"aria-label":"Message input",placeholder:Q?"Type a message... (/ + @)":"Waiting for CLI connection...",disabled:!Q,rows:1,className:"w-full px-1 py-1.5 text-base sm:text-sm bg-transparent resize-none outline-none text-cc-fg font-sans-ui placeholder:text-cc-muted disabled:opacity-50 overflow-y-auto",style:{minHeight:"36px",maxHeight:"200px"}})}),l.jsx("div",{className:"flex items-center justify-end gap-1 px-3 pb-1 sm:hidden",children:l.jsx(Q2,{isRunning:nt,canSend:Kt,onSend:oe,onInterrupt:Be,size:"mobile"})}),l.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 px-2.5 pb-2",children:[l.jsx(Ch,{onClick:()=>{var U;return(U=z.current)==null?void 0:U.click()},disabled:!Q,active:Q,title:"Attach file",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:l.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})})}),l.jsx(Ch,{onClick:wt,disabled:!Q||!t.trim(),active:Q&&!!t.trim(),title:"Save as prompt",children:l.jsx(X2,{})}),l.jsx(Y2,{isPlan:G,isConnected:Q,onToggle:We,modeLabel:ye,size:"desktop"}),l.jsx("div",{className:"flex-1"}),l.jsx(G2,{sessionId:e}),l.jsx(Q2,{isRunning:nt,canSend:Kt,onSend:oe,onInterrupt:Be,size:"desktop"})]})]})]})})}function H9(e){if(e.type==="setMode")return`Set mode to "${e.mode}"`;const n=e.destination==="session"?"for session":"always";if(e.type==="addRules"||e.type==="replaceRules"){const i=e.rules[0];if(i!=null&&i.ruleContent)return`Allow "${i.ruleContent}" ${n}`;if(i!=null&&i.toolName)return`Allow ${i.toolName} ${n}`}return e.type==="addDirectories"?`Trust ${e.directories[0]||"directory"} ${n}`:`Allow ${n}`}function q9(e,t){const n={};for(const[i,a]of Object.entries(t)){const o=e[Number(i)],u=typeof(o==null?void 0:o.question)=="string"&&o.question?o.question:i;n[u]=a}return n}function V9({permission:e,sessionId:t}){const[n,i]=k.useState(!1),a=W(p=>p.removePermission);function o(p,g){i(!0),Xn(t,{type:"permission_response",request_id:e.request_id,behavior:"allow",updated_input:p,...g!=null&&g.length?{updated_permissions:g}:{}}),a(t,e.request_id)}function u(){i(!0),Xn(t,{type:"permission_response",request_id:e.request_id,behavior:"deny",message:"Denied by user"}),a(t,e.request_id)}const h=e.tool_name==="AskUserQuestion",f=e.permission_suggestions;return l.jsx("div",{className:"px-2 sm:px-4 py-3 border-b border-cc-border animate-[fadeSlideIn_0.2s_ease-out]",children:l.jsx("div",{className:"max-w-3xl mx-auto",children:l.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[l.jsx("div",{className:`w-7 h-7 sm:w-8 sm:h-8 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${h?"bg-cc-primary/10 border border-cc-primary/20":"bg-cc-warning/10 border border-cc-warning/20"}`,children:h?l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4 text-cc-primary",children:l.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})}):l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4 text-cc-warning",children:l.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[l.jsx("span",{className:`text-xs font-semibold ${h?"text-cc-primary":"text-cc-warning"}`,children:h?"Question":"Permission Request"}),!h&&l.jsx("span",{className:"text-[11px] text-cc-muted font-mono-code",children:e.display_name||e.tool_name}),e.title&&l.jsx("span",{className:"text-[11px] text-cc-muted",children:e.title})]}),h?l.jsx(W9,{input:e.input,onSelect:p=>o({...e.input,answers:p}),disabled:n}):l.jsx(X9,{toolName:e.tool_name,input:e.input,description:e.description}),e.decision_reason&&l.jsx("p",{className:"text-xs text-cc-muted mt-1 italic",children:e.decision_reason}),e.ai_validation&&!h&&l.jsx(Y9,{validation:e.ai_validation}),!h&&l.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[l.jsxs("button",{onClick:()=>o(),disabled:n,className:"inline-flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium rounded-lg bg-cc-success/90 hover:bg-cc-success text-white disabled:opacity-50 transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:l.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7"})}),"Allow"]}),f==null?void 0:f.map((p,g)=>l.jsxs("button",{onClick:()=>o(void 0,[p]),disabled:n,title:`${p.type}: ${JSON.stringify(p)}`,className:"inline-flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium rounded-lg bg-cc-primary/10 hover:bg-cc-primary/20 text-cc-primary border border-cc-primary/20 disabled:opacity-50 transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:l.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7"})}),H9(p)]},g)),l.jsxs("button",{onClick:u,disabled:n,className:"inline-flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg border border-cc-border disabled:opacity-50 transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:l.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"Deny"]})]})]})]})})})}function G9(e){return[/^Invalid Anthropic/i,/^Anthropic .*(rate limit|overloaded|unavailable|error|lacks permission)/i,/^AI service/i,/^AI evaluation timed out/i,/^Model not found/i,/^No Anthropic API key/i].some(n=>n.test(e))}function Y9({validation:e}){const t=e.verdict==="uncertain"&&G9(e.reason),n=e.verdict==="safe"?"bg-cc-success/10 text-cc-success":e.verdict==="dangerous"?"bg-cc-error/10 text-cc-error":"bg-cc-warning/10 text-cc-warning",i=t?"AI analysis unavailable — manual review:":"AI analysis:";return l.jsxs("div",{className:`mt-2 flex items-center gap-1.5 text-[11px] px-2 py-1.5 rounded-md ${n}`,children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0",children:l.jsx("path",{d:"M8 1a2.5 2.5 0 00-2.5 2.5v.382a8 8 0 00-1.074.646l-.33-.191a2.5 2.5 0 00-3.415.912 2.5 2.5 0 00.916 3.42l.33.19A8 8 0 001.5 9.5v.382A8 8 0 002 10.5l-.33.19a2.5 2.5 0 00-.916 3.42 2.5 2.5 0 003.415.912l.33-.191a8 8 0 001.074.646V16A2.5 2.5 0 008 13.5 2.5 2.5 0 0010.5 16v-.713a8 8 0 001.074-.646l.33.191a2.5 2.5 0 003.415-.912 2.5 2.5 0 00-.916-3.42L14 10.5V9.5l.33-.19a2.5 2.5 0 00.916-3.42 2.5 2.5 0 00-3.415-.912l-.33.191A8 8 0 0010.5 4.882V4.5A2.5 2.5 0 008 2V1z"})}),l.jsx("span",{className:"font-medium",children:i}),l.jsx("span",{children:e.reason})]})}function X9({toolName:e,input:t,description:n}){return e==="Bash"?l.jsx(Q9,{input:t}):e==="Edit"?l.jsx(Z9,{input:t}):e==="Write"?l.jsx(K9,{input:t}):e==="Read"?l.jsx(J9,{input:t}):e==="Glob"?l.jsx(eP,{input:t}):e==="Grep"?l.jsx(tP,{input:t}):e==="ExitPlanMode"?l.jsx(nP,{input:t}):l.jsx(xC,{input:t,description:n})}function Q9({input:e}){const t=typeof e.command=="string"?e.command:"",n=typeof e.description=="string"?e.description:"";return l.jsxs("div",{className:"space-y-1.5",children:[n&&l.jsx("div",{className:"text-xs text-cc-muted",children:n}),l.jsxs("pre",{className:"text-xs text-cc-fg font-mono-code bg-cc-code-bg/30 rounded-lg px-2 sm:px-3 py-2 max-h-32 overflow-y-auto overflow-x-auto whitespace-pre-wrap break-words",children:[l.jsx("span",{className:"text-cc-muted select-none",children:"$ "}),t]})]})}function W9({input:e,onSelect:t,disabled:n}){const i=Array.isArray(e.questions)?e.questions:[],[a,o]=k.useState({}),[u,h]=k.useState({}),[f,p]=k.useState({});function g(N){return q9(i,N)}function v(N,S){const C=String(N);o(E=>({...E,[C]:S})),p(E=>({...E,[C]:!1})),i.length<=1&&t(g({[C]:S}))}function b(N){var E;const S=String(N),C=(E=u[S])==null?void 0:E.trim();C&&(o(R=>({...R,[S]:C})),i.length<=1&&t(g({[S]:C})))}function y(N,S){const C=String(N);h(R=>({...R,[C]:S}));const E=S.trim();o(R=>{if(!E){const A={...R};return delete A[C],A}return{...R,[C]:E}})}function _(N){const S=String(N);p(C=>{const E=!!C[S],R={...C,[S]:!E};return E&&(o(A=>{const O={...A};return delete O[S],O}),h(A=>{const O={...A};return delete O[S],O})),R})}function j(){t(g(a))}if(i.length===0){const N=typeof e.question=="string"?e.question:"";return N?l.jsx("div",{className:"text-sm text-cc-fg bg-cc-code-bg/30 rounded-lg px-3 py-2",children:N}):l.jsx(xC,{input:e})}return l.jsxs("div",{className:"space-y-3",children:[i.map((N,S)=>{const C=typeof N.header=="string"?N.header:"",E=typeof N.question=="string"?N.question:"",R=Array.isArray(N.options)?N.options:[],A=String(S),O=a[A],P=f[A];return l.jsxs("div",{className:"space-y-2",children:[C&&l.jsx("span",{className:"inline-block text-[10px] font-semibold text-cc-primary bg-cc-primary/10 px-1.5 py-0.5 rounded",children:C}),E&&l.jsx("p",{className:"text-sm text-cc-fg leading-relaxed",children:E}),R.length>0&&l.jsxs("div",{className:"space-y-1.5",children:[R.map((z,Z)=>{const I=typeof z.label=="string"?z.label:String(z),q=typeof z.description=="string"?z.description:"",L=O===I;return l.jsx("button",{onClick:()=>v(S,I),disabled:n,className:`w-full text-left px-3 py-2 rounded-lg border transition-all cursor-pointer disabled:opacity-50 ${L?"border-cc-primary bg-cc-primary/10 ring-1 ring-cc-primary/30":"border-cc-border bg-cc-hover/50 hover:bg-cc-hover hover:border-cc-primary/30"}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${L?"border-cc-primary":"border-cc-muted/40"}`,children:L&&l.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-primary"})}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:I}),q&&l.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5 leading-snug",children:q})]})]})},Z)}),l.jsx("button",{onClick:()=>_(S),disabled:n,className:`w-full text-left px-3 py-2 rounded-lg border transition-all cursor-pointer disabled:opacity-50 ${P?"border-cc-primary bg-cc-primary/10 ring-1 ring-cc-primary/30":"border-cc-border bg-cc-hover/50 hover:bg-cc-hover hover:border-cc-primary/30"}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${P?"border-cc-primary":"border-cc-muted/40"}`,children:P&&l.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-primary"})}),l.jsx("span",{className:"text-xs font-medium text-cc-muted",children:"Other..."})]})}),P&&l.jsxs("div",{className:"pl-6",children:[l.jsx("input",{type:"text",value:u[A]||"",onChange:z=>y(S,z.target.value),onKeyDown:z=>{z.key==="Enter"&&b(S)},placeholder:"Type your answer...",className:"w-full px-2.5 py-1.5 text-xs bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50",autoFocus:!0}),i.length<=1&&l.jsx("p",{className:"mt-1 text-[10px] text-cc-muted",children:"Press Enter to submit"})]})]})]},S)}),i.length>1&&Object.keys(a).length>0&&l.jsx("button",{onClick:j,disabled:n,className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-lg bg-cc-primary hover:bg-cc-primary-hover text-white disabled:opacity-50 transition-colors cursor-pointer",children:"Submit answers"})]})}function Z9({input:e}){const t=String(e.file_path||""),n=String(e.old_string||""),i=String(e.new_string||"");return l.jsx(Oo,{oldText:n,newText:i,fileName:t,mode:"compact"})}function K9({input:e}){const t=String(e.file_path||""),n=String(e.content||"");return l.jsx(Oo,{newText:n,fileName:t,mode:"compact"})}function J9({input:e}){const t=String(e.file_path||"");return l.jsx("div",{className:"text-xs text-cc-muted font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2",children:t})}function eP({input:e}){const t=typeof e.pattern=="string"?e.pattern:"",n=typeof e.path=="string"?e.path:"";return l.jsxs("div",{className:"text-xs font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-0.5",children:[l.jsx("div",{className:"text-cc-fg",children:t}),n&&l.jsx("div",{className:"text-cc-muted",children:n})]})}function tP({input:e}){const t=typeof e.pattern=="string"?e.pattern:"",n=typeof e.path=="string"?e.path:"",i=typeof e.glob=="string"?e.glob:"";return l.jsxs("div",{className:"text-xs font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-0.5",children:[l.jsx("div",{className:"text-cc-fg",children:t}),n&&l.jsx("div",{className:"text-cc-muted",children:n}),i&&l.jsx("div",{className:"text-cc-muted",children:i})]})}function nP({input:e}){const t=typeof e.plan=="string"?e.plan:"",n=Array.isArray(e.allowedPrompts)?e.allowedPrompts:[];return l.jsxs("div",{className:"space-y-2",children:[t&&l.jsxs("div",{className:"rounded-xl border border-cc-border overflow-hidden bg-cc-card",children:[l.jsxs("div",{className:"px-3 py-2 border-b border-cc-border bg-cc-primary/[0.04] flex items-center gap-2",children:[l.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded bg-cc-primary/15 text-cc-primary shrink-0",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:l.jsx("path",{d:"M3 3.5h10M3 8h10M3 12.5h6",strokeLinecap:"round"})})}),l.jsx("span",{className:"text-[11px] text-cc-primary font-semibold tracking-wide uppercase",children:"Plan"})]}),l.jsx("div",{className:"px-3 py-3 max-h-72 overflow-y-auto markdown-body text-[13px] text-cc-fg leading-relaxed",children:l.jsx(mv,{remarkPlugins:[wv],components:{h1:({children:i})=>l.jsx("h1",{className:"text-base font-semibold text-cc-fg mb-2",children:i}),h2:({children:i})=>l.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-1.5 mt-3 first:mt-0",children:i}),h3:({children:i})=>l.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-1.5 mt-2",children:i}),p:({children:i})=>l.jsx("p",{className:"mb-2 last:mb-0",children:i}),ul:({children:i})=>l.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:i}),ol:({children:i})=>l.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:i}),li:({children:i})=>l.jsx("li",{children:i}),strong:({children:i})=>l.jsx("strong",{className:"font-semibold text-cc-fg",children:i}),a:({href:i,children:a})=>l.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline",children:a}),code:i=>{const{children:a,className:o}=i;return/language-(\w+)/.exec(o||"")||typeof a=="string"&&a.includes(`
|
|
105
|
+
`).map(n=>n.trim()).find(n=>n.length>0);return t?t.length>B2?`${t.slice(0,B2)}…`:t:""}function aC(e,t){const n=wo(e,t);return{label:n?`${Hi(e)} · ${n}`:Hi(e),toolName:e}}function b9(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.type==="tool_use")return aC(n.name,n.input);if(n.type==="text"&&n.text.trim())return{label:bx(n.text),italic:!0};if(n.type==="thinking"&&n.thinking.trim())return{label:bx(n.thinking),italic:!0}}return null}function y9(e){var t;switch(e.kind){case"subagent":return{label:`Subagent · ${e.description||"Subagent"}`,toolName:"Task"};case"tool_msg_group":{const n=e.items[e.items.length-1];return n?aC(n.name,n.input):null}case"activity_run":return Rf(e).latest;case"message":{const n=e.msg;if(n.role==="system")return{label:n.content,italic:!0};const i=n.contentBlocks;return i&&i.length>0?b9(i)??{label:"Thinking…",italic:!0}:(t=n.content)!=null&&t.trim()?{label:bx(n.content),italic:!0}:{label:"Thinking…",italic:!0}}}}function lC(e){switch(e.kind){case"message":return[e.msg.timestamp,e.msg.timestamp];case"tool_msg_group":return[e.startedAt,e.endedAt];case"subagent":{let t=null,n=null;for(const i of e.children){const[a,o]=lC(i);a!==null&&(t===null||a<t)&&(t=a),o!==null&&(n===null||o>n)&&(n=o)}return[t,n]}case"activity_run":{const t=Rf(e);return[t.startedAt,t.endedAt]}}}function Rf(e,t){let n=0,i=0,a=0,o=null,u=null;for(const f of e.children){if(f.kind==="subagent")i++;else if(f.kind==="tool_msg_group")n+=f.items.length;else if(f.kind==="message")for(const v of f.msg.contentBlocks??[])v.type==="tool_use"&&n++,v.type==="tool_result"&&v.is_error&&a++;else{const v=Rf(f);n+=v.toolCalls,i+=v.subagents,a+=v.errors}const[p,g]=lC(f);p!==null&&(o===null||p<o)&&(o=p),g!==null&&(u===null||g>u)&&(u=g)}t!==void 0&&o!==null&&(u=Math.max(u??t,t));const h=e.children[e.children.length-1];return{toolCalls:n,subagents:i,errors:a,steps:e.children.length,startedAt:o,endedAt:u,latest:h?y9(h):null}}function _9({run:e,live:t,children:n}){const[i,a]=k.useState(!1),o=t?Date.now():void 0,u=k.useMemo(()=>Rf(e,o),[e,o]),h=u.startedAt!==null&&u.endedAt!==null?Math.max(0,u.endedAt-u.startedAt):null,f=[];u.toolCalls>0&&f.push(`${u.toolCalls} tool call${u.toolCalls===1?"":"s"}`),u.subagents>0&&f.push(`${u.subagents} subagent${u.subagents===1?"":"s"}`),u.errors>0&&f.push(l.jsxs("span",{className:"text-cc-error",children:[u.errors," error",u.errors===1?"":"s"]},"err")),h!==null&&h>=1e3&&f.push(po(h));const p=t?"Working":"Worked",g=`${u.steps} step${u.steps===1?"":"s"}`,v=u.latest;return l.jsxs("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]","data-activity-run":e.key,children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(Uh,{}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("button",{type:"button",onClick:()=>a(b=>!b),"aria-expanded":i,"aria-label":`${p}: ${g}, ${i?"collapse":"expand"} details`,className:"w-full flex items-center gap-1.5 py-0.5 text-left group cursor-pointer min-w-0",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:`w-2.5 h-2.5 shrink-0 text-cc-muted/40 group-hover:text-cc-muted/70 transition-transform duration-200 ${i?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx("span",{"aria-hidden":"true",className:`w-1.5 h-1.5 rounded-full shrink-0 ${t?"bg-cc-primary animate-[typing-breathe_1.5s_ease-in-out_infinite]":"bg-cc-success/60"}`}),l.jsx("span",{className:"text-[11px] font-medium text-cc-fg/70 shrink-0",children:p}),f.length>0&&l.jsx("span",{className:"text-[11px] text-cc-muted/60 font-mono-code truncate min-w-0 tabular-nums",children:f.map((b,y)=>l.jsxs("span",{children:[l.jsx("span",{className:"text-cc-muted/35",children:" · "}),b]},y))}),l.jsx("span",{className:"ml-auto text-[10px] text-cc-muted/40 group-hover:text-cc-muted/70 shrink-0 tabular-nums",children:i?"hide":g})]}),!i&&v&&l.jsxs("div",{role:"status",className:"flex items-center gap-1.5 pl-4 py-0.5 text-[11px] min-w-0",children:[v.toolName&&l.jsx(ol,{type:Lo(v.toolName)}),l.jsx("span",{className:`truncate min-w-0 ${v.italic?"italic text-cc-muted/60":"font-mono-code text-cc-muted/70"}`,children:v.label})]})]})]}),i&&l.jsx("div",{className:"mt-4 space-y-5 sm:space-y-7 animate-[fadeSlideIn_0.2s_ease-out]",children:n})]})}const Nh=100,w9=40,S9=120,F2=1e4,k9=15*6e4,g0=new Map,j9=[],N9=[];function C9(e){const t=e.split("/").filter(Boolean);return t.length===0?e:t.slice(-2).join("/")}function E9(e){if(e.role!=="assistant")return null;const t=e.contentBlocks;if(!t||t.length===0)return null;let n=null;for(const i of t){if(i.type==="text"&&i.text.trim()||i.type==="thinking")return null;if(i.type==="tool_use"){if(n===null)n=i.name;else if(n!==i.name)return null}}return n}function I2(e){return(e.contentBlocks||[]).filter(n=>n.type==="tool_use").map(n=>({id:n.id,name:n.name,input:n.input}))}function T9(e){return e.kind==="message"?(e.msg.contentBlocks||[]).filter(n=>n.type==="tool_use").filter(n=>n.name==="Task").map(n=>n.id):e.kind==="tool_msg_group"&&e.toolName==="Task"?e.items.map(t=>t.id):[]}function oC(e){const t=[];for(const n of e){const i=E9(n);if(i){const a=t[t.length-1];if((a==null?void 0:a.kind)==="tool_msg_group"&&a.toolName===i){a.items.push(...I2(n)),a.endedAt=Math.max(a.endedAt,n.timestamp);continue}t.push({kind:"tool_msg_group",toolName:i,items:I2(n),firstId:n.id,startedAt:n.timestamp,endedAt:n.timestamp})}else t.push({kind:"message",msg:n})}return t}function cC(e,t,n){const i=oC(e),a=[];for(const o of i){a.push(o);const u=T9(o);for(const h of u){const f=n.get(h);if(f&&f.length>0){const p=t.get(h)||{description:"Subagent",agentType:""},g=cC(f,t,n);a.push({kind:"subagent",taskToolUseId:h,description:p.description,agentType:p.agentType,backend:p.backend,status:p.status,receiverCount:p.receiverCount,senderThreadId:p.senderThreadId,receiverThreadIds:p.receiverThreadIds,children:g})}}}return a}function M9(e){const t=new Map;for(const a of e)if(a.contentBlocks){for(const o of a.contentBlocks)if(o.type==="tool_use"&&o.name==="Task"){const{input:u,id:h}=o,f=Array.isArray(u==null?void 0:u.receiver_thread_ids)?u.receiver_thread_ids.filter(b=>typeof b=="string"&&b.length>0):void 0,p=f&&f.length>0?f.length:void 0,g=typeof(u==null?void 0:u.sender_thread_id)=="string"&&u.sender_thread_id.length>0?u.sender_thread_id:void 0,v=typeof(u==null?void 0:u.codex_status)=="string"||g!==void 0||p!==void 0;t.set(h,{description:String((u==null?void 0:u.description)||"Subagent"),agentType:String((u==null?void 0:u.subagent_type)||""),backend:v?"codex":"claude",status:typeof(u==null?void 0:u.codex_status)=="string"?u.codex_status:void 0,receiverCount:p,senderThreadId:g,receiverThreadIds:f})}}if(t.size===0)return oC(e);const n=new Map,i=[];for(const a of e)if(a.parentToolUseId&&t.has(a.parentToolUseId)){let o=n.get(a.parentToolUseId);o||(o=[],n.set(a.parentToolUseId,o)),o.push(a)}else i.push(a);return cC(i,t,n)}function A9({group:e}){const[t,n]=k.useState(!1),i=Lo(e.toolName),a=Hi(e.toolName),o=e.items.length;if(o===1){const u=e.items[0];return l.jsx("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(U2,{}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"border border-cc-border rounded-[10px] overflow-hidden bg-cc-card tool-card",children:[l.jsxs("button",{onClick:()=>n(!t),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx(ol,{type:i}),l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:a}),l.jsx("span",{className:"text-xs text-cc-muted truncate flex-1 font-mono-code",children:wo(u.name,u.input)})]}),t&&l.jsx("div",{className:"px-3 pb-3 pt-0 border-t border-cc-border mt-0",children:l.jsx("pre",{className:"mt-2 text-[11px] text-cc-muted font-mono-code whitespace-pre-wrap leading-relaxed max-h-60 overflow-y-auto",children:JSON.stringify(u.input,null,2)})})]})})]})})}return l.jsx("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(U2,{}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsxs("div",{className:"border border-cc-border rounded-[10px] overflow-hidden bg-cc-card tool-card",children:[l.jsxs("button",{onClick:()=>n(!t),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-cc-hover transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 text-cc-muted transition-transform shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx(ol,{type:i}),l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:a}),l.jsx("span",{className:"text-[10px] text-cc-muted bg-cc-hover rounded-full px-1.5 py-0.5 tabular-nums font-medium",children:o})]}),t&&l.jsx("div",{className:"border-t border-cc-border px-3 py-1.5",children:e.items.map((u,h)=>{const f=wo(u.name,u.input);return l.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-cc-muted font-mono-code truncate",children:[l.jsx("span",{className:"w-1 h-1 rounded-full bg-cc-muted/40 shrink-0"}),l.jsx("span",{className:"truncate",children:f||JSON.stringify(u.input).slice(0,80)})]},u.id||h)})})]})})]})})}function kv({entries:e,toolActivity:t,liveRunKey:n}){return l.jsx(l.Fragment,{children:e.map((i,a)=>{if(i.kind==="activity_run")return l.jsx(_9,{run:i,live:i.key===n,children:l.jsx(kv,{entries:i.children,toolActivity:t})},i.key);if(i.kind==="tool_msg_group")return l.jsx(A9,{group:i},i.firstId||a);if(i.kind==="subagent")return l.jsx(L9,{group:i},i.taskToolUseId);const o=i.msg,u=R9(o),h=t&&u.length>0?t.filter(p=>u.includes(p.toolUseId)):[],f=h.length>0&&h.every(p=>p.completedAt);return l.jsxs("div",{children:[l.jsx(e9,{message:o}),f&&l.jsx(h9,{entries:h})]},o.id)})})}function R9(e){var t;return(t=e.contentBlocks)!=null&&t.length?e.contentBlocks.filter(n=>n.type==="tool_use").map(n=>n.id):[]}function O9(e){if(!e)return null;const t=e.trim().toLowerCase();return t?t==="completed"?{label:"completed",summaryLabel:"completed",className:"text-green-600 bg-green-500/15"}:t==="failed"||t==="error"||t==="errored"?{label:"failed",summaryLabel:"failed",className:"text-cc-error bg-cc-error/10"}:t==="pending"||t==="pendinginit"||t==="pending_init"?{label:"pending",summaryLabel:"pending",className:"text-amber-700 bg-amber-500/15"}:t==="running"||t==="inprogress"||t==="in_progress"||t==="started"?{label:"running",summaryLabel:"running",className:"text-blue-600 bg-blue-500/15"}:{label:e,summaryLabel:"running",className:"text-amber-700 bg-amber-500/15"}:null}function L9({group:e}){const[t,n]=k.useState(!1),i=e.description||"Subagent",a=e.agentType,o=e.children.length,u=O9(e.status),h=e.receiverCount,f=e.senderThreadId,p=e.receiverThreadIds||[],g=e.backend||"claude",v=e.children[e.children.length-1],b=k.useMemo(()=>{var y,_;if(!v)return"";if(v.kind==="tool_msg_group")return`${Hi(v.toolName)}${v.items.length>1?` ×${v.items.length}`:""}`;if(v.kind==="message"&&v.msg.role==="assistant"){const j=(y=v.msg.content)==null?void 0:y.trim();if(j)return j.length>60?j.slice(0,60)+"...":j;const N=(_=v.msg.contentBlocks)==null?void 0:_.find(S=>S.type==="tool_use");if(N)return Hi(N.name)}return""},[v]);return l.jsx("div",{className:"animate-[fadeSlideIn_0.3s_ease-out]",children:l.jsxs("div",{className:"ml-10 border-l border-cc-border/50 pl-4",children:[l.jsxs("button",{type:"button",onClick:()=>n(!t),className:"relative z-10 flex items-center gap-1.5 py-1 text-left cursor-pointer group w-full",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-2.5 h-2.5 text-cc-muted/40 group-hover:text-cc-muted/70 transition-transform shrink-0 ${t?"rotate-90":""}`,children:l.jsx("path",{d:"M6 4l4 4-4 4"})}),l.jsx("span",{className:"text-[11px] font-medium text-cc-primary/70",children:i}),a&&l.jsx("span",{className:"text-[10px] text-cc-muted/50",children:a}),l.jsx("span",{className:"text-[10px] text-cc-muted/40",children:g==="codex"?"Codex":"Claude"}),u&&l.jsx("span",{className:`text-[10px] ${u.className}`,children:u.label}),h!==void 0&&l.jsxs("span",{className:"text-[10px] text-cc-muted/40",children:[h," agent",h===1?"":"s"]}),!t&&b&&l.jsx("span",{className:"text-[11px] text-cc-muted/40 truncate ml-1 font-mono-code",children:b}),l.jsx("span",{className:"text-[10px] text-cc-muted/40 tabular-nums shrink-0 ml-auto",children:o})]}),t&&l.jsxs("div",{className:"space-y-3 pb-2 mt-1",children:[(f||p.length>0)&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-cc-muted/50 pl-4",children:[f&&l.jsxs("span",{className:"font-mono-code",children:["sender: ",f]}),p.length>0&&l.jsxs("span",{children:["receivers: ",p.map(y=>l.jsx("span",{className:"font-mono-code ml-1",children:y},y))]})]}),l.jsx(kv,{entries:e.children})]})]})})}function U2(){return l.jsx("div",{className:"w-7 h-7 rounded-full avatar-ring flex items-center justify-center shrink-0 mt-0.5",children:l.jsx("div",{className:"avatar-inner w-full h-full rounded-full flex items-center justify-center",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-primary",children:l.jsx("path",{d:"M8 2L10.5 6.5L15 8L10.5 9.5L8 14L5.5 9.5L1 8L5.5 6.5L8 2Z"})})})})}function D9({sessionId:e}){var Zt;const t=W(ie=>ie.messages.get(e)??j9),n=W(ie=>(ie.sdkSessions||N9).find(ke=>ke.sessionId===e)),i=W(ie=>ie.streamingStartedAt.get(e)),a=W(ie=>ie.streamingOutputTokens.get(e)),o=W(ie=>ie.sessionStatus.get(e)),u=W(ie=>ie.lastActivityAt.get(e)),h=W(ie=>ie.sessionProcesses.get(e)),f=W(ie=>ie.toolProgress.get(e)),p=W(ie=>ie.toolActivity.get(e)),g=k.useRef(null),v=k.useRef(null),b=k.useRef(!0),[y,_]=k.useState(0),[j,N]=k.useState(Nh),[S,C]=k.useState([]),[E,R]=k.useState(0),[A,O]=k.useState(!1),[P,z]=k.useState(!1),[Z,I]=k.useState(!1),[q,L]=k.useState(""),de=k.useRef(new Set),Q=W(ie=>ie.chatTabReentryTickBySession.get(e)??0),V=k.useMemo(()=>t.some(ie=>ie.role==="assistant"&&ie.isStreaming),[t]),G=k.useMemo(()=>(h??[]).filter(ie=>ie.status==="running"),[h]),H=G.length>0,ae=k.useMemo(()=>{const ie=p??[];for(let ke=ie.length-1;ke>=0;ke--)if(!ie[ke].completedAt)return ie[ke]},[p]),ye=k.useMemo(()=>G.length>0?Math.min(...G.map(ie=>ie.startedAt)):null,[G]),T=k.useMemo(()=>(n==null?void 0:n.backendType)==="codex"?"":((n==null?void 0:n.resumeSessionAt)||"").trim(),[n==null?void 0:n.backendType,n==null?void 0:n.resumeSessionAt]),Ne=T.length>0,Ce=n!=null&&n.forkSession?"Forked from":"Continuing from",$=k.useMemo(()=>{if(S.length===0)return t;const ie=[],ke=new Set;for(const Qe of S)ke.has(Qe.id)||(ke.add(Qe.id),ie.push(Qe));for(const Qe of t)ke.has(Qe.id)||(ke.add(Qe.id),ie.push(Qe));return ie},[S,t]),B=k.useMemo(()=>M9($),[$]);k.useEffect(()=>{N(Nh),C([]),R(0),O(!1),z(!1),I(!1),L(""),de.current=new Set},[e,T]);const oe=B.length,be=oe>j,je=k.useMemo(()=>be?B.slice(oe-j):B,[B,be,oe,j]),Ee=oe-je.length,Be=va(),Oe=k.useMemo(()=>Be?v9(je):je,[Be,je]),Te=Oe[Oe.length-1],Re=o==="running"&&(Te==null?void 0:Te.kind)==="activity_run"?Te.key:void 0,Ft=k.useCallback(()=>{const ie=v.current,ke=(ie==null?void 0:ie.scrollHeight)??0;N(Qe=>Qe+Nh),requestAnimationFrame(()=>{if(ie){const Qe=ie.scrollHeight;ie.scrollTop+=Qe-ke}})},[]),vn=k.useCallback(async(ie={})=>{if(!Ne||!T||Z)return;const ke=v.current,Qe=(ke==null?void 0:ke.scrollHeight)??0,nt=P?E:0;I(!0),L("");try{const Kt=await we.getClaudeSessionHistory(T,{cursor:nt,limit:w9}),It=Kt.messages.map(U=>({id:U.id,role:U.role,content:U.content,contentBlocks:U.role==="assistant"?U.contentBlocks:void 0,timestamp:U.timestamp||Date.now(),model:U.role==="assistant"?U.model:void 0,stopReason:U.role==="assistant"?U.stopReason:void 0})),ce=[];for(const U of It)de.current.has(U.id)||(de.current.add(U.id),ce.push(U));C(U=>[...ce,...U]),R(Kt.nextCursor),O(Kt.hasMore),z(!0),ce.length>0&&N(U=>U+ce.length),ie.preserveScroll!==!1&&ke&&requestAnimationFrame(()=>{const U=ke.scrollHeight;ke.scrollTop+=U-Qe})}catch(Kt){const It=Kt instanceof Error?Kt.message:String(Kt);L(It||"Failed to load previous history"),P||(C([]),R(0),O(!1))}finally{I(!1)}},[Ne,T,Z,P,E]);k.useEffect(()=>{if(!i&&o!=="running"&&!H){_(0);return}const ie=i||Date.now();_(Date.now()-ie);const ke=setInterval(()=>_(Date.now()-ie),1e3);return()=>clearInterval(ke)},[i,o,H]);function Vt(){const ie=v.current;if(!ie)return;b.current=ie.scrollHeight-ie.scrollTop-ie.clientHeight<120;const ke=Math.max(0,ie.scrollHeight-ie.clientHeight-ie.scrollTop);g0.set(e,ke),Ne&&P&&A&&!Z&&ie.scrollTop<=S9&&vn({preserveScroll:!0})}const St=k.useCallback(()=>{const ie=v.current;if(!ie)return;const ke=ie.style.scrollBehavior;ie.style.scrollBehavior="auto",ie.scrollTop=ie.scrollHeight,ie.style.scrollBehavior=ke},[]),wt=k.useCallback(()=>{const ie=v.current;if(!ie)return;const ke=ie.style.scrollBehavior;ie.style.scrollBehavior="auto";const Qe=g0.get(e);typeof Qe=="number"?ie.scrollTop=Math.max(0,ie.scrollHeight-ie.clientHeight-Qe):ie.scrollTop=ie.scrollHeight,ie.style.scrollBehavior=ke},[e]);if(k.useEffect(()=>{requestAnimationFrame(()=>wt())},[e,wt]),k.useEffect(()=>()=>{const ie=v.current;if(!ie)return;const ke=Math.max(0,ie.scrollHeight-ie.clientHeight-ie.scrollTop);g0.set(e,ke)},[e]),k.useEffect(()=>{Q&&requestAnimationFrame(()=>St())},[Q,St]),k.useEffect(()=>{var ie;b.current&&((ie=g.current)==null||ie.scrollIntoView({behavior:"smooth"}))},[t]),$.length===0)return l.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 select-none px-6",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-cc-primary/10 to-cc-primary/5 border border-cc-primary/15 flex items-center justify-center shadow-[0_4px_20px_rgba(217,119,87,0.08)]",children:l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-7 h-7 text-cc-primary",children:[l.jsx("polyline",{points:"4 17 10 11 4 5"}),l.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),l.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 text-cc-primary/40 animate-[gentle-bounce_2s_ease-in-out_infinite]",children:l.jsx("path",{d:"M8 2L10.5 6.5L15 8L10.5 9.5L8 14L5.5 9.5L1 8L5.5 6.5L8 2Z"})})})]}),l.jsx("div",{className:"text-center max-w-xs",children:Ne?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-cc-fg font-medium mb-1.5",children:"This session has prior context"}),l.jsxs("p",{className:"text-xs text-cc-muted leading-relaxed mb-4",children:[Ce," ",l.jsx("span",{className:"font-mono-code text-cc-fg/70",children:T.slice(0,8)}),". Load earlier messages when needed."]}),l.jsxs("button",{onClick:()=>void vn({preserveScroll:!1}),disabled:Z,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium text-cc-fg bg-cc-card border border-cc-border rounded-xl hover:bg-cc-hover hover:border-cc-primary/20 transition-all disabled:opacity-60 disabled:cursor-not-allowed cursor-pointer shadow-[0_2px_8px_rgba(0,0,0,0.04)]",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M8 2v12M3 9l5 5 5-5",strokeLinecap:"round",strokeLinejoin:"round"})}),Z?"Loading...":"Load previous history"]}),q&&l.jsx("p",{className:"text-xs text-cc-error mt-2",children:q})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[15px] text-cc-fg font-medium mb-1.5",children:"Start a conversation"}),l.jsx("p",{className:"text-xs text-cc-muted leading-relaxed",children:"Send a message to begin working with The Companion."})]})})]});const We=o==="running"&&u!=null?Math.max(0,Date.now()-u):0,xt=H&&(o!=="running"||We>=F2)?"background":We>=k9&&!ae?"stalled":We>=F2?"quiet":"active";return l.jsxs("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:[l.jsx("div",{className:"pointer-events-none absolute top-0 inset-x-0 h-6 bg-gradient-to-b from-cc-bg to-transparent z-10"}),l.jsx("div",{ref:v,onScroll:Vt,className:"h-full overflow-y-auto overflow-x-hidden overscroll-y-contain px-4 sm:px-6 py-5 sm:py-8",children:l.jsxs("div",{className:"max-w-3xl mx-auto space-y-5 sm:space-y-7",children:[Ne&&!P&&l.jsxs("div",{className:"rounded-xl border border-cc-border bg-cc-card p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs font-medium text-cc-fg",children:[Ce," existing Claude thread"]}),l.jsxs("p",{className:"text-[11px] text-cc-muted mt-1",children:[T," ",n!=null&&n.cwd?`· ${C9(n.cwd)}`:""]})]}),l.jsx("button",{onClick:()=>void vn({preserveScroll:!0}),disabled:Z,className:"shrink-0 inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-cc-fg bg-cc-card border border-cc-border rounded-lg hover:bg-cc-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed cursor-pointer",children:Z?"Loading...":"Load previous history"})]}),q&&l.jsx("p",{className:"text-xs text-cc-error mt-2",children:q})]}),Ne&&P&&l.jsx("div",{className:"flex justify-center",children:l.jsx("p",{className:"text-[11px] text-cc-muted",children:A?Z?"Loading older transcript...":"Scroll to top to load older transcript":"Loaded all available prior transcript"})}),be&&l.jsx("div",{className:"flex justify-center pb-3",children:l.jsxs("button",{onClick:Ft,className:"flex items-center gap-2 px-4 py-2 text-xs font-medium text-cc-muted hover:text-cc-fg bg-cc-card border border-cc-border rounded-xl hover:bg-cc-hover hover:border-cc-primary/20 transition-all cursor-pointer shadow-[0_2px_6px_rgba(0,0,0,0.03)]",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M8 3v10M3 8l5-5 5 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Load ",Math.min(Nh,Ee)," more",l.jsxs("span",{className:"text-cc-muted/50 tabular-nums",children:["(",Ee," hidden)"]})]})}),l.jsx(kv,{entries:Oe,toolActivity:p,liveRunKey:Re}),f&&f.size>0&&!V&&l.jsx(d9,{tools:Array.from(f.values())}),o==="compacting"&&l.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-cc-warning font-mono-code pl-10 py-1",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6",opacity:"0.2"}),l.jsx("path",{d:"M8 2a6 6 0 0 1 6 6",strokeLinecap:"round"})]}),l.jsx("span",{children:"Compacting context..."})]}),(o==="running"||H)&&y>=0&&l.jsxs("div",{"data-testid":"activity-indicator","data-activity-tier":xt,className:`flex items-center gap-2 text-[11px] font-mono-code pl-10 stats-glow py-1 ${xt==="stalled"?"text-cc-warning":"text-cc-muted"}`,children:[l.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${xt==="stalled"?"bg-cc-warning animate-[typing-breathe_1.5s_ease-in-out_infinite]":"bg-cc-primary animate-[typing-breathe_1.5s_ease-in-out_infinite]"}`}),xt==="background"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-fg/70",children:G.length===1?"Background process running":`${G.length} background processes running`}),ye!=null&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"tabular-nums",children:po(Math.max(0,Date.now()-ye))})]}),((Zt=G[0])==null?void 0:Zt.description)&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"truncate max-w-[24ch]",children:G[0].description})]})]}):xt==="stalled"?l.jsxs("span",{children:["No activity for ",po(We)," — the agent may be stuck"]}):xt==="quiet"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-fg/70",children:ae?`Running ${ae.toolName}`:"Still working…"}),l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"tabular-nums",children:ae?po(Math.max(0,Date.now()-ae.startedAt)):`no update for ${po(We)}`}),(ae==null?void 0:ae.preview)&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"truncate max-w-[32ch]",children:ae.preview})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-fg/70",children:"Generating"}),l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsx("span",{className:"tabular-nums",children:po(y)}),(a??0)>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-cc-muted/30",children:"|"}),l.jsxs("span",{className:"tabular-nums",children:[ru(a)," tokens"]})]})]})]}),l.jsx("div",{ref:g})]})})]})}const z9={codex:"✳",xhigh:"★",max:"■",mini:"⚡"};function $9(e,t){for(const[i,a]of Object.entries(z9))if(e.includes(i))return a;const n=["◆","●","◕","✦"];return n[t%n.length]}function P9(e){return e.map((t,n)=>({value:t.value,label:t.label||t.value,icon:$9(t.value,n)}))}const uC=[{value:"claude-opus-5-5",label:"Opus 5.5",icon:""},{value:"claude-opus-5",label:"Opus 5",icon:""},{value:"claude-opus-4-8",label:"Opus 4.8",icon:""},{value:"claude-fable-5-1",label:"Fable 5.1",icon:"★"},{value:"claude-fable-5",label:"Fable 5",icon:"★"},{value:"claude-opus-4-7",label:"Opus 4.7",icon:""},{value:"claude-opus-4-6",label:"Opus 4.6",icon:""},{value:"claude-sonnet-5-5",label:"Sonnet 5.5",icon:""},{value:"claude-sonnet-5",label:"Sonnet 5",icon:""},{value:"claude-haiku-5-5",label:"Haiku 5.5",icon:""},{value:"claude-haiku-4-5-20251001",label:"Haiku 4.5",icon:""}],dC=[{value:"gpt-6-astra",label:"GPT-6-Astra",icon:"✦"},{value:"gpt-5.6-sol",label:"GPT-5.6-Sol",icon:"■"},{value:"gpt-5.6-terra",label:"GPT-5.6-Terra",icon:"✳"},{value:"gpt-5.6-luna",label:"GPT-5.6-Luna",icon:"⚡"},{value:"gpt-5.5",label:"GPT-5.5",icon:"◆"},{value:"gpt-5.2",label:"GPT-5.2",icon:"●"}],jv=[{value:"bypassPermissions",label:"Agent"},{value:"plan",label:"Plan"}],Nv=[{value:"bypassPermissions",label:"Auto"},{value:"plan",label:"Plan"}],B9=[{value:"",label:"Default"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"xHigh"},{value:"max",label:"Max"}],hC=[{value:"bypassPermissions",label:"Full Auto"},{value:"acceptEdits",label:"Auto-Edit"},{value:"default",label:"Supervised"}],fC=[{value:"bypassPermissions",label:"Full Auto"},{value:"default",label:"Supervised"}];function pC(e){return e==="codex"?dC:uC}function H2(e){return e==="codex"?Nv:jv}function hF(e){return e==="codex"?fC:hC}function q2(e){return e==="codex"?dC[0].value:uC[0].value}function V2(e){return e==="codex"?Nv[0].value:jv[0].value}function fF(e){return e==="codex"?fC[0].value:hC[0].value}function F9(e){return e==="codex"?[]:B9}function G2({sessionId:e}){const[t,n]=k.useState(!1),i=k.useRef(null),a=W(b=>b.sdkSessions.find(y=>y.sessionId===e)||null),o=W(b=>b.sessions.get(e)),u=W(b=>b.cliConnected.get(e)??!1),h=(a==null?void 0:a.backendType)??(o==null?void 0:o.backend_type)??"claude",f=(o==null?void 0:o.model)??(a==null?void 0:a.model)??"",p=pC(h),g=p.find(b=>b.value===f)||(f?{label:f,icon:"?"}:null),v=k.useCallback(b=>{if(n(!1),b===f)return;Xn(e,{type:"set_model",model:b});const{sdkSessions:y,setSdkSessions:_}=W.getState();_(y.map(j=>j.sessionId===e?{...j,model:b}:j))},[e,f]);return k.useEffect(()=>{if(!t)return;const b=y=>{i.current&&!i.current.contains(y.target)&&n(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[t]),k.useEffect(()=>{if(!t)return;const b=y=>{y.key==="Escape"&&n(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]),!u||!g?null:l.jsxs("div",{ref:i,className:"relative shrink-0",children:[l.jsxs("button",{onClick:()=>n(b=>!b),className:`flex items-center gap-1 h-8 px-2 rounded-md text-[12px] font-medium transition-colors cursor-pointer ${t?"text-cc-fg bg-cc-active":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,title:`Current model: ${g.label}`,"aria-label":"Switch model","aria-expanded":t,"aria-haspopup":"listbox",children:[g.icon&&l.jsx("span",{className:"text-[13px] leading-none",children:g.icon}),l.jsx("span",{children:g.label}),l.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor",className:"w-2.5 h-2.5 opacity-50",children:l.jsx("path",{d:"M6 8L1.5 3.5h9L6 8z"})})]}),t&&l.jsx("div",{className:"absolute right-0 bottom-full mb-1 z-50 min-w-[160px] rounded-lg border border-cc-separator bg-cc-bg shadow-lg overflow-hidden",role:"listbox","aria-label":"Select model",children:p.map(b=>l.jsxs("button",{onClick:()=>v(b.value),className:`w-full flex items-center gap-2 px-3 min-h-[44px] text-[13px] transition-colors cursor-pointer ${b.value===f?"text-cc-fg bg-cc-active font-medium":"text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,role:"option","aria-selected":b.value===f,children:[b.icon&&l.jsx("span",{className:"text-[14px] leading-none w-5 text-center",children:b.icon}),l.jsx("span",{className:"flex-1 text-left",children:b.label}),b.value===f&&l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-primary shrink-0",children:l.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})]},b.value))})]})}function mC({open:e,loading:t,prompts:n,selectedIndex:i,onSelect:a,menuRef:o,className:u=""}){return e?l.jsx("div",{ref:o,className:`max-h-[240px] overflow-y-auto bg-cc-card border border-cc-border rounded-[10px] shadow-lg z-20 py-1 ${u}`,children:t?l.jsx("div",{className:"px-3 py-2 text-[12px] text-cc-muted",children:"Searching prompts..."}):n.length>0?n.map((h,f)=>l.jsxs("button",{"data-prompt-index":f,onClick:()=>a(h),className:`w-full px-3 py-2 text-left flex items-center gap-2.5 transition-colors cursor-pointer ${f===i?"bg-cc-hover":"hover:bg-cc-hover/50"}`,children:[l.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-cc-hover text-cc-muted shrink-0",children:l.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[l.jsx("path",{d:"M2.5 8a5.5 5.5 0 1111 0v3a2.5 2.5 0 01-2.5 2.5h-1",strokeLinecap:"round"}),l.jsx("circle",{cx:"8",cy:"8",r:"1.75",fill:"currentColor",stroke:"none"})]})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-[13px] font-medium text-cc-fg truncate",children:["@",h.name]}),l.jsx("div",{className:"text-[11px] text-cc-muted truncate",children:h.content})]}),l.jsx("span",{className:"text-[10px] text-cc-muted shrink-0",children:h.scope})]},h.id)):l.jsx("div",{className:"px-3 py-2 text-[12px] text-cc-muted",children:"No prompts found."})}):null}function gC({text:e,caretPos:t,cwd:n,enabled:i=!0}){const[a,o]=k.useState(!1),[u,h]=k.useState(0),[f,p]=k.useState([]),[g,v]=k.useState(!1),b=k.useRef(null),y=k.useCallback(async()=>{v(!0);try{const S=await we.listPrompts(n);p(S.filter(C=>!!C.name.trim()))}catch{p([])}finally{v(!1)}},[n]);k.useEffect(()=>{y()},[y]);const _=k.useMemo(()=>{const S=e.slice(0,t),C=S.match(/(^|\s)@([^\s@]*)$/);if(!C||C.index===void 0)return null;const E=S.length-C[0].length+C[1].length;return{query:C[2]||"",start:E,end:t}},[e,t]),j=k.useMemo(()=>{if(!a||!_)return[];const S=_.query.toLowerCase();if(!S)return f;const C=f.filter(R=>R.name.toLowerCase().startsWith(S)),E=f.filter(R=>!R.name.toLowerCase().startsWith(S)&&R.name.toLowerCase().includes(S));return[...C,...E]},[a,_,f]);k.useEffect(()=>{const S=i&&!!_;S&&!a?(o(!0),h(0)):!S&&a&&o(!1)},[i,_,a]),k.useEffect(()=>{u>=j.length&&h(Math.max(0,j.length-1))},[j.length,u]),k.useEffect(()=>{if(!b.current||!a)return;const C=b.current.querySelectorAll("[data-prompt-index]")[u];C&&C.scrollIntoView({block:"nearest"})},[u,a]);const N=k.useCallback(S=>{if(!_)return{nextText:e,nextCursor:t};const C=`${S.content} `,E=`${e.slice(0,_.start)}${C}${e.slice(_.end)}`,R=_.start+C.length;return{nextText:E,nextCursor:R}},[_,e,t]);return{mentionMenuOpen:a,setMentionMenuOpen:o,mentionMenuIndex:u,setMentionMenuIndex:h,mentionContext:_,filteredPrompts:j,promptsLoading:g,savedPrompts:f,selectPrompt:N,refreshPrompts:y,mentionMenuRef:b}}const I9=[];function Y2({isPlan:e,isConnected:t,onToggle:n,modeLabel:i,size:a}){const o=a==="desktop",u=o?"px-2.5 py-1.5":"px-2 py-1",h=o?"text-cc-primary border-cc-primary/30 bg-cc-primary/8 hover:bg-cc-primary/12 cursor-pointer":"text-cc-primary border-cc-primary/30 bg-cc-primary/8",f=o?"text-cc-muted border-cc-border hover:text-cc-fg hover:bg-cc-hover cursor-pointer":"text-cc-muted border-cc-border";return l.jsxs("button",{onClick:n,disabled:!t,className:`flex items-center gap-1.5 ${u} rounded-md text-[12px] font-semibold transition-all border select-none shrink-0 ${t?e?h:f:"opacity-30 cursor-not-allowed text-cc-muted border-transparent"}`,title:"Toggle mode (Shift+Tab)",children:[e?l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[l.jsx("rect",{x:"3",y:"3",width:"3.5",height:"10",rx:"0.75"}),l.jsx("rect",{x:"9.5",y:"3",width:"3.5",height:"10",rx:"0.75"})]}):l.jsxs("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:[l.jsx("path",{d:"M2.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),l.jsx("path",{d:"M8.5 4l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}),l.jsx("span",{children:i})]})}function Ch({onClick:e,disabled:t,active:n,title:i,children:a}){return l.jsx("button",{onClick:e,disabled:t,className:`flex items-center justify-center w-8 h-8 rounded-md transition-colors ${n?"text-cc-muted hover:text-cc-fg hover:bg-cc-hover cursor-pointer":"text-cc-muted opacity-30 cursor-not-allowed"}`,title:i,children:a})}function X2(){return l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:l.jsx("path",{d:"M4 2.75h8A1.25 1.25 0 0113.25 4v9.25L8 10.5l-5.25 2.75V4A1.25 1.25 0 014 2.75z"})})}function Q2({isRunning:e,canSend:t,onSend:n,onInterrupt:i,size:a}){const o=a==="desktop",u=o?"w-9 h-9":"w-10 h-10",h=o?"bg-cc-primary hover:bg-cc-primary-hover hover:scale-105 text-white cursor-pointer shadow-[0_4px_16px_rgba(217,119,87,0.25)]":"bg-cc-primary hover:bg-cc-primary-hover active:scale-95 text-white cursor-pointer shadow-[0_4px_16px_rgba(217,119,87,0.25)]";return e?l.jsx("button",{onClick:i,className:`flex items-center justify-center ${u} rounded-lg bg-cc-error/10 hover:bg-cc-error/20 text-cc-error transition-colors cursor-pointer`,title:"Stop generation",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}):l.jsx("button",{onClick:n,disabled:!t,className:`flex items-center justify-center ${u} rounded-full transition-all duration-200 ${t?h:"bg-cc-hover text-cc-muted cursor-not-allowed"}`,title:"Send message",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M3 2l11 6-11 6V9.5l7-1.5-7-1.5V2z"})})})}function U9({sessionId:e}){var It,ce;const[t,n]=k.useState(""),[i,a]=k.useState([]),[o,u]=k.useState(null),[h,f]=k.useState(!1),[p,g]=k.useState(!1),[v,b]=k.useState(0),[y,_]=k.useState(!1),[j,N]=k.useState(""),[S,C]=k.useState("global"),[E,R]=k.useState(null),[A,O]=k.useState(0),P=k.useRef(null),z=k.useRef(null),Z=k.useRef(null),I=k.useRef(null),q=W(U=>U.cliConnected),L=W(U=>U.sessions.get(e)),de=W(U=>U.previousPermissionMode.get(e)||"acceptEdits"),Q=q.get(e)??!1,V=(L==null?void 0:L.permissionMode)||"acceptEdits",G=V==="plan",H=(L==null?void 0:L.backend_type)==="codex",ye=((ce=(It=(H?Nv:jv).find(U=>U.value===V))==null?void 0:It.label)==null?void 0:ce.toLowerCase())||V,T=gC({text:t,caretPos:A,cwd:L==null?void 0:L.cwd,enabled:!p}),Ne=k.useMemo(()=>{const U=[];if(L!=null&&L.slash_commands)for(const fe of L.slash_commands)U.push({name:fe,type:"command"});if(L!=null&&L.skills)for(const fe of L.skills)U.push({name:fe,type:"skill"});return U},[L==null?void 0:L.slash_commands,L==null?void 0:L.skills]),Ce=k.useMemo(()=>{if(!p)return[];const U=t.match(/^\/(\S*)$/);if(!U)return[];const fe=U[1].toLowerCase();return fe===""?Ne:Ne.filter(Ae=>Ae.name.toLowerCase().includes(fe))},[t,p,Ne]);k.useEffect(()=>{const U=t.startsWith("/")&&/^\/\S*$/.test(t)&&Ne.length>0;U&&!p?(g(!0),b(0)):!U&&p&&g(!1)},[t,Ne.length,p]),k.useEffect(()=>{v>=Ce.length&&b(Math.max(0,Ce.length-1))},[Ce.length,v]),k.useEffect(()=>{if(!Z.current||!p)return;const fe=Z.current.querySelectorAll("[data-cmd-index]")[v];fe&&fe.scrollIntoView({block:"nearest"})},[v,p]),k.useEffect(()=>{if(I.current===null||!P.current)return;const U=I.current;P.current.setSelectionRange(U,U),I.current=null},[t]);const $=k.useCallback(U=>{var fe;n(`/${U.name} `),g(!1),(fe=P.current)==null||fe.focus()},[]),B=k.useCallback(U=>{var Ae;const fe=T.selectPrompt(U);I.current=fe.nextCursor,n(fe.nextText),T.setMentionMenuOpen(!1),O(fe.nextCursor),(Ae=P.current)==null||Ae.focus(),P.current&&(P.current.style.height="auto",P.current.style.height=Math.min(P.current.scrollHeight,200)+"px")},[T]);function oe(){var ze;const U=t.trim();if(!U||!Q)return;const fe=k0(),Ae=i.length>0?i.map(st=>({name:st.name,media_type:st.mediaType,data:st.base64,size:st.size})):void 0;Xn(e,{type:"user_message",content:U,session_id:e,attachments:Ae,client_msg_id:fe});const tt=W.getState();tt.appendMessage(e,{id:fe,role:"user",content:U,attachments:Ae,timestamp:Date.now()}),tt.setSessionStatus(e,"running"),tt.setLastActivity(e,Date.now()),tt.streamingStartedAt.has(e)||tt.setStreamingStats(e,{startedAt:Date.now()}),n(""),a([]),u(null),g(!1),T.setMentionMenuOpen(!1),P.current&&(P.current.style.height="auto"),(ze=P.current)==null||ze.focus()}function be(U){if(p&&Ce.length>0){if(U.key==="ArrowDown"){U.preventDefault(),b(fe=>(fe+1)%Ce.length);return}if(U.key==="ArrowUp"){U.preventDefault(),b(fe=>(fe-1+Ce.length)%Ce.length);return}if(U.key==="Tab"&&!U.shiftKey){U.preventDefault(),$(Ce[v]);return}if(U.key==="Enter"&&!U.shiftKey){U.preventDefault(),$(Ce[v]);return}if(U.key==="Escape"){U.preventDefault(),g(!1);return}}if(T.mentionMenuOpen&&U.key==="Escape"){U.preventDefault(),T.setMentionMenuOpen(!1);return}if(T.mentionMenuOpen&&T.filteredPrompts.length>0){if(U.key==="ArrowDown"){U.preventDefault(),T.setMentionMenuIndex(fe=>(fe+1)%T.filteredPrompts.length);return}if(U.key==="ArrowUp"){U.preventDefault(),T.setMentionMenuIndex(fe=>(fe-1+T.filteredPrompts.length)%T.filteredPrompts.length);return}if(U.key==="Tab"&&!U.shiftKey||U.key==="Enter"&&!U.shiftKey){U.preventDefault(),B(T.filteredPrompts[T.mentionMenuIndex]);return}}if(T.mentionMenuOpen&&T.filteredPrompts.length===0&&(U.key==="Enter"&&!U.shiftKey||U.key==="Tab"&&!U.shiftKey)){U.preventDefault();return}if(U.key==="Tab"&&U.shiftKey){U.preventDefault(),We();return}U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),oe())}function je(U){n(U.target.value),O(U.target.selectionStart??U.target.value.length);const fe=U.target;fe.style.height="auto",fe.style.height=Math.min(fe.scrollHeight,200)+"px"}function Ee(){P.current&&O(P.current.selectionStart??0)}function Be(){Xn(e,{type:"interrupt"})}async function Oe(U){if(U.length===0)return;const fe=[],Ae=[];let tt=i.reduce((ze,st)=>ze+st.size,0);for(const ze of U){if(ze.size>vf){Ae.push(`${ze.name} is too large (${pa(ze.size)}, max ${pa(vf)})`);continue}if(tt+ze.size>bf){Ae.push(`${ze.name} would exceed the per-message limit (${pa(bf)})`);continue}const{base64:st,mediaType:rn}=await eC(ze);fe.push({name:ze.name,base64:st,mediaType:rn,size:ze.size}),tt+=ze.size}fe.length>0&&a(ze=>[...ze,...fe]),u(Ae.length>0?Ae.join("; "):null)}async function Te(U){const fe=U.target.files;fe&&(await Oe(Array.from(fe)),U.target.value="")}function Re(U){a(fe=>fe.filter((Ae,tt)=>tt!==U))}async function Ft(U){var tt;const fe=(tt=U.clipboardData)==null?void 0:tt.items;if(!fe)return;const Ae=[];for(const ze of Array.from(fe)){if(ze.kind!=="file")continue;const st=ze.getAsFile();if(!st)continue;const rn=st.name&&st.name.length>0?st.name:`pasted-${Date.now()}.${(st.type.split("/")[1]||"bin").replace(/[^a-zA-Z0-9]/g,"")}`;Ae.push(new File([st],rn,{type:st.type,lastModified:st.lastModified}))}Ae.length>0&&(U.preventDefault(),await Oe(Ae))}function vn(U){U.dataTransfer.types.includes("Files")&&(U.preventDefault(),U.stopPropagation(),f(!0))}function Vt(U){U.currentTarget===U.target&&f(!1)}async function St(U){if(!U.dataTransfer.types.includes("Files"))return;U.preventDefault(),U.stopPropagation(),f(!1);const fe=Array.from(U.dataTransfer.files);fe.length>0&&await Oe(fe)}function wt(){const U=t.trim().slice(0,32);N(U||""),R(null),_(fe=>!fe)}function We(){if(!Q)return;const U=W.getState();if(!G)U.setPreviousPermissionMode(e,V),Xn(e,{type:"set_permission_mode",mode:"plan"}),U.updateSession(e,{permissionMode:"plan"});else{const fe=de||(H?"bypassPermissions":"acceptEdits");Xn(e,{type:"set_permission_mode",mode:fe}),U.updateSession(e,{permissionMode:fe})}}async function xt(){const U=t.trim(),fe=j.trim();if(!U||!fe)return;if(S==="project"&&!(L!=null&&L.cwd)){R("No project folder available for this session");return}const Ae={name:fe,content:U,scope:S};S==="project"&&(Ae.projectPaths=[L.cwd]);try{await we.createPrompt(Ae),await T.refreshPrompts(),_(!1),N(""),C("global"),R(null)}catch(tt){const ze=tt instanceof Error&&tt.message?tt.message:"Could not save prompt.";R(ze)}}const ie=W(U=>U.promptSuggestions.get(e))??I9,ke=W(U=>U.clearPromptSuggestions),nt=W(U=>U.sessionStatus).get(e)==="running",Kt=t.trim().length>0&&Q;return l.jsx("div",{className:`shrink-0 px-0 sm:px-6 pt-0 sm:pt-3 pb-5 sm:pb-4 bg-cc-input-bg sm:bg-transparent relative ${h?"ring-2 ring-cc-primary/40 rounded-2xl":""}`,onDragOver:vn,onDragLeave:Vt,onDrop:St,children:l.jsxs("div",{className:"max-w-3xl mx-auto",children:[h&&l.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none rounded-2xl bg-cc-primary/5 border-2 border-dashed border-cc-primary/40",children:l.jsx("span",{className:"text-sm text-cc-primary font-medium",children:"Drop files to attach"})}),i.length>0&&l.jsx("div",{className:"flex items-center gap-2 mb-2 px-3 sm:px-0 flex-wrap",children:i.map((U,fe)=>l.jsx(sC,{name:U.name,mediaType:U.mediaType,base64:U.base64,size:U.size,onRemove:()=>Re(fe)},fe))}),o&&l.jsx("div",{className:"mb-2 px-3 sm:px-0 text-[11px] text-cc-error",children:o}),l.jsx("input",{ref:z,type:"file",multiple:!0,onChange:Te,className:"hidden","aria-label":"Attach files"}),ie.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 px-2 sm:px-4 pb-2",children:ie.map((U,fe)=>l.jsx("button",{onClick:()=>{if(!Q||nt)return;const Ae=k0();Xn(e,{type:"user_message",content:U,session_id:e,client_msg_id:Ae}),W.getState().appendMessage(e,{id:Ae,role:"user",content:U,timestamp:Date.now()}),ke(e)},disabled:!Q||nt,className:"text-xs px-2.5 py-1.5 rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg border border-cc-border transition-colors cursor-pointer truncate max-w-[280px]",title:U,children:U},fe))}),l.jsxs("div",{className:`relative overflow-visible transition-all duration-200 border-t border-cc-separator sm:border sm:border-cc-border sm:bg-cc-input-bg/95 sm:rounded-[16px] sm:backdrop-blur-sm composer-card ${G?"sm:border-cc-primary/40 sm:shadow-[0_10px_30px_rgba(217,119,87,0.08)]":"sm:focus-within:border-cc-primary/25"}`,children:[p&&Ce.length>0&&l.jsx("div",{ref:Z,className:"absolute left-2 right-2 bottom-full mb-1 max-h-[240px] overflow-y-auto bg-cc-card border border-cc-border rounded-[10px] shadow-lg z-20 py-1",children:Ce.map((U,fe)=>l.jsxs("button",{"data-cmd-index":fe,onClick:()=>$(U),className:`w-full px-3 py-2 text-left flex items-center gap-2.5 transition-colors cursor-pointer ${fe===v?"bg-cc-hover":"hover:bg-cc-hover/50"}`,children:[l.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-cc-hover text-cc-muted shrink-0",children:U.type==="skill"?l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M8 1l1.796 3.64L14 5.255l-3 2.924.708 4.126L8 10.5l-3.708 1.805L5 8.18 2 5.255l4.204-.615L8 1z"})}):l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M5 12L10 4",strokeLinecap:"round"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("span",{className:"text-[13px] font-medium text-cc-fg",children:["/",U.name]}),l.jsx("span",{className:"ml-2 text-[11px] text-cc-muted",children:U.type})]})]},`${U.type}-${U.name}`))}),l.jsx(mC,{open:T.mentionMenuOpen,loading:T.promptsLoading,prompts:T.filteredPrompts,selectedIndex:T.mentionMenuIndex,onSelect:B,menuRef:T.mentionMenuRef,className:"absolute left-2 right-2 bottom-full mb-1"}),y&&l.jsxs("div",{className:"absolute left-2 right-2 bottom-full mb-1 bg-cc-card border border-cc-border rounded-[10px] shadow-lg z-20 p-3 space-y-2",children:[l.jsx("div",{className:"text-xs font-semibold text-cc-fg",children:"Save prompt"}),l.jsx("input",{value:j,onChange:U=>{N(U.target.value),E&&R(null)},placeholder:"Prompt title","aria-label":"Prompt title",className:"w-full px-2 py-1.5 text-sm bg-cc-input-bg border border-cc-border rounded-md text-cc-fg focus:outline-none focus:border-cc-primary/40"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button","aria-pressed":S==="global",onClick:()=>C("global"),className:`px-2 py-0.5 text-[11px] rounded border transition-colors cursor-pointer ${S==="global"?"border-cc-primary/40 text-cc-primary bg-cc-primary/8":"border-cc-border text-cc-muted hover:text-cc-fg"}`,children:"Global"}),l.jsx("button",{type:"button","aria-pressed":S==="project",onClick:()=>C("project"),className:`px-2 py-0.5 text-[11px] rounded border transition-colors cursor-pointer ${S==="project"?"border-cc-primary/40 text-cc-primary bg-cc-primary/8":"border-cc-border text-cc-muted hover:text-cc-fg"}`,children:"This project"})]}),S==="project"&&(L==null?void 0:L.cwd)&&l.jsx("div",{className:"text-[10px] text-cc-muted font-mono-code truncate",title:L.cwd,children:L.cwd}),E?l.jsx("div",{className:"text-[11px] text-cc-error",children:E}):null,l.jsxs("div",{className:"flex items-center gap-1.5 justify-end",children:[l.jsx("button",{onClick:()=>{_(!1),C("global"),R(null)},className:"px-2 py-1 text-[11px] rounded-md border border-cc-border text-cc-muted hover:text-cc-fg cursor-pointer",children:"Cancel"}),l.jsx("button",{onClick:xt,disabled:!j.trim()||!t.trim(),className:`px-2 py-1 text-[11px] rounded-md border ${j.trim()&&t.trim()?"border-cc-primary/40 text-cc-primary bg-cc-primary/8 cursor-pointer":"border-cc-border text-cc-muted cursor-not-allowed"}`,children:"Save"})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 px-3 pt-1.5 pb-0.5 sm:hidden",children:[l.jsx(Y2,{isPlan:G,isConnected:Q,onToggle:We,modeLabel:ye,size:"mobile"}),l.jsx(G2,{sessionId:e}),l.jsx("div",{className:"flex-1"}),l.jsx(Ch,{onClick:wt,disabled:!Q||!t.trim(),active:Q&&!!t.trim(),title:"Save as prompt",children:l.jsx(X2,{})}),l.jsx(Ch,{onClick:()=>{var U;return(U=z.current)==null?void 0:U.click()},disabled:!Q,active:Q,title:"Attach file",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:l.jsx("path",{d:"M11.5 6.5L7 11a2 2 0 1 1-2.83-2.83l5-5a3.25 3.25 0 1 1 4.6 4.6l-5.7 5.7a4.5 4.5 0 0 1-6.36-6.36L7 2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),l.jsx("div",{className:"px-3 sm:px-3 pt-1 sm:pt-2.5",children:l.jsx("textarea",{ref:P,value:t,onChange:je,onKeyDown:be,onClick:Ee,onKeyUp:Ee,onPaste:Ft,"aria-label":"Message input",placeholder:Q?"Type a message... (/ + @)":"Waiting for CLI connection...",disabled:!Q,rows:1,className:"w-full px-1 py-1.5 text-base sm:text-sm bg-transparent resize-none outline-none text-cc-fg font-sans-ui placeholder:text-cc-muted disabled:opacity-50 overflow-y-auto",style:{minHeight:"36px",maxHeight:"200px"}})}),l.jsx("div",{className:"flex items-center justify-end gap-1 px-3 pb-1 sm:hidden",children:l.jsx(Q2,{isRunning:nt,canSend:Kt,onSend:oe,onInterrupt:Be,size:"mobile"})}),l.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 px-2.5 pb-2",children:[l.jsx(Ch,{onClick:()=>{var U;return(U=z.current)==null?void 0:U.click()},disabled:!Q,active:Q,title:"Attach file",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-4 h-4",children:l.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})})}),l.jsx(Ch,{onClick:wt,disabled:!Q||!t.trim(),active:Q&&!!t.trim(),title:"Save as prompt",children:l.jsx(X2,{})}),l.jsx(Y2,{isPlan:G,isConnected:Q,onToggle:We,modeLabel:ye,size:"desktop"}),l.jsx("div",{className:"flex-1"}),l.jsx(G2,{sessionId:e}),l.jsx(Q2,{isRunning:nt,canSend:Kt,onSend:oe,onInterrupt:Be,size:"desktop"})]})]})]})})}function H9(e){if(e.type==="setMode")return`Set mode to "${e.mode}"`;const n=e.destination==="session"?"for session":"always";if(e.type==="addRules"||e.type==="replaceRules"){const i=e.rules[0];if(i!=null&&i.ruleContent)return`Allow "${i.ruleContent}" ${n}`;if(i!=null&&i.toolName)return`Allow ${i.toolName} ${n}`}return e.type==="addDirectories"?`Trust ${e.directories[0]||"directory"} ${n}`:`Allow ${n}`}function q9(e,t){const n={};for(const[i,a]of Object.entries(t)){const o=e[Number(i)],u=typeof(o==null?void 0:o.question)=="string"&&o.question?o.question:i;n[u]=a}return n}function V9({permission:e,sessionId:t}){const[n,i]=k.useState(!1),a=W(p=>p.removePermission);function o(p,g){i(!0),Xn(t,{type:"permission_response",request_id:e.request_id,behavior:"allow",updated_input:p,...g!=null&&g.length?{updated_permissions:g}:{}}),a(t,e.request_id)}function u(){i(!0),Xn(t,{type:"permission_response",request_id:e.request_id,behavior:"deny",message:"Denied by user"}),a(t,e.request_id)}const h=e.tool_name==="AskUserQuestion",f=e.permission_suggestions;return l.jsx("div",{className:"px-2 sm:px-4 py-3 border-b border-cc-border animate-[fadeSlideIn_0.2s_ease-out]",children:l.jsx("div",{className:"max-w-3xl mx-auto",children:l.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[l.jsx("div",{className:`w-7 h-7 sm:w-8 sm:h-8 rounded-lg flex items-center justify-center shrink-0 mt-0.5 ${h?"bg-cc-primary/10 border border-cc-primary/20":"bg-cc-warning/10 border border-cc-warning/20"}`,children:h?l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4 text-cc-primary",children:l.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})}):l.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4 text-cc-warning",children:l.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[l.jsx("span",{className:`text-xs font-semibold ${h?"text-cc-primary":"text-cc-warning"}`,children:h?"Question":"Permission Request"}),!h&&l.jsx("span",{className:"text-[11px] text-cc-muted font-mono-code",children:e.display_name||e.tool_name}),e.title&&l.jsx("span",{className:"text-[11px] text-cc-muted",children:e.title})]}),h?l.jsx(W9,{input:e.input,onSelect:p=>o({...e.input,answers:p}),disabled:n}):l.jsx(X9,{toolName:e.tool_name,input:e.input,description:e.description}),e.decision_reason&&l.jsx("p",{className:"text-xs text-cc-muted mt-1 italic",children:e.decision_reason}),e.ai_validation&&!h&&l.jsx(Y9,{validation:e.ai_validation}),!h&&l.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[l.jsxs("button",{onClick:()=>o(),disabled:n,className:"inline-flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium rounded-lg bg-cc-success/90 hover:bg-cc-success text-white disabled:opacity-50 transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:l.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7"})}),"Allow"]}),f==null?void 0:f.map((p,g)=>l.jsxs("button",{onClick:()=>o(void 0,[p]),disabled:n,title:`${p.type}: ${JSON.stringify(p)}`,className:"inline-flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium rounded-lg bg-cc-primary/10 hover:bg-cc-primary/20 text-cc-primary border border-cc-primary/20 disabled:opacity-50 transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:l.jsx("path",{d:"M3 8.5l3.5 3.5 6.5-7"})}),H9(p)]},g)),l.jsxs("button",{onClick:u,disabled:n,className:"inline-flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium rounded-lg bg-cc-hover hover:bg-cc-active text-cc-fg border border-cc-border disabled:opacity-50 transition-colors cursor-pointer",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",children:l.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"Deny"]})]})]})]})})})}function G9(e){return[/^Invalid Anthropic/i,/^Anthropic .*(rate limit|overloaded|unavailable|error|lacks permission)/i,/^AI service/i,/^AI evaluation timed out/i,/^Model not found/i,/^No Anthropic API key/i].some(n=>n.test(e))}function Y9({validation:e}){const t=e.verdict==="uncertain"&&G9(e.reason),n=e.verdict==="safe"?"bg-cc-success/10 text-cc-success":e.verdict==="dangerous"?"bg-cc-error/10 text-cc-error":"bg-cc-warning/10 text-cc-warning",i=t?"AI analysis unavailable — manual review:":"AI analysis:";return l.jsxs("div",{className:`mt-2 flex items-center gap-1.5 text-[11px] px-2 py-1.5 rounded-md ${n}`,children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0",children:l.jsx("path",{d:"M8 1a2.5 2.5 0 00-2.5 2.5v.382a8 8 0 00-1.074.646l-.33-.191a2.5 2.5 0 00-3.415.912 2.5 2.5 0 00.916 3.42l.33.19A8 8 0 001.5 9.5v.382A8 8 0 002 10.5l-.33.19a2.5 2.5 0 00-.916 3.42 2.5 2.5 0 003.415.912l.33-.191a8 8 0 001.074.646V16A2.5 2.5 0 008 13.5 2.5 2.5 0 0010.5 16v-.713a8 8 0 001.074-.646l.33.191a2.5 2.5 0 003.415-.912 2.5 2.5 0 00-.916-3.42L14 10.5V9.5l.33-.19a2.5 2.5 0 00.916-3.42 2.5 2.5 0 00-3.415-.912l-.33.191A8 8 0 0010.5 4.882V4.5A2.5 2.5 0 008 2V1z"})}),l.jsx("span",{className:"font-medium",children:i}),l.jsx("span",{children:e.reason})]})}function X9({toolName:e,input:t,description:n}){return e==="Bash"?l.jsx(Q9,{input:t}):e==="Edit"?l.jsx(Z9,{input:t}):e==="Write"?l.jsx(K9,{input:t}):e==="Read"?l.jsx(J9,{input:t}):e==="Glob"?l.jsx(eP,{input:t}):e==="Grep"?l.jsx(tP,{input:t}):e==="ExitPlanMode"?l.jsx(nP,{input:t}):l.jsx(xC,{input:t,description:n})}function Q9({input:e}){const t=typeof e.command=="string"?e.command:"",n=typeof e.description=="string"?e.description:"";return l.jsxs("div",{className:"space-y-1.5",children:[n&&l.jsx("div",{className:"text-xs text-cc-muted",children:n}),l.jsxs("pre",{className:"text-xs text-cc-fg font-mono-code bg-cc-code-bg/30 rounded-lg px-2 sm:px-3 py-2 max-h-32 overflow-y-auto overflow-x-auto whitespace-pre-wrap break-words",children:[l.jsx("span",{className:"text-cc-muted select-none",children:"$ "}),t]})]})}function W9({input:e,onSelect:t,disabled:n}){const i=Array.isArray(e.questions)?e.questions:[],[a,o]=k.useState({}),[u,h]=k.useState({}),[f,p]=k.useState({});function g(N){return q9(i,N)}function v(N,S){const C=String(N);o(E=>({...E,[C]:S})),p(E=>({...E,[C]:!1})),i.length<=1&&t(g({[C]:S}))}function b(N){var E;const S=String(N),C=(E=u[S])==null?void 0:E.trim();C&&(o(R=>({...R,[S]:C})),i.length<=1&&t(g({[S]:C})))}function y(N,S){const C=String(N);h(R=>({...R,[C]:S}));const E=S.trim();o(R=>{if(!E){const A={...R};return delete A[C],A}return{...R,[C]:E}})}function _(N){const S=String(N);p(C=>{const E=!!C[S],R={...C,[S]:!E};return E&&(o(A=>{const O={...A};return delete O[S],O}),h(A=>{const O={...A};return delete O[S],O})),R})}function j(){t(g(a))}if(i.length===0){const N=typeof e.question=="string"?e.question:"";return N?l.jsx("div",{className:"text-sm text-cc-fg bg-cc-code-bg/30 rounded-lg px-3 py-2",children:N}):l.jsx(xC,{input:e})}return l.jsxs("div",{className:"space-y-3",children:[i.map((N,S)=>{const C=typeof N.header=="string"?N.header:"",E=typeof N.question=="string"?N.question:"",R=Array.isArray(N.options)?N.options:[],A=String(S),O=a[A],P=f[A];return l.jsxs("div",{className:"space-y-2",children:[C&&l.jsx("span",{className:"inline-block text-[10px] font-semibold text-cc-primary bg-cc-primary/10 px-1.5 py-0.5 rounded",children:C}),E&&l.jsx("p",{className:"text-sm text-cc-fg leading-relaxed",children:E}),R.length>0&&l.jsxs("div",{className:"space-y-1.5",children:[R.map((z,Z)=>{const I=typeof z.label=="string"?z.label:String(z),q=typeof z.description=="string"?z.description:"",L=O===I;return l.jsx("button",{onClick:()=>v(S,I),disabled:n,className:`w-full text-left px-3 py-2 rounded-lg border transition-all cursor-pointer disabled:opacity-50 ${L?"border-cc-primary bg-cc-primary/10 ring-1 ring-cc-primary/30":"border-cc-border bg-cc-hover/50 hover:bg-cc-hover hover:border-cc-primary/30"}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${L?"border-cc-primary":"border-cc-muted/40"}`,children:L&&l.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-primary"})}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs font-medium text-cc-fg",children:I}),q&&l.jsx("p",{className:"text-[11px] text-cc-muted mt-0.5 leading-snug",children:q})]})]})},Z)}),l.jsx("button",{onClick:()=>_(S),disabled:n,className:`w-full text-left px-3 py-2 rounded-lg border transition-all cursor-pointer disabled:opacity-50 ${P?"border-cc-primary bg-cc-primary/10 ring-1 ring-cc-primary/30":"border-cc-border bg-cc-hover/50 hover:bg-cc-hover hover:border-cc-primary/30"}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${P?"border-cc-primary":"border-cc-muted/40"}`,children:P&&l.jsx("span",{className:"w-2 h-2 rounded-full bg-cc-primary"})}),l.jsx("span",{className:"text-xs font-medium text-cc-muted",children:"Other..."})]})}),P&&l.jsxs("div",{className:"pl-6",children:[l.jsx("input",{type:"text",value:u[A]||"",onChange:z=>y(S,z.target.value),onKeyDown:z=>{z.key==="Enter"&&b(S)},placeholder:"Type your answer...",className:"w-full px-2.5 py-1.5 text-xs bg-cc-input-bg border border-cc-border rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:border-cc-primary/50",autoFocus:!0}),i.length<=1&&l.jsx("p",{className:"mt-1 text-[10px] text-cc-muted",children:"Press Enter to submit"})]})]})]},S)}),i.length>1&&Object.keys(a).length>0&&l.jsx("button",{onClick:j,disabled:n,className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-lg bg-cc-primary hover:bg-cc-primary-hover text-white disabled:opacity-50 transition-colors cursor-pointer",children:"Submit answers"})]})}function Z9({input:e}){const t=String(e.file_path||""),n=String(e.old_string||""),i=String(e.new_string||"");return l.jsx(Oo,{oldText:n,newText:i,fileName:t,mode:"compact"})}function K9({input:e}){const t=String(e.file_path||""),n=String(e.content||"");return l.jsx(Oo,{newText:n,fileName:t,mode:"compact"})}function J9({input:e}){const t=String(e.file_path||"");return l.jsx("div",{className:"text-xs text-cc-muted font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2",children:t})}function eP({input:e}){const t=typeof e.pattern=="string"?e.pattern:"",n=typeof e.path=="string"?e.path:"";return l.jsxs("div",{className:"text-xs font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-0.5",children:[l.jsx("div",{className:"text-cc-fg",children:t}),n&&l.jsx("div",{className:"text-cc-muted",children:n})]})}function tP({input:e}){const t=typeof e.pattern=="string"?e.pattern:"",n=typeof e.path=="string"?e.path:"",i=typeof e.glob=="string"?e.glob:"";return l.jsxs("div",{className:"text-xs font-mono-code bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-0.5",children:[l.jsx("div",{className:"text-cc-fg",children:t}),n&&l.jsx("div",{className:"text-cc-muted",children:n}),i&&l.jsx("div",{className:"text-cc-muted",children:i})]})}function nP({input:e}){const t=typeof e.plan=="string"?e.plan:"",n=Array.isArray(e.allowedPrompts)?e.allowedPrompts:[];return l.jsxs("div",{className:"space-y-2",children:[t&&l.jsxs("div",{className:"rounded-xl border border-cc-border overflow-hidden bg-cc-card",children:[l.jsxs("div",{className:"px-3 py-2 border-b border-cc-border bg-cc-primary/[0.04] flex items-center gap-2",children:[l.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded bg-cc-primary/15 text-cc-primary shrink-0",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:l.jsx("path",{d:"M3 3.5h10M3 8h10M3 12.5h6",strokeLinecap:"round"})})}),l.jsx("span",{className:"text-[11px] text-cc-primary font-semibold tracking-wide uppercase",children:"Plan"})]}),l.jsx("div",{className:"px-3 py-3 max-h-72 overflow-y-auto markdown-body text-[13px] text-cc-fg leading-relaxed",children:l.jsx(mv,{remarkPlugins:[wv],components:{h1:({children:i})=>l.jsx("h1",{className:"text-base font-semibold text-cc-fg mb-2",children:i}),h2:({children:i})=>l.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-1.5 mt-3 first:mt-0",children:i}),h3:({children:i})=>l.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-1.5 mt-2",children:i}),p:({children:i})=>l.jsx("p",{className:"mb-2 last:mb-0",children:i}),ul:({children:i})=>l.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:i}),ol:({children:i})=>l.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:i}),li:({children:i})=>l.jsx("li",{children:i}),strong:({children:i})=>l.jsx("strong",{className:"font-semibold text-cc-fg",children:i}),a:({href:i,children:a})=>l.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-cc-primary hover:underline",children:a}),code:i=>{const{children:a,className:o}=i;return/language-(\w+)/.exec(o||"")||typeof a=="string"&&a.includes(`
|
|
106
106
|
`)?l.jsx("pre",{className:"my-2 px-2.5 py-2 rounded-lg bg-cc-code-bg text-cc-code-fg text-[12px] font-mono-code leading-relaxed overflow-x-auto border border-cc-border",children:l.jsx("code",{children:a})}):l.jsx(JN,{textClassName:"text-[12px] text-cc-code-fg",children:a})},pre:({children:i})=>l.jsx(l.Fragment,{children:i}),blockquote:({children:i})=>l.jsx("blockquote",{className:"border-l-2 border-cc-primary/40 pl-2 text-cc-muted italic my-2",children:i})},children:t})})]}),n.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsx("div",{className:"text-[10px] text-cc-muted uppercase tracking-wider",children:"Requested permissions"}),l.jsx("div",{className:"space-y-1",children:n.map((i,a)=>l.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-mono-code bg-cc-code-bg/30 rounded-lg px-2.5 py-1.5",children:[l.jsx("span",{className:"text-cc-muted shrink-0",children:String(i.tool||"")}),l.jsx("span",{className:"text-cc-fg",children:String(i.prompt||"")})]},a))})]}),!t&&n.length===0&&l.jsx("div",{className:"text-xs text-cc-muted",children:"Plan approval requested"})]})}function xC({input:e,description:t}){const n=Object.entries(e).filter(([,i])=>i!=null&&i!=="");return n.length===0&&t?l.jsx("div",{className:"text-xs text-cc-fg",children:t}):l.jsxs("div",{className:"space-y-1",children:[t&&l.jsx("div",{className:"text-xs text-cc-muted mb-1",children:t}),l.jsx("div",{className:"bg-cc-code-bg/30 rounded-lg px-3 py-2 space-y-1",children:n.map(([i,a])=>{const o=typeof a=="string"?a.length>200?a.slice(0,200)+"...":a:JSON.stringify(a);return l.jsxs("div",{className:"flex gap-2 text-[11px] font-mono-code",children:[l.jsxs("span",{className:"text-cc-muted shrink-0",children:[i,":"]}),l.jsx("span",{className:"text-cc-fg break-all",children:o})]},i)})})]})}function sP({entry:e,onDismiss:t}){const{request:n,behavior:i,reason:a}=e,o=i==="allow";let u=n.tool_name;if(n.tool_name==="Bash"&&typeof n.input.command=="string"){const h=n.input.command;u=h.length>60?h.slice(0,60)+"...":h}else(n.tool_name==="Read"||n.tool_name==="Write"||n.tool_name==="Edit")&&typeof n.input.file_path=="string"?u=`${n.tool_name} ${n.input.file_path}`:n.tool_name==="Glob"&&typeof n.input.pattern=="string"?u=`Glob ${n.input.pattern}`:n.tool_name==="Grep"&&typeof n.input.pattern=="string"&&(u=`Grep ${n.input.pattern}`);return l.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 text-[11px] ${o?"text-cc-success":"text-cc-error"}`,children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 shrink-0 opacity-70",children:l.jsx("path",{fillRule:"evenodd",d:"M8 1.246l.542.228c1.926.812 3.732.95 5.408.435l.61-.187v6.528a5.75 5.75 0 01-2.863 4.973L8 15.5l-3.697-2.277A5.75 5.75 0 011.44 8.25V1.722l.61.187c1.676.515 3.482.377 5.408-.435L8 1.246z",clipRule:"evenodd"})}),l.jsxs("span",{className:"flex-1",children:["AI auto-",o?"approved":"denied",":"," ",l.jsx("span",{className:"font-mono-code opacity-80",children:u}),a&&l.jsxs("span",{className:"text-cc-muted ml-1",children:["(",a,")"]})]}),t&&l.jsx("button",{onClick:t,className:"opacity-50 hover:opacity-100 transition-opacity cursor-pointer flex-shrink-0","aria-label":"Dismiss notification",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:l.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})})]})}const iP=[],rP=[],W2="activity-tray-panel";function aP(e,t){const n=Math.round(((t||Date.now())-e)/1e3);if(n<60)return`${n}s`;const i=Math.floor(n/60),a=n%60;return`${i}m${a>0?` ${a}s`:""}`}function lP(e,t,n=4e3){const[i,a]=k.useState(!1),o=k.useRef(void 0),u=e.length+t.length,h=u>0&&e.every(f=>f.status==="completed")&&t.every(f=>f.status!=="running");return k.useEffect(()=>(clearTimeout(o.current),h?o.current=setTimeout(()=>a(!0),n):a(!1),()=>clearTimeout(o.current)),[h,n]),k.useEffect(()=>{a(!1)},[u]),i}function oP(e){const[t,n]=k.useState(0);return k.useEffect(()=>{if(!e)return;const i=setInterval(()=>n(a=>a+1),1e3);return()=>clearInterval(i)},[e]),t}function cP({status:e}){return e==="running"||e==="in_progress"?l.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[l.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-cc-warning opacity-75 animate-ping"}),l.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cc-warning"})]}):e==="completed"?l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cc-success shrink-0"}):e==="failed"?l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cc-error shrink-0"}):l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cc-muted/30 shrink-0"})}function uP({agent:e,tick:t}){const[n,i]=k.useState(!1),a=e.status!=="running",o=!!e.summary,u=l.jsxs(l.Fragment,{children:[l.jsx(cP,{status:e.status}),l.jsx("span",{className:"text-[11px] text-cc-fg/80 truncate flex-1 font-medium",children:e.name}),e.agentType&&l.jsx("span",{className:"text-[9px] text-cc-muted/50 uppercase tracking-wider shrink-0",children:e.agentType}),l.jsx("span",{className:"text-[10px] text-cc-muted/50 tabular-nums font-mono-code",children:aP(e.startedAt,e.completedAt)})]});return l.jsxs("div",{className:`transition-opacity duration-300 ${a?"opacity-60":""}`,children:[o?l.jsx("button",{type:"button",onClick:()=>i(!n),"aria-expanded":n,className:"w-full flex items-center gap-2 px-2.5 min-h-[36px] text-left hover:bg-cc-hover/50 rounded-md transition-colors cursor-pointer",children:u}):l.jsx("div",{className:"flex items-center gap-2 px-2.5 min-h-[36px]",children:u}),n&&e.summary&&l.jsx("p",{className:"px-2.5 pb-1.5 ml-4 text-[10px] text-cc-muted/60 leading-relaxed line-clamp-3 font-mono-code",children:e.summary})]})}function dP({task:e}){const t=e.status==="completed",n=e.status==="in_progress";return l.jsxs("div",{className:`flex items-center gap-2 px-2.5 min-h-[32px] transition-opacity duration-300 ${t?"opacity-40":""}`,children:[l.jsx("span",{className:"shrink-0 flex items-center justify-center w-3.5 h-3.5",children:n?l.jsx("svg",{className:"w-3.5 h-3.5 text-cc-primary animate-spin",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:l.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"28",strokeDashoffset:"8",strokeLinecap:"round"})}):t?l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success","aria-hidden":!0,children:l.jsx("path",{fillRule:"evenodd",d:"M8 15A7 7 0 108 1a7 7 0 000 14zm3.354-9.354a.5.5 0 00-.708-.708L7 8.586 5.354 6.94a.5.5 0 10-.708.708l2 2a.5.5 0 00.708 0l4-4z",clipRule:"evenodd"})}):l.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-muted/40","aria-hidden":!0,children:l.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})})}),l.jsx("span",{className:`text-[11px] leading-snug flex-1 truncate ${t?"text-cc-muted line-through":"text-cc-fg/80"}`,children:e.subject}),n&&e.activeForm&&l.jsx("span",{className:"text-[10px] text-cc-muted/50 italic truncate max-w-[120px] shrink-0",children:e.activeForm})]})}function hP({sessionId:e}){const[t,n]=k.useState(!1),i=k.useRef(null),a=k.useRef(null),o=W(E=>E.sessionTasks.get(e)??iP),u=W(E=>E.sessionBackgroundAgents.get(e)??rP),h=lP(o,u),f=u.some(E=>E.status==="running"),p=oP(f),g=u.filter(E=>E.status==="running").length,v=o.length,b=o.filter(E=>E.status==="completed").length,y=o.filter(E=>E.status==="in_progress").length,_=o.length>0||u.length>0,j=g>0||y>0,N=k.useCallback(()=>n(!1),[]);k.useEffect(()=>{if(!t)return;const E=R=>{R.key==="Escape"&&(R.stopPropagation(),N())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[t,N]),k.useEffect(()=>{if(!t)return;const E=R=>{i.current&&!i.current.contains(R.target)&&N()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[t,N]),k.useEffect(()=>{t&&a.current&&a.current.focus()},[t]);const[S,C]=k.useState(!1);return k.useEffect(()=>{_&&C(!1)},[_,o.length,u.length]),!_||S?null:l.jsxs("div",{ref:i,className:`absolute bottom-3 right-3 z-20 transition-opacity duration-500 ${h?"opacity-0 pointer-events-none":"opacity-100"}`,style:h?void 0:{animation:"fadeSlideIn 0.3s ease-out"},onTransitionEnd:()=>{h&&C(!0)},children:[t&&l.jsxs("div",{ref:a,id:W2,role:"dialog","aria-label":"Activity panel",tabIndex:-1,className:"mb-1.5 w-72 max-w-[calc(100vw-2rem)] max-h-64 overflow-y-auto rounded-xl border border-cc-border/60 bg-cc-surface/95 backdrop-blur-xl shadow-lg shadow-black/20 outline-none",style:{animation:"fadeSlideIn 0.2s ease-out"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-cc-border/40",children:[l.jsx("span",{className:"text-[11px] font-semibold text-cc-fg/70 uppercase tracking-wider",role:"heading","aria-level":3,children:"Activity"}),l.jsx("button",{type:"button",onClick:N,className:"flex items-center justify-center w-7 h-7 -mr-1 rounded-md text-cc-muted/40 hover:text-cc-muted/70 hover:bg-cc-hover/50 transition-colors cursor-pointer","aria-label":"Close activity tray",children:l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:l.jsx("path",{d:"M4.646 4.646a.5.5 0 01.708 0L8 7.293l2.646-2.647a.5.5 0 01.708.708L8.707 8l2.647 2.646a.5.5 0 01-.708.708L8 8.707l-2.646 2.647a.5.5 0 01-.708-.708L7.293 8 4.646 5.354a.5.5 0 010-.708z"})})})]}),u.length>0&&l.jsxs("div",{className:"py-1",children:[l.jsx("div",{className:"px-3 py-1",role:"heading","aria-level":4,children:l.jsx("span",{className:"text-[9px] text-cc-muted/40 uppercase tracking-widest font-semibold",children:"Agents"})}),u.map(E=>l.jsx(uP,{agent:E,tick:p},E.toolUseId))]}),u.length>0&&o.length>0&&l.jsx("div",{className:"border-t border-cc-border/30 mx-2",role:"separator"}),o.length>0&&l.jsxs("div",{className:"py-1",children:[l.jsx("div",{className:"px-3 py-1",role:"heading","aria-level":4,children:l.jsx("span",{className:"text-[9px] text-cc-muted/40 uppercase tracking-widest font-semibold",children:"Tasks"})}),o.map(E=>l.jsx(dP,{task:E},E.id))]})]}),l.jsxs("button",{type:"button",onClick:()=>n(!t),"aria-expanded":t,"aria-controls":W2,className:`
|
|
107
107
|
flex items-center gap-2 px-3 min-h-[36px] rounded-full
|
|
108
108
|
border border-cc-border/50 bg-cc-surface/90 backdrop-blur-lg
|
|
@@ -129,7 +129,7 @@ ${X.resumeSessionId}`,children:"Continue"})]})]},`${X.resumeSessionId}-row-${X.s
|
|
|
129
129
|
`)})]}),n==="done"&&l.jsxs("div",{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-success",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm3.78-9.72a.75.75 0 0 0-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.06 0l4.25-4.25z"})}),l.jsx("h2",{className:"text-base font-semibold text-cc-success",children:"Sandbox Image Updated"})]}),l.jsx("p",{className:"text-sm text-cc-muted mb-5",children:"The Docker image has been updated successfully."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("button",{type:"button",onClick:b,className:"px-4 py-2 min-h-[40px] rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Done"})})]}),n==="error"&&l.jsxs("div",{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-4 h-4 text-cc-error",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM5.22 5.22a.75.75 0 0 1 1.06 0L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 1 1-1.06 1.06L8 9.06l-1.72 1.72a.75.75 0 0 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 0-1.06z"})}),l.jsx("h2",{className:"text-base font-semibold text-cc-error",children:"Image Update Failed"})]}),l.jsxs("p",{className:"text-sm text-cc-muted mb-2",children:["Failed to update the Docker image.",(u==null?void 0:u.error)&&l.jsx("span",{className:"block mt-1 text-xs text-cc-error",children:u.error})]}),(u==null?void 0:u.progress)&&u.progress.length>0&&l.jsx("pre",{className:"px-3 py-2 text-[10px] font-mono-code bg-cc-code-bg rounded-lg text-cc-muted max-h-[120px] overflow-auto whitespace-pre-wrap mb-4","data-testid":"pull-progress",children:u.progress.slice(-20).join(`
|
|
130
130
|
`)}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("button",{type:"button",onClick:y,className:"px-4 py-2 min-h-[40px] rounded-lg text-sm font-medium bg-cc-hover hover:bg-cc-active text-cc-fg transition-colors cursor-pointer",children:"Close"}),l.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 min-h-[40px] rounded-lg text-sm font-medium bg-cc-primary hover:bg-cc-primary-hover text-white transition-colors cursor-pointer",children:"Retry"})]})]})]})})}function mF({phase:e}){return l.jsx("div",{className:"relative bg-black/50 rounded-lg overflow-hidden h-[300px] flex items-center justify-center",children:l.jsxs("div",{className:"bg-cc-bg rounded-xl shadow-xl border border-cc-border w-full max-w-sm mx-4 overflow-hidden",children:[e==="prompt"&&l.jsxs("div",{className:"p-5",children:[l.jsx("h2",{className:"text-sm font-semibold text-cc-fg mb-1.5",children:"Update Sandbox Image?"}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"A new version of The Companion was installed. Would you like to also update the sandbox Docker image?"}),l.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-lg bg-cc-hover text-xs text-cc-fg mb-4",children:[l.jsx("span",{children:"Always update automatically"}),l.jsx("span",{className:"relative inline-flex h-4 w-7 rounded-full bg-cc-border",children:l.jsx("span",{className:"inline-block h-3 w-3 rounded-full bg-white shadow translate-x-0 mt-0.5 ml-0.5"})})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-hover text-cc-fg",children:"Skip"}),l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Update"})]})]}),e==="pulling"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[l.jsx("svg",{className:"w-3.5 h-3.5 animate-spin text-cc-primary",viewBox:"0 0 24 24",fill:"none",children:l.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2.5",strokeDasharray:"31.4 31.4",strokeLinecap:"round"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-fg",children:"Updating Sandbox Image..."})]}),l.jsx("pre",{className:"px-2 py-1.5 text-[9px] font-mono-code bg-cc-code-bg rounded text-cc-muted max-h-[80px] overflow-auto whitespace-pre-wrap",children:`Pulling the-companion:latest...
|
|
131
131
|
Layer 1/5: abc123 downloading
|
|
132
|
-
Layer 2/5: def456 complete`})]}),e==="done"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm3.78-9.72a.75.75 0 0 0-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.06 0l4.25-4.25z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-success",children:"Sandbox Image Updated"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"The Docker image has been updated successfully."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Done"})})]}),e==="error"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-error",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM5.22 5.22a.75.75 0 0 1 1.06 0L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 1 1-1.06 1.06L8 9.06l-1.72 1.72a.75.75 0 0 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 0-1.06z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-error",children:"Image Update Failed"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"Failed to update the Docker image."}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-hover text-cc-fg",children:"Close"}),l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Retry"})]})]})]})})}function OB(){const[e,t]=k.useState(null),[n,i]=k.useState({state:"idle"}),[a,o]=k.useState(""),[u,h]=k.useState(!1),[f,p]=k.useState(""),g=k.useCallback(async()=>{try{t(await we.getClaudeAccount())}catch(A){p(A instanceof Error?A.message:String(A))}},[]);k.useEffect(()=>{g(),we.getClaudeLoginStatus().then(i).catch(()=>{})},[g]);const v=async()=>{h(!0),p(""),o("");try{const A=await we.startClaudeLogin();i(A),A.state==="error"&&A.error&&p(A.error)}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},b=async()=>{h(!0),p("");try{const A=await we.submitClaudeLoginCode(a);i(A),A.state==="success"&&(o(""),await g())}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},y=async()=>{h(!0);try{i(await we.cancelClaudeLogin()),o("")}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},_=async()=>{h(!0),p("");try{const A=await we.claudeLogout();!A.ok&&A.error&&p(A.error),i({state:"idle"}),await g()}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},j=n.state==="awaiting_code",N=n.state==="verifying",S=j||N,C=(e==null?void 0:e.cliAvailable)===!1,E=e!=null&&e.orgName&&e.email&&e.orgName.includes(e.email)?null:(e==null?void 0:e.orgName)??null,R=e!=null&&e.authenticated?[e.email,e.subscriptionType?LB(e.subscriptionType):null,E].filter(Boolean).join(" · "):null;return l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"block text-sm font-medium",children:"Claude Account"}),l.jsx("p",{className:"text-xs text-cc-muted",children:"Sign in with your Claude subscription. You'll open a link, approve on any device, and paste the code back here — no terminal access needed."}),C&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:"Claude CLI not found on this machine. Install it to sign in."}),!C&&e&&!S&&l.jsx("p",{className:"text-xs text-cc-muted","data-testid":"claude-account-status",children:R?`Signed in as ${R}`:e.authenticated?"Signed in":"Not signed in"}),S&&l.jsxs("div",{className:"px-3 py-3 rounded-lg bg-cc-bg border border-cc-primary/20 space-y-3",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("p",{className:"text-xs text-cc-muted",children:"1. Open this link and approve:"}),l.jsx("a",{href:n.authUrl,target:"_blank",rel:"noreferrer","data-testid":"claude-auth-url",className:"block text-xs text-cc-primary underline break-all",children:n.authUrl})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs text-cc-muted",htmlFor:"claude-auth-code",children:"2. Paste the code you were shown:"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{id:"claude-auth-code",type:"text",value:a,disabled:N,autoComplete:"off",spellCheck:!1,onChange:A=>o(A.target.value),onKeyDown:A=>{A.key==="Enter"&&a.trim()&&!u&&(A.preventDefault(),b())},placeholder:"Paste code here",className:"flex-1 px-3 py-2 min-h-[40px] text-sm font-mono-code bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"}),l.jsx("button",{type:"button",onClick:b,disabled:u||!a.trim(),className:`px-3 py-2 min-h-[40px] rounded-lg text-sm font-medium transition-colors ${u||!a.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:N?"Verifying…":"Submit"})]})]}),n.error&&l.jsx("p",{role:"alert",className:"text-xs text-cc-error",children:n.error})]}),n.state==="success"&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Signed in to Claude. New sessions will use this account."}),(n.state==="error"||f)&&l.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:f||n.error}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[S?l.jsx("button",{type:"button",onClick:y,disabled:u,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Cancel"}):l.jsx("button",{type:"button",onClick:v,disabled:u||C,className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${u||C?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:u?"Starting…":e!=null&&e.authenticated?"Sign in again":"Sign in with Claude"}),(e==null?void 0:e.authenticated)&&!S&&l.jsx("button",{type:"button",onClick:_,disabled:u,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Sign out"})]})]})}function LB(e){return e.charAt(0).toUpperCase()+e.slice(1)}const DB=2e3;function zB(){const[e,t]=k.useState(null),[n,i]=k.useState({state:"idle"}),[a,o]=k.useState(!1),[u,h]=k.useState(""),[f,p]=k.useState(!1),g=k.useRef(null),v=k.useCallback(async()=>{try{t(await we.getCodexAccount())}catch(R){h(R instanceof Error?R.message:String(R))}},[]),b=k.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=null)},[]),y=k.useCallback(()=>{b(),g.current=setInterval(async()=>{try{const R=await we.getCodexLoginStatus();i(R),R.state!=="pending"&&(b(),R.state==="success"&&v())}catch{}},DB)},[v,b]);k.useEffect(()=>(v(),we.getCodexLoginStatus().then(R=>{i(R),R.state==="pending"&&y()}).catch(()=>{}),b),[v,y,b]);const _=async()=>{o(!0),h("");try{const R=await we.startCodexLogin();i(R),R.state==="pending"?y():R.error&&h(R.error)}catch(R){h(R instanceof Error?R.message:String(R))}finally{o(!1)}},j=async()=>{o(!0),b();try{i(await we.cancelCodexLogin())}catch(R){h(R instanceof Error?R.message:String(R))}finally{o(!1)}},N=async()=>{o(!0),h("");try{const R=await we.codexLogout();!R.ok&&R.error&&h(R.error),i({state:"idle"}),await v()}catch(R){h(R instanceof Error?R.message:String(R))}finally{o(!1)}},S=async()=>{if(n.userCode)try{await navigator.clipboard.writeText(n.userCode),p(!0),setTimeout(()=>p(!1),1500)}catch{}},C=n.state==="pending",E=(e==null?void 0:e.cliAvailable)===!1;return l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"block text-sm font-medium",children:"ChatGPT Subscription (Codex)"}),l.jsx("p",{className:"text-xs text-cc-muted",children:"Sign in with your ChatGPT plan to use Codex without an API key. You'll get a code to enter on any device — no terminal access needed."}),E&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:"Codex CLI not found on this machine. Install it to sign in."}),!E&&e&&!C&&l.jsx("p",{className:"text-xs text-cc-muted","data-testid":"codex-account-status",children:e.authenticated?e.method==="apiKey"?"Authenticated with an OpenAI API key":`Signed in as ${e.email||"ChatGPT account"}${e.planType?` (${e.planType})`:""}`:"Not signed in"}),C&&l.jsxs("div",{className:"px-3 py-3 rounded-lg bg-cc-bg border border-cc-primary/20 space-y-2",children:[l.jsxs("p",{className:"text-xs text-cc-muted",children:["1. Open"," ",l.jsx("a",{href:n.verificationUrl,target:"_blank",rel:"noreferrer",className:"text-cc-primary underline",children:n.verificationUrl})]}),l.jsx("p",{className:"text-xs text-cc-muted",children:"2. Enter this code:"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"font-mono-code text-lg tracking-widest bg-cc-code-bg px-3 py-1.5 rounded text-cc-code-fg","data-testid":"codex-user-code",children:n.userCode}),l.jsx("button",{type:"button",onClick:S,className:"px-2 py-1 min-h-[32px] rounded-md text-xs bg-cc-hover text-cc-fg cursor-pointer",children:f?"Copied":"Copy"})]}),l.jsx("p",{className:"text-xs text-cc-muted",role:"status",children:"Waiting for approval…"})]}),n.state==="success"&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Signed in to Codex. New sessions will use this account."}),(n.state==="error"||u)&&l.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:u||n.error}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[C?l.jsx("button",{type:"button",onClick:j,disabled:a,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Cancel"}):l.jsx("button",{type:"button",onClick:_,disabled:a||E,className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${a||E?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:a?"Starting…":e!=null&&e.authenticated?"Sign in again":"Sign in with ChatGPT"}),(e==null?void 0:e.authenticated)&&!C&&l.jsx("button",{type:"button",onClick:N,disabled:a,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Sign out"})]})]})}const v0=["welcome","claude","codex","done"],nS='button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function _x(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $B({onComplete:e}){const[t,n]=k.useState("welcome"),[i,a]=k.useState(""),[o,u]=k.useState(""),[h,f]=k.useState(!1),[p,g]=k.useState(""),[v,b]=k.useState(!1),[y,_]=k.useState(!1),[j,N]=k.useState(_x),S=k.useRef(null);k.useEffect(()=>{j||requestAnimationFrame(()=>N(!0))},[j]),k.useEffect(()=>{const q=S.current;if(!q)return;function L(Q){if(Q.key==="Escape"){Q.preventDefault();return}if(Q.key!=="Tab")return;const V=q.querySelectorAll(nS);if(V.length===0)return;const G=V[0],H=V[V.length-1];Q.shiftKey?document.activeElement===G&&(Q.preventDefault(),H.focus()):document.activeElement===H&&(Q.preventDefault(),G.focus())}document.addEventListener("keydown",L);const de=q.querySelector(nS);return de==null||de.focus(),()=>document.removeEventListener("keydown",L)},[t]);const C=k.useCallback(async()=>{if(!i.trim()){n("codex");return}f(!0),g("");try{await we.updateSettings({claudeCodeOAuthToken:i.trim()}),b(!0),n("codex")}catch(q){g(q instanceof Error?q.message:"Failed to save token")}finally{f(!1)}},[i]),E=k.useCallback(async()=>{f(!0),g("");try{(await we.getSettings()).codexDeviceAuthConfigured?(_(!0),await A()):g("No Codex auth found yet. Complete the sign-in above, then check again.")}catch(q){g(q instanceof Error?q.message:"Failed to check auth status")}finally{f(!1)}},[]),R=k.useCallback(async()=>{f(!0),g("");try{await we.updateSettings({openaiApiKey:o.trim()}),_(!0),await A()}catch(q){g(q instanceof Error?q.message:"Failed to save API key")}finally{f(!1)}},[o]),A=k.useCallback(async()=>{try{await we.updateSettings({onboardingCompleted:!0})}catch{}n("done")},[]),O=k.useCallback(()=>{e()},[e]),P=k.useCallback(async()=>{await A(),e()},[A,e]),z=k.useCallback(q=>{g(""),n(q)},[]),Z=v0.indexOf(t),I=_x();return $o.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"linear-gradient(145deg, var(--color-cc-bg) 0%, color-mix(in srgb, var(--color-cc-bg) 94%, var(--color-cc-primary) 6%) 100%)",opacity:j?1:0,transition:I?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",style:{background:"linear-gradient(90deg, transparent 0%, var(--color-cc-primary) 30%, var(--color-cc-primary) 70%, transparent 100%)",opacity:.6}}),l.jsxs("div",{ref:S,role:"dialog","aria-modal":"true","aria-label":"Provider setup",className:"w-full max-w-[520px] mx-6",style:{transform:j?"translateY(0)":"translateY(12px)",opacity:j?1:0,transition:I?"none":"transform 500ms cubic-bezier(0.16, 1, 0.3, 1) 100ms, opacity 400ms cubic-bezier(0.16, 1, 0.3, 1) 100ms"},children:[t!=="done"&&l.jsx("div",{className:"flex items-center gap-1.5 mb-6 justify-center",role:"status","aria-label":`Step ${Z+1} of ${v0.length-1}`,children:v0.slice(0,3).map((q,L)=>l.jsx("div",{className:"h-[3px] rounded-full transition-[transform,background,opacity] duration-300",style:{width:32,transform:L===Z?"scaleX(1)":"scaleX(0.375)",transformOrigin:"center",background:L<=Z?"var(--color-cc-primary)":"var(--color-cc-border)",opacity:L<=Z?1:.5}},q))}),l.jsxs("div",{className:"bg-cc-card border border-cc-border overflow-hidden",style:{borderRadius:16,boxShadow:"0 1px 3px var(--color-cc-border), 0 8px 32px var(--color-cc-border)"},children:[t==="welcome"&&l.jsx(PB,{onSetupClaude:()=>z("claude"),onSetupCodex:()=>z("codex")}),t==="claude"&&l.jsx(BB,{token:i,onTokenChange:a,onSave:C,onSkip:()=>z("codex"),saving:h,error:p}),t==="codex"&&l.jsx(FB,{apiKey:o,onApiKeyChange:u,onCheckAuth:E,onSaveApiKey:R,onSkip:()=>A(),onBack:()=>z("claude"),saving:h,error:p}),t==="done"&&l.jsx(IB,{claudeConfigured:v,codexConfigured:y,onDone:O})]}),t==="welcome"&&l.jsx("button",{onClick:P,className:"w-full text-center text-xs text-cc-muted hover:text-cc-fg transition-colors mt-4 min-h-[44px] flex items-center justify-center",children:"Skip setup — I'll configure this later in Settings"})]})]}),document.body)}function PB({onSetupClaude:e,onSetupCodex:t}){return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"First time setup"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Welcome to The Companion"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Connect your AI providers to start coding. Configure one or both."})]}),l.jsxs("div",{className:"space-y-2.5",children:[l.jsxs("button",{onClick:e,className:"provider-card--claude group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-primary/10 text-cc-primary",children:"C"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Claude Code"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"Anthropic's coding agent — requires an OAuth token"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l.jsxs("button",{onClick:t,className:"provider-card--codex group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-codex/10 text-cc-codex",children:"X"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Codex"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"OpenAI's coding agent — log in via ChatGPT"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]})]})}function BB({token:e,onTokenChange:t,onSave:n,onSkip:i,saving:a,error:o}){const u=k.useRef(null);k.useEffect(()=>{var f;(f=u.current)==null||f.focus()},[]);const h="claude-token-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 1 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Claude Code"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Sign in with your Claude subscription — no terminal needed."})]}),l.jsx(OB,{}),l.jsx("div",{className:"mt-5 pt-4 border-t border-cc-border",children:l.jsx("p",{className:"text-xs text-cc-muted mb-2",children:"Or paste a long-lived token instead — generate one with:"})}),l.jsxs("div",{className:"rounded-lg overflow-hidden mb-4 border border-cc-border",style:{background:"var(--color-cc-code-bg)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-cc-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-error opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-warning opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-success opacity-60"})]}),l.jsx(UB,{text:"claude setup-token"})]}),l.jsx("div",{className:"px-3.5 py-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-cc-muted text-xs font-mono-code select-none","aria-hidden":"true",children:"$"}),l.jsx("code",{className:"text-[13px] font-mono-code text-cc-fg select-all",children:"claude setup-token"})]})})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{htmlFor:"claude-token",className:"text-xs text-cc-muted block mb-1.5",children:"OAuth Token"}),l.jsx("input",{ref:u,id:"claude-token",type:"password",value:e,onChange:f=>t(f.target.value),placeholder:"Paste the token from your terminal...","aria-describedby":o?h:void 0,"aria-invalid":o?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary focus:border-cc-primary font-mono-code transition-shadow duration-150"})]}),o&&l.jsxs("div",{id:h,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:o})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsx("button",{onClick:i,className:"flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:n,disabled:a,className:"btn-primary-aa flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:a?"none":"0 1px 3px var(--color-cc-primary-btn)"},children:a?"Saving...":e.trim()?"Save & Continue":"Continue"})]})]})}function FB({apiKey:e,onApiKeyChange:t,onCheckAuth:n,onSaveApiKey:i,onSkip:a,onBack:o,saving:u,error:h}){const[f,p]=k.useState(!1),g="codex-auth-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 2 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Codex"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Sign in with your ChatGPT account — no terminal needed."})]}),l.jsx(zB,{}),h&&l.jsxs("div",{id:g,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:h})]}),l.jsxs("div",{className:"mb-4",children:[l.jsxs("button",{onClick:()=>p(!f),className:"text-xs text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3 h-3 transition-transform duration-150",style:{transform:f?"rotate(90deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),"Or use an API key instead"]}),l.jsx("div",{className:"accordion-panel","data-open":f?"true":"false",children:l.jsx("div",{className:"accordion-inner",children:l.jsxs("div",{className:"mt-3",children:[l.jsx("label",{htmlFor:"openai-key",className:"text-xs text-cc-muted block mb-1.5",children:"OpenAI API Key"}),l.jsx("input",{id:"openai-key",type:"password",value:e,onChange:v=>t(v.target.value),placeholder:"sk-...","aria-describedby":h?g:void 0,"aria-invalid":h?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-codex focus:border-cc-codex font-mono-code transition-shadow duration-150"})]})})})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsxs("button",{onClick:o,className:"px-3 py-2.5 min-h-[44px] min-w-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),l.jsx("div",{className:"flex-1"}),l.jsx("button",{onClick:a,className:"px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:e.trim()?i:n,disabled:u,className:"btn-codex-aa px-5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:u?"none":"0 1px 3px var(--color-cc-codex-btn)"},children:u?"Checking...":e.trim()?"Save & Finish":"I've logged in"})]})]})}function IB({claudeConfigured:e,codexConfigured:t,onDone:n}){const i=!e&&!t,a=_x(),[o,u]=k.useState(a);return k.useEffect(()=>{o||requestAnimationFrame(()=>u(!0))},[o]),l.jsxs("div",{className:"p-7 pb-6 text-center",style:{opacity:o?1:0,transform:o?"translateY(0)":"translateY(8px)",transition:a?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1), transform 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"w-14 h-14 mx-auto rounded-2xl flex items-center justify-center mb-5",style:{background:i?"var(--color-cc-hover)":"color-mix(in srgb, var(--color-cc-success) 12%, transparent)"},children:i?l.jsx("svg",{className:"w-6 h-6 text-cc-muted",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}):l.jsx("svg",{className:"w-6 h-6 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg mb-2",children:i?"Setup Skipped":"You're all set!"}),l.jsx("div",{className:"text-sm text-cc-muted leading-relaxed mb-6",children:i?"You can configure providers anytime in Settings.":l.jsxs(l.Fragment,{children:[e&&l.jsx("span",{className:"block",children:"Claude Code is ready."}),t&&l.jsx("span",{className:"block",children:"Codex is ready."}),l.jsx("span",{className:"block mt-1 text-xs",children:"You can update these anytime in Settings."})]})}),l.jsx("button",{onClick:n,className:"btn-primary-aa w-full px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background] duration-150",style:{boxShadow:"0 1px 3px var(--color-cc-primary-btn)"},children:"Get Started"})]})}function UB({text:e}){const[t,n]=k.useState(!1),i=k.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e]);return l.jsx("button",{onClick:i,className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1 min-h-[44px] min-w-[44px] justify-end","aria-label":"Copy command",children:t?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"w-3 h-3 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"Copy"]})})}function HB(e){return W(t=>{var n;return!e||!t.magicUiAvailable?!1:((n=t.sessions.get(e))==null?void 0:n.magicUiActive)===!0})}const qB=k.lazy(()=>Zn(()=>import("./Playground-CvoHRMBd.js"),__vite__mapDeps([0,1])).then(e=>({default:e.Playground}))),VB=k.lazy(()=>Zn(()=>import("./SettingsPage-BZ2fBrHD.js"),[]).then(e=>({default:e.SettingsPage}))),GB=k.lazy(()=>Zn(()=>import("./IntegrationsPage-C3aW9cDI.js"),[]).then(e=>({default:e.IntegrationsPage}))),YB=k.lazy(()=>Zn(()=>import("./LinearSettingsPage-DDHFHt7j.js"),[]).then(e=>({default:e.LinearSettingsPage}))),XB=k.lazy(()=>Zn(()=>import("./LinearOAuthSettingsPage-_eAbciJN.js"),[]).then(e=>({default:e.LinearOAuthSettingsPage}))),QB=k.lazy(()=>Zn(()=>import("./TailscalePage-DFRiFKcb.js"),[]).then(e=>({default:e.TailscalePage}))),WB=k.lazy(()=>Zn(()=>import("./PromptsPage-CzTs1_Se.js"),[]).then(e=>({default:e.PromptsPage}))),ZB=k.lazy(()=>Zn(()=>Promise.resolve().then(()=>SP),void 0).then(e=>({default:e.EnvManager}))),KB=k.lazy(()=>Zn(()=>import("./SandboxManager-C3tFkiWz.js"),[]).then(e=>({default:e.SandboxManager}))),JB=k.lazy(()=>Zn(()=>import("./CronManager-Bq2lOMbZ.js"),[]).then(e=>({default:e.CronManager}))),eF=k.lazy(()=>Zn(()=>import("./AgentsPage-Byq8wvdn.js"),[]).then(e=>({default:e.AgentsPage}))),tF=k.lazy(()=>Zn(()=>import("./RunsPage-B7xru-Xy.js"),[]).then(e=>({default:e.RunsPage}))),nF=k.lazy(()=>Zn(()=>import("./DashboardPage-V77HIt8S.js"),[]).then(e=>({default:e.DashboardPage}))),sF=k.lazy(()=>Zn(()=>import("./MagicUIView-C0aiMTet.js"),__vite__mapDeps([2,1])).then(e=>({default:e.MagicUIView})));function bs(){return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"text-sm text-cc-muted",children:"Loading..."})})}function iF(){return k.useSyncExternalStore(e=>(window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)),()=>window.location.hash)}function rF(){const e=W(T=>T.isAuthenticated),t=W(T=>T.darkMode),n=W(T=>T.currentSessionId),i=W(T=>T.sidebarOpen),a=W(T=>T.taskPanelOpen),o=W(T=>T.homeResetKey),u=W(T=>T.activeTab),h=HB(n),f=W(T=>T.sessionCreating),p=W(T=>T.sessionCreatingBackend),g=W(T=>T.creationProgress),v=W(T=>T.creationError),b=W(T=>T.creationDraft),y=W(T=>T.updateOverlayActive),_=iF(),j=k.useMemo(()=>Kx(_),[_]),N=j.page==="settings",S=j.page==="prompts",C=j.page==="integrations",E=j.page==="integration-linear",R=j.page==="integration-linear-oauth",A=j.page==="integration-tailscale",O=j.page==="environments",P=j.page==="sandboxes",z=j.page==="scheduled",Z=j.page==="agents"||j.page==="agent-detail",I=j.page==="runs",q=j.page==="dashboard",L=j.page==="session"||j.page==="home";k.useEffect(()=>{J8(_||"#/")},[_]),k.useEffect(()=>{document.documentElement.classList.toggle("dark",t)},[t]);const de=k.useRef(W.getState().currentSessionId);k.useEffect(()=>{if(de.current!==null&&j.page==="home"){Jx(de.current,!0),de.current=null;return}if(de.current=null,j.page==="session"){const T=W.getState();T.currentSessionId!==j.sessionId&&T.setCurrentSession(j.sessionId),Do(j.sessionId)}else if(j.page==="home"){const T=W.getState();T.currentSessionId!==null&&T.setCurrentSession(null)}},[j]);const Q=W(T=>n?T.changedFilesTick.get(n)??0:0),V=W(T=>T.diffBase),G=W(T=>T.setGitChangedFilesCount),H=W(T=>{var Ne,Ce;return n&&(((Ne=T.sessions.get(n))==null?void 0:Ne.cwd)||((Ce=T.sdkSessions.find($=>$.sessionId===n))==null?void 0:Ce.cwd))||null});k.useEffect(()=>{if(!n||!H)return;let T=!1;return we.getChangedFiles(H,V).then(({files:Ne})=>{if(T)return;const Ce=`${H}/`,$=Ne.filter(B=>B.path===H||B.path.startsWith(Ce)).length;G(n,$)}).catch(()=>{}),()=>{T=!0}},[n,H,V,Q,G]),k.useEffect(()=>{const T=()=>{we.checkForUpdate().then(Ce=>{W.getState().setUpdateInfo(Ce)}).catch(()=>{})};T();const Ne=setInterval(T,300*1e3);return()=>clearInterval(Ne)},[]),k.useEffect(()=>{const T=()=>{we.getClaudeCompat().then(Ce=>{W.getState().setClaudeCompatInfo(Ce)}).catch(()=>{})};T();const Ne=setInterval(T,300*1e3);return()=>clearInterval(Ne)},[]);const[ae,ye]=k.useState(!1);return k.useEffect(()=>{e&&we.getSettings().then(T=>{T.publicUrl&&W.getState().setPublicUrl(T.publicUrl),W.getState().setMagicUiAvailable(!!T.magicUiEnabled&&!!T.claudeCliAvailable),T.onboardingCompleted||ye(!0)}).catch(()=>{})},[e]),k.useEffect(()=>{localStorage.getItem("companion_docker_prompt_pending")==="1"&&localStorage.removeItem("companion_docker_prompt_pending")},[]),e?j.page==="playground"?l.jsx(k.Suspense,{fallback:l.jsx(bs,{}),children:l.jsx(qB,{})}):l.jsxs("div",{className:"fixed inset-0 flex font-sans-ui bg-cc-bg text-cc-fg antialiased pt-safe overflow-hidden overscroll-none",children:[i&&l.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>W.getState().setSidebarOpen(!1)}),l.jsx("div",{className:`
|
|
132
|
+
Layer 2/5: def456 complete`})]}),e==="done"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-success",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm3.78-9.72a.75.75 0 0 0-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.06 0l4.25-4.25z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-success",children:"Sandbox Image Updated"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"The Docker image has been updated successfully."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Done"})})]}),e==="error"&&l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-cc-error",children:l.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zM5.22 5.22a.75.75 0 0 1 1.06 0L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 1 1-1.06 1.06L8 9.06l-1.72 1.72a.75.75 0 0 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 0-1.06z"})}),l.jsx("h2",{className:"text-sm font-semibold text-cc-error",children:"Image Update Failed"})]}),l.jsx("p",{className:"text-xs text-cc-muted mb-4",children:"Failed to update the Docker image."}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-hover text-cc-fg",children:"Close"}),l.jsx("span",{className:"px-3 py-1.5 rounded-lg text-xs bg-cc-primary text-white",children:"Retry"})]})]})]})})}function OB(){const[e,t]=k.useState(null),[n,i]=k.useState({state:"idle"}),[a,o]=k.useState(""),[u,h]=k.useState(!1),[f,p]=k.useState(""),g=k.useCallback(async()=>{try{t(await we.getClaudeAccount())}catch(A){p(A instanceof Error?A.message:String(A))}},[]);k.useEffect(()=>{g(),we.getClaudeLoginStatus().then(i).catch(()=>{})},[g]);const v=async()=>{h(!0),p(""),o("");try{const A=await we.startClaudeLogin();i(A),A.state==="error"&&A.error&&p(A.error)}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},b=async()=>{h(!0),p("");try{const A=await we.submitClaudeLoginCode(a);i(A),A.state==="success"&&(o(""),await g())}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},y=async()=>{h(!0);try{i(await we.cancelClaudeLogin()),o("")}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},_=async()=>{h(!0),p("");try{const A=await we.claudeLogout();!A.ok&&A.error&&p(A.error),i({state:"idle"}),await g()}catch(A){p(A instanceof Error?A.message:String(A))}finally{h(!1)}},j=n.state==="awaiting_code",N=n.state==="verifying",S=j||N,C=(e==null?void 0:e.cliAvailable)===!1,E=e!=null&&e.orgName&&e.email&&e.orgName.includes(e.email)?null:(e==null?void 0:e.orgName)??null,R=e!=null&&e.authenticated?[e.email,e.subscriptionType?LB(e.subscriptionType):null,E].filter(Boolean).join(" · "):null;return l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"block text-sm font-medium",children:"Claude Account"}),l.jsx("p",{className:"text-xs text-cc-muted",children:"Sign in with your Claude subscription. You'll open a link, approve on any device, and paste the code back here — no terminal access needed."}),C&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:"Claude CLI not found on this machine. Install it to sign in."}),!C&&e&&!S&&l.jsx("p",{className:"text-xs text-cc-muted","data-testid":"claude-account-status",children:R?`Signed in as ${R}`:e.authenticated?"Signed in":"Not signed in"}),S&&l.jsxs("div",{className:"px-3 py-3 rounded-lg bg-cc-bg border border-cc-primary/20 space-y-3",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("p",{className:"text-xs text-cc-muted",children:"1. Open this link and approve:"}),l.jsx("a",{href:n.authUrl,target:"_blank",rel:"noreferrer","data-testid":"claude-auth-url",className:"block text-xs text-cc-primary underline break-all",children:n.authUrl})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs text-cc-muted",htmlFor:"claude-auth-code",children:"2. Paste the code you were shown:"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{id:"claude-auth-code",type:"text",value:a,disabled:N,autoComplete:"off",spellCheck:!1,onChange:A=>o(A.target.value),onKeyDown:A=>{A.key==="Enter"&&a.trim()&&!u&&(A.preventDefault(),b())},placeholder:"Paste code here",className:"flex-1 px-3 py-2 min-h-[40px] text-sm font-mono-code bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40"}),l.jsx("button",{type:"button",onClick:b,disabled:u||!a.trim(),className:`px-3 py-2 min-h-[40px] rounded-lg text-sm font-medium transition-colors ${u||!a.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:N?"Verifying…":"Submit"})]})]}),n.error&&l.jsx("p",{role:"alert",className:"text-xs text-cc-error",children:n.error})]}),n.state==="success"&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Signed in to Claude. New sessions will use this account."}),(n.state==="error"||f)&&l.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:f||n.error}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[S?l.jsx("button",{type:"button",onClick:y,disabled:u,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Cancel"}):l.jsx("button",{type:"button",onClick:v,disabled:u||C,className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${u||C?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:u?"Starting…":e!=null&&e.authenticated?"Sign in again":"Sign in with Claude"}),(e==null?void 0:e.authenticated)&&!S&&l.jsx("button",{type:"button",onClick:_,disabled:u,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Sign out"})]})]})}function LB(e){return e.charAt(0).toUpperCase()+e.slice(1)}const DB=2e3;function zB(){const[e,t]=k.useState(null),[n,i]=k.useState({state:"idle"}),[a,o]=k.useState(!1),[u,h]=k.useState(""),[f,p]=k.useState(!1),g=k.useRef(null),v=k.useCallback(async()=>{try{t(await we.getCodexAccount())}catch(R){h(R instanceof Error?R.message:String(R))}},[]),b=k.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=null)},[]),y=k.useCallback(()=>{b(),g.current=setInterval(async()=>{try{const R=await we.getCodexLoginStatus();i(R),R.state!=="pending"&&(b(),R.state==="success"&&v())}catch{}},DB)},[v,b]);k.useEffect(()=>(v(),we.getCodexLoginStatus().then(R=>{i(R),R.state==="pending"&&y()}).catch(()=>{}),b),[v,y,b]);const _=async()=>{o(!0),h("");try{const R=await we.startCodexLogin();i(R),R.state==="pending"?y():R.error&&h(R.error)}catch(R){h(R instanceof Error?R.message:String(R))}finally{o(!1)}},j=async()=>{o(!0),b();try{i(await we.cancelCodexLogin())}catch(R){h(R instanceof Error?R.message:String(R))}finally{o(!1)}},N=async()=>{o(!0),h("");try{const R=await we.codexLogout();!R.ok&&R.error&&h(R.error),i({state:"idle"}),await v()}catch(R){h(R instanceof Error?R.message:String(R))}finally{o(!1)}},S=async()=>{if(n.userCode)try{await navigator.clipboard.writeText(n.userCode),p(!0),setTimeout(()=>p(!1),1500)}catch{}},C=n.state==="pending",E=(e==null?void 0:e.cliAvailable)===!1;return l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"block text-sm font-medium",children:"ChatGPT Subscription (Codex)"}),l.jsx("p",{className:"text-xs text-cc-muted",children:"Sign in with your ChatGPT plan to use Codex without an API key. You'll get a code to enter on any device — no terminal access needed."}),E&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:"Codex CLI not found on this machine. Install it to sign in."}),!E&&e&&!C&&l.jsx("p",{className:"text-xs text-cc-muted","data-testid":"codex-account-status",children:e.authenticated?e.method==="apiKey"?"Authenticated with an OpenAI API key":`Signed in as ${e.email||"ChatGPT account"}${e.planType?` (${e.planType})`:""}`:"Not signed in"}),C&&l.jsxs("div",{className:"px-3 py-3 rounded-lg bg-cc-bg border border-cc-primary/20 space-y-2",children:[l.jsxs("p",{className:"text-xs text-cc-muted",children:["1. Open"," ",l.jsx("a",{href:n.verificationUrl,target:"_blank",rel:"noreferrer",className:"text-cc-primary underline",children:n.verificationUrl})]}),l.jsx("p",{className:"text-xs text-cc-muted",children:"2. Enter this code:"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"font-mono-code text-lg tracking-widest bg-cc-code-bg px-3 py-1.5 rounded text-cc-code-fg","data-testid":"codex-user-code",children:n.userCode}),l.jsx("button",{type:"button",onClick:S,className:"px-2 py-1 min-h-[32px] rounded-md text-xs bg-cc-hover text-cc-fg cursor-pointer",children:f?"Copied":"Copy"})]}),l.jsx("p",{className:"text-xs text-cc-muted",role:"status",children:"Waiting for approval…"})]}),n.state==="success"&&l.jsx("div",{role:"status",className:"px-3 py-2 rounded-lg bg-cc-success/10 border border-cc-success/20 text-xs text-cc-success",children:"Signed in to Codex. New sessions will use this account."}),(n.state==="error"||u)&&l.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-cc-error/10 border border-cc-error/20 text-xs text-cc-error",children:u||n.error}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[C?l.jsx("button",{type:"button",onClick:j,disabled:a,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Cancel"}):l.jsx("button",{type:"button",onClick:_,disabled:a||E,className:`px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${a||E?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:a?"Starting…":e!=null&&e.authenticated?"Sign in again":"Sign in with ChatGPT"}),(e==null?void 0:e.authenticated)&&!C&&l.jsx("button",{type:"button",onClick:N,disabled:a,className:"px-4 py-2 min-h-[44px] rounded-lg text-sm font-medium bg-cc-hover text-cc-fg cursor-pointer",children:"Sign out"})]})]})}const v0=["welcome","claude","codex","done"],nS='button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function _x(){return typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $B({onComplete:e}){const[t,n]=k.useState("welcome"),[i,a]=k.useState(""),[o,u]=k.useState(""),[h,f]=k.useState(!1),[p,g]=k.useState(""),[v,b]=k.useState(!1),[y,_]=k.useState(!1),[j,N]=k.useState(_x),S=k.useRef(null);k.useEffect(()=>{j||requestAnimationFrame(()=>N(!0))},[j]),k.useEffect(()=>{const q=S.current;if(!q)return;function L(Q){if(Q.key==="Escape"){Q.preventDefault();return}if(Q.key!=="Tab")return;const V=q.querySelectorAll(nS);if(V.length===0)return;const G=V[0],H=V[V.length-1];Q.shiftKey?document.activeElement===G&&(Q.preventDefault(),H.focus()):document.activeElement===H&&(Q.preventDefault(),G.focus())}document.addEventListener("keydown",L);const de=q.querySelector(nS);return de==null||de.focus(),()=>document.removeEventListener("keydown",L)},[t]);const C=k.useCallback(async()=>{if(!i.trim()){n("codex");return}f(!0),g("");try{await we.updateSettings({claudeCodeOAuthToken:i.trim()}),b(!0),n("codex")}catch(q){g(q instanceof Error?q.message:"Failed to save token")}finally{f(!1)}},[i]),E=k.useCallback(async()=>{f(!0),g("");try{(await we.getSettings()).codexDeviceAuthConfigured?(_(!0),await A()):g("No Codex auth found yet. Complete the sign-in above, then check again.")}catch(q){g(q instanceof Error?q.message:"Failed to check auth status")}finally{f(!1)}},[]),R=k.useCallback(async()=>{f(!0),g("");try{await we.updateSettings({openaiApiKey:o.trim()}),_(!0),await A()}catch(q){g(q instanceof Error?q.message:"Failed to save API key")}finally{f(!1)}},[o]),A=k.useCallback(async()=>{try{await we.updateSettings({onboardingCompleted:!0})}catch{}n("done")},[]),O=k.useCallback(()=>{e()},[e]),P=k.useCallback(async()=>{await A(),e()},[A,e]),z=k.useCallback(q=>{g(""),n(q)},[]),Z=v0.indexOf(t),I=_x();return $o.createPortal(l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"linear-gradient(145deg, var(--color-cc-bg) 0%, color-mix(in srgb, var(--color-cc-bg) 94%, var(--color-cc-primary) 6%) 100%)",opacity:j?1:0,transition:I?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",style:{background:"linear-gradient(90deg, transparent 0%, var(--color-cc-primary) 30%, var(--color-cc-primary) 70%, transparent 100%)",opacity:.6}}),l.jsxs("div",{ref:S,role:"dialog","aria-modal":"true","aria-label":"Provider setup",className:"w-full max-w-[520px] mx-6",style:{transform:j?"translateY(0)":"translateY(12px)",opacity:j?1:0,transition:I?"none":"transform 500ms cubic-bezier(0.16, 1, 0.3, 1) 100ms, opacity 400ms cubic-bezier(0.16, 1, 0.3, 1) 100ms"},children:[t!=="done"&&l.jsx("div",{className:"flex items-center gap-1.5 mb-6 justify-center",role:"status","aria-label":`Step ${Z+1} of ${v0.length-1}`,children:v0.slice(0,3).map((q,L)=>l.jsx("div",{className:"h-[3px] rounded-full transition-[transform,background,opacity] duration-300",style:{width:32,transform:L===Z?"scaleX(1)":"scaleX(0.375)",transformOrigin:"center",background:L<=Z?"var(--color-cc-primary)":"var(--color-cc-border)",opacity:L<=Z?1:.5}},q))}),l.jsxs("div",{className:"bg-cc-card border border-cc-border overflow-hidden",style:{borderRadius:16,boxShadow:"0 1px 3px var(--color-cc-border), 0 8px 32px var(--color-cc-border)"},children:[t==="welcome"&&l.jsx(PB,{onSetupClaude:()=>z("claude"),onSetupCodex:()=>z("codex")}),t==="claude"&&l.jsx(BB,{token:i,onTokenChange:a,onSave:C,onSkip:()=>z("codex"),saving:h,error:p}),t==="codex"&&l.jsx(FB,{apiKey:o,onApiKeyChange:u,onCheckAuth:E,onSaveApiKey:R,onSkip:()=>A(),onBack:()=>z("claude"),saving:h,error:p}),t==="done"&&l.jsx(IB,{claudeConfigured:v,codexConfigured:y,onDone:O})]}),t==="welcome"&&l.jsx("button",{onClick:P,className:"w-full text-center text-xs text-cc-muted hover:text-cc-fg transition-colors mt-4 min-h-[44px] flex items-center justify-center",children:"Skip setup — I'll configure this later in Settings"})]})]}),document.body)}function PB({onSetupClaude:e,onSetupCodex:t}){return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"First time setup"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Welcome to The Companion"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Connect your AI providers to start coding. Configure one or both."})]}),l.jsxs("div",{className:"space-y-2.5",children:[l.jsxs("button",{onClick:e,className:"provider-card--claude group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-primary/10 text-cc-primary",children:"C"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Claude Code"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"Anthropic's coding agent — requires an OAuth token"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),l.jsxs("button",{onClick:t,className:"provider-card--codex group w-full flex items-center gap-3.5 p-3.5 min-h-[52px] rounded-xl border border-cc-border bg-cc-bg text-left transition-[transform,border-color,box-shadow] duration-150",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 font-semibold text-sm bg-cc-codex/10 text-cc-codex",children:"X"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium text-cc-fg",children:"Codex"}),l.jsx("div",{className:"text-[11px] text-cc-muted leading-snug mt-0.5",children:"OpenAI's coding agent — log in via ChatGPT"})]}),l.jsx("svg",{className:"w-4 h-4 text-cc-muted flex-shrink-0 transition-transform duration-150 group-hover:translate-x-0.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]})]})}function BB({token:e,onTokenChange:t,onSave:n,onSkip:i,saving:a,error:o}){const u=k.useRef(null);k.useEffect(()=>{var f;(f=u.current)==null||f.focus()},[]);const h="claude-token-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 1 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Claude Code"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Sign in with your Claude subscription — no terminal needed."})]}),l.jsx(OB,{}),l.jsx("div",{className:"mt-5 pt-4 border-t border-cc-border",children:l.jsx("p",{className:"text-xs text-cc-muted mb-2",children:"Or paste a long-lived token instead — generate one with:"})}),l.jsxs("div",{className:"rounded-lg overflow-hidden mb-4 border border-cc-border",style:{background:"var(--color-cc-code-bg)"},children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-cc-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-error opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-warning opacity-60"}),l.jsx("div",{className:"w-[7px] h-[7px] rounded-full bg-cc-success opacity-60"})]}),l.jsx(UB,{text:"claude setup-token"})]}),l.jsx("div",{className:"px-3.5 py-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-cc-muted text-xs font-mono-code select-none","aria-hidden":"true",children:"$"}),l.jsx("code",{className:"text-[13px] font-mono-code text-cc-fg select-all",children:"claude setup-token"})]})})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{htmlFor:"claude-token",className:"text-xs text-cc-muted block mb-1.5",children:"OAuth Token"}),l.jsx("input",{ref:u,id:"claude-token",type:"password",value:e,onChange:f=>t(f.target.value),placeholder:"Paste the token from your terminal...","aria-describedby":o?h:void 0,"aria-invalid":o?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary focus:border-cc-primary font-mono-code transition-shadow duration-150"})]}),o&&l.jsxs("div",{id:h,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:o})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsx("button",{onClick:i,className:"flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:n,disabled:a,className:"btn-primary-aa flex-1 px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:a?"none":"0 1px 3px var(--color-cc-primary-btn)"},children:a?"Saving...":e.trim()?"Save & Continue":"Continue"})]})]})}function FB({apiKey:e,onApiKeyChange:t,onCheckAuth:n,onSaveApiKey:i,onSkip:a,onBack:o,saving:u,error:h}){const[f,p]=k.useState(!1),g="codex-auth-error";return l.jsxs("div",{className:"p-7 pb-6",children:[l.jsxs("div",{className:"mb-5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-[0.12em] text-cc-muted font-medium mb-2",children:"Step 2 of 2"}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg leading-tight",children:"Set up Codex"}),l.jsx("p",{className:"text-sm text-cc-muted mt-1.5 leading-relaxed",children:"Sign in with your ChatGPT account — no terminal needed."})]}),l.jsx(zB,{}),h&&l.jsxs("div",{id:g,role:"alert",className:"flex items-start gap-2 mb-4 text-xs text-cc-error",children:[l.jsxs("svg",{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 8v4m0 4h.01"})]}),l.jsx("span",{children:h})]}),l.jsxs("div",{className:"mb-4",children:[l.jsxs("button",{onClick:()=>p(!f),className:"text-xs text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3 h-3 transition-transform duration-150",style:{transform:f?"rotate(90deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),"Or use an API key instead"]}),l.jsx("div",{className:"accordion-panel","data-open":f?"true":"false",children:l.jsx("div",{className:"accordion-inner",children:l.jsxs("div",{className:"mt-3",children:[l.jsx("label",{htmlFor:"openai-key",className:"text-xs text-cc-muted block mb-1.5",children:"OpenAI API Key"}),l.jsx("input",{id:"openai-key",type:"password",value:e,onChange:v=>t(v.target.value),placeholder:"sk-...","aria-describedby":h?g:void 0,"aria-invalid":h?!0:void 0,className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-codex focus:border-cc-codex font-mono-code transition-shadow duration-150"})]})})})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[l.jsxs("button",{onClick:o,className:"px-3 py-2.5 min-h-[44px] min-w-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1",children:[l.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),l.jsx("div",{className:"flex-1"}),l.jsx("button",{onClick:a,className:"px-4 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors",children:"Skip"}),l.jsx("button",{onClick:e.trim()?i:n,disabled:u,className:"btn-codex-aa px-5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background,opacity] duration-150 disabled:opacity-50",style:{boxShadow:u?"none":"0 1px 3px var(--color-cc-codex-btn)"},children:u?"Checking...":e.trim()?"Save & Finish":"I've logged in"})]})]})}function IB({claudeConfigured:e,codexConfigured:t,onDone:n}){const i=!e&&!t,a=_x(),[o,u]=k.useState(a);return k.useEffect(()=>{o||requestAnimationFrame(()=>u(!0))},[o]),l.jsxs("div",{className:"p-7 pb-6 text-center",style:{opacity:o?1:0,transform:o?"translateY(0)":"translateY(8px)",transition:a?"none":"opacity 400ms cubic-bezier(0.16, 1, 0.3, 1), transform 400ms cubic-bezier(0.16, 1, 0.3, 1)"},children:[l.jsx("div",{className:"w-14 h-14 mx-auto rounded-2xl flex items-center justify-center mb-5",style:{background:i?"var(--color-cc-hover)":"color-mix(in srgb, var(--color-cc-success) 12%, transparent)"},children:i?l.jsx("svg",{className:"w-6 h-6 text-cc-muted",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}):l.jsx("svg",{className:"w-6 h-6 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),l.jsx("h2",{className:"text-xl font-semibold text-cc-fg mb-2",children:i?"Setup Skipped":"You're all set!"}),l.jsx("div",{className:"text-sm text-cc-muted leading-relaxed mb-6",children:i?"You can configure providers anytime in Settings.":l.jsxs(l.Fragment,{children:[e&&l.jsx("span",{className:"block",children:"Claude Code is ready."}),t&&l.jsx("span",{className:"block",children:"Codex is ready."}),l.jsx("span",{className:"block mt-1 text-xs",children:"You can update these anytime in Settings."})]})}),l.jsx("button",{onClick:n,className:"btn-primary-aa w-full px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium text-white transition-[background] duration-150",style:{boxShadow:"0 1px 3px var(--color-cc-primary-btn)"},children:"Get Started"})]})}function UB({text:e}){const[t,n]=k.useState(!1),i=k.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e]);return l.jsx("button",{onClick:i,className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors flex items-center gap-1 min-h-[44px] min-w-[44px] justify-end","aria-label":"Copy command",children:t?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"w-3 h-3 text-cc-success",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24","aria-hidden":"true",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"Copy"]})})}function HB(e){return W(t=>{var n;return!e||!t.magicUiAvailable?!1:((n=t.sessions.get(e))==null?void 0:n.magicUiActive)===!0})}const qB=k.lazy(()=>Zn(()=>import("./Playground-DWAal5bL.js"),__vite__mapDeps([0,1])).then(e=>({default:e.Playground}))),VB=k.lazy(()=>Zn(()=>import("./SettingsPage-CrV1Tb8F.js"),[]).then(e=>({default:e.SettingsPage}))),GB=k.lazy(()=>Zn(()=>import("./IntegrationsPage-DrE-8KPE.js"),[]).then(e=>({default:e.IntegrationsPage}))),YB=k.lazy(()=>Zn(()=>import("./LinearSettingsPage-C1RHlPwX.js"),[]).then(e=>({default:e.LinearSettingsPage}))),XB=k.lazy(()=>Zn(()=>import("./LinearOAuthSettingsPage-Czi_NsX1.js"),[]).then(e=>({default:e.LinearOAuthSettingsPage}))),QB=k.lazy(()=>Zn(()=>import("./TailscalePage-ba0g8QT1.js"),[]).then(e=>({default:e.TailscalePage}))),WB=k.lazy(()=>Zn(()=>import("./PromptsPage-D2YI_-95.js"),[]).then(e=>({default:e.PromptsPage}))),ZB=k.lazy(()=>Zn(()=>Promise.resolve().then(()=>SP),void 0).then(e=>({default:e.EnvManager}))),KB=k.lazy(()=>Zn(()=>import("./SandboxManager-vWbQKeLT.js"),[]).then(e=>({default:e.SandboxManager}))),JB=k.lazy(()=>Zn(()=>import("./CronManager-DNN709nr.js"),[]).then(e=>({default:e.CronManager}))),eF=k.lazy(()=>Zn(()=>import("./AgentsPage-0Fi6tbQN.js"),[]).then(e=>({default:e.AgentsPage}))),tF=k.lazy(()=>Zn(()=>import("./RunsPage-dn5rSkPu.js"),[]).then(e=>({default:e.RunsPage}))),nF=k.lazy(()=>Zn(()=>import("./DashboardPage-6cNRrqGQ.js"),[]).then(e=>({default:e.DashboardPage}))),sF=k.lazy(()=>Zn(()=>import("./MagicUIView-BVM8CqGg.js"),__vite__mapDeps([2,1])).then(e=>({default:e.MagicUIView})));function bs(){return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"text-sm text-cc-muted",children:"Loading..."})})}function iF(){return k.useSyncExternalStore(e=>(window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)),()=>window.location.hash)}function rF(){const e=W(T=>T.isAuthenticated),t=W(T=>T.darkMode),n=W(T=>T.currentSessionId),i=W(T=>T.sidebarOpen),a=W(T=>T.taskPanelOpen),o=W(T=>T.homeResetKey),u=W(T=>T.activeTab),h=HB(n),f=W(T=>T.sessionCreating),p=W(T=>T.sessionCreatingBackend),g=W(T=>T.creationProgress),v=W(T=>T.creationError),b=W(T=>T.creationDraft),y=W(T=>T.updateOverlayActive),_=iF(),j=k.useMemo(()=>Kx(_),[_]),N=j.page==="settings",S=j.page==="prompts",C=j.page==="integrations",E=j.page==="integration-linear",R=j.page==="integration-linear-oauth",A=j.page==="integration-tailscale",O=j.page==="environments",P=j.page==="sandboxes",z=j.page==="scheduled",Z=j.page==="agents"||j.page==="agent-detail",I=j.page==="runs",q=j.page==="dashboard",L=j.page==="session"||j.page==="home";k.useEffect(()=>{J8(_||"#/")},[_]),k.useEffect(()=>{document.documentElement.classList.toggle("dark",t)},[t]);const de=k.useRef(W.getState().currentSessionId);k.useEffect(()=>{if(de.current!==null&&j.page==="home"){Jx(de.current,!0),de.current=null;return}if(de.current=null,j.page==="session"){const T=W.getState();T.currentSessionId!==j.sessionId&&T.setCurrentSession(j.sessionId),Do(j.sessionId)}else if(j.page==="home"){const T=W.getState();T.currentSessionId!==null&&T.setCurrentSession(null)}},[j]);const Q=W(T=>n?T.changedFilesTick.get(n)??0:0),V=W(T=>T.diffBase),G=W(T=>T.setGitChangedFilesCount),H=W(T=>{var Ne,Ce;return n&&(((Ne=T.sessions.get(n))==null?void 0:Ne.cwd)||((Ce=T.sdkSessions.find($=>$.sessionId===n))==null?void 0:Ce.cwd))||null});k.useEffect(()=>{if(!n||!H)return;let T=!1;return we.getChangedFiles(H,V).then(({files:Ne})=>{if(T)return;const Ce=`${H}/`,$=Ne.filter(B=>B.path===H||B.path.startsWith(Ce)).length;G(n,$)}).catch(()=>{}),()=>{T=!0}},[n,H,V,Q,G]),k.useEffect(()=>{const T=()=>{we.checkForUpdate().then(Ce=>{W.getState().setUpdateInfo(Ce)}).catch(()=>{})};T();const Ne=setInterval(T,300*1e3);return()=>clearInterval(Ne)},[]),k.useEffect(()=>{const T=()=>{we.getClaudeCompat().then(Ce=>{W.getState().setClaudeCompatInfo(Ce)}).catch(()=>{})};T();const Ne=setInterval(T,300*1e3);return()=>clearInterval(Ne)},[]);const[ae,ye]=k.useState(!1);return k.useEffect(()=>{e&&we.getSettings().then(T=>{T.publicUrl&&W.getState().setPublicUrl(T.publicUrl),W.getState().setMagicUiAvailable(!!T.magicUiEnabled&&!!T.claudeCliAvailable),T.onboardingCompleted||ye(!0)}).catch(()=>{})},[e]),k.useEffect(()=>{localStorage.getItem("companion_docker_prompt_pending")==="1"&&localStorage.removeItem("companion_docker_prompt_pending")},[]),e?j.page==="playground"?l.jsx(k.Suspense,{fallback:l.jsx(bs,{}),children:l.jsx(qB,{})}):l.jsxs("div",{className:"fixed inset-0 flex font-sans-ui bg-cc-bg text-cc-fg antialiased pt-safe overflow-hidden overscroll-none",children:[i&&l.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>W.getState().setSidebarOpen(!1)}),l.jsx("div",{className:`
|
|
133
133
|
fixed inset-y-0 left-0 md:relative md:inset-auto z-40 md:z-auto
|
|
134
134
|
h-full shrink-0 transition-all duration-200 pt-safe md:pt-0
|
|
135
135
|
${i?"w-full md:w-[260px] translate-x-0":"w-0 -translate-x-full md:w-0 md:-translate-x-full"}
|
|
@@ -139,4 +139,4 @@ Layer 2/5: def456 complete`})]}),e==="done"&&l.jsxs("div",{className:"p-5",child
|
|
|
139
139
|
h-full shrink-0 transition-all duration-200 pt-safe lg:pt-0
|
|
140
140
|
${a?"w-full lg:w-[320px] translate-x-0":"w-0 translate-x-full lg:w-0 lg:translate-x-full"}
|
|
141
141
|
overflow-hidden
|
|
142
|
-
`,children:l.jsx(_B,{sessionId:n})})]}),l.jsx(AB,{active:y}),l.jsx(RB,{}),ae&&l.jsx($B,{onComplete:()=>ye(!1)})]}):l.jsx(rR,{})}class aF extends k.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){ga(t,{source:"react_error_boundary",componentStack:n.componentStack})}render(){return this.state.hasError?l.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg px-4",children:l.jsxs("div",{className:"max-w-md w-full rounded-xl border border-cc-border bg-cc-card p-5 shadow-sm",children:[l.jsx("h1",{className:"text-base font-semibold",children:"A runtime error occurred"}),l.jsx("p",{className:"text-sm text-cc-muted mt-2",children:"Reload the page to recover. The error has been reported."}),l.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-4 inline-flex items-center rounded-md bg-cc-primary px-3 py-1.5 text-sm text-white hover:bg-cc-primary-hover cursor-pointer",children:"Reload"})]})}):this.props.children}}K8();g4.createRoot(document.getElementById("root")).render(l.jsx(k.StrictMode,{children:l.jsx(aF,{children:l.jsx(rF,{})})}));Zn(()=>import("./sw-register-
|
|
142
|
+
`,children:l.jsx(_B,{sessionId:n})})]}),l.jsx(AB,{active:y}),l.jsx(RB,{}),ae&&l.jsx($B,{onComplete:()=>ye(!1)})]}):l.jsx(rR,{})}class aF extends k.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){ga(t,{source:"react_error_boundary",componentStack:n.componentStack})}render(){return this.state.hasError?l.jsx("div",{className:"h-[100dvh] flex items-center justify-center bg-cc-bg text-cc-fg px-4",children:l.jsxs("div",{className:"max-w-md w-full rounded-xl border border-cc-border bg-cc-card p-5 shadow-sm",children:[l.jsx("h1",{className:"text-base font-semibold",children:"A runtime error occurred"}),l.jsx("p",{className:"text-sm text-cc-muted mt-2",children:"Reload the page to recover. The error has been reported."}),l.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-4 inline-flex items-center rounded-md bg-cc-primary px-3 py-1.5 text-sm text-white hover:bg-cc-primary-hover cursor-pointer",children:"Reload"})]})}):this.props.children}}K8();g4.createRoot(document.getElementById("root")).render(l.jsx(k.StrictMode,{children:l.jsx(aF,{children:l.jsx(rF,{})})}));Zn(()=>import("./sw-register-BBun0drK.js"),[]).catch(()=>{});export{sP as A,ol as B,OB as C,oF as D,wo as E,jP as F,cB as G,qP as H,_h as I,Lo as J,$o as K,wu as L,D9 as M,q2 as N,pC as O,V9 as P,P9 as Q,q9 as R,CB as S,hS as T,jB as U,H9 as V,cF as W,fF as X,hF as Y,Zn as _,we as a,Zg as b,zB as c,Xn as d,lR as e,U9 as f,Z8 as g,fP as h,_P as i,l as j,e9 as k,_9 as l,Oo as m,Jx as n,pF as o,mF as p,d9 as q,k as r,uF as s,QP as t,W as u,h9 as v,pP as w,aB as x,lB as y,Hi as z};
|