@kimuson/claude-code-viewer 0.4.0-beta.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/README.md +20 -3
  2. package/dist/standalone/.next/BUILD_ID +1 -1
  3. package/dist/standalone/.next/app-build-manifest.json +2 -2
  4. package/dist/standalone/.next/build-manifest.json +2 -2
  5. package/dist/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  6. package/dist/standalone/.next/server/app/api/[[...route]]/route.js +8 -8
  7. package/dist/standalone/.next/server/app/api/[[...route]]/route_client-reference-manifest.js +1 -1
  8. package/dist/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  9. package/dist/standalone/.next/server/app/projects/[projectId]/latest/page_client-reference-manifest.js +1 -1
  10. package/dist/standalone/.next/server/app/projects/[projectId]/sessions/[sessionId]/page.js +1 -1
  11. package/dist/standalone/.next/server/app/projects/[projectId]/sessions/[sessionId]/page_client-reference-manifest.js +1 -1
  12. package/dist/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  13. package/dist/standalone/.next/server/pages/500.html +1 -1
  14. package/dist/standalone/.next/static/chunks/app/projects/[projectId]/sessions/[sessionId]/page-017b6ec1c81ac313.js +1 -0
  15. package/dist/standalone/.next/static/css/{b96ebe4fbf6b8e90.css → 45fa9b95e9a0f110.css} +1 -1
  16. package/dist/standalone/node_modules/.pnpm/{node-releases@2.0.25 → node-releases@2.0.26}/node_modules/node-releases/data/processed/envs.json +1 -1
  17. package/dist/standalone/package.json +7 -7
  18. package/package.json +7 -7
  19. package/dist/standalone/.next/static/chunks/app/projects/[projectId]/sessions/[sessionId]/page-e31d3f73d1c089c3.js +0 -1
  20. /package/dist/standalone/.next/static/{78s42fGhS1UdQK6hy94yh → c4tthSX8OBHcATFEpNk3-}/_buildManifest.js +0 -0
  21. /package/dist/standalone/.next/static/{78s42fGhS1UdQK6hy94yh → c4tthSX8OBHcATFEpNk3-}/_ssgManifest.js +0 -0
  22. /package/dist/standalone/node_modules/.pnpm/{node-releases@2.0.25 → node-releases@2.0.26}/node_modules/node-releases/data/release-schedule/release-schedule.json +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[998],{12259:(e,s,t)=>{"use strict";t.d(s,{SessionPageContent:()=>sa});var r=t(26423),a=t(52875),n=t(19864),l=t(86429),i=t(67225),o=t(25070),d=t(83068),c=t(20072),m=t(69087),x=t(63031),u=t(57484),h=t(78238),g=t(72379),p=t(67826),f=t(63710),b=t(36150),j=t(87574),v=t(62544);let y=e=>{let{permissionRequest:s,isOpen:t,onResponse:a}=e,[n,l]=(0,m.useState)(!1),[i,o]=(0,m.useState)(!1),{config:d}=(0,j.U)();if(!s)return null;let c=async e=>{l(!0);let t={permissionRequestId:s.id,decision:e};try{await a(t)}finally{l(!1)}},y=async e=>{try{await navigator.clipboard.writeText(e)}catch(e){console.error("Failed to copy to clipboard:",e)}},N=Object.entries(s.toolInput),w=N.length>0;return(0,r.jsx)(b.lG,{open:t,onOpenChange:()=>!n,children:(0,r.jsxs)(b.Cf,{className:"max-w-4xl max-h-[80vh] overflow-hidden flex flex-col",children:[(0,r.jsxs)(b.c7,{className:"flex-shrink-0",children:[(0,r.jsxs)(b.L3,{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-orange-600",children:"⚠️"}),"Claude Code Permission Request"]}),(0,r.jsx)(b.rr,{children:"Claude Code wants to execute the following tool and needs your permission."})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-4 pr-2",children:[(0,r.jsx)("div",{className:"rounded-lg border p-4 space-y-3",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(g.E,{variant:"secondary",className:"text-sm",children:s.toolName})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,v._)(s.timestamp,{locale:d.locale,target:"time"})})]})}),w&&(0,r.jsx)("div",{className:"rounded-lg border",children:(0,r.jsxs)(f.Nt,{open:i,onOpenChange:o,children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 hover:bg-muted/50 cursor-pointer",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium",children:"Tool Parameters"}),(0,r.jsxs)(g.E,{variant:"outline",className:"text-xs",children:[N.length," parameter",1!==N.length?"s":""]})]}),i?(0,r.jsx)(u.A,{className:"h-4 w-4"}):(0,r.jsx)(h.A,{className:"h-4 w-4"})]})}),(0,r.jsx)(f.Ke,{className:"px-4 pb-4",children:(0,r.jsx)("div",{className:"space-y-3",children:N.map(e=>{let[s,t]=e;return((e,s)=>{let t=(e=>null===e?"null":void 0===e?"undefined":"boolean"==typeof e||"number"==typeof e?e.toString():"string"==typeof e?e:JSON.stringify(e,null,2))(s),a=t.length>100;return(0,r.jsxs)("div",{className:"border rounded-lg p-3 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:e}),(0,r.jsx)(p.$,{variant:"ghost",size:"sm",onClick:()=>y(t),className:"h-6 w-6 p-0",children:(0,r.jsx)(x.A,{className:"h-3 w-3"})})]}),(0,r.jsx)("div",{className:"text-xs font-mono bg-muted p-2 rounded ".concat(a?"max-h-32 overflow-y-auto":""),children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words",children:t})})]},e)})(s,t)})})})]})}),!w&&(0,r.jsx)("div",{className:"rounded-lg border p-4 text-center text-muted-foreground",children:"This tool has no parameters."})]}),(0,r.jsxs)("div",{className:"flex-shrink-0 flex gap-3 justify-end pt-4 border-t",children:[(0,r.jsx)(p.$,{variant:"outline",onClick:()=>c("deny"),disabled:n,className:"min-w-20",children:"Deny"}),(0,r.jsx)(p.$,{onClick:()=>c("allow"),disabled:n,className:"min-w-20",children:"Allow"})]})]})})};var N=t(11368),w=t(87066),k=t(74138),C=t(64619),A=t(34449),S=t(48594),P=t(70172),M=t(76783);let R=e=>(0,P.useSuspenseInfiniteQuery)({queryKey:(0,M.RM)(e).queryKey,queryFn:async s=>{let{pageParam:t}=s;return await (0,M.RM)(e,t).queryFn()},initialPageParam:void 0,getNextPageParam:e=>e.nextCursor,refetchOnReconnect:!0}),E=e=>{switch(e.kind){case"command":if(void 0===e.commandArgs)return e.commandName;return"".concat(e.commandName," ").concat(e.commandArgs);case"local-command":return e.stdout;case"text":return e.content;default:throw Error("Invalid first command")}};var T=t(48544),I=t(54402),_=t(13445),F=t(99432),D=t(55496),q=t(15257),$=t(54287),K=t(88523),L=t(36007),z=t(94613),B=t(54760),U=t(27606),O=t(118),Z=t(81927),H=t(47528),V=t(15674),W=t(46731);let Q=e=>{let{content:s,className:t=""}=e,{resolvedTheme:a}=(0,z.D)(),n="dark"===a?U.A:O.A;return(0,r.jsx)("div",{className:"prose prose-neutral dark:prose-invert max-w-none ".concat(t),children:(0,r.jsx)(V.oz,{remarkPlugins:[W.A],components:{h1(e){let{children:s,...t}=e;return(0,r.jsx)("h1",{className:"text-3xl font-bold mb-6 mt-8 pb-3 border-b border-border text-foreground",...t,children:s})},h2(e){let{children:s,...t}=e;return(0,r.jsx)("h2",{className:"text-2xl font-semibold mb-4 mt-8 pb-2 border-b border-border/50 text-foreground",...t,children:s})},h3(e){let{children:s,...t}=e;return(0,r.jsx)("h3",{className:"text-xl font-semibold mb-3 mt-6 text-foreground",...t,children:s})},h4(e){let{children:s,...t}=e;return(0,r.jsx)("h4",{className:"text-lg font-medium mb-2 mt-4 text-foreground",...t,children:s})},h5(e){let{children:s,...t}=e;return(0,r.jsx)("h5",{className:"text-base font-medium mb-2 mt-4 text-foreground",...t,children:s})},h6(e){let{children:s,...t}=e;return(0,r.jsx)("h6",{className:"text-sm font-medium mb-2 mt-4 text-muted-foreground",...t,children:s})},p(e){let{children:s,...t}=e;return(0,r.jsx)("p",{className:"mb-4 leading-7 text-foreground break-all",...t,children:s})},ul(e){let{children:s,...t}=e;return(0,r.jsx)("ul",{className:"mb-4 ml-6 list-disc space-y-2",...t,children:s})},ol(e){let{children:s,...t}=e;return(0,r.jsx)("ol",{className:"mb-4 ml-6 list-decimal space-y-2",...t,children:s})},li(e){let{children:s,...t}=e;return(0,r.jsx)("li",{className:"leading-7 text-foreground",...t,children:s})},code(e){let{className:s,children:t,...a}=e,l=/language-(\w+)/.exec(s||"");return l?(0,r.jsxs)("div",{className:"relative my-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between bg-muted/30 px-4 py-2 border-b border-border rounded-t-lg",children:(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:l[1]})}),(0,r.jsx)(B.A,{style:n,language:l[1],PreTag:"div",className:"!mt-0 !rounded-t-none !rounded-b-lg !border-t-0 !border !border-border",customStyle:{margin:0,borderTopLeftRadius:0,borderTopRightRadius:0},children:String(t).replace(/\n$/,"")})]}):(0,r.jsx)("code",{className:"bg-muted/70 px-2 py-1 rounded-md text-sm font-mono text-foreground border break-all",...a,children:t})},pre(e){let{children:s,...t}=e;return(0,r.jsx)("pre",{...t,children:s})},blockquote(e){let{children:s,...t}=e;return(0,r.jsx)("blockquote",{className:"border-l-4 border-primary/30 bg-muted/30 pl-6 pr-4 py-4 my-6 italic rounded-r-lg",...t,children:(0,r.jsx)("div",{className:"text-muted-foreground",children:s})})},a(e){let{children:s,href:t,...a}=e;return(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 underline underline-offset-4 decoration-primary/30 hover:decoration-primary/60 transition-colors",...a,children:s})},table(e){let{children:s,...t}=e;return(0,r.jsx)("div",{className:"overflow-x-auto my-6 rounded-lg border border-border max-w-full",children:(0,r.jsx)("table",{className:"w-full border-collapse",...t,children:s})})},thead(e){let{children:s,...t}=e;return(0,r.jsx)("thead",{className:"bg-muted/50",...t,children:s})},th(e){let{children:s,...t}=e;return(0,r.jsx)("th",{className:"border-b border-border px-4 py-3 text-left font-semibold text-foreground",...t,children:s})},td(e){let{children:s,...t}=e;return(0,r.jsx)("td",{className:"border-b border-border px-4 py-3 text-foreground",...t,children:s})},hr(e){let{...s}=e;return(0,r.jsx)("hr",{className:"my-8 border-t border-border",...s})},strong(e){let{children:s,...t}=e;return(0,r.jsx)("strong",{className:"font-semibold text-foreground",...t,children:s})},em(e){let{children:s,...t}=e;return(0,r.jsx)("em",{className:"italic text-foreground",...t,children:s})}},children:s})})};var G=t(1975);let J=e=>{let{conversation:s,sidechainConversations:t,trigger:n,getToolResult:l}=e,i=(e=>{var s;let t=e.at(0),r="".concat(e.length," conversations (").concat((null==t?void 0:t.type)!=="summary"&&(null==t?void 0:t.type)!=="file-history-snapshot"?null==t?void 0:t.uuid:"",")");return t&&null!=(s=(e=>"user"!==e.type?null:"string"==typeof e.message.content?e.message.content:(()=>{let s=e.message.content.at(0);return void 0===s?null:"string"==typeof s?s:"text"===s.type?s.text:null})())(t))?s:r})(t),o=s.uuid,d=t.length;return(0,r.jsxs)(b.lG,{children:[(0,r.jsx)(b.zM,{asChild:!0,children:null!=n?n:(0,r.jsx)(p.$,{variant:"outline",size:"sm",className:"w-full my-2 items-center justify-start hover:bg-accent transition-colors","data-testid":"sidechain-task-button",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 overflow-hidden w-full",children:[(0,r.jsx)($.A,{className:"h-4 w-4 flex-shrink-0 text-primary"}),(0,r.jsxs)("span",{className:"overflow-hidden text-ellipsis text-left flex-1",children:[(0,r.jsx)(a.x6,{id:"assistant.tool.view_task",message:"View Task"}),":"," ",i]}),(0,r.jsx)(g.E,{variant:"secondary",className:"ml-auto flex-shrink-0 text-xs",children:d})]})})}),(0,r.jsxs)(b.Cf,{className:"w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1400px] h-[85vh] max-h-[85vh] flex flex-col p-0","data-testid":"sidechain-task-modal",children:[(0,r.jsx)(b.c7,{className:"px-6 py-4 border-b bg-muted/30",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,r.jsx)("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,r.jsx)(G.A,{className:"h-5 w-5 text-primary"})})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(b.L3,{className:"text-lg font-semibold leading-tight mb-1",children:i.length>120?"".concat(i.slice(0,120),"..."):i}),(0,r.jsxs)(b.rr,{className:"text-xs flex items-center gap-2 flex-wrap",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)(a.x6,{id:"assistant.tool.task_id",message:"Task ID"}),":"," ",(0,r.jsx)("code",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:o.slice(0,8)})]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:"•"}),(0,r.jsx)("span",{children:(0,r.jsx)(a.x6,{id:"assistant.tool.message_count",message:"{count} messages",values:{count:d}})})]})]})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,r.jsx)(ep,{conversations:t,getToolResult:l})})]})]})},X=e=>{let{input:s}=e,t=Object.entries(s);return 0===t.length?null:(0,r.jsx)("span",{children:t.map((e,s)=>{let[t,a]=e,n="string"==typeof a?a:JSON.stringify(a).replace(/^"|"$/g,"");return(0,r.jsxs)("span",{children:[s>0&&(0,r.jsx)("span",{className:"text-muted-foreground",children:", "}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[t,"="]}),(0,r.jsx)("span",{children:n})]},t)})})},Y=Z.Ay$.object({prompt:Z.Ay$.string()}),ee=e=>{let{content:s,getToolResult:t,getSidechainConversationByPrompt:n,getSidechainConversations:l}=e,{resolvedTheme:i}=(0,z.D)(),o="dark"===i?U.A:O.A;if("text"===s.type)return(0,r.jsx)("div",{className:"w-full mx-1 sm:mx-2 my-4 sm:my-6",children:(0,r.jsx)(Q,{content:s.text})});if("thinking"===s.type)return(0,r.jsx)(H.Zp,{className:"bg-muted/50 border-dashed gap-2 py-3 mb-2 hover:shadow-sm transition-all duration-200",children:(0,r.jsxs)(f.Nt,{children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsx)(H.aR,{className:"cursor-pointer hover:bg-muted/80 rounded-t-lg transition-all duration-200 py-0 px-4 group",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(q.A,{className:"h-4 w-4 text-muted-foreground group-hover:text-yellow-600 transition-colors"}),(0,r.jsx)(H.ZB,{className:"text-sm font-medium group-hover:text-foreground transition-colors",children:(0,r.jsx)(a.x6,{id:"assistant.thinking",message:"Thinking"})}),(0,r.jsx)(u.A,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"})]})})}),(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{className:"py-2 px-4",children:(0,r.jsx)("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:s.thinking})})})]})});if("tool_use"===s.type){let e=t(s.id),i=(()=>{let e="Task"===s.name?Y.safeParse(s.input):void 0;if(void 0===e||!1===e.success)return;let i=n(e.data.prompt);if(void 0!==i)return(0,r.jsx)(J,{conversation:i,sidechainConversations:l(i.uuid).map(e=>({...e,isSidechain:!1})),getToolResult:t,trigger:(0,r.jsxs)(p.$,{variant:"ghost",size:"sm",className:"h-auto py-1.5 px-3 text-xs hover:bg-blue-100 dark:hover:bg-blue-900/30 rounded-none flex items-center gap-1",children:[(0,r.jsx)($.A,{className:"h-3 w-3"}),(0,r.jsx)(a.x6,{id:"assistant.tool.view_task_details",message:"View Task"})]})})})();return(0,r.jsx)(H.Zp,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",children:(0,r.jsxs)(f.Nt,{children:[(0,r.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsx)("div",{className:"flex-1 min-w-0 cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/20 transition-all duration-200 px-3 py-1.5 group",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(K.A,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 flex-shrink-0"}),(0,r.jsxs)("div",{className:"w-full min-w-0 text-sm font-medium group-hover:text-foreground transition-colors overflow-hidden text-ellipsis whitespace-nowrap",children:[s.name,Object.keys(s.input).length>0&&(0,r.jsxs)("span",{className:"font-normal",children:[" ","(",(0,r.jsx)(X,{input:s.input}),")"]})]}),(0,r.jsx)(u.A,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 flex-shrink-0"})]})})}),i&&(0,r.jsx)("div",{className:"flex-shrink-0 border-l border-blue-200 dark:border-blue-800 flex items-center",children:i})]}),(0,r.jsx)(f.Ke,{children:(0,r.jsxs)("div",{className:"space-y-3 py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground mb-1",children:(0,r.jsx)(a.x6,{id:"assistant.tool.tool_id",message:"Tool ID"})}),(0,r.jsx)("code",{className:"text-xs bg-background/50 px-2 py-1 rounded border border-blue-200 dark:border-blue-800 font-mono",children:s.id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground mb-2",children:(0,r.jsx)(a.x6,{id:"assistant.tool.input_parameters",message:"Input Parameters"})}),(0,r.jsx)(B.A,{style:o,language:"json",PreTag:"div",className:"text-xs rounded",children:JSON.stringify(s.input,null,2)})]}),e&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground mb-2",children:(0,r.jsx)(a.x6,{id:"assistant.tool.result",message:"Tool Result"})}),(0,r.jsx)("div",{className:"bg-background rounded border p-3",children:"string"==typeof e.content?(0,r.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:e.content}):e.content.map(e=>{if("image"===e.type)return(0,r.jsx)(L.default,{src:"data:".concat(e.source.media_type,";base64,").concat(e.source.data),alt:"Tool Result"},e.source.data);if("text"===e.type)return(0,r.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:e.text},e.text);throw Error("Unexpected tool result content type")})})]})]})})]})})}return s.type,null},es=e=>{let{conversation:s}=e,t=Object.keys(s.snapshot.trackedFileBackups).length,{config:a}=(0,j.U)();return(0,r.jsxs)(f.Nt,{children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[(0,r.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["File History Snapshot ",t>0&&"(".concat(t," files)")]}),(0,r.jsx)(u.A,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{className:"bg-background rounded border p-3 mt-2",children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Timestamp: "}),(0,r.jsx)("span",{children:(0,v._)(s.snapshot.timestamp,{locale:a.locale})})]}),(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"Message ID: "}),(0,r.jsx)("span",{className:"font-mono",children:s.messageId})]}),(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsxs)("span",{className:"text-muted-foreground",children:["Is Snapshot Update:"," "]}),(0,r.jsx)("span",{children:s.isSnapshotUpdate?"Yes":"No"})]}),t>0&&(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsx)("div",{className:"text-muted-foreground mb-1",children:"Tracked Files:"}),(0,r.jsx)("ul",{className:"list-disc list-inside space-y-1",children:Object.keys(s.snapshot.trackedFileBackups).map(e=>(0,r.jsx)("li",{className:"font-mono text-xs break-all",children:e},e))})]})]})})})]})},et=e=>{let{children:s}=e;return(0,r.jsxs)(f.Nt,{children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"Meta Information"}),(0,r.jsx)(u.A,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{className:"bg-background rounded border p-3 mt-2",children:s})})]})},er=e=>{let{children:s}=e;return(0,r.jsxs)(f.Nt,{children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"Summarized"}),(0,r.jsx)(u.A,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{className:"bg-background rounded border p-3 mt-2",children:(0,r.jsx)("pre",{className:"text-xs overflow-x-auto",children:s})})})]})},ea=e=>{let{children:s}=e;return(0,r.jsxs)(f.Nt,{children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"System Message"}),(0,r.jsx)(u.A,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{className:"bg-background rounded border p-3 mt-2",children:(0,r.jsx)("pre",{className:"text-xs overflow-x-auto",children:s})})})]})};var en=t(64551),el=t(19429),ei=t(98670),eo=t(98021);let ed=RegExp("<(?<tag>[^>]+)>(?<content>\\s*[^<]*?\\s*)<\\/\\k<tag>>","g"),ec=eo.object({tag:eo.string(),content:eo.string()});eo.union([eo.object({kind:eo.literal("command"),commandName:eo.string(),commandArgs:eo.string().optional(),commandMessage:eo.string().optional()}),eo.object({kind:eo.literal("local-command"),stdout:eo.string()}),eo.object({kind:eo.literal("text"),content:eo.string()})]);let em=e=>{let{text:s,id:t}=e,a=(e=>{var s,t,r,a;let n=Array.from(e.matchAll(ed)).map(e=>ec.safeParse(e.groups)).filter(e=>e.success).map(e=>e.data);if(0===n.length)return{kind:"text",content:e};let l=null==(s=n.find(e=>"command-name"===e.tag))?void 0:s.content,i=null==(t=n.find(e=>"command-args"===e.tag))?void 0:t.content,o=null==(r=n.find(e=>"command-message"===e.tag))?void 0:r.content,d=null==(a=n.find(e=>"local-command-stdout"===e.tag))?void 0:a.content;switch(!0){case void 0!==l:return{kind:"command",commandName:l,commandArgs:i,commandMessage:o};case void 0!==d:return{kind:"local-command",stdout:d};default:return{kind:"text",content:e}}})(s);return"command"===a.kind?(0,r.jsxs)(H.Zp,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",id:t,children:[(0,r.jsx)(H.aR,{className:"py-0 px-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(ei.A,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),(0,r.jsx)(H.ZB,{className:"text-sm font-medium",children:"Claude Code Command"}),(0,r.jsx)(g.E,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:a.commandName})]})}),a.commandArgs||a.commandMessage?(0,r.jsx)(H.Wu,{className:"py-0 px-4",children:(0,r.jsx)("div",{className:"space-y-2",children:(0,r.jsxs)("div",{children:[a.commandArgs&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Arguments:"}),(0,r.jsx)("div",{className:"bg-background rounded border p-2 mt-1",children:(0,r.jsx)("code",{className:"text-xs whitespace-pre-line break-all",children:a.commandArgs})})]}),a.commandMessage&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Message:"}),(0,r.jsx)("div",{className:"bg-background rounded border p-2 mt-1",children:(0,r.jsx)("code",{className:"text-xs whitespace-pre-line break-all",children:a.commandMessage})})]})]})})}):null]}):"local-command"===a.kind?(0,r.jsxs)(H.Zp,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",children:[(0,r.jsx)(H.aR,{className:"py-0 px-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(ei.A,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),(0,r.jsx)(H.ZB,{className:"text-sm font-medium",children:"Local Command"})]})}),(0,r.jsx)(H.Wu,{className:"py-0 px-4",children:(0,r.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:a.stdout})})]}):(0,r.jsx)(Q,{className:"w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50",content:a.content})},ex=e=>{let{content:s,id:t}=e;return"string"==typeof s?(0,r.jsx)(em,{text:s,id:t}):"text"===s.type?(0,r.jsx)(em,{text:s.text,id:t}):"image"===s.type?"base64"===s.source.type?(0,r.jsxs)(H.Zp,{className:"border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20",id:t,children:[(0,r.jsxs)(H.aR,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(en.A,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),(0,r.jsx)(H.ZB,{className:"text-sm font-medium",children:(0,r.jsx)(a.x6,{id:"user.content.image",message:"Image"})}),(0,r.jsx)(g.E,{variant:"outline",className:"border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300",children:s.source.media_type})]}),(0,r.jsx)(H.BT,{className:"text-xs",children:(0,r.jsx)(a.x6,{id:"user.content.image.description",message:"User uploaded image content"})})]}),(0,r.jsx)(H.Wu,{children:(0,r.jsx)("div",{className:"rounded-lg border overflow-hidden bg-background",children:(0,r.jsx)(L.default,{src:"data:".concat(s.source.media_type,";base64,").concat(s.source.data),alt:"User uploaded content",className:"max-w-full h-auto max-h-96 object-contain"})})})]}):(0,r.jsx)(H.Zp,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:t,children:(0,r.jsxs)(H.aR,{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(el.A,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),(0,r.jsx)(H.ZB,{className:"text-sm font-medium",children:(0,r.jsx)(a.x6,{id:"user.content.unsupported_media",message:"Unsupported Media"})}),(0,r.jsx)(g.E,{variant:"destructive",children:(0,r.jsx)(a.x6,{id:"common.error",message:"Error"})})]}),(0,r.jsx)(H.BT,{className:"text-xs",children:(0,r.jsx)(a.x6,{id:"user.content.unsupported_media.description",message:"Media type not supported for display"})})]})}):(s.type,null)},eu=e=>{let{conversation:s,getToolResult:t,isRootSidechain:a,getSidechainConversationByPrompt:n,getSidechainConversations:l,existsRelatedTaskCall:i}=e;if("summary"===s.type)return(0,r.jsx)(er,{children:s.summary});if("system"===s.type)return(0,r.jsx)(ea,{children:s.content});if("file-history-snapshot"===s.type)return(0,r.jsx)(es,{conversation:s});if(s.isSidechain){if(!a(s)||"user"!==s.type)return null;let e=s.message.content;return"string"==typeof e&&!0===i(e)?null:(0,r.jsx)(J,{conversation:s,sidechainConversations:l(s.uuid).map(e=>({...e,isSidechain:!1})),getToolResult:t})}if("user"===s.type){let e="string"==typeof s.message.content?(0,r.jsx)(ex,{content:s.message.content,id:"message-".concat(s.uuid)}):(0,r.jsx)("ul",{className:"w-full",id:"message-".concat(s.uuid),children:s.message.content.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(ex,{content:e})},e.toString()))});return!0===s.isMeta?(0,r.jsx)(et,{children:e}):e}return"assistant"===s.type?(0,r.jsx)("ul",{className:"w-full",children:s.message.content.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)(ee,{content:e,getToolResult:t,getSidechainConversationByPrompt:n,getSidechainConversations:l})},e.toString()))}):null},eh=e=>{if("user"===e.type)return"user_".concat(e.uuid);if("assistant"===e.type)return"assistant_".concat(e.uuid);if("system"===e.type)return"system_".concat(e.uuid);if("summary"===e.type)return"summary_".concat(e.leafUuid);if("file-history-snapshot"===e.type)return"file-history-snapshot_".concat(e.messageId);throw Error("Unknown conversation type: ".concat(e))},eg=e=>{let{errorLine:s}=e;return(0,r.jsx)("li",{className:"w-full flex justify-start",children:(0,r.jsx)("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2",children:(0,r.jsxs)(f.Nt,{children:[(0,r.jsx)(f.R6,{asChild:!0,children:(0,r.jsxs)("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 border-l-2 border-red-400",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(_.A,{className:"h-3 w-3 text-red-500"}),(0,r.jsx)("span",{className:"text-xs font-medium text-red-600",children:(0,r.jsx)(a.x6,{id:"conversation.error.schema",message:"Schema Error"})})]}),(0,r.jsx)(u.A,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{className:"bg-background rounded border border-red-200 p-3 mt-2",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)(D.Fc,{variant:"destructive",className:"border-red-200 bg-red-50",children:[(0,r.jsx)(_.A,{className:"h-4 w-4"}),(0,r.jsx)(D.XL,{className:"text-red-800",children:(0,r.jsx)(a.x6,{id:"conversation.error.schema_validation",message:"Schema Validation Error"})}),(0,r.jsxs)(D.TN,{className:"text-red-700",children:[(0,r.jsx)(a.x6,{id:"conversation.error.schema_validation.description",message:"This conversation entry failed to parse correctly. This might indicate a format change or parsing issue."})," ",(0,r.jsxs)("a",{href:"https://github.com/d-kimuson/claude-code-viewer/issues",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-red-600 hover:text-red-800 underline underline-offset-4",children:[(0,r.jsx)(a.x6,{id:"conversation.error.report_issue",message:"Report this issue"}),(0,r.jsx)(F.A,{className:"h-3 w-3"})]})]})]}),(0,r.jsxs)("div",{className:"bg-gray-50 border rounded px-3 py-2",children:[(0,r.jsx)("h5",{className:"text-xs font-medium text-gray-700 mb-2",children:(0,r.jsx)(a.x6,{id:"conversation.error.raw_content",message:"Raw Content:"})}),(0,r.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800",children:s})]})]})})})]})})})},ep=e=>{let{conversations:s,getToolResult:t}=e,{isRootSidechain:a,getSidechainConversations:n,getSidechainConversationByPrompt:l,existsRelatedTaskCall:i}=(e=>{let s=e.filter(e=>"summary"!==e.type&&"file-history-snapshot"!==e.type).filter(e=>!0===e.isSidechain),t=(0,m.useMemo)(()=>new Map(s.map(e=>[e.uuid,e])),[s]),r=(0,m.useMemo)(()=>new Map(s.filter(e=>"user"===e.type).filter(e=>null===e.parentUuid&&"string"==typeof e.message.content).map(e=>[e.message.content,e])),[s]),a=(0,m.useMemo)(()=>new Set(e.filter(e=>"assistant"===e.type).flatMap(e=>[...e.message.content.filter(e=>"tool_use"===e.type)]).flatMap(e=>{if("Task"!==e.name)return[];let s=Y.safeParse(e.input);return!1===s.success?[]:[s.data.prompt]})),[e]),n=(0,m.useCallback)(e=>{if(null===e.parentUuid)return e;let s=t.get(e.parentUuid);return void 0===s?e:n(s)},[t]),l=(0,m.useMemo)(()=>{let e=new Map;for(let r of s){let s=n(r);if(e.has(s.uuid)){var t;null==(t=e.get(s.uuid))||t.push(r)}else e.set(s.uuid,[r])}return e},[s,n]),i=(0,m.useCallback)(e=>"summary"!==e.type&&"file-history-snapshot"!==e.type&&l.has(e.uuid),[l]),o=(0,m.useCallback)(e=>{var s;return null!=(s=l.get(e))?s:[]},[l]);return{isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:(0,m.useCallback)(e=>r.get(e),[r]),existsRelatedTaskCall:e=>a.has(e)}})((0,m.useMemo)(()=>s.filter(e=>"x-error"!==e.type),[s]));return(0,r.jsx)("ul",{children:s.flatMap(e=>{if("x-error"===e.type)return(0,r.jsx)(eg,{errorLine:e.line},"error_".concat(e.line));let s=(0,r.jsx)(eu,{conversation:e,getToolResult:t,isRootSidechain:a,getSidechainConversations:n,getSidechainConversationByPrompt:l,existsRelatedTaskCall:i},eh(e)),o="summary"!==e.type&&"file-history-snapshot"!==e.type&&e.isSidechain;return[(0,r.jsx)("li",{className:"w-full flex ".concat(o||"assistant"===e.type||"system"===e.type||"summary"===e.type?"justify-start":"justify-end"," animate-in fade-in slide-in-from-bottom-2 duration-300"),children:(0,r.jsx)("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]",children:s})},eh(e))]})})};var ef=t(7356),eb=t(81229),ej=t(49060),ev=t(54655),ey=t(90157),eN=t(84269),ew=t(52446),ek=t(98113);function eC(e){let{className:s,...t}=e;return(0,r.jsx)("textarea",{"data-slot":"textarea",className:(0,ek.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex min-h-[60px] w-full min-w-0 resize-none rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",s),...t})}var eA=t(31116);let eS=e=>{let{hunk:s}=e;return(0,r.jsxs)("div",{className:"relative flex overflow-x-auto",children:[(0,r.jsxs)("div",{className:"flex-shrink-0 sticky left-0 z-10 bg-white dark:bg-gray-900",children:[(0,r.jsx)("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:s.lines.map((e,s)=>(0,r.jsx)("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:"added"!==e.type&&"hunk"!==e.type&&e.oldLineNumber?e.oldLineNumber:" "},"old-".concat(e.oldLineNumber,"-").concat(s)))}),(0,r.jsx)("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:s.lines.map((e,s)=>(0,r.jsx)("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:"deleted"!==e.type&&"hunk"!==e.type&&e.newLineNumber?e.newLineNumber:" "},"new-".concat(e.newLineNumber,"-").concat(s)))})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:s.lines.map((e,s)=>(0,r.jsx)("div",{className:(0,ek.cn)("flex border-l-4",{"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800/50 border-l-green-400":"added"===e.type,"bg-red-50 dark:bg-red-950/30 border-red-200 dark:border-red-800/50 border-l-red-400":"deleted"===e.type,"bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800/50 border-l-blue-400":"hunk"===e.type,"bg-white dark:bg-gray-900 border-gray-100 dark:border-gray-800 border-l-transparent":"unchanged"===e.type}),children:(0,r.jsx)("div",{className:"flex-1 px-2 py-0.5",children:(0,r.jsxs)("span",{className:"font-mono text-xs whitespace-pre block leading-tight",children:[(0,r.jsx)("span",{className:(0,ek.cn)({"text-green-600 dark:text-green-400":"added"===e.type,"text-red-600 dark:text-red-400":"deleted"===e.type,"text-blue-600 dark:text-blue-400 font-medium":"hunk"===e.type,"text-gray-400 dark:text-gray-600":"unchanged"===e.type}),children:"added"===e.type?"+":"deleted"===e.type?"-":"hunk"===e.type?"":" "}),e.content||" "]})})},"content-".concat(e.content,"-").concat(e.oldLineNumber,"-").concat(e.newLineNumber,"-").concat(s)))})]})},eP=e=>{let{fileDiff:s,isCollapsed:t,onToggleCollapse:a}=e,n=async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(s.filename),N.oR.success("ファイル名をコピーしました")}catch(e){console.error("Failed to copy filename:",e),N.oR.error("ファイル名のコピーに失敗しました")}};return(0,r.jsxs)(p.$,{onClick:a,className:"w-full bg-gray-50 dark:bg-gray-800 px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors sticky top-0 z-20",children:[(0,r.jsxs)("div",{className:"w-full flex items-center gap-2",children:[t?(0,r.jsx)(h.A,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}):(0,r.jsx)(u.A,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}),(0,r.jsx)("div",{className:"w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs font-mono flex-shrink-0",children:s.isNew?(0,r.jsx)("span",{className:"text-green-600 dark:text-green-400",children:"A"}):s.isDeleted?(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400",children:"D"}):s.isRenamed?(0,r.jsx)("span",{className:"text-blue-600 dark:text-blue-400",children:"R"}):(0,r.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"M"})}),(0,r.jsx)("span",{className:"font-mono text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0",children:s.filename}),(0,r.jsxs)("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:[s.linesAdded>0&&(0,r.jsxs)("span",{className:"text-green-600 dark:text-green-400",children:["+",s.linesAdded]}),s.linesDeleted>0&&(0,r.jsxs)("span",{className:"text-red-600 dark:text-red-400",children:["-",s.linesDeleted]})]}),(0,r.jsx)(p.$,{onClick:n,variant:"ghost",size:"sm",className:"flex-shrink-0 p-1 h-5 w-5 hover:bg-gray-200 dark:hover:bg-gray-600",children:(0,r.jsx)(x.A,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})})]}),s.isBinary&&(0,r.jsx)("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-left",children:"Binary file (content not shown)"})]})},eM=e=>{let{fileDiff:s,className:t}=e,[a,n]=(0,m.useState)(!1),l=()=>{n(!a)};return s.isBinary?(0,r.jsxs)("div",{className:(0,ek.cn)("border border-gray-200 dark:border-gray-700 rounded-lg",t),children:[(0,r.jsx)(eP,{fileDiff:s,isCollapsed:a,onToggleCollapse:l}),!a&&(0,r.jsx)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:"Binary file cannot be displayed"})]}):(0,r.jsxs)("div",{className:(0,ek.cn)("border border-gray-200 dark:border-gray-700 rounded-lg",t),children:[(0,r.jsx)(eP,{fileDiff:s,isCollapsed:a,onToggleCollapse:l}),!a&&(0,r.jsx)("div",{className:"border-t border-gray-200 dark:border-gray-700",children:s.hunks.map((e,s)=>(0,r.jsx)(eS,{hunk:e},"".concat(e.oldStart,"-").concat(e.newStart,"-").concat(s)))})]})},eR=e=>{let{summary:s,className:t}=e;return(0,r.jsx)("div",{className:(0,ek.cn)("bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700",t),children:(0,r.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(ef.A,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),(0,r.jsxs)("span",{className:"font-medium",children:[(0,r.jsxs)("span",{className:"hidden sm:inline",children:[s.filesChanged," ",(0,r.jsx)(a.x6,{id:"diff.files.changed",message:"files changed"})]}),(0,r.jsxs)("span",{className:"sm:hidden",children:[s.filesChanged," ",(0,r.jsx)(a.x6,{id:"diff.files",message:"files"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[s.insertions>0&&(0,r.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["+",s.insertions]}),s.deletions>0&&(0,r.jsxs)("span",{className:"text-red-600 dark:text-red-400 font-medium",children:["-",s.deletions]})]})]})})},eE=e=>{let{label:s,value:t,onValueChange:a,refs:n}=e,l=(0,m.useId)();return(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{htmlFor:l,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s}),(0,r.jsxs)(ew.l6,{value:t,onValueChange:a,children:[(0,r.jsx)(ew.bq,{className:"w-full sm:w-80",children:(0,r.jsx)(ew.yv,{})}),(0,r.jsx)(ew.gC,{id:l,children:n.map(e=>(0,r.jsx)(ew.eb,{value:e.name,children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(e=>{switch(e){case"branch":default:return(0,r.jsx)(eb.A,{className:"h-4 w-4"});case"commit":return(0,r.jsx)("span",{className:"text-xs",children:"\uD83D\uDCDD"});case"working":return(0,r.jsx)("span",{className:"text-xs",children:"\uD83D\uDEA7"})}})(e.type),(0,r.jsx)("span",{children:e.displayName}),e.sha&&(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:e.sha.substring(0,7)})]})},e.name))})]})]})},eT=e=>{let{isOpen:s,onOpenChange:t,projectId:l,defaultCompareFrom:i="HEAD",defaultCompareTo:o="working"}=e,{i18n:d}=(0,a.uB)(),c=(0,m.useId)(),[x,h]=(0,m.useState)(i),[g,f]=(0,m.useState)(o),[j,v]=(0,m.useState)(new Map),[y,w]=(0,m.useState)(""),[C,A]=(0,m.useState)(!1),{data:S,isLoading:P}=(e=>(0,eA.useQuery)({queryKey:(0,M.vf)(e).queryKey,queryFn:(0,M.vf)(e).queryFn,staleTime:3e4}))(l),{data:R,isLoading:E}=(e=>(0,eA.useQuery)({queryKey:(0,M.xQ)(e).queryKey,queryFn:(0,M.xQ)(e).queryFn,staleTime:3e4}))(l),{mutate:T,data:I,isPending:_,error:F}=(0,n.useMutation)({mutationFn:async e=>{let{projectId:s,fromRef:t,toRef:r}=e,a=await k.s.api.projects[":projectId"].git.diff.$post({param:{projectId:s},json:{fromRef:t,toRef:r}});if(!a.ok)throw Error("Failed to get diff: ".concat(a.statusText));return a.json()}}),D=(e=>(0,n.useMutation)({mutationFn:async s=>{let{files:t,message:r}=s,a=await k.s.api.projects[":projectId"].git.commit.$post({param:{projectId:e},json:{projectId:e,files:t,message:r}});if(!a.ok)throw Error("Failed to commit files: ".concat(a.statusText));return a.json()}}))(l),q=(e=>(0,n.useMutation)({mutationFn:async()=>{let s=await k.s.api.projects[":projectId"].git.push.$post({param:{projectId:e},json:{projectId:e}});if(!s.ok)throw Error("Failed to push commits: ".concat(s.statusText));return s.json()}}))(l),$=(e=>(0,n.useMutation)({mutationFn:async s=>{let{files:t,message:r}=s,a=await k.s.api.projects[":projectId"].git["commit-and-push"].$post({param:{projectId:e},json:{projectId:e,files:t,message:r}});if(!a.ok)throw Error("Failed to commit and push: ".concat(a.statusText));return a.json()}}))(l),K=(null==S?void 0:S.success)&&S.data?[{name:"working",type:"working",displayName:d._("Uncommitted changes")},{name:"HEAD",type:"commit",displayName:"HEAD"},...S.data.map(e=>({name:"branch:".concat(e.name),type:"branch",displayName:e.name+(e.current?" (current)":""),sha:e.commit})),...(null==R?void 0:R.success)&&R.data?R.data.map(e=>({name:"commit:".concat(e.sha),type:"commit",displayName:"".concat(e.message.substring(0,50)).concat(e.message.length>50?"...":""),sha:e.sha})):[]]:[],L=(0,m.useCallback)(()=>{x&&g&&x!==g&&T({projectId:l,fromRef:x,toRef:g})},[x,g,T,l]);(0,m.useEffect)(()=>{(null==I?void 0:I.success)&&I.data.files.length>0&&v(new Map(I.data.files.map(e=>[e.filePath,!0])))},[I]),(0,m.useEffect)(()=>{s&&x&&g&&L()},[s,x,g,L]);let z=async()=>{let e=Array.from(j.entries()).filter(e=>{let[s,t]=e;return t}).map(e=>{let[s]=e;return s});console.log("[DiffModal.handleCommit] Selected files state:",j),console.log("[DiffModal.handleCommit] Filtered selected files:",e),console.log("[DiffModal.handleCommit] Total files:",(null==I?void 0:I.success)?I.data.files.length:0);try{let s=await D.mutateAsync({files:e,message:y});console.log("[DiffModal.handleCommit] Commit result:",s),s.success?(N.oR.success("Committed ".concat(s.filesCommitted," files (").concat(s.commitSha.slice(0,7),")")),w(""),L()):N.oR.error(s.error,{description:s.details})}catch(e){console.error("[DiffModal.handleCommit] Error:",e),N.oR.error(d._("Failed to commit"))}},B=async()=>{try{let e=await q.mutateAsync();console.log("[DiffModal.handlePush] Push result:",e),e.success?N.oR.success("Pushed to ".concat(e.remote,"/").concat(e.branch)):N.oR.error(e.error,{description:e.details})}catch(e){console.error("[DiffModal.handlePush] Error:",e),N.oR.error(d._("Failed to push"))}},U=async()=>{let e=Array.from(j.entries()).filter(e=>{let[s,t]=e;return t}).map(e=>{let[s]=e;return s});console.log("[DiffModal.handleCommitAndPush] Selected files:",e);try{let t=await $.mutateAsync({files:e,message:y});if(console.log("[DiffModal.handleCommitAndPush] Result:",t),t.success)N.oR.success("Committed and pushed (".concat(t.commitSha.slice(0,7),")")),w(""),L();else if(!1===t.success&&"commitSucceeded"in t&&t.commitSucceeded){var s;N.oR.warning("Committed (".concat(null==(s=t.commitSha)?void 0:s.slice(0,7),"), but push failed: ").concat(t.error),{action:{label:d._("Retry Push"),onClick:B}}),w(""),L()}else N.oR.error(t.error,{description:t.details})}catch(e){console.error("[DiffModal.handleCommitAndPush] Error:",e),N.oR.error(d._("Failed to commit and push"))}},O=Array.from(j.values()).filter(Boolean).length,Z=0===O||0===y.trim().length||D.isPending;return(0,r.jsx)(b.lG,{open:s,onOpenChange:t,children:(0,r.jsxs)(b.Cf,{className:"max-w-7xl w-[95vw] h-[90vh] overflow-hidden flex flex-col px-2 md:px-8",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-end",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 flex-1",children:[(0,r.jsx)(eE,{label:d._("Compare from"),value:x,onValueChange:h,refs:K.filter(e=>"working"!==e.name)}),(0,r.jsx)(eE,{label:d._("Compare to"),value:g,onValueChange:f,refs:K})]}),(0,r.jsx)(p.$,{onClick:()=>{L()},disabled:_||P||E||x===g,className:"sm:self-end w-full sm:w-auto",children:_?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.A,{className:"w-4 h-4 mr-2 animate-spin"}),(0,r.jsx)(a.x6,{id:"common.loading",message:"Loading..."})]}):(0,r.jsx)(ev.A,{className:"w-4 h-4"})})]}),F&&(0,r.jsx)("div",{className:"bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,r.jsx)("p",{className:"text-red-600 dark:text-red-400 text-sm",children:F.message})}),(null==I?void 0:I.success)&&(0,r.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,r.jsx)(eR,{summary:{filesChanged:I.data.files.length,insertions:I.data.summary.totalAdditions,deletions:I.data.summary.totalDeletions,files:I.data.diffs.map(e=>({filename:e.file.filePath,oldFilename:e.file.oldPath,isNew:"added"===e.file.status,isDeleted:"deleted"===e.file.status,isRenamed:"renamed"===e.file.status,isBinary:!1,hunks:e.hunks,linesAdded:e.file.additions,linesDeleted:e.file.deletions}))},className:"mb-3"}),"working"===g&&(0,r.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg mb-4 border border-gray-200 dark:border-gray-700",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>A(!C),className:"w-full flex items-center justify-between p-2 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors rounded-t-lg",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:(0,r.jsx)(a.x6,{id:"diff.commit.changes",message:"Commit Changes"})}),C?(0,r.jsx)(ey.A,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):(0,r.jsx)(u.A,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"})]}),C&&(0,r.jsxs)("div",{className:"p-4 pt-0 space-y-3",children:[(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(p.$,{size:"sm",variant:"ghost",onClick:()=>{(null==I?void 0:I.success)&&I.data.files.length>0&&v(new Map(I.data.files.map(e=>[e.filePath,!0])))},disabled:D.isPending,children:(0,r.jsx)(a.x6,{id:"diff.select.all",message:"Select All"})}),(0,r.jsx)(p.$,{size:"sm",variant:"ghost",onClick:()=>{(null==I?void 0:I.success)&&I.data.files.length>0&&v(new Map(I.data.files.map(e=>[e.filePath,!1])))},disabled:D.isPending,children:(0,r.jsx)(a.x6,{id:"diff.deselect.all",message:"Deselect All"})}),(0,r.jsxs)("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[O," / ",I.data.files.length," files selected"]})]})}),(0,r.jsx)("div",{className:"space-y-2 max-h-40 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded p-2",children:I.data.files.map(e=>{var s;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(eN.S,{id:"file-".concat(e.filePath),checked:null!=(s=j.get(e.filePath))&&s,onCheckedChange:()=>(e=>{v(s=>{let t=new Map(s),r=!s.get(e);return t.set(e,r),t})})(e.filePath),disabled:D.isPending}),(0,r.jsx)("label",{htmlFor:"file-".concat(e.filePath),className:"text-sm font-mono cursor-pointer flex-1",children:e.filePath})]},e.filePath)})}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:c,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:(0,r.jsx)(a.x6,{id:"diff.commit.message",message:"Commit message"})}),(0,r.jsx)(eC,{id:c,placeholder:"Enter commit message...",value:y,onChange:e=>w(e.target.value),disabled:D.isPending,className:"resize-none",rows:3})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)(p.$,{onClick:z,disabled:Z,className:"w-full sm:w-auto",children:D.isPending?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.A,{className:"w-4 h-4 mr-2 animate-spin"}),(0,r.jsx)(a.x6,{id:"diff.committing",message:"Committing..."})]}):(0,r.jsx)(a.x6,{id:"diff.commit",message:"Commit"})}),(0,r.jsx)(p.$,{onClick:B,disabled:q.isPending,variant:"outline",className:"w-full sm:w-auto",children:q.isPending?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.A,{className:"w-4 h-4 mr-2 animate-spin"}),(0,r.jsx)(a.x6,{id:"diff.pushing",message:"Pushing..."})]}):(0,r.jsx)(a.x6,{id:"diff.push",message:"Push"})}),(0,r.jsx)(p.$,{onClick:U,disabled:Z||$.isPending,variant:"secondary",className:"w-full sm:w-auto",children:$.isPending?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ej.A,{className:"w-4 h-4 mr-2 animate-spin"}),(0,r.jsx)(a.x6,{id:"diff.committing.pushing",message:"Committing & Pushing..."})]}):(0,r.jsx)(a.x6,{id:"diff.commit.push",message:"Commit & Push"})}),Z&&!D.isPending&&!$.isPending&&(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:0===O?(0,r.jsx)(a.x6,{id:"diff.select.file",message:"Select at least one file"}):(0,r.jsx)(a.x6,{id:"diff.enter.message",message:"Enter a commit message"})})]})]})]}),(0,r.jsx)("div",{className:"space-y-3",children:I.data.diffs.map(e=>(0,r.jsx)(eM,{fileDiff:{filename:e.file.filePath,oldFilename:e.file.oldPath,isNew:"added"===e.file.status,isDeleted:"deleted"===e.file.status,isRenamed:"renamed"===e.file.status,isBinary:!1,hunks:e.hunks,linesAdded:e.file.additions,linesDeleted:e.file.deletions}},e.file.filePath))})]}),_&&(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,r.jsxs)("div",{className:"text-center space-y-2",children:[(0,r.jsx)(ej.A,{className:"w-8 h-8 animate-spin mx-auto"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,r.jsx)(a.x6,{id:"diff.loading",message:"Loading diff..."})})]})})]})})};var eI=t(93809),e_=t(34496),eF=t(27758);let eD=(0,m.forwardRef)((e,s)=>{let{projectId:t,inputValue:n,onCommandSelect:l,className:i}=e,{i18n:o}=(0,a.uB)(),[d,c]=(0,m.useState)(!1),[x,u]=(0,m.useState)(-1),h=(0,m.useRef)(null),g=(0,m.useRef)(null),{data:b}=(0,eA.useQuery)({queryKey:(0,M.FN)(t).queryKey,queryFn:(0,M.FN)(t).queryFn,staleTime:3e5}),{shouldShowCompletion:j,filteredCommands:v}=(0,m.useMemo)(()=>{let e=[...(null==b?void 0:b.defaultCommands)||[],...(null==b?void 0:b.globalCommands)||[],...(null==b?void 0:b.projectCommands)||[]],s=n.startsWith("/"),t=s?n.slice(1).toLowerCase():"",r=s?e.filter(e=>e.toLowerCase().includes(t)):[];return{shouldShowCompletion:s,filteredCommands:r}},[b,n]),y=j&&v.length>0;d!==y&&(c(y),u(-1));let N=(0,m.useCallback)(e=>{l("/".concat(e," ")),c(!1),u(-1)},[l]),w=(0,m.useCallback)(e=>{if(e>=0&&g.current){let s=g.current.querySelectorAll('button[role="option"]')[e];s&&s.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),k=(0,m.useCallback)(e=>{if(!d||0===v.length)return!1;switch(e.key){case"ArrowDown":return e.preventDefault(),u(e=>{let s=e<v.length-1?e+1:0;return requestAnimationFrame(()=>w(s)),s}),!0;case"ArrowUp":return e.preventDefault(),u(e=>{let s=e>0?e-1:v.length-1;return requestAnimationFrame(()=>w(s)),s}),!0;case"Enter":case"Tab":if(x>=0&&x<v.length){e.preventDefault();let s=v[x];return s&&N(s),!0}break;case"Escape":return e.preventDefault(),c(!1),u(-1),!0}return!1},[d,v.length,x,N,w,v]);return((0,m.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&(c(!1),u(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,m.useImperativeHandle)(s,()=>({handleKeyDown:k}),[k]),j&&0!==v.length)?(0,r.jsx)("div",{ref:h,className:(0,ek.cn)("relative",i),children:(0,r.jsx)(f.Nt,{open:d,onOpenChange:c,children:(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{ref:g,className:"absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{height:"15rem"},role:"listbox","aria-label":o._("Available commands"),children:(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:v.length>0&&(0,r.jsxs)("div",{className:"p-1.5",children:[(0,r.jsxs)("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2",role:"presentation",children:[(0,r.jsx)(ei.A,{className:"w-3.5 h-3.5"}),"Available Commands (",v.length,")"]}),v.map((e,s)=>(0,r.jsxs)(p.$,{variant:"ghost",size:"sm",className:(0,ek.cn)("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",s===x?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>N(e),onMouseEnter:()=>u(s),role:"option","aria-selected":s===x,"aria-label":"Command: /".concat(e),title:"/".concat(e),children:[(0,r.jsx)("span",{className:"text-muted-foreground mr-1.5 flex-shrink-0",children:"/"}),(0,r.jsx)("span",{className:"font-medium truncate min-w-0",children:e}),s===x&&(0,r.jsx)(eF.A,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},e))]})})})})})}):null});var eq=t(40472),e$=t(80882);let eK=function(e,s){let t=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return(0,eA.useQuery)({queryKey:(0,M.Vl)(e,s).queryKey,queryFn:(0,M.Vl)(e,s).queryFn,enabled:t&&!!e,staleTime:3e5})},eL=(0,m.forwardRef)((e,s)=>{let{projectId:t,inputValue:n,onFileSelect:l,className:i}=e,{i18n:o}=(0,a.uB)(),[d,c]=(0,m.useState)(!1),[x,u]=(0,m.useState)(-1),h=(0,m.useRef)(null),g=(0,m.useRef)(null),{shouldShow:b,searchPath:j,beforeAt:v,afterAt:y}=(0,m.useMemo)(()=>(e=>{let s=e.lastIndexOf("@");if(-1===s)return{shouldShow:!1,searchPath:"",beforeAt:"",afterAt:""};let t=e.slice(0,s),r=e.slice(s+1),a=r.split(/\s/),n=a[0]||"";return{shouldShow:!(a.length>1),searchPath:n,beforeAt:t,afterAt:r}})(n),[n]),{basePath:N,filterTerm:w}=(0,m.useMemo)(()=>{if(!j)return{basePath:"/",filterTerm:""};let e=j.lastIndexOf("/");if(-1===e)return{basePath:"/",filterTerm:j};let s=j.slice(0,e+1);return{basePath:"/"===s?"/":s,filterTerm:j.slice(e+1)}},[j]),{data:k,isLoading:C}=eK(t,N,b),A=(0,m.useMemo)(()=>(null==k?void 0:k.entries)?w?k.entries.filter(e=>e.name.toLowerCase().includes(w.toLowerCase())):k.entries:[],[null==k?void 0:k.entries,w]),S=b&&!C&&A.length>0;d!==S&&(c(S),u(-1));let P=(0,m.useCallback)(function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=e.path,r=y.split(/\s/).slice(1).join(" ");l("".concat(v,"@").concat(t).concat(r).trim()+("directory"!==e.type||s?" ":"/")),("file"===e.type||s)&&(c(!1),u(-1))},[v,y,l]),M=(0,m.useCallback)(e=>{if(e>=0&&g.current){let s=g.current.querySelectorAll('button[role="option"]')[e];s&&s.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),R=(0,m.useCallback)(e=>{if(!d||0===A.length)return!1;switch(e.key){case"ArrowDown":return e.preventDefault(),u(e=>{let s=e<A.length-1?e+1:0;return requestAnimationFrame(()=>M(s)),s}),!0;case"ArrowUp":return e.preventDefault(),u(e=>{let s=e>0?e-1:A.length-1;return requestAnimationFrame(()=>M(s)),s}),!0;case"Enter":if(x>=0&&x<A.length){e.preventDefault();let s=A[x];return s&&P(s,!0),!0}break;case"Tab":if(x>=0&&x<A.length){e.preventDefault();let s=A[x];return s&&P(s,"file"===s.type),!0}break;case"Escape":return e.preventDefault(),c(!1),u(-1),!0}return!1},[d,A.length,x,P,M,A]);return((0,m.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&(c(!1),u(-1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,m.useImperativeHandle)(s,()=>({handleKeyDown:R}),[R]),!b||C||0===A.length)?null:(0,r.jsx)("div",{ref:h,className:(0,ek.cn)("relative",i),children:(0,r.jsx)(f.Nt,{open:d,onOpenChange:c,children:(0,r.jsx)(f.Ke,{children:(0,r.jsx)("div",{ref:g,className:"absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{height:"15rem"},role:"listbox","aria-label":o._("Available files and directories"),children:(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:A.length>0&&(0,r.jsxs)("div",{className:"p-1.5",children:[(0,r.jsxs)("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2",role:"presentation",children:[(0,r.jsx)(eq.A,{className:"w-3.5 h-3.5"}),"Files & Directories (",A.length,")","/"!==N&&(0,r.jsxs)("span",{className:"text-xs font-mono text-muted-foreground/70",children:["in ",N]})]}),A.map((e,s)=>(0,r.jsxs)(p.$,{variant:"ghost",size:"sm",className:(0,ek.cn)("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",s===x?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>P(e,"file"===e.type),onMouseEnter:()=>u(s),role:"option","aria-selected":s===x,"aria-label":"".concat(e.type,": ").concat(e.name),title:e.path,children:["directory"===e.type?(0,r.jsx)(e$.A,{className:"w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0"}):(0,r.jsx)(eq.A,{className:"w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0"}),(0,r.jsx)("span",{className:"font-medium truncate min-w-0",children:e.name}),"directory"===e.type&&(0,r.jsx)("span",{className:"text-muted-foreground ml-1 flex-shrink-0",children:"/"}),s===x&&(0,r.jsx)(eF.A,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},e.path))]})})})})})})});eL.displayName="FileCompletion";let ez=e=>{let{projectId:s,message:t,commandCompletionRef:a,fileCompletionRef:n,handleCommandSelect:l,handleFileSelect:i,cursorPosition:o}=e,d=(0,m.useMemo)(()=>((e,s,t)=>{let r,a,n=window.innerHeight,l=48+36*Math.min(t,5)+12,i=s.top<n/2,o=n-s.top,d=s.top;i&&o>=l+20?(r="below",a=e.top+24):!i&&d>=l+20?(r="above",a=e.top-l-16):o>d?(r="below",a=e.top+24):(r="above",a=e.top-l-16);let c=window.innerWidth;return{top:a,left:Math.max(16,Math.min(e.left-16,c-512-16)),placement:r}})(o.relative,o.absolute,5),[o]);return(0,r.jsxs)("div",{className:"absolute w-full max-w-sm sm:max-w-md lg:max-w-lg xl:max-w-xl",style:{top:d.top,left:d.left,maxWidth:Math.min(512,.8*window.innerWidth)},children:[(0,r.jsx)(eD,{ref:a,projectId:s,inputValue:t,onCommandSelect:l,className:"absolute left-0 right-0 ".concat("above"===d.placement?"bottom-full mb-2":"top-full mt-1")}),(0,r.jsx)(eL,{ref:n,projectId:s,inputValue:t,onFileSelect:i,className:"absolute left-0 right-0 ".concat("above"===d.placement?"bottom-full mb-2":"top-full mt-1")})]})},eB=e=>{let{projectId:s,onSubmit:t,isPending:n,error:l,placeholder:o,buttonText:d,minHeight:c="min-h-[100px]",containerClassName:x="",disabled:u=!1,buttonSize:h="lg"}=e,{i18n:g}=(0,a.uB)(),[f,b]=(0,m.useState)(""),[v,y]=(0,m.useState)({relative:{top:0,left:0},absolute:{top:0,left:0}}),N=(0,m.useRef)(null),w=(0,m.useRef)(null),k=(0,m.useRef)(null),C=(0,m.useRef)(null),A=(0,m.useId)(),{config:S}=(0,j.U)(),P=async()=>{f.trim()&&(await t(f.trim()),b(""))},M=(0,m.useCallback)(()=>{let e=w.current,s=N.current;if(null===e||null===s)return;let t=e.selectionStart,r=e.value.substring(0,t),a=e.value.substring(t),n=document.createTextNode(r),l=document.createTextNode(a),i=document.createElement("span");i.innerHTML="&nbsp;";let o=document.createElement("div");o.innerHTML="",o.append(n,i,l);let d=window.getComputedStyle(e);for(let e of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])o.style[e]=d[e];o.style.visibility="hidden",s.prepend(o);let c=i.getBoundingClientRect(),m=s.getBoundingClientRect();return s.removeChild(o),{relative:{top:c.top-m.top-e.scrollTop,left:c.left-m.left-e.scrollLeft},absolute:{top:c.top-e.scrollTop,left:c.left-e.scrollLeft}}},[]);return(0,r.jsxs)("div",{className:x,children:[l&&(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-3 text-sm text-red-600 dark:text-red-400 bg-gradient-to-r from-red-50 to-red-100/50 dark:from-red-950/30 dark:to-red-900/20 border border-red-200/50 dark:border-red-800/50 rounded-xl mb-4 animate-in fade-in slide-in-from-top-2 duration-300 shadow-sm",children:[(0,r.jsx)(el.A,{className:"w-4 h-4 shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"font-medium",children:(0,r.jsx)(a.x6,{id:"chat.error.send_failed",message:"Failed to send message. Please try again."})})]}),(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-blue-500/20 via-purple-500/20 to-pink-500/20 rounded-2xl blur opacity-0 group-hover:opacity-100 transition-opacity duration-500","aria-hidden":"true"}),(0,r.jsxs)("div",{className:"relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden",children:[(0,r.jsx)("div",{className:"relative",ref:N,children:(0,r.jsx)(eC,{ref:w,value:f,onChange:e=>{if(e.target.value.endsWith("@")||e.target.value.endsWith("/")){let e=M();e&&y(e)}b(e.target.value)},onKeyDown:e=>{var s,t;if((null==(s=C.current)||!s.handleKeyDown(e))&&(null==(t=k.current)||!t.handleKeyDown(e))&&"Enter"===e.key&&!e.nativeEvent.isComposing){let s=null==S?void 0:S.enterKeyBehavior;"enter-send"!==s||e.shiftKey||e.metaKey?"shift-enter-send"===s&&e.shiftKey&&!e.metaKey?(e.preventDefault(),P()):"command-enter-send"===s&&e.metaKey&&!e.shiftKey&&(e.preventDefault(),P()):(e.preventDefault(),P())}},placeholder:o,className:"".concat(c," resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-4 text-lg transition-all duration-200 placeholder:text-muted-foreground/60"),disabled:n||u,maxLength:4e3,"aria-label":g._("Message input with completion support"),"aria-describedby":A,"aria-expanded":f.startsWith("/")||f.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"})}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-5 py-3 bg-muted/30 border-t border-border/40",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-xs font-medium text-muted-foreground/80",id:A,children:[f.length,(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"/4000"})]}),(f.startsWith("/")||f.includes("@"))&&(0,r.jsxs)("span",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium flex items-center gap-1",children:[(0,r.jsx)(eI.A,{className:"w-3 h-3"}),(0,r.jsx)(a.x6,{id:"chat.autocomplete.active",message:"Autocomplete active"})]})]}),(0,r.jsx)(p.$,{onClick:P,disabled:!f.trim()||n||u,size:h,className:"gap-2 transition-all duration-200 hover:shadow-md hover:scale-105 active:scale-95 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 disabled:from-muted disabled:to-muted",children:n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{className:"w-4 h-4 animate-spin"}),(0,r.jsx)("span",{children:(0,r.jsx)(a.x6,{id:"chat.status.processing",message:"Processing..."})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e_.A,{className:"w-4 h-4"}),d]})})]})]}),(0,r.jsx)(ez,{projectId:s,message:f,commandCompletionRef:k,fileCompletionRef:C,handleCommandSelect:e=>{var s;b(e),null==(s=w.current)||s.focus()},handleFileSelect:e=>{var s;b(e),null==(s=w.current)||s.focus()},cursorPosition:v})]})]})};var eU=t(49612);let eO=(e,s)=>{let t=(0,eU.useRouter)();return(0,n.useMutation)({mutationFn:async s=>{let t=await k.s.api.cc["session-processes"].$post({json:{projectId:e,baseSessionId:s.baseSessionId,message:s.message}},{init:{signal:AbortSignal.timeout(2e4)}});if(!t.ok)throw Error(t.statusText);return t.json()},onSuccess:async r=>{null==s||s(),t.push("/projects/".concat(e,"/sessions/").concat(r.sessionProcess.sessionId))}})},eZ=e=>{let{projectId:s,sessionId:t,sessionProcessId:l}=e,{i18n:i}=(0,a.uB)(),o=(0,n.useMutation)({mutationFn:async e=>{let r=await k.s.api.cc["session-processes"][":sessionProcessId"].continue.$post({param:{sessionProcessId:e.sessionProcessId},json:{projectId:s,baseSessionId:t,continueMessage:e.message}},{init:{signal:AbortSignal.timeout(2e4)}});if(!r.ok)throw Error(r.statusText);return r.json()}}),{config:d}=(0,j.U)(),c=async e=>{await o.mutateAsync({message:e,sessionProcessId:l})},m=(0,r.jsx)(a.x6,{id:"chat.send",message:"Send"});return(0,r.jsxs)("div",{className:"relative mt-8 mb-6",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-border to-transparent h-px top-0"}),(0,r.jsx)("div",{className:"pt-8",children:(0,r.jsx)(eB,{projectId:s,onSubmit:c,isPending:o.isPending,error:o.error,placeholder:(()=>{let e=null==d?void 0:d.enterKeyBehavior;return"enter-send"===e?i._("Type your message... (Start with / for commands, @ for files, Enter to send)"):"command-enter-send"===e?i._("Type your message... (Start with / for commands, @ for files, Command+Enter to send)"):i._("Type your message... (Start with / for commands, @ for files, Shift+Enter to send)")})(),buttonText:m,minHeight:"min-h-[120px]",containerClassName:"",buttonSize:"lg"})})]})},eH=e=>{let{projectId:s,sessionId:t}=e,{i18n:n}=(0,a.uB)(),l=eO(s),{config:i}=(0,j.U)(),o=async e=>{await l.mutateAsync({message:e,baseSessionId:t})},d=(0,r.jsx)(a.x6,{id:"chat.resume",message:"Resume"});return(0,r.jsxs)("div",{className:"relative mt-8 mb-6",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-border to-transparent h-px top-0"}),(0,r.jsx)("div",{className:"pt-8",children:(0,r.jsx)(eB,{projectId:s,onSubmit:o,isPending:l.isPending,error:l.error,placeholder:(()=>{let e=null==i?void 0:i.enterKeyBehavior;return"enter-send"===e?n._("Type your message... (Start with / for commands, @ for files, Enter to send)"):"command-enter-send"===e?n._("Type your message... (Start with / for commands, @ for files, Command+Enter to send)"):n._("Type your message... (Start with / for commands, @ for files, Shift+Enter to send)")})(),buttonText:d,minHeight:"min-h-[120px]",containerClassName:"",buttonSize:"lg"})})]})};var eV=t(97146),eW=t(87959),eQ=t(7307),eG=t.n(eQ),eJ=t(57440),eX=t(47115),eY=t(23393),e0=t(75882);let e4=e=>{let{projectId:s}=e,t=(0,eY.useQueryClient)(),{i18n:n}=(0,a.uB)(),{data:l,isLoading:i,error:o}=(0,eA.useQuery)({queryKey:(0,M.fj)(s).queryKey,queryFn:(0,M.fj)(s).queryFn});return(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsx)("div",{className:"p-3 border-b border-sidebar-border",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:(0,r.jsx)(a.x6,{id:"mcp.title",message:"MCP Servers"})}),(0,r.jsx)(p.$,{onClick:()=>{t.invalidateQueries({queryKey:(0,M.fj)(s).queryKey})},variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:i,title:n._("Reload MCP servers"),children:(0,r.jsx)(e0.A,{className:"w-3 h-3 ".concat(i?"animate-spin":"")})})]})}),(0,r.jsxs)("div",{className:"flex-1 overflow-auto p-3",children:[i&&(0,r.jsx)("div",{className:"flex items-center justify-center h-32",children:(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:(0,r.jsx)(a.x6,{id:"common.loading",message:"Loading..."})})}),o&&(0,r.jsx)("div",{className:"text-sm text-red-500",children:(0,r.jsx)(a.x6,{id:"mcp.error.load_failed",message:"Failed to load MCP servers: {error}",values:{error:o.message}})}),l&&0===l.servers.length&&(0,r.jsx)("div",{className:"text-sm text-muted-foreground text-center py-8",children:(0,r.jsx)(a.x6,{id:"mcp.no.servers",message:"No MCP servers found"})}),l&&l.servers.length>0&&(0,r.jsx)("div",{className:"space-y-3",children:l.servers.map(e=>(0,r.jsx)("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:(0,r.jsx)("div",{className:"flex items-start justify-between",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:e.name}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:e.command})]})})},e.name))})]})]})};var e1=t(81543),e2=t(1242),e5=t(83054),e6=t(52023),e3=t(87440),e8=t(17284),e7=t(96086);let e9=e=>{let{projectId:s,onSuccess:t}=e,{i18n:n}=(0,a.uB)(),l=eO(s,t),{config:i}=(0,j.U)(),o=async e=>{await l.mutateAsync({message:e})};return(0,r.jsx)(eB,{projectId:s,onSubmit:o,isPending:l.isPending,error:l.error,placeholder:(()=>{let e=null==i?void 0:i.enterKeyBehavior;return"enter-send"===e?n._("Type your message here... (Start with / for commands, @ for files, Enter to send)"):"command-enter-send"===e?n._("Type your message here... (Start with / for commands, @ for files, Command+Enter to send)"):n._("Type your message here... (Start with / for commands, @ for files, Shift+Enter to send)")})(),buttonText:(0,r.jsx)(a.x6,{id:"chat.button.start",message:"Start Chat"}),minHeight:"min-h-[200px]",containerClassName:"px-0 py-6",buttonSize:"lg"})},se=e=>{let{projectId:s,trigger:t}=e,[n,l]=(0,m.useState)(!1);return(0,r.jsxs)(b.lG,{open:n,onOpenChange:l,children:[(0,r.jsx)(b.zM,{asChild:!0,children:t}),(0,r.jsxs)(b.Cf,{className:"w-[95vw] md:w-[80vw]","data-testid":"start-new-chat-modal",children:[(0,r.jsx)(b.c7,{children:(0,r.jsxs)(b.L3,{className:"flex items-center gap-2",children:[(0,r.jsx)(G.A,{className:"w-5 h-5"}),(0,r.jsx)(a.x6,{id:"chat.modal.title",message:"Start New Chat"})]})}),(0,r.jsx)(e9,{projectId:s,onSuccess:()=>{l(!1)}})]})]})},ss=e=>{let{sessions:s,currentSessionId:t,projectId:n,hasNextPage:l,isFetchingNextPage:i,onLoadMore:o,isMobile:d=!1}=e,c=(0,C.md)(I.n),{config:m}=(0,j.U)(),x=[...s].sort((e,s)=>{let t=c.find(s=>s.sessionId===e.id),r=c.find(e=>e.sessionId===s.id),a=null==t?void 0:t.status,n=null==r?void 0:r.status,l=e=>"running"===e?0:"paused"===e?1:2,i=l(a),o=l(n);if(i!==o)return i-o;let d=e.lastModifiedAt?e.lastModifiedAt.getTime():0;return(s.lastModifiedAt?s.lastModifiedAt.getTime():0)-d});return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"border-b border-sidebar-border p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"font-semibold text-lg",children:(0,r.jsx)(a.x6,{id:"sessions.title",message:"Sessions"})}),(0,r.jsx)(se,{projectId:n,trigger:(0,r.jsxs)(p.$,{size:"sm",variant:"outline",className:"gap-1.5","data-testid":!0===d?"start-new-chat-button-mobile":"start-new-chat-button",children:[(0,r.jsx)(e7.A,{className:"w-3.5 h-3.5"}),(0,r.jsx)(a.x6,{id:"sessions.new",message:"New"})]})})]}),(0,r.jsxs)("p",{className:"text-xs text-sidebar-foreground/70",children:[s.length," ",(0,r.jsx)(a.x6,{id:"sessions.total",message:"total"})]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-2 space-y-0.5",children:[x.map(e=>{let s=e.id===t,l=null!==e.meta.firstUserMessage?E(e.meta.firstUserMessage):e.id,i=c.find(s=>s.sessionId===e.id),o=(null==i?void 0:i.status)==="running",d=(null==i?void 0:i.status)==="paused";return(0,r.jsx)(eG(),{href:"/projects/".concat(n,"/sessions/").concat(e.id),className:(0,ek.cn)("block rounded-lg p-2.5 transition-all duration-200 hover:bg-blue-50/60 dark:hover:bg-blue-950/40 hover:border-blue-300/60 dark:hover:border-blue-700/60 hover:shadow-sm border border-sidebar-border/40 bg-sidebar/30",s&&"bg-blue-100 dark:bg-blue-900/50 border-blue-400 dark:border-blue-600 shadow-md ring-1 ring-blue-200/50 dark:ring-blue-700/50 hover:bg-blue-100 dark:hover:bg-blue-900/50 hover:border-blue-400 dark:hover:border-blue-600"),children:(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1",children:l}),(o||d)&&(0,r.jsx)(g.E,{variant:o?"default":"secondary",className:(0,ek.cn)("text-xs",o&&"bg-green-500 text-white",d&&"bg-yellow-500 text-white"),children:o?(0,r.jsx)(a.x6,{id:"session.status.running",message:"Running"}):(0,r.jsx)(a.x6,{id:"session.status.paused",message:"Paused"})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-sidebar-foreground/70",children:[(0,r.jsx)(G.A,{className:"w-3 h-3"}),(0,r.jsx)("span",{children:e.meta.messageCount})]}),e.lastModifiedAt&&(0,r.jsx)("span",{className:"text-xs text-sidebar-foreground/60",children:(0,v._)(e.lastModifiedAt,{locale:m.locale,target:"time"})})]})]})},e.id)}),l&&o&&(0,r.jsx)("div",{className:"p-2",children:(0,r.jsx)(p.$,{onClick:o,disabled:i,variant:"outline",size:"sm",className:"w-full",children:i?(0,r.jsx)(a.x6,{id:"common.loading",message:"Loading..."}):(0,r.jsx)(a.x6,{id:"sessions.load.more",message:"Load More"})})})]})]})},st=e=>{let{currentSessionId:s,projectId:t,isOpen:n,onClose:l}=e,{i18n:i}=(0,a.uB)(),{data:d,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:u}=R(t),h=d.pages.flatMap(e=>e.sessions),[g,f]=(0,m.useState)("sessions"),[b,j]=(0,m.useState)(!1);(0,m.useEffect)(()=>{j(!0)},[]),(0,m.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return n&&(document.addEventListener("keydown",e),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",e),document.body.style.overflow=""}},[n,l]);let v=e=>{f(e)};return b?(0,e5.createPortal)((0,r.jsxs)("div",{className:(0,ek.cn)("fixed inset-0 z-50 transition-all duration-300 ease-out md:hidden",n?"visible opacity-100":"invisible opacity-0 pointer-events-none"),children:[(0,r.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm cursor-default",onClick:e=>{e.target===e.currentTarget&&l()},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&l()},"aria-label":i._("Close sidebar")}),(0,r.jsxs)("div",{className:(0,ek.cn)("absolute left-0 top-0 h-full w-80 max-w-[85vw] bg-sidebar text-sidebar-foreground transition-transform duration-300 ease-out flex",n?"translate-x-0":"-translate-x-full"),children:[(0,r.jsx)("div",{className:"w-12 flex flex-col border-r border-sidebar-border bg-sidebar/50",children:(0,r.jsxs)(eX.Bc,{children:[(0,r.jsxs)(eX.m_,{children:[(0,r.jsx)(eX.k$,{asChild:!0,children:(0,r.jsx)(eG(),{href:"/projects",className:"w-12 h-12 flex items-center justify-center border-b border-sidebar-border hover:bg-sidebar-accent transition-colors",children:(0,r.jsx)(eW.A,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),(0,r.jsx)(eX.ZI,{side:"right",children:(0,r.jsx)("p",{children:(0,r.jsx)(a.x6,{id:"sidebar.back.to.projects",message:"Back to projects"})})})]}),(0,r.jsxs)("div",{className:"flex flex-col p-2 space-y-1",children:[(0,r.jsxs)(eX.m_,{children:[(0,r.jsx)(eX.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button",onClick:()=>v("sessions"),className:(0,ek.cn)("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground","sessions"===g?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"sessions-tab-button-mobile",children:(0,r.jsx)(G.A,{className:"w-4 h-4"})})}),(0,r.jsx)(eX.ZI,{side:"right",children:(0,r.jsx)("p",{children:(0,r.jsx)(a.x6,{id:"sidebar.show.session.list",message:"Show session list"})})})]}),(0,r.jsxs)(eX.m_,{children:[(0,r.jsx)(eX.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button",onClick:()=>v("mcp"),className:(0,ek.cn)("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground","mcp"===g?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"mcp-tab-button-mobile",children:(0,r.jsx)(eV.A,{className:"w-4 h-4"})})}),(0,r.jsx)(eX.ZI,{side:"right",children:(0,r.jsx)("p",{children:(0,r.jsx)(a.x6,{id:"sidebar.show.mcp.settings",message:"Show MCP server settings"})})})]}),(0,r.jsxs)(eX.m_,{children:[(0,r.jsx)(eX.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button",onClick:()=>v("settings"),className:(0,ek.cn)("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground","settings"===g?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"settings-tab-button-mobile",children:(0,r.jsx)(e1.A,{className:"w-4 h-4"})})}),(0,r.jsx)(eX.ZI,{side:"right",children:(0,r.jsx)(a.x6,{id:"settings.tab.title",message:"Settings for display and notifications"})})]}),(0,r.jsxs)(eX.m_,{children:[(0,r.jsx)(eX.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button",onClick:()=>v("system-info"),className:(0,ek.cn)("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground","system-info"===g?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"system-info-tab-button-mobile",children:(0,r.jsx)(e2.A,{className:"w-4 h-4"})})}),(0,r.jsx)(eX.ZI,{side:"right",children:(0,r.jsx)(a.x6,{id:"system.info.tab.title",message:"Show system information"})})]})]})]})}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold capitalize",children:g}),(0,r.jsx)(p.$,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0 hover:bg-sidebar-accent/50",children:(0,r.jsx)(o.A,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(()=>{switch(g){case"sessions":return(0,r.jsx)(ss,{sessions:h.map(e=>({...e,lastModifiedAt:new Date(e.lastModifiedAt)})),currentSessionId:s,projectId:t,hasNextPage:x,isFetchingNextPage:u,onLoadMore:()=>c(),isMobile:!0});case"mcp":return(0,r.jsx)(e4,{projectId:t});case"settings":return(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(m.Suspense,{fallback:(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,r.jsx)("div",{className:"text-sm text-sidebar-foreground/70",children:(0,r.jsx)(a.x6,{id:"settings.loading",message:"Loading settings..."})})}),children:(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{className:"font-medium text-sm text-sidebar-foreground",children:(0,r.jsx)(a.x6,{id:"settings.session.display",message:"Session Display"})}),(0,r.jsx)(e3.o,{openingProjectId:t})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{className:"font-medium text-sm text-sidebar-foreground",children:(0,r.jsx)(a.x6,{id:"settings.notifications",message:"Notifications"})}),(0,r.jsx)(e6.T,{})]})]})})});case"system-info":return(0,r.jsx)(e8.m,{});default:return null}})()})]})]})]}),document.body):null},sr=e=>{let{currentSessionId:s,projectId:t,className:n,isMobileOpen:l=!1,onMobileOpenChange:i}=e,{data:o,fetchNextPage:d,hasNextPage:c,isFetchingNextPage:x}=R(t),u=o.pages.flatMap(e=>e.sessions),h=(0,m.useMemo)(()=>[{id:"sessions",icon:G.A,title:"Show session list",content:(0,r.jsx)(ss,{sessions:u.map(e=>({...e,lastModifiedAt:new Date(e.lastModifiedAt)})),currentSessionId:s,projectId:t,hasNextPage:c,isFetchingNextPage:x,onLoadMore:()=>d()})},{id:"mcp",icon:eV.A,title:"Show MCP server settings",content:(0,r.jsx)(e4,{projectId:t})}],[u,s,t,c,x,d]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:(0,ek.cn)("hidden md:flex h-full",n),children:(0,r.jsx)(eJ.GlobalSidebar,{projectId:t,additionalTabs:h,defaultActiveTab:"sessions",headerButton:(0,r.jsx)(eX.Bc,{children:(0,r.jsxs)(eX.m_,{children:[(0,r.jsx)(eX.k$,{asChild:!0,children:(0,r.jsx)(eG(),{href:"/projects",className:"w-12 h-12 flex items-center justify-center hover:bg-sidebar-accent transition-colors",children:(0,r.jsx)(eW.A,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),(0,r.jsx)(eX.ZI,{side:"right",children:(0,r.jsx)("p",{children:(0,r.jsx)(a.x6,{id:"sidebar.back.to.projects",message:"Back to projects"})})})]})})})}),(0,r.jsx)(st,{currentSessionId:s,projectId:t,isOpen:l,onClose:()=>null==i?void 0:i(!1)})]})},sa=e=>{var s;let{projectId:t,sessionId:x}=e,{session:u,conversations:h,getToolResult:f}=((e,s)=>{var t;let r=null==(t=((e,s)=>(0,T.useSuspenseQuery)({queryKey:(0,M.ib)(e,s).queryKey,queryFn:(0,M.ib)(e,s).queryFn}))(e,s).data)?void 0:t.session;if(null==r)throw Error("Session not found");let a=(0,m.useMemo)(()=>new Map(r.conversations.flatMap(e=>"user"!==e.type||"string"==typeof e.message.content?[]:e.message.content.flatMap(e=>"string"==typeof e||"tool_result"!==e.type?[]:[[e.tool_use_id,e]]))),[r.conversations]),n=(0,m.useCallback)(e=>a.get(e),[a]);return{session:r,conversations:r.conversations,getToolResult:n}})(t,x),{data:b}=R(t),j=b.pages[0].project,v=(0,n.useMutation)({mutationFn:async e=>{let s=await k.s.api.cc["session-processes"][":sessionProcessId"].abort.$post({param:{sessionProcessId:e},json:{projectId:t}});if(!s.ok)throw Error(s.statusText);return s.json()}}),P=(()=>{let e=(0,C.md)(I.n),s=(0,m.useCallback)(s=>e.find(e=>e.sessionId===s),[e]);return{sessionProcesses:e,getSessionProcess:s}})(),{currentPermissionRequest:_,isDialogOpen:F,onPermissionResponse:D}=(()=>{let[e,s]=(0,m.useState)(null),[t,r]=(0,m.useState)(!1);return(0,w.t)("permissionRequested",e=>{e.permissionRequest&&(s(e.permissionRequest),r(!0))}),{currentPermissionRequest:e,isDialogOpen:t,onPermissionResponse:(0,m.useCallback)(async e=>{try{if(!(await k.s.api.cc["permission-response"].$post({json:e})).ok)throw Error("Failed to send permission response");r(!1),s(null)}catch(e){console.error("Error sending permission response:",e),N.oR.error("Failed to send permission response")}},[])}})(),q=(0,m.useMemo)(()=>P.getSessionProcess(x),[P,x]);(e=>{let s=(0,C.md)(A.E),t=(0,C.md)(A.e),r=(0,m.useRef)(e);(0,m.useEffect)(()=>{let a=r.current;r.current=e,a&&!e&&(N.oR.success("Task completed"),t&&(0,S.$E)(s.soundType))},[e,t,s.soundType])})((null==q?void 0:q.status)==="running");let[$,K]=(0,m.useState)(0),[L,z]=(0,m.useState)(!1),[B,U]=(0,m.useState)(!1),O=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if((null==q?void 0:q.status)==="running"&&h.length!==$){K(h.length);let e=O.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}},[h,null==q?void 0:q.status,$]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sr,{currentSessionId:x,projectId:t,isMobileOpen:L,onMobileOpenChange:z}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[(0,r.jsx)("header",{className:"px-2 sm:px-3 py-2 sm:py-3 sticky top-0 z-10 bg-background w-full flex-shrink-0 min-w-0",children:(0,r.jsxs)("div",{className:"space-y-2 sm:space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3",children:[(0,r.jsx)(p.$,{variant:"ghost",size:"sm",className:"md:hidden flex-shrink-0",onClick:()=>z(!0),"data-testid":"mobile-sidebar-toggle-button",children:(0,r.jsx)(l.A,{className:"w-4 h-4"})}),(0,r.jsx)("h1",{className:"text-lg sm:text-2xl md:text-3xl font-bold break-all overflow-ellipsis line-clamp-1 px-1 sm:px-5 min-w-0",children:null!==u.meta.firstUserMessage?E(u.meta.firstUserMessage):x})]}),(0,r.jsxs)("div",{className:"px-1 sm:px-5 flex flex-wrap items-center gap-1 sm:gap-2",children:[(null==j?void 0:j.claudeProjectPath)&&(0,r.jsx)(g.E,{variant:"secondary",className:"h-6 sm:h-8 text-xs sm:text-sm flex items-center",children:null!=(s=j.meta.projectPath)?s:j.claudeProjectPath}),(0,r.jsx)(g.E,{variant:"secondary",className:"h-6 sm:h-8 text-xs sm:text-sm flex items-center",children:x})]}),(null==q?void 0:q.status)==="running"&&(0,r.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2 p-1 bg-primary/10 border border-primary/20 rounded-lg mx-1 sm:mx-5 animate-in fade-in slide-in-from-top-2 duration-300",children:[(0,r.jsx)(i.A,{className:"w-3 h-3 sm:w-4 sm:h-4 animate-spin text-primary"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"text-xs sm:text-sm font-medium",children:(0,r.jsx)(a.x6,{id:"session.conversation.in.progress",message:"Conversation is in progress..."})}),(0,r.jsx)("div",{className:"w-full bg-primary/10 rounded-full h-1 mt-1 overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-primary rounded-full animate-pulse",style:{width:"70%"}})})]}),(0,r.jsxs)(p.$,{variant:"ghost",size:"sm",onClick:()=>{v.mutate(q.id)},disabled:v.isPending,children:[v.isPending?(0,r.jsx)(i.A,{className:"w-3 h-3 sm:w-4 sm:h-4 animate-spin"}):(0,r.jsx)(o.A,{className:"w-3 h-3 sm:w-4 sm:h-4"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:(0,r.jsx)(a.x6,{id:"session.conversation.abort",message:"Abort"})})]})]}),(null==q?void 0:q.status)==="paused"&&(0,r.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2 p-1 bg-orange-50/80 dark:bg-orange-950/50 border border-orange-300/50 dark:border-orange-800/50 rounded-lg mx-1 sm:mx-5 animate-in fade-in slide-in-from-top-2 duration-300",children:[(0,r.jsx)(d.A,{className:"w-3 h-3 sm:w-4 sm:h-4 text-orange-600 dark:text-orange-400 animate-pulse"}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)("p",{className:"text-xs sm:text-sm font-medium text-orange-900 dark:text-orange-200",children:(0,r.jsx)(a.x6,{id:"session.conversation.paused",message:"Conversation is paused..."})})}),(0,r.jsxs)(p.$,{variant:"ghost",size:"sm",onClick:()=>{v.mutate(q.id)},disabled:v.isPending,className:"hover:bg-orange-100 dark:hover:bg-orange-900/50 text-orange-900 dark:text-orange-200",children:[v.isPending?(0,r.jsx)(i.A,{className:"w-3 h-3 sm:w-4 sm:h-4 animate-spin"}):(0,r.jsx)(o.A,{className:"w-3 h-3 sm:w-4 sm:h-4"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:(0,r.jsx)(a.x6,{id:"session.conversation.abort",message:"Abort"})})]})]})]})}),(0,r.jsx)("div",{ref:O,className:"flex-1 overflow-y-auto min-h-0 min-w-0","data-testid":"scrollable-content",children:(0,r.jsxs)("main",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 relative z-5 min-w-0",children:[(0,r.jsx)(ep,{conversations:h,getToolResult:f}),(null==q?void 0:q.status)==="running"&&(0,r.jsx)("div",{className:"flex justify-start items-center py-8 animate-in fade-in duration-500",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(i.A,{className:"w-8 h-8 animate-spin text-primary"}),(0,r.jsx)("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground font-medium animate-pulse",children:(0,r.jsx)(a.x6,{id:"session.processing",message:"Claude Code is processing..."})})]})}),void 0!==q?(0,r.jsx)(eZ,{projectId:t,sessionId:x,sessionProcessId:q.id}):(0,r.jsx)(eH,{projectId:t,sessionId:x})]})})]}),(0,r.jsx)(p.$,{onClick:()=>U(!0),className:"fixed bottom-15 right-6 w-14 h-14 rounded-full shadow-lg hover:shadow-xl transition-all duration-200 z-50",size:"lg",children:(0,r.jsx)(c.A,{className:"w-6 h-6"})}),(0,r.jsx)(eT,{projectId:t,isOpen:B,onOpenChange:U}),(0,r.jsx)(y,{permissionRequest:_,isOpen:F,onResponse:D})]})}},28643:(e,s,t)=>{Promise.resolve().then(t.bind(t,2767)),Promise.resolve().then(t.bind(t,85259)),Promise.resolve().then(t.bind(t,23393)),Promise.resolve().then(t.bind(t,74564)),Promise.resolve().then(t.bind(t,30800)),Promise.resolve().then(t.bind(t,94628)),Promise.resolve().then(t.bind(t,19864)),Promise.resolve().then(t.bind(t,17872)),Promise.resolve().then(t.bind(t,65883)),Promise.resolve().then(t.bind(t,31116)),Promise.resolve().then(t.bind(t,70172)),Promise.resolve().then(t.bind(t,40840)),Promise.resolve().then(t.bind(t,48544)),Promise.resolve().then(t.bind(t,12259))},54402:(e,s,t)=>{"use strict";t.d(s,{n:()=>r});let r=(0,t(60679).eU)([])},55496:(e,s,t)=>{"use strict";t.d(s,{Fc:()=>i,TN:()=>d,XL:()=>o});var r=t(26423),a=t(67739),n=t(98113);let l=(0,a.F)("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function i(e){let{className:s,variant:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,n.cn)(l({variant:t}),s),...a})}function o(e){let{className:s,...t}=e;return(0,r.jsx)("div",{"data-slot":"alert-title",className:(0,n.cn)("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",s),...t})}function d(e){let{className:s,...t}=e;return(0,r.jsx)("div",{"data-slot":"alert-description",className:(0,n.cn)("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",s),...t})}},79394:(e,s,t)=>{"use strict";t.d(s,{E:()=>n,l:()=>a});var r=t(69087);let a=(0,r.createContext)(null),n=()=>{let e=(0,r.useContext)(a);if(!e)throw Error("useSSEContext must be used within SSEProvider");return e}},87066:(e,s,t)=>{"use strict";t.d(s,{t:()=>n});var r=t(69087),a=t(79394);let n=(e,s)=>{let{addEventListener:t}=(0,a.E)(),n=(0,r.useRef)(s);(0,r.useEffect)(()=>{n.current=s}),(0,r.useEffect)(()=>{let s=t(e,e=>{n.current(e)});return()=>{s()}},[e,t])}}},e=>{e.O(0,[761,307,794,870,92,580,716,63,139,311,358],()=>e(e.s=28643)),_N_E=e.O()}]);