"use strict";exports.id=9703,exports.ids=[9703],exports.modules={75433:(e,t,s)=>{s.d(t,{Vw:()=>j});var a=s(10326),r=s(17577);s(90434);var n=s(87403),l=s(2982),i=s(35047),o=s(3885),c=s(61421);let d=(0,r.memo)(function({status:e}){let t=c.F4[e];return"spinner"===t.type?a.jsx("span",{"data-testid":"status-indicator",className:`
          w-3 h-3 rounded-full flex-shrink-0
          border-2 border-t-transparent
          ${t.className}
          animate-spin
        `,title:t.label,"aria-label":t.label}):a.jsx("span",{"data-testid":"status-indicator",className:`
        w-3 h-3 rounded-full flex-shrink-0
        ${t.className}
      `,title:t.label,"aria-label":t.label})}),u=(0,r.memo)(function({branch:e,isSelected:t,onClick:s}){return(0,a.jsxs)("button",{"data-testid":"branch-list-item",onClick:s,"aria-current":t?"true":void 0,className:`
        w-full px-4 py-3 flex flex-col gap-1
        hover:bg-gray-800 transition-colors
        focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500
        ${t?"bg-gray-700 border-l-2 border-blue-500":"border-l-2 border-transparent"}
      `,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 w-full",children:[a.jsx(d,{status:e.status}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 text-left",children:[a.jsx("p",{className:"text-sm font-medium text-white truncate",children:e.name}),a.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.repositoryName})]}),e.hasUnread&&a.jsx("span",{"data-testid":"unread-indicator",className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0","aria-label":"Has unread messages"})]}),e.description&&a.jsx("div",{"data-testid":"branch-description",className:"pl-6 pr-2 mt-1 text-left",children:a.jsx("p",{className:"text-xs text-gray-400 line-clamp-2",children:e.description})})]})}),m=[{key:"updatedAt",label:"Updated"},{key:"repositoryName",label:"Repository"},{key:"branchName",label:"Branch"},{key:"status",label:"Status"}],x=(0,r.memo)(function(){let{sortKey:e,sortDirection:t,setSortKey:s,setSortDirection:l}=(0,n.Sz)(),[i,o]=(0,r.useState)(!1),c=(0,r.useRef)(null);(0,r.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&o(!1)}if(i)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,r.useEffect)(()=>{function e(e){"Escape"===e.key&&o(!1)}if(i)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]);let d=(0,r.useCallback)(()=>{o(e=>!e)},[]),u=(0,r.useCallback)(a=>{a===e?l("asc"===t?"desc":"asc"):(s(a),l("updatedAt"===a?"desc":"asc")),o(!1)},[e,t,s,l]),x=(0,r.useCallback)(()=>{l("asc"===t?"desc":"asc")},[t,l]),g=m.find(t=>t.key===e)?.label||"Sort";return(0,a.jsxs)("div",{ref:c,className:"relative","data-testid":"sort-selector",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsxs)("button",{type:"button",onClick:d,"aria-expanded":i,"aria-haspopup":"listbox","aria-label":`Sort by ${g}`,className:" flex items-center gap-1 px-2 py-1 rounded text-xs text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:[a.jsx(p,{className:"w-3 h-3"}),a.jsx("span",{className:"hidden sm:inline",children:g})]}),a.jsx("button",{type:"button",onClick:x,"aria-label":"asc"===t?"Sort ascending":"Sort descending",className:" p-1 rounded text-gray-300 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors ",children:"asc"===t?a.jsx(h,{className:"w-3 h-3"}):a.jsx(b,{className:"w-3 h-3"})})]}),i&&a.jsx("div",{role:"listbox","aria-label":"Sort options",className:" absolute right-0 top-full mt-1 z-50 min-w-[140px] py-1 rounded-md shadow-lg bg-gray-800 border border-gray-600 ",children:m.map(s=>(0,a.jsxs)("button",{type:"button",role:"option","aria-selected":e===s.key,onClick:()=>u(s.key),className:`
                w-full px-3 py-2 text-left text-sm
                flex items-center justify-between
                hover:bg-gray-700 transition-colors
                ${e===s.key?"text-blue-400":"text-gray-300"}
              `,children:[a.jsx("span",{children:s.label}),e===s.key&&a.jsx("span",{className:"text-xs",children:"asc"===t?"ASC":"DESC"})]},s.key))})]})});function p({className:e}){return a.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})})}function h({className:e}){return a.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})}function b({className:e}){return a.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function g(e){let t=function(e){let t=e.sessionStatusByCli?.claude;if(t){if(t.isWaitingForResponse)return"waiting";if(t.isProcessing)return"running";if(t.isRunning)return"ready"}return e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isSessionRunning?"ready":"idle"}(e),s=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt));return{id:e.id,name:e.name,repositoryName:e.repositoryName,status:t,hasUnread:s,lastActivity:e.updatedAt,description:e.description}}let f={waiting:0,ready:1,running:2,generating:3,idle:4},y=(0,r.memo)(function(){let e=(0,i.useRouter)(),{worktrees:t,selectedWorktreeId:s,selectWorktree:l}=(0,o.Mu)(),{closeMobileDrawer:c,sortKey:d,sortDirection:m}=(0,n.Sz)(),[p,h]=(0,r.useState)(""),b=(0,r.useMemo)(()=>{let e=t.map(g),s=e;if(p.trim()){let t=p.toLowerCase();s=e.filter(e=>e.name.toLowerCase().includes(t)||e.repositoryName.toLowerCase().includes(t))}return function(e,t,s){let a=[...e];return a.sort((e,a)=>{let r=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,s=t(e.lastActivity);r=t(a.lastActivity)-s;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),s=a.repositoryName.toLowerCase();r=t.localeCompare(s);break}case"branchName":{let t=e.name.toLowerCase(),s=a.name.toLowerCase();r=t.localeCompare(s);break}case"status":r=f[e.status]-f[a.status]}return("updatedAt"===t?"desc"===s:"asc"===s)?r:-r}),a}(s,d,m)},[t,p,d,m]),y=t=>{l(t),e.push(`/worktrees/${t}`),c()};return(0,a.jsxs)("nav",{"data-testid":"sidebar","aria-label":"Branch navigation",className:"h-full flex flex-col bg-gray-900 text-white",role:"navigation",children:[a.jsx("div",{"data-testid":"sidebar-header",className:"flex-shrink-0 px-4 py-4 border-b border-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Branches"}),a.jsx(x,{})]})}),a.jsx("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-700",children:a.jsx("input",{type:"text",placeholder:"Search branches...",value:p,onChange:e=>h(e.target.value),className:" w-full px-3 py-2 rounded-md bg-gray-800 text-white placeholder-gray-400 border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent "})}),a.jsx("div",{"data-testid":"branch-list",className:"flex-1 overflow-y-auto",children:0===b.length?a.jsx("div",{className:"px-4 py-8 text-center text-gray-400",children:p?"No branches found":"No branches available"}):b.map(e=>a.jsx(u,{branch:e,isSelected:e.id===s,onClick:()=>y(e.id)},e.id))})]})});var w=s(22202);let v="transform transition-transform duration-300 ease-out",j=(0,r.memo)(function({children:e}){let{isOpen:t,isMobileDrawerOpen:s,closeMobileDrawer:r}=(0,n.Sz)();return(0,l.d)()?(0,a.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex flex-col",children:[s&&a.jsx("div",{"data-testid":"drawer-overlay",className:"fixed inset-0 bg-black/50 z-40",onClick:r,"aria-hidden":"true"}),a.jsx("aside",{"data-testid":"sidebar-container",className:`
            fixed left-0 top-0 h-full w-72 z-50
            ${v}
            ${s?"translate-x-0":"-translate-x-full"}
          `,role:"complementary",children:a.jsx(y,{})}),a.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",role:"main",children:e})]}):(0,a.jsxs)("div",{"data-testid":"app-shell",className:"h-screen flex",children:[a.jsx("aside",{"data-testid":"sidebar-container",className:`
          fixed left-0 top-0 h-full w-72
          ${v}
          ${t?"translate-x-0":"-translate-x-full"}
        `,style:{zIndex:w.k.SIDEBAR},role:"complementary","aria-hidden":!t,children:a.jsx(y,{})}),a.jsx("main",{className:`
          flex-1 min-w-0 h-full overflow-hidden
          transition-[padding] duration-300 ease-out
          ${t?"md:pl-72":"md:pl-0"}
        `,role:"main",children:e})]})})},28676:(e,t,s)=>{s.d(t,{u:()=>n});var a=s(10326),r=s(17577);function n({isOpen:e,onClose:t,title:s,children:n,size:l="lg",showCloseButton:i=!0,disableClose:o=!1}){let c=(0,r.useRef)(null);return e?(0,a.jsxs)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:o?void 0:t}),a.jsx("div",{className:"flex min-h-full items-center justify-center p-2 sm:p-4",children:(0,a.jsxs)("div",{ref:c,className:`relative w-full ${{sm:"max-w-[calc(100vw-2rem)] sm:max-w-md",md:"max-w-[calc(100vw-2rem)] sm:max-w-2xl",lg:"max-w-[calc(100vw-2rem)] sm:max-w-4xl",xl:"max-w-[calc(100vw-2rem)] sm:max-w-6xl",full:"max-w-[calc(100vw-2rem)] sm:max-w-[95vw]"}[l]} bg-white rounded-lg shadow-xl transform transition-all`,children:[(s||i)&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3 sm:py-4 border-b border-gray-200",children:[a.jsx("h3",{className:"text-base sm:text-lg font-semibold text-gray-900 truncate pr-2",children:s}),i&&a.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 transition-colors flex-shrink-0",children:a.jsx("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsx("div",{className:"px-4 sm:px-6 py-3 sm:py-4",children:n})]})})]}):null}},77758:(e,t,s)=>{s.d(t,{Ct:()=>c,zx:()=>r,Zb:()=>n,aY:()=>o,Ol:()=>l,ll:()=>i,u_:()=>d.u});var a=s(10326);function r({variant:e="primary",size:t="md",fullWidth:s=!1,loading:r=!1,disabled:n,className:l="",children:i,...o}){let c=["btn",{primary:"btn-primary",secondary:"btn-secondary",danger:"btn-danger",ghost:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-500"}[e],{sm:"btn-sm",md:"",lg:"btn-lg"}[t],s?"w-full":"",n||r?"opacity-50 cursor-not-allowed":"",l].filter(Boolean).join(" ");return(0,a.jsxs)("button",{className:c,disabled:n||r,...o,children:[r&&(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),i]})}function n({hover:e=!1,padding:t="md",className:s="",children:r,...n}){let l=["card",e?"card-hover":"",{none:"",sm:"p-3",md:"p-4",lg:"p-6"}[t],s].filter(Boolean).join(" ");return a.jsx("div",{className:l,...n,children:r})}function l({className:e="",children:t,...s}){return a.jsx("div",{className:`mb-3 ${e}`,...s,children:t})}function i({className:e="",children:t,...s}){return a.jsx("h3",{className:`text-lg font-semibold text-gray-900 ${e}`,...s,children:t})}function o({className:e="",children:t,...s}){return a.jsx("div",{className:e,...s,children:t})}function c({variant:e="gray",dot:t=!1,className:s="",children:r,...n}){let l=["badge",{success:"badge-success",warning:"badge-warning",error:"badge-error",info:"badge-info",gray:"badge-gray"}[e],s].filter(Boolean).join(" ");return(0,a.jsxs)("span",{className:l,...n,children:[t&&a.jsx("span",{className:`mr-1.5 inline-block h-2 w-2 rounded-full ${{success:"bg-green-600",warning:"bg-yellow-600",error:"bg-red-600",info:"bg-blue-600",gray:"bg-gray-600"}[e]}`,"aria-hidden":"true"}),r]})}s(17577);var d=s(28676)},15470:(e,t,s)=>{s.d(t,{R:()=>m});var a=s(10326),r=s(17577),n=s(73002);function l(e,t){if(!t.trim())return e;let s=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(s),a=e.description.toLowerCase().includes(s);return t||a})})).filter(e=>e.commands.length>0)}function i({groups:e,onSelect:t,highlightedIndex:s=-1,className:r=""}){let n=0;return 0===e.length?a.jsx("div",{className:`text-sm text-gray-500 p-4 text-center ${r}`,children:"No commands available"}):a.jsx("div",{className:`overflow-y-auto ${r}`,children:e.map(e=>(0,a.jsxs)("div",{className:"mb-2",children:[a.jsx("div",{className:"px-3 py-1.5 text-xs font-semibold text-gray-500 uppercase tracking-wider bg-gray-50",children:e.label}),a.jsx("div",{children:e.commands.map(e=>{let r=n;n++;let l=r===s;return(0,a.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":l,onClick:()=>t(e),className:`w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-blue-50 transition-colors ${l?"bg-blue-100":""}`,children:[(0,a.jsxs)("span",{className:"text-blue-600 font-mono text-sm flex-shrink-0",children:["/",e.name]}),a.jsx("span",{className:"text-gray-600 text-sm truncate",children:e.description})]},e.name)})})]},e.category))})}function o({isOpen:e,groups:t,onSelect:s,onClose:n,isMobile:o=!1,position:c,onFreeInput:d}){let[u,m]=(0,r.useState)(""),[x,p]=(0,r.useState)(0),h=(0,r.useRef)(null),b=(0,r.useMemo)(()=>l(t,u),[t,u]),g=(0,r.useMemo)(()=>b.flatMap(e=>e.commands),[b]),f=(0,r.useCallback)(e=>{s(e),n()},[s,n]);return((0,r.useCallback)(t=>{if(e)switch(t.key){case"Escape":t.preventDefault(),n();break;case"ArrowDown":t.preventDefault(),p(e=>Math.min(e+1,g.length-1));break;case"ArrowUp":t.preventDefault(),p(e=>Math.max(e-1,0));break;case"Enter":t.preventDefault(),g[x]&&f(g[x])}},[e,g,x,n,f]),e)?o?(0,a.jsxs)(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:n,"aria-hidden":"true"}),(0,a.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-white rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Commands"}),a.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"p-2 rounded-full hover:bg-gray-100",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsx("div",{className:"px-4 py-2 border-b border-gray-100",children:a.jsx("input",{ref:h,type:"text",value:u,onChange:e=>m(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})}),d&&(0,a.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:d,className:"w-full px-4 py-3 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors",children:[a.jsx("span",{className:"text-blue-600",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.jsx("span",{className:"text-gray-600",children:"Enter custom command..."})]}),a.jsx(i,{groups:b,onSelect:f,highlightedIndex:x,className:"flex-1 overflow-y-auto pb-20"})]})]}):(0,a.jsxs)("div",{role:"listbox",className:"absolute bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:c?{top:c.top,left:c.left}:{bottom:"100%",left:0,marginBottom:"4px"},children:[a.jsx("div",{className:"px-3 py-2 border-b border-gray-100",children:a.jsx("input",{ref:h,type:"text",value:u,onChange:e=>m(e.target.value),placeholder:"Search commands...",className:"w-full px-3 py-1.5 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500"})}),d&&(0,a.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:d,className:"w-full px-3 py-2 text-left border-b border-gray-100 flex items-center gap-2 hover:bg-blue-50 transition-colors text-sm",children:[a.jsx("span",{className:"text-blue-600",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.jsx("span",{className:"text-gray-600",children:"Enter custom command..."})]}),a.jsx(i,{groups:b,onSelect:f,highlightedIndex:x,className:"flex-1 overflow-y-auto"}),(0,a.jsxs)("div",{className:"px-3 py-1.5 border-t border-gray-100 text-xs text-gray-400 flex gap-3",children:[(0,a.jsxs)("span",{children:[a.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Enter"})," select"]}),(0,a.jsxs)("span",{children:[a.jsx("kbd",{className:"px-1 py-0.5 bg-gray-100 rounded",children:"Esc"})," close"]})]})]}):null}function c({worktreeId:e,cliToolId:t,disabled:s=!1,onInterrupt:n}){let[l,i]=(0,r.useState)(!1),o=(0,r.useRef)(0),c=(0,r.useCallback)(async()=>{let s=Date.now();if(!(s-o.current<1e3)){o.current=s,i(!0);try{let s=await fetch(`/api/worktrees/${e}/interrupt`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:t})});if(s.ok)n?.();else{let e=await s.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",e.error||s.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{i(!1)}}},[e,t,n]);return a.jsx("button",{type:"button",onClick:c,disabled:s||l,className:"flex-shrink-0 p-2 text-orange-600 hover:bg-orange-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Stop processing","data-testid":"interrupt-button",children:l?(0,a.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):a.jsx(d,{})})}function d(){return a.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var u=s(2982);function m({worktreeId:e,onMessageSent:t,cliToolId:s,isSessionRunning:i=!1}){let[d,m]=(0,r.useState)(""),[x,p]=(0,r.useState)(!1),[h,b]=(0,r.useState)(null),[g,f]=(0,r.useState)(!1),[y,w]=(0,r.useState)(!1),v=(0,r.useRef)(null),j=(0,r.useRef)(null),N=(0,r.useRef)(!1),k=(0,r.useRef)(null),C=(0,u.d)(),{groups:S}=function(e){let[t,s]=(0,r.useState)([]),[a,i]=(0,r.useState)(!0),[o,c]=(0,r.useState)(null),[d,u]=(0,r.useState)(""),m=(0,r.useCallback)(async()=>{try{i(!0),c(null);let t=e?`/api/worktrees/${e}/slash-commands`:"/api/slash-commands",a=await fetch(t);if(!a.ok)throw Error(`HTTP error ${a.status}`);let r=await a.json();s(r.groups)}catch(e){c((0,n.zG)(e)),s([])}finally{i(!1)}},[e]),x=(0,r.useMemo)(()=>t.flatMap(e=>e.commands),[t]),p=(0,r.useMemo)(()=>l(t,d),[t,d]);return{groups:t,filteredGroups:p,allCommands:x,loading:a,error:o,filter:d,setFilter:u,refresh:(0,r.useCallback)(()=>{m()},[m])}}(e),L=async()=>{if(!g&&d.trim()&&!x)try{p(!0),b(null);let a=s||"claude";await n.Iv.sendMessage(e,d.trim(),a),m(""),t?.(a)}catch(e){b((0,n.zG)(e))}finally{p(!1)}},M=async e=>{e.preventDefault(),await L()},E=()=>{w(!1),v.current?.focus()};return(0,a.jsxs)("div",{ref:k,className:"space-y-2 relative",children:[h&&a.jsx("div",{className:"p-2 bg-red-50 border border-red-200 rounded text-sm text-red-800",children:h}),(0,a.jsxs)("form",{onSubmit:M,className:"flex items-end gap-2 bg-white border border-gray-300 rounded-lg px-4 py-2 focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500",children:[C&&a.jsx("button",{type:"button",onClick:()=>w(!0),className:"flex-shrink-0 p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-full transition-colors","aria-label":"Show slash commands","data-testid":"mobile-command-button",children:a.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),a.jsx("textarea",{ref:v,value:d,onChange:e=>{let t=e.target.value;m(t),"/"===t||t.startsWith("/")&&!t.includes(" ")?w(!0):w(!1)},onKeyDown:e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&y){e.preventDefault(),E();return}if(N.current&&"Enter"===e.key){N.current=!1;return}if("Enter"===e.key&&!g&&!y){if(C)return;e.shiftKey||(e.preventDefault(),L())}}},onCompositionStart:()=>{f(!0),N.current=!1,j.current&&clearTimeout(j.current)},onCompositionEnd:()=>{f(!1),N.current=!0,j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{N.current=!1},300)},placeholder:C?"Type your message...":"Type your message... (/ for commands, Shift+Enter for line break)",disabled:x,rows:1,className:"flex-1 outline-none bg-transparent resize-none py-1 overflow-y-auto scrollbar-thin",style:{minHeight:"24px",maxHeight:"160px"}}),a.jsx(c,{worktreeId:e,cliToolId:s||"claude",disabled:!i}),a.jsx("button",{type:"submit",disabled:!d.trim()||x,className:"flex-shrink-0 p-2 text-blue-600 hover:bg-blue-50 rounded-full transition-colors disabled:text-gray-300 disabled:hover:bg-transparent","aria-label":"Send message",children:x?(0,a.jsxs)("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):a.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),a.jsx(o,{isOpen:y,groups:S,onSelect:e=>{m(`/${e.name} `),w(!1),v.current?.focus()},onClose:E,isMobile:C,onFreeInput:()=>{w(!1),m("/"),setTimeout(()=>{v.current?.focus()},50)}})]})}},61421:(e,t,s)=>{s.d(t,{F4:()=>r,Ie:()=>l,xh:()=>n});let a={idle:"bg-gray-500",ready:"bg-green-500",spinner:"border-blue-500",waiting:"bg-yellow-500",error:"bg-red-500"},r={idle:{className:a.idle,label:"Idle",type:"dot"},ready:{className:a.ready,label:"Ready",type:"dot"},running:{className:a.spinner,label:"Running",type:"spinner"},waiting:{className:a.waiting,label:"Waiting for response",type:"dot"},generating:{className:a.spinner,label:"Generating",type:"spinner"}},n={idle:{className:a.idle,label:"Idle",type:"dot"},ready:{className:a.ready,label:"Ready",type:"dot"},running:{className:a.spinner,label:"Running",type:"spinner"},waiting:{className:a.waiting,label:"Waiting for response",type:"dot"},error:{className:a.error,label:"Error",type:"dot"}},l={idle:{className:a.idle,label:"Idle - No active session",type:"dot"},ready:{className:a.ready,label:"Ready - Waiting for input",type:"dot"},running:{className:a.spinner,label:"Running - Processing",type:"spinner"},waiting:{className:a.waiting,label:"Waiting - User input required",type:"dot"},error:{className:a.error,label:"Error",type:"dot"}}},22202:(e,t,s)=>{s.d(t,{k:()=>a});let a={DROPDOWN:10,SIDEBAR:30,MODAL:50,MAXIMIZED_EDITOR:55,TOAST:60,CONTEXT_MENU:70}},2982:(e,t,s)=>{s.d(t,{d:()=>r});var a=s(17577);function r(e={}){let{breakpoint:t=768}=e,[s,r]=(0,a.useState)(!1);return s}},63601:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var a=s(66621);let r=e=>[{type:"image/png",sizes:"180x180",url:(0,a.fillMetadataSegment)(".",e.params,"apple-icon.png")+"?31a89e65aa4ac65b"}]},71150:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var a=s(66621);let r=e=>[{type:"image/png",sizes:"32x32",url:(0,a.fillMetadataSegment)(".",e.params,"icon.png")+"?32d9127ba30ee286"}]}};