@slycode/slycode 0.2.20 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/pty-handler.js +58 -12
- package/dist/bridge/pty-handler.js.map +1 -1
- package/dist/messaging/index.js +6 -6
- package/dist/messaging/index.js.map +1 -1
- package/dist/messaging/stt.d.ts +1 -1
- package/dist/messaging/stt.js +41 -9
- package/dist/messaging/stt.js.map +1 -1
- package/dist/web/.next/BUILD_ID +1 -1
- package/dist/web/.next/build-manifest.json +2 -2
- package/dist/web/.next/server/app/_global-error.html +2 -2
- package/dist/web/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.html +1 -1
- package/dist/web/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/.next/server/app/project/[id]/page_client-reference-manifest.js +1 -1
- package/dist/web/.next/server/chunks/[root-of-the-server]__f3e501b6._.js +1 -1
- package/dist/web/.next/server/chunks/ssr/src_components_c4135402._.js +1 -1
- package/dist/web/.next/server/pages/404.html +1 -1
- package/dist/web/.next/server/pages/500.html +2 -2
- package/dist/web/.next/static/chunks/{8cb404d087e9f3c7.js → 4049cceee6a49323.js} +1 -1
- package/dist/web/src/app/api/projects/route.ts +11 -2
- package/dist/web/src/components/CardModal.tsx +31 -24
- package/package.json +2 -2
- package/templates/kanban-seed.json +1 -1
- /package/dist/web/.next/static/{tQdF18XbrwPnmXEMVlcfU → 0sPAbk-Qw-InZ0rdHjHnC}/_buildManifest.js +0 -0
- /package/dist/web/.next/static/{tQdF18XbrwPnmXEMVlcfU → 0sPAbk-Qw-InZ0rdHjHnC}/_clientMiddlewareManifest.json +0 -0
- /package/dist/web/.next/static/{tQdF18XbrwPnmXEMVlcfU → 0sPAbk-Qw-InZ0rdHjHnC}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,72630,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(22016),n=e.i(18566),o=e.i(38307),s=e.i(64103),i=e.i(1088),d=e.i(97480);let l=[{key:"card",label:"Card",template:"{{card.title}} [{{card.id}}]\nType: {{card.type}} | Priority: {{card.priority}}\n{{card.description}}",color:"bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-200"},{key:"project",label:"Project",template:"{{project.name}} ({{projectPath}})",color:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},{key:"stage",label:"Stage",template:"{{stage}}",color:"bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200"},{key:"areas",label:"Areas",template:"{{card.areas}}",color:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200"}];function c({onClose:e,projectId:a="",projectPath:n,actionUpdateCount:l=0,onShowActionUpdates:c}){let u,[h,g]=(0,r.useState)(null),[v,b]=(0,r.useState)(null),[f,k]=(0,r.useState)([]),[j,w]=(0,r.useState)(!0),[N,y]=(0,r.useState)(null),[C,S]=(0,r.useState)("idle"),[_,$]=(0,r.useState)(null),[T,L]=(0,r.useState)(null),[M,D]=(0,r.useState)({level:"list",commandId:null}),[E,I]=(0,r.useState)("commands"),[R,A]=(0,r.useState)(!1),[B,O]=(0,r.useState)(!1),[P,W]=(0,r.useState)(0),F=(0,i.useVoice)(),H=(0,r.useRef)(null),z=(0,r.useRef)(!1),U=(0,r.useCallback)(async(e=!1)=>{try{e||w(!0);let[t,r,a,n]=await Promise.all([fetch("/api/terminal-classes"),fetch("/api/sly-actions"),fetch("/api/dashboard"),fetch("/api/sly-actions")]);if(!t.ok||!r.ok)throw Error("Failed to load configuration");let s=await t.json(),i=await r.json();if(a.ok){let e=((await a.json()).projects||[]).map(e=>e.id);k(e)}n.ok&&$((0,o.normalizeActionsConfig)(await n.json())),g(s),b(i),e&&W(e=>e+1)}catch(t){e||y(t instanceof Error?t.message:"Failed to load configuration")}finally{e||w(!1)}},[]);(0,r.useEffect)(()=>{U()},[U]),(0,r.useEffect)(()=>{B&&!R&&U(!0),O(R)},[R,B,U]);let V=(0,r.useCallback)(async()=>{z.current||U(!0)},[U]);(0,s.usePolling)(V,5e3);let q=(0,r.useCallback)(e=>{z.current=e},[]),J=(0,r.useCallback)(async e=>{S("saving");try{if(!(await fetch("/api/sly-actions",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw Error("Save failed");b(e),S("saved"),setTimeout(()=>S("idle"),2e3)}catch{S("error"),setTimeout(()=>S("idle"),3e3)}},[]),K=(0,r.useCallback)((e,t)=>{v&&J({...v,commands:{...v.commands,[e]:{...v.commands[e],...t}}})},[v,J]),G=(0,r.useCallback)((e,t,r)=>{v&&(J({...v,commands:{...v.commands,[e]:{label:t,description:"New command",group:r||"Ungrouped",placement:"both",prompt:"Enter your command prompt here...",scope:"global",projects:[]}}}),D({level:"edit",commandId:e}))},[v,J]),X=(0,r.useCallback)(e=>{if(!v)return;let{[e]:t,...r}=v.commands,a=Object.fromEntries(Object.entries(v.classAssignments||{}).map(([t,r])=>[t,r.filter(t=>t!==e)]));J({...v,commands:r,classAssignments:a}),D({level:"list",commandId:null})},[v,J]),Y=v?[...new Set(Object.values(v.commands).map(e=>e.group).filter(e=>!!e))].sort():[],Q=e=>D({level:"edit",commandId:e}),Z=(0,r.useCallback)(()=>{D({level:"list",commandId:null})},[]),ee=M.commandId&&v?v.commands[M.commandId]:null;(0,r.useEffect)(()=>{let t=t=>{"Escape"!==t.key||R||(t.stopImmediatePropagation(),"list"!==M.level?Z():e())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[M.level,R,e,Z]);let et=_?(0,o.getActionsForClass)(_.commands,_.classAssignments,"action-assistant"):[];return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t=>{t.target===t.currentTarget&&("idle"===F.voiceState||"disabled"===F.voiceState)&&e()},children:(0,t.jsxs)("div",{className:"flex h-[90vh] w-[90vw] max-w-5xl flex-col overflow-hidden rounded-xl bg-white shadow-(--shadow-overlay) dark:bg-void-900",onClick:e=>e.stopPropagation(),children:[(u="Sly Actions","edit"===M.level&&ee&&(u=ee.label),(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-void-200 px-6 py-4 dark:border-void-700",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["list"!==M.level&&(0,t.jsx)("button",{onClick:Z,className:"rounded p-1 hover:bg-void-100 dark:hover:bg-void-700",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),(0,t.jsx)("h2",{className:"text-lg font-semibold",children:u})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["saving"===C&&(0,t.jsx)("span",{className:"text-sm text-void-500",children:"Saving..."}),"saved"===C&&(0,t.jsx)("span",{className:"text-sm text-green-600 dark:text-green-400",children:"Saved"}),"error"===C&&(0,t.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400",children:"Save failed"}),(0,t.jsx)("button",{onClick:()=>U(!0),className:"rounded p-1 hover:bg-void-100 dark:hover:bg-void-700",title:"Refresh commands",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,t.jsx)("button",{onClick:e,className:"rounded p-1 hover:bg-void-100 dark:hover:bg-void-700",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})),(0,t.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[(0,t.jsx)("div",{className:`h-full overflow-y-auto ${R?"opacity-30 pointer-events-none":""}`,children:(()=>{if(j)return(0,t.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,t.jsx)("span",{className:"text-void-500",children:"Loading configuration..."})});if(N)return(0,t.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,t.jsx)("span",{className:"text-red-500",children:N})});if(!v||!h)return(0,t.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,t.jsx)("span",{className:"text-void-500",children:"No configuration found"})});switch(M.level){case"list":return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex border-b border-void-200 dark:border-void-700 px-6",children:[(0,t.jsx)("button",{onClick:()=>I("commands"),className:`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors ${"commands"===E?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-void-500 hover:text-void-700 dark:hover:text-void-300"}`,children:"Commands"}),(0,t.jsx)("button",{onClick:()=>I("classes"),className:`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors ${"classes"===E?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-void-500 hover:text-void-700 dark:hover:text-void-300"}`,children:"Classes"}),l>0&&c&&(0,t.jsxs)("button",{onClick:c,className:"ml-auto px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors border-transparent text-neon-blue-500 hover:text-neon-blue-400 flex items-center gap-1.5",children:["Updates",(0,t.jsx)("span",{className:"flex h-5 min-w-[20px] items-center justify-center rounded-full bg-neon-blue-500 px-1.5 text-[11px] font-bold text-white",children:l})]})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:"commands"===E?(0,t.jsx)(x,{commands:v.commands,onSelectCommand:Q,onCreateCommand:G,existingGroups:Y}):(0,t.jsx)(m,{commands:v.commands,classAssignments:v.classAssignments||{},classes:h,onUpdate:e=>{J({...v,classAssignments:e})}})})]});case"edit":return M.commandId&&ee?(0,t.jsx)(p,{commandId:M.commandId,command:ee,existingGroups:Y,availableProjects:f,onUpdate:e=>K(M.commandId,e),onDelete:()=>X(M.commandId),onEditingChange:q},`${M.commandId}-${P}`):null}})()}),R&&(0,t.jsx)("div",{className:"absolute inset-0",onClick:()=>A(!1)})]}),(0,t.jsxs)("div",{className:`border-t border-void-200 dark:border-void-700 transition-all duration-300 ${R?"h-[60%]":"h-12"}`,children:[(0,t.jsxs)("button",{onClick:()=>A(!R),className:"flex w-full items-center justify-between px-6 py-3 hover:bg-void-50 dark:hover:bg-void-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Action Assistant"}),(0,t.jsx)("span",{className:"text-xs text-void-400",children:"(Terminal for configuring actions)"})]}),(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform ${R?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})]}),R&&_&&(0,t.jsx)("div",{className:"h-[calc(100%-48px)] overflow-hidden",children:(0,t.jsx)(d.ClaudeTerminalPanel,{sessionName:"action-assistant:global",cwd:n,actionsConfig:_,actions:et,context:{project:{name:"SlyCode"},projectPath:n},onSessionChange:e=>L(e?{hasHistory:e.hasHistory}:null),voiceTerminalId:"action-assistant",onTerminalReady:e=>{H.current=e?.sendInput??null,e?F.registerTerminal("action-assistant",e):F.unregisterTerminal("action-assistant")}})})]})]})})}let u={startup:{label:"Startup",color:"bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-200"},toolbar:{label:"Toolbar",color:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},both:{label:"Both",color:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200"}};function x({commands:e,onSelectCommand:a,onCreateCommand:n,existingGroups:o}){let s=Object.entries(e),[i,d]=(0,r.useState)(new Set),[l,c]=(0,r.useState)(!1),[x,m]=(0,r.useState)(""),[h,p]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),b=s.reduce((e,[t,r])=>{let a=r.group||"Ungrouped";return e[a]||(e[a]=[]),e[a].push([t,r]),e},{});Object.values(b).forEach(e=>{e.sort((e,t)=>e[1].label.localeCompare(t[1].label))});let f=Object.keys(b).sort((e,t)=>"Ungrouped"===e?1:"Ungrouped"===t?-1:e.localeCompare(t));return(0,t.jsxs)("div",{className:"p-6",children:[f.map(e=>{let r=b[e],n=i.has(e);return(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("button",{onClick:()=>{d(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},className:"flex items-center gap-2 w-full text-left py-2 px-3 bg-void-100 dark:bg-void-800 rounded-t-lg hover:bg-void-200 dark:hover:bg-void-700",children:[(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform ${n?"":"rotate-90"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,t.jsx)("span",{className:"font-medium text-sm",children:e}),(0,t.jsxs)("span",{className:"text-xs text-void-500",children:["(",r.length,")"]})]}),!n&&(0,t.jsxs)("table",{className:"w-full border border-t-0 border-void-200 dark:border-void-700 rounded-b-lg overflow-hidden",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-void-200 text-left text-xs text-void-500 dark:border-void-700 bg-void-50 dark:bg-void-800/50",children:[(0,t.jsx)("th",{className:"py-2 px-3 font-medium",children:"Name"}),(0,t.jsx)("th",{className:"py-2 px-3 font-medium",children:"Label"}),(0,t.jsx)("th",{className:"py-2 px-3 font-medium",children:"Placement"}),(0,t.jsx)("th",{className:"py-2 px-3 w-8"})]})}),(0,t.jsx)("tbody",{children:r.map(([e,r])=>{let n=u[r.placement]||u.both;return(0,t.jsxs)("tr",{onClick:()=>a(e),className:"cursor-pointer border-b border-void-100 hover:bg-void-50 dark:border-void-800 dark:hover:bg-void-800 last:border-b-0",children:[(0,t.jsx)("td",{className:"py-2 px-3 font-mono text-xs",children:e}),(0,t.jsxs)("td",{className:"py-2 px-3 text-sm relative group",children:[r.label,r.description&&(0,t.jsx)("div",{className:"absolute left-0 top-full z-50 mt-1 hidden w-64 rounded-md bg-void-800 px-3 py-2 text-xs text-void-100 shadow-(--shadow-overlay) group-hover:block dark:bg-void-700",children:r.description})]}),(0,t.jsx)("td",{className:"py-2 px-3",children:(0,t.jsx)("span",{className:`rounded-full px-1.5 py-0.5 text-xs ${n.color}`,children:n.label})}),(0,t.jsx)("td",{className:"py-2 px-3 text-right",children:(0,t.jsx)("svg",{className:"inline h-3 w-3 text-void-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]},e)})})]})]},e)}),l?(0,t.jsxs)("div",{className:"mt-4 p-4 border border-void-300 dark:border-void-600 rounded-lg bg-void-50 dark:bg-void-800",children:[(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Create New Command"}),(0,t.jsxs)("div",{className:"flex gap-3 mb-3",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"block text-xs text-void-500 mb-1",children:"Command ID"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>m(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"my-command",className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm font-mono dark:border-void-600 dark:bg-void-700","data-voice-target":!0,autoFocus:!0})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"block text-xs text-void-500 mb-1",children:"Label"}),(0,t.jsx)("input",{type:"text",value:h,onChange:e=>p(e.target.value),placeholder:"My Command",className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-700","data-voice-target":!0})]}),(0,t.jsxs)("div",{className:"w-40",children:[(0,t.jsx)("label",{className:"block text-xs text-void-500 mb-1",children:"Group"}),(0,t.jsxs)("select",{value:g,onChange:e=>v(e.target.value),className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-700",children:[(0,t.jsx)("option",{value:"",children:"Ungrouped"}),o.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{onClick:()=>c(!1),className:"rounded px-3 py-1.5 text-sm hover:bg-void-200 dark:hover:bg-void-600",children:"Cancel"}),(0,t.jsx)("button",{onClick:()=>{x.trim()&&h.trim()&&(n(x.trim(),h.trim(),g.trim()),c(!1),m(""),p(""),v(""))},disabled:!x.trim()||!h.trim(),className:"rounded bg-blue-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50",children:"Create"})]})]}):(0,t.jsx)("div",{className:"mt-4 flex justify-end",children:(0,t.jsx)("button",{onClick:()=>c(!0),className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",children:"+ New Command"})})]})}function m({commands:e,classAssignments:a,classes:n,onUpdate:o}){let[s,i]=(0,r.useState)(null),[d,l]=(0,r.useState)(null),[c,x]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),p=Object.keys(e),g=()=>{x(null),h(null)};return(0,t.jsxs)("div",{className:"p-6 space-y-3",children:[(0,t.jsx)("p",{className:"text-xs text-void-400 mb-4",children:"Assign commands to terminal classes and drag to reorder. The order here determines the button order in the UI."}),n.classes.map(r=>{let n,v=a[r.id]||[],b=s===r.id,f=p.filter(e=>!v.includes(e));return(0,t.jsxs)("div",{className:"border border-void-200 dark:border-void-700 rounded-lg overflow-hidden",children:[(0,t.jsxs)("button",{onClick:()=>i(b?null:r.id),className:"flex items-center justify-between w-full px-4 py-3 bg-void-50 dark:bg-void-800 hover:bg-void-100 dark:hover:bg-void-700 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform ${b?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,t.jsx)("span",{className:"font-medium text-sm",children:r.name}),(0,t.jsxs)("span",{className:"text-xs text-void-400 font-mono",children:["(",r.id,")"]})]}),(0,t.jsxs)("span",{className:"text-xs text-void-500",children:[v.length," command",1!==v.length?"s":""]})]}),b&&(0,t.jsxs)("div",{className:"border-t border-void-200 dark:border-void-700",children:[0===v.length?(0,t.jsx)("div",{className:"px-4 py-3 text-sm text-void-400 italic",children:"No commands assigned"}):(0,t.jsx)("ul",{className:"divide-y divide-void-100 dark:divide-void-800",children:v.map((n,s)=>{let i=e[n],d=c?.classId===r.id&&c.fromIndex===s,l=c?.classId===r.id&&m===s;return(0,t.jsxs)("li",{draggable:!0,onDragStart:()=>{x({classId:r.id,fromIndex:s})},onDragOver:e=>{e.preventDefault(),h(s)},onDrop:()=>{var e;return e=r.id,void(c&&c.classId===e&&((e,t,r)=>{let n=[...a[e]||[]],[s]=n.splice(t,1);n.splice(r,0,s),o({...a,[e]:n})})(e,c.fromIndex,s),x(null),h(null))},onDragEnd:g,className:`flex items-center gap-2 px-4 py-2 text-sm ${d?"opacity-30":""} ${l?"bg-blue-50 dark:bg-blue-900/20":"hover:bg-void-50 dark:hover:bg-void-800"}`,children:[(0,t.jsx)("span",{className:"cursor-grab text-void-400 hover:text-void-600 dark:hover:text-void-300 select-none",children:(0,t.jsxs)("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"9",cy:"6",r:"1.5"}),(0,t.jsx)("circle",{cx:"15",cy:"6",r:"1.5"}),(0,t.jsx)("circle",{cx:"9",cy:"12",r:"1.5"}),(0,t.jsx)("circle",{cx:"15",cy:"12",r:"1.5"}),(0,t.jsx)("circle",{cx:"9",cy:"18",r:"1.5"}),(0,t.jsx)("circle",{cx:"15",cy:"18",r:"1.5"})]})}),(0,t.jsxs)("span",{className:"text-xs text-void-400 w-5 text-right",children:[s+1,"."]}),(0,t.jsx)("span",{className:"font-mono text-xs text-void-500",children:n}),(0,t.jsx)("span",{className:"text-void-300 dark:text-void-600",children:"-"}),(0,t.jsx)("span",{className:"flex-1 truncate",children:i?.label||n}),i&&(0,t.jsx)("span",{className:`rounded-full px-1.5 py-0.5 text-xs ${(u[i.placement]||u.both).color}`,children:(u[i.placement]||u.both).label}),(0,t.jsx)("button",{onClick:()=>{var e;let t;return e=r.id,t=(a[e]||[]).filter(e=>e!==n),void o({...a,[e]:t})},className:"rounded p-0.5 text-void-400 hover:bg-red-100 hover:text-red-600 dark:hover:bg-red-900/30 dark:hover:text-red-400",title:"Remove from this class",children:(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},n)})}),(0,t.jsx)("div",{className:"px-4 py-2 border-t border-void-100 dark:border-void-800",children:d===r.id?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("select",{autoFocus:!0,defaultValue:"",onChange:e=>{var t,n;let s;e.target.value&&(t=r.id,n=e.target.value,s=[...a[t]||[],n],o({...a,[t]:s}),l(null))},onBlur:()=>l(null),className:"flex-1 rounded border border-void-300 px-2 py-1 text-sm dark:border-void-600 dark:bg-void-800",children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select command..."}),Object.keys(n=f.reduce((t,r)=>{let a=e[r]?.group||"Ungrouped";return t[a]||(t[a]=[]),t[a].push(r),t},{})).sort((e,t)=>"Ungrouped"===e?1:"Ungrouped"===t?-1:e.localeCompare(t)).map(r=>(0,t.jsx)("optgroup",{label:r,children:n[r].sort((t,r)=>(e[t]?.label||t).localeCompare(e[r]?.label||r)).map(r=>(0,t.jsx)("option",{value:r,children:e[r]?.label||r},r))},r))]}),(0,t.jsx)("button",{onClick:()=>l(null),className:"text-xs text-void-500 hover:text-void-700 dark:hover:text-void-300",children:"Cancel"})]}):(0,t.jsxs)("button",{onClick:()=>l(r.id),disabled:0===f.length,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Command"]})})]})]},r.id)})]})}let h=[{id:"startup",label:"Startup"},{id:"toolbar",label:"Toolbar"},{id:"both",label:"Both"}];function p({commandId:e,command:a,existingGroups:n,availableProjects:o,onUpdate:s,onDelete:i,onEditingChange:d}){let[c,u]=(0,r.useState)(!1),[x,m]=(0,r.useState)(a.label),[p,g]=(0,r.useState)(a.description),[v,b]=(0,r.useState)(a.group||""),[f,k]=(0,r.useState)(a.prompt),[j,w]=(0,r.useState)(a.placement||"both"),[N,y]=(0,r.useState)(a.scope||"global"),[C,S]=(0,r.useState)(a.projects||[]),[_,$]=(0,r.useState)(!1),[T,L]=(0,r.useState)(!1),M=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let e=setTimeout(()=>{let e={},t=!1;x!==a.label&&(e.label=x,t=!0),p!==a.description&&(e.description=p,t=!0),(v||void 0)!==a.group&&(e.group=v||void 0,t=!0),j!==(a.placement||"both")&&(e.placement=j,t=!0),N!==(a.scope||"global")&&(e.scope=N,t=!0);let r="specific"===N?C:[];JSON.stringify(r)!==JSON.stringify(a.projects||[])&&(e.projects=r,t=!0),t&&s(e)},500);return()=>clearTimeout(e)},[x,p,v,j,N,C,a,s]),(0,r.useEffect)(()=>{let e=setTimeout(()=>{f!==a.prompt&&s({prompt:f})},500);return()=>clearTimeout(e)},[f,a.prompt,s]),(0,t.jsxs)("div",{className:"p-6 flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex gap-3 mb-3",children:[(0,t.jsxs)("div",{className:"w-36 flex-shrink-0",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Name"}),(0,t.jsx)("input",{type:"text",value:e,readOnly:!0,className:"w-full rounded border border-void-300 bg-void-50 px-2 py-1.5 font-mono text-sm dark:border-void-600 dark:bg-void-800"})]}),(0,t.jsxs)("div",{className:"w-32 flex-shrink-0",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Label"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>m(e.target.value),onFocus:()=>d?.(!0),onBlur:()=>d?.(!1),className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-800","data-voice-target":!0})]}),(0,t.jsxs)("div",{className:"w-36 flex-shrink-0 relative",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Group"}),(0,t.jsx)("input",{type:"text",value:v,onChange:e=>b(e.target.value),onFocus:()=>{$(!0),d?.(!0)},onBlur:()=>{setTimeout(()=>$(!1),150),d?.(!1)},placeholder:"Ungrouped",className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-800","data-voice-target":!0}),_&&n.length>0&&(0,t.jsx)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-void-800 border border-void-300 dark:border-void-600 rounded shadow-(--shadow-overlay) z-10 max-h-32 overflow-y-auto",children:n.map(e=>(0,t.jsx)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),b(e),$(!1)},className:"w-full text-left px-2 py-1 text-sm hover:bg-void-100 dark:hover:bg-void-700",children:e},e))})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Description"}),(0,t.jsx)("input",{type:"text",value:p,onChange:e=>g(e.target.value),onFocus:()=>d?.(!0),onBlur:()=>d?.(!1),className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-800","data-voice-target":!0})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4 mb-3 py-2 px-3 rounded-lg bg-void-50 dark:bg-void-800/50 border border-void-100 dark:border-void-700/50",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 uppercase tracking-wide",children:"Placement"}),(0,t.jsx)("div",{className:"flex rounded-md border border-void-200 dark:border-void-600 overflow-hidden",children:h.map(e=>(0,t.jsx)("button",{onClick:()=>w(e.id),className:`px-2.5 py-1 text-xs font-medium transition-colors ${j===e.id?"bg-blue-600 text-white":"bg-white hover:bg-void-50 dark:bg-void-800 dark:hover:bg-void-700 text-void-600 dark:text-void-300"}`,children:e.label},e.id))})]}),(0,t.jsx)("div",{className:"h-5 w-px bg-void-200 dark:bg-void-600"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 uppercase tracking-wide",children:"Scope"}),(0,t.jsxs)("div",{className:"flex rounded-md border border-void-200 dark:border-void-600 overflow-hidden",children:[(0,t.jsx)("button",{onClick:()=>y("global"),className:`px-2.5 py-1 text-xs font-medium transition-colors ${"global"===N?"bg-blue-600 text-white":"bg-white hover:bg-void-50 dark:bg-void-800 dark:hover:bg-void-700 text-void-600 dark:text-void-300"}`,children:"All Projects"}),(0,t.jsx)("button",{onClick:()=>y("specific"),className:`px-2.5 py-1 text-xs font-medium transition-colors ${"specific"===N?"bg-blue-600 text-white":"bg-white hover:bg-void-50 dark:bg-void-800 dark:hover:bg-void-700 text-void-600 dark:text-void-300"}`,children:"Specific"})]}),"specific"===N&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("button",{onClick:()=>L(!T),className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400",children:[C.length>0?`${C.length} project${1!==C.length?"s":""}`:"Select...",(0,t.jsx)("svg",{className:`h-3 w-3 transition-transform ${T?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})})]})]}),"specific"===N&&T&&o.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-3 -mt-1 px-3",children:o.map(e=>(0,t.jsxs)("label",{className:`flex items-center gap-1 rounded border px-2 py-0.5 cursor-pointer text-xs ${C.includes(e)?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-void-200 hover:bg-void-50 dark:border-void-700"}`,children:[(0,t.jsx)("input",{type:"checkbox",checked:C.includes(e),onChange:()=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},className:"h-3 w-3 rounded border-void-300"}),(0,t.jsx)("span",{children:e})]},e))}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-void-500",children:"Prompt Template"}),(0,t.jsxs)("div",{className:"flex gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-void-400 mr-1",children:"Insert:"}),l.map(e=>(0,t.jsx)("button",{onClick:()=>(e=>{if(!M.current)return;let t=M.current,r=t.selectionStart,a=t.selectionEnd;k(f.substring(0,r)+e+f.substring(a)),setTimeout(()=>{t.focus(),t.selectionStart=r+e.length,t.selectionEnd=r+e.length},0)})(e.template),className:`rounded px-2 py-0.5 text-xs font-medium min-w-[60px] ${e.color} hover:opacity-80`,children:e.label},e.key))]})]}),(0,t.jsx)("textarea",{ref:M,value:f,onChange:e=>k(e.target.value),onFocus:()=>d?.(!0),onBlur:()=>d?.(!1),className:"flex-1 w-full rounded-lg border border-void-300 px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 resize-none font-mono",placeholder:"Enter the prompt template for this command...","data-voice-target":!0})]}),(0,t.jsx)("div",{className:"flex justify-end pt-3",children:c?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400",children:"Delete this command?"}),(0,t.jsx)("button",{onClick:()=>{i(),u(!1)},className:"rounded bg-red-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-red-700",children:"Yes, Delete"}),(0,t.jsx)("button",{onClick:()=>u(!1),className:"rounded bg-void-200 px-3 py-1.5 text-sm font-medium text-void-700 hover:bg-void-300 dark:bg-void-700 dark:text-void-200 dark:hover:bg-void-600",children:"Cancel"})]}):(0,t.jsxs)("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 rounded-lg border border-red-300 px-3 py-1.5 text-xs font-medium text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/20",children:[(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Delete"]})})]})}var g=e.i(71174);let v={add:"bg-emerald-950/40 text-emerald-300",remove:"bg-red-950/40 text-red-300",context:"text-void-300",header:"bg-neon-blue-950/30 text-neon-blue-300 font-medium"},b={add:"text-emerald-600",remove:"text-red-600",context:"text-void-600",header:"text-neon-blue-600"},f={add:"+",remove:"-",context:" ",header:""};function k({entry:e,currentContent:a,newContent:n,onClose:o}){let[s,i]=(0,r.useState)("diff"),d=null===a;(0,r.useEffect)(()=>{function e(e){"Escape"===e.key&&(e.stopPropagation(),o())}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]);let l=(0,r.useMemo)(()=>{let t=a??"";return function(e){let t=[],r=0,a=0;for(let n of e.split("\n"))if(n.startsWith("@@")){let e=n.match(/@@ -(\d+)/);if(e){r=parseInt(e[1],10)-1;let t=n.match(/\+(\d+)/);t&&(a=parseInt(t[1],10)-1)}t.push({type:"header",content:n})}else n.startsWith("---")||n.startsWith("+++")||n.startsWith("Index:")||n.startsWith("===")||(n.startsWith("+")?(a++,t.push({type:"add",content:n.slice(1),newLineNo:a})):n.startsWith("-")?(r++,t.push({type:"remove",content:n.slice(1),oldLineNo:r})):(n.startsWith(" ")||""===n)&&(r++,a++,t.push({type:"context",content:n.startsWith(" ")?n.slice(1):n,oldLineNo:r,newLineNo:a})));return t}((0,g.createTwoFilesPatch)(`current/${e.name}.md`,`updated/${e.name}.md`,t,n,e.currentVersion??"(none)",e.upstreamVersion,{context:4}))},[a,n,e]),c=(0,r.useMemo)(()=>{let e=0,t=0;for(let r of l)"add"===r.type&&e++,"remove"===r.type&&t++;return{additions:e,deletions:t}},[l]);return(0,t.jsx)("div",{className:"fixed inset-0 z-[55] flex items-center justify-center bg-black/60",onClick:e=>{e.target===e.currentTarget&&o()},children:(0,t.jsxs)("div",{className:"mx-4 flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-lg border border-void-700 bg-void-850 shadow-(--shadow-overlay)",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-void-700 px-5 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-void-100",children:e.name}),d?(0,t.jsx)("span",{className:"rounded bg-emerald-900/40 px-2 py-0.5 text-xs font-medium text-emerald-300",children:"New action"}):(0,t.jsxs)("span",{className:"rounded bg-amber-900/40 px-2 py-0.5 text-xs font-medium text-amber-300",children:["v",e.currentVersion," → v",e.upstreamVersion]}),(0,t.jsxs)("span",{className:"text-xs text-void-500",children:[(0,t.jsxs)("span",{className:"text-emerald-400",children:["+",c.additions]})," ",(0,t.jsxs)("span",{className:"text-red-400",children:["-",c.deletions]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!d&&(0,t.jsxs)("div",{className:"flex gap-1 rounded-md border border-void-700 bg-void-900 p-0.5",children:[(0,t.jsx)("button",{onClick:()=>i("diff"),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${"diff"===s?"bg-void-800 text-void-100 shadow-sm":"text-void-400 hover:text-void-200"}`,children:"Diff"}),(0,t.jsx)("button",{onClick:()=>i("new"),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${"new"===s?"bg-void-800 text-void-100 shadow-sm":"text-void-400 hover:text-void-200"}`,children:"Full"})]}),(0,t.jsx)("button",{onClick:o,className:"rounded p-1 text-void-400 hover:bg-void-800 hover:text-void-200",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]}),(e.changedFields?.length||e.newClasses?.length)&&(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 border-b border-void-700 px-5 py-3",children:[e.changedFields?.map(e=>(0,t.jsxs)("span",{className:"rounded bg-amber-900/40 px-2 py-0.5 text-[10px] font-medium text-amber-300",children:[e," changed"]},e)),e.newClasses?.length?(0,t.jsxs)("span",{className:"rounded bg-neon-blue-900/40 px-2 py-0.5 text-[10px] font-medium text-neon-blue-300",children:["New classes: ",e.newClasses.join(", ")]}):null]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)("div",{className:"font-mono text-xs leading-relaxed",children:"diff"===s||d?l.map((e,r)=>(0,t.jsxs)("div",{className:`flex ${v[e.type]}`,children:[(0,t.jsx)("span",{className:`w-10 flex-shrink-0 select-none px-2 text-right ${b[e.type]}`,children:"header"===e.type?"···":e.oldLineNo??e.newLineNo??""}),(0,t.jsx)("span",{className:`w-10 flex-shrink-0 select-none px-2 text-right ${b[e.type]}`,children:"header"===e.type?"···":e.newLineNo??""}),(0,t.jsx)("span",{className:`w-4 flex-shrink-0 select-none text-center ${b[e.type]}`,children:f[e.type]}),(0,t.jsx)("span",{className:"flex-1 whitespace-pre-wrap break-all px-2",children:e.content})]},r)):n.split("\n").map((e,r)=>(0,t.jsxs)("div",{className:"flex text-void-300",children:[(0,t.jsx)("span",{className:"w-10 flex-shrink-0 select-none px-2 text-right text-void-600",children:r+1}),(0,t.jsx)("span",{className:"flex-1 whitespace-pre-wrap break-all px-2",children:e})]},r))})})]})})}function j({onClose:e}){let[a,n]=(0,r.useState)([]),[o,s]=(0,r.useState)(!0),[i,d]=(0,r.useState)(null),[l,c]=(0,r.useState)(!1),[u,x]=(0,r.useState)(new Set),[m,h]=(0,r.useState)(null),p=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/cli-assets/updates");if(e.ok){let t=await e.json();n(t.actionEntries??[])}}catch{}s(!1)},[]);async function g(e){try{let t=await fetch(`/api/file?${new URLSearchParams({path:`updates/actions/${e.name}.md`})}`),r=t.ok?await t.json():null,a=r?.content??"",n=null;if("update"===e.status){let t=await fetch(`/api/file?${new URLSearchParams({path:`store/actions/${e.name}.md`})}`),r=t.ok?await t.json():null;n=r?.content??null}h({entry:e,currentContent:n,newContent:a})}catch{}}async function v(e){d(e.name);try{(await fetch("/api/cli-assets/updates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetType:"action",assetName:e.name})})).ok&&(x(t=>new Set(t).add(e.name)),fetch("/api/sly-actions/invalidate",{method:"POST"}).catch(()=>{}))}finally{d(null)}}async function b(e){try{await fetch("/api/cli-assets/updates",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetType:"action",assetName:e.name,contentHash:e.contentHash})}),n(t=>t.filter(t=>t.name!==e.name))}catch{}}async function f(){for(let e of(c(!0),a.filter(e=>!u.has(e.name))))await v(e);c(!1)}(0,r.useEffect)(()=>{p()},[p]),(0,r.useEffect)(()=>{function t(t){"Escape"!==t.key||m||e()}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,m]);let j=a.filter(e=>!u.has(e.name)),w=a.filter(e=>u.has(e.name));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:t=>{t.target===t.currentTarget&&e()},children:(0,t.jsxs)("div",{className:"mx-4 flex max-h-[85vh] w-full max-w-2xl flex-col overflow-hidden rounded-lg border border-void-200 bg-white shadow-(--shadow-overlay) dark:border-void-700 dark:bg-void-850",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-void-200 px-5 py-4 dark:border-void-700",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("svg",{className:"h-5 w-5 text-neon-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h7"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold text-void-900 dark:text-void-100",children:"Action Updates"}),j.length>0&&(0,t.jsx)("span",{className:"rounded-full bg-neon-blue-500 px-2 py-0.5 text-[10px] font-bold text-white",children:j.length})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[j.length>1&&(0,t.jsx)("button",{onClick:f,disabled:l,className:"rounded-md border border-emerald-400/40 bg-emerald-400/15 px-3 py-1.5 text-xs font-medium text-emerald-600 transition-colors hover:bg-emerald-400/25 disabled:opacity-50 dark:text-emerald-400",children:l?(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-emerald-600 border-t-emerald-300"}),"Accepting..."]}):`Accept All (${j.length})`}),(0,t.jsx)("button",{onClick:e,className:"rounded p-1 text-void-400 hover:bg-void-100 hover:text-void-700 dark:hover:bg-void-800 dark:hover:text-void-200",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:o?(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-neon-blue-400 border-t-transparent"})}):0===j.length&&0===w.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16",children:[(0,t.jsx)("svg",{className:"mb-3 h-10 w-10 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,t.jsx)("p",{className:"text-sm font-medium text-void-500 dark:text-void-400",children:"All actions are up to date"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-void-400 dark:text-void-500",children:"No updates available"})]}):(0,t.jsxs)("div",{className:"space-y-3",children:[w.map(e=>(0,t.jsx)("div",{className:"rounded-lg border border-emerald-500/30 bg-emerald-50 p-4 dark:bg-emerald-950/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("svg",{className:"h-5 w-5 text-emerald-500 dark:text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-emerald-700 dark:text-emerald-300",children:e.name}),(0,t.jsx)("span",{className:"text-xs text-emerald-600/70 dark:text-emerald-400/70",children:"new"===e.status?"Installed":`Updated to v${e.upstreamVersion}`})]})},e.name)),j.map(e=>{let r=i===e.name;return(0,t.jsx)("div",{className:"rounded-lg border border-void-200 bg-white p-4 dark:border-void-700 dark:bg-void-850",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-void-900 dark:text-void-100",children:e.name}),"update"===e.status?(0,t.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",children:"Update"}):(0,t.jsx)("span",{className:"rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",children:"New"})]}),(0,t.jsx)("div",{className:"mt-1 flex items-center gap-2 text-xs text-void-500 dark:text-void-400",children:"update"===e.status?(0,t.jsxs)("span",{children:["v",e.currentVersion," → v",e.upstreamVersion]}):(0,t.jsxs)("span",{children:["v",e.upstreamVersion]})}),e.description&&(0,t.jsx)("p",{className:"mt-1.5 text-xs text-void-500 line-clamp-2 dark:text-void-400",children:e.description}),e.changedFields?.length||e.newClasses?.length?(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[e.changedFields?.map(e=>(0,t.jsxs)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",children:[e," changed"]},e)),e.newClasses?.length?(0,t.jsxs)("span",{className:"rounded bg-neon-blue-100 px-1.5 py-0.5 text-[10px] font-medium text-neon-blue-700 dark:bg-neon-blue-900/40 dark:text-neon-blue-300",children:["+",e.newClasses.length," class",1!==e.newClasses.length?"es":""]}):null]}):null]}),(0,t.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[(0,t.jsx)("button",{onClick:()=>g(e),title:"Preview changes",className:"rounded-md border border-void-300 bg-void-50 p-1.5 text-void-500 transition-colors hover:bg-void-100 hover:text-void-700 dark:border-void-600 dark:bg-void-800 dark:hover:bg-void-700 dark:hover:text-void-200",children:(0,t.jsxs)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),(0,t.jsx)("button",{onClick:()=>v(e),disabled:r||l,title:"update"===e.status?`Update to v${e.upstreamVersion}`:"Install action",className:"rounded-md border border-emerald-400/40 bg-emerald-400/15 p-1.5 text-emerald-500 transition-colors hover:bg-emerald-400/25 disabled:opacity-50 dark:text-emerald-400",children:r?(0,t.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-emerald-600 border-t-emerald-300"}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,t.jsx)("button",{onClick:()=>b(e),title:"Dismiss this version",className:"rounded-md border border-void-300 bg-void-50 p-1.5 text-void-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:border-void-600 dark:bg-void-800 dark:hover:bg-red-950/30 dark:hover:text-red-400",children:(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})},e.name)})]})})]})}),m&&(0,t.jsx)(k,{entry:m.entry,currentContent:m.currentContent,newContent:m.newContent,onClose:()=>h(null)})]})}function w(e){return e>=90?{background:"linear-gradient(90deg, #ff3b5c, #ff6b81)",glow:"0 0 8px rgba(255, 59, 92, 0.5)"}:e>=70?{background:"linear-gradient(90deg, #ff8c00, #ffaa00)",glow:"0 0 8px rgba(255, 140, 0, 0.5)"}:{background:"linear-gradient(90deg, #00e676, #00bfff)",glow:"0 0 8px rgba(0, 191, 255, 0.4)"}}function N(e){let t=e/0x40000000;return t>=1?`${t.toFixed(1)}G`:`${(e/1048576).toFixed(0)}M`}function y({value:e,label:r}){let a=w(e),n=Math.min(100,Math.max(0,e)),o="Memory"===r?"MEM":"Swap"===r?"SWP":r.toUpperCase();return(0,t.jsxs)("div",{className:"relative h-3.5 w-10 overflow-hidden rounded bg-void-200 dark:bg-void-700",title:`${r}: ${e.toFixed(1)}%`,children:[(0,t.jsx)("div",{className:"h-full rounded transition-all duration-300",style:{width:`${n}%`,background:a.background,boxShadow:a.glow}}),(0,t.jsx)("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold text-white mix-blend-difference",children:o})]})}function C({value:e,label:r,detail:a}){let n=w(e),o=Math.min(100,Math.max(0,e));return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,t.jsx)("span",{className:"text-void-600 dark:text-void-400",children:r}),(0,t.jsx)("span",{className:"font-mono text-void-800 dark:text-void-200",children:a||`${e.toFixed(1)}%`})]}),(0,t.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-void-200 dark:bg-void-700",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${o}%`,background:n.background,boxShadow:n.glow}})})]})}function S({isOpen:e,terminalCount:r,onConfirm:a,onCancel:n,isLoading:o}){return e?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:(0,t.jsxs)("div",{className:"mx-4 w-full max-w-sm rounded-lg bg-void-50 p-6 shadow-(--shadow-overlay) dark:bg-void-800",children:[(0,t.jsx)("h3",{className:"mb-2 text-lg font-semibold text-void-900 dark:text-void-100",children:"Stop All Terminals?"}),(0,t.jsxs)("p",{className:"mb-4 text-sm text-void-600 dark:text-void-400",children:["This will stop all ",r," running terminal",1!==r?"s":"",". Any active sessions will be terminated."]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{onClick:n,disabled:o,className:"rounded-lg border border-void-300 px-4 py-2 text-sm font-medium text-void-700 hover:bg-void-50 dark:border-void-600 dark:text-void-300 dark:hover:bg-void-700",children:"Cancel"}),(0,t.jsx)("button",{onClick:a,disabled:o,className:"rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50",children:o?"Stopping...":"Stop All"})]})]})}):null}function _(){let[e,a]=(0,r.useState)(null),[n,o]=(0,r.useState)(null),[i,d]=(0,r.useState)(!1),[l,c]=(0,r.useState)(!1),[u,x]=(0,r.useState)(!1),[m,h]=(0,r.useState)(!1),p=(0,r.useRef)(null),g=(0,r.useCallback)(async e=>{try{let t=await fetch("/api/system-stats",{signal:e});if(t.ok){let e=await t.json();a(e)}}catch{}try{let t=await fetch("/api/bridge/stats",{signal:e});if(t.ok){let e=await t.json();o(e),h(!1)}else h(!0)}catch{h(!0)}},[]);(0,s.usePolling)(g,5e3),(0,r.useEffect)(()=>{if(!i)return;let e=e=>{p.current&&!p.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let v=async()=>{x(!0);try{(await fetch("/api/bridge/sessions/stop-all",{method:"POST"})).ok&&await g()}catch(e){console.error("Failed to stop all sessions:",e)}finally{x(!1),c(!1)}},b=e?.cpu??0,f=e?e.memory.used/e.memory.total*100:0,k=e?.swap?.total?e.swap.used/e.swap.total*100:0,j=(e?.swap?.total??0)>0,_=n?.bridgeTerminals??0,$=n?.activelyWorking??0,T=w(Math.max(b,f,j?k:0));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{ref:p,className:"relative cursor-pointer",onClick:()=>d(e=>!e),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-void-200 bg-void-50 px-2 py-1 dark:border-void-700 dark:bg-void-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 sm:hidden",children:[(0,t.jsx)("div",{className:"h-2.5 w-2.5 rounded-full",style:{background:T.background},title:`CPU: ${b.toFixed(0)}% | Mem: ${f.toFixed(0)}%${j?` | Swap: ${k.toFixed(0)}%`:""}`}),(0,t.jsx)("span",{className:"text-[10px] font-mono text-void-600 dark:text-void-400",children:m?"--":_}),$>0&&(0,t.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-green-500"})]})]}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-2",children:[(0,t.jsx)(y,{value:b,label:"CPU"}),(0,t.jsx)(y,{value:f,label:"Memory"}),j&&(0,t.jsx)(y,{value:k,label:"Swap"}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 text-xs text-void-600 dark:text-void-400",title:`${_} terminal${1!==_?"s":""} running`,children:[(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,t.jsx)("span",{className:"font-mono",children:m?"--":_})]}),$>0&&(0,t.jsxs)("div",{className:"flex items-center gap-0.5",title:`${$} actively working`,children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),(0,t.jsx)("span",{className:"text-xs font-mono text-green-600 dark:text-green-400",children:$})]})]})]}),i&&(0,t.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-64 rounded-lg border border-void-200 bg-white p-3 shadow-(--shadow-overlay) dark:border-void-700 dark:bg-void-800",children:[(0,t.jsx)("h4",{className:"mb-3 text-sm font-semibold text-void-900 dark:text-void-100",children:"System Health"}),(0,t.jsxs)("div",{className:"mb-3 space-y-2",children:[(0,t.jsx)(C,{value:b,label:"CPU",detail:`${b.toFixed(1)}%`}),(0,t.jsx)(C,{value:f,label:"Memory",detail:e?`${N(e.memory.used)} / ${N(e.memory.total)}`:"--"}),j&&(0,t.jsx)(C,{value:k,label:"Swap",detail:e?.swap?`${N(e.swap.used)} / ${N(e.swap.total)}`:"--"})]}),(0,t.jsx)("div",{className:"my-3 border-t border-void-200 dark:border-void-700"}),(0,t.jsxs)("div",{className:"mb-3 space-y-1 text-xs",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-void-600 dark:text-void-400",children:"Terminals running"}),(0,t.jsx)("span",{className:"font-mono text-void-800 dark:text-void-200",children:m?"--":_})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-void-600 dark:text-void-400",children:"Actively working"}),(0,t.jsx)("span",{className:`font-mono ${$>0?"text-green-600 dark:text-green-400":"text-void-800 dark:text-void-200"}`,children:m?"--":$})]})]}),_>0&&!m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"my-3 border-t border-void-200 dark:border-void-700"}),(0,t.jsx)("button",{onClick:()=>c(!0),className:"w-full rounded-lg bg-red-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-red-700",children:"Stop All Terminals"})]}),m&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:"Bridge unavailable"})]})]}),(0,t.jsx)(S,{isOpen:l,terminalCount:_,onConfirm:v,onCancel:()=>c(!1),isLoading:u})]})}var $=e.i(5903),T=e.i(22530);function L({name:e,description:o,tags:s,projectId:i,projectPath:d,showArchived:l=!1,onToggleArchived:u,showAutomations:x=!1,hasActiveAutomations:m=!1,onToggleAutomations:h,onRefresh:p}){let[g,v]=(0,r.useState)(!1),[b,f]=(0,r.useState)(!1),[k,w]=(0,r.useState)(!1),[N,y]=(0,r.useState)(!1),[C,S]=(0,r.useState)(0),L=(0,n.useRouter)();(0,r.useEffect)(()=>{let e=!0;async function t(){try{let t=await fetch("/api/cli-assets/updates");if(t.ok&&e){let e=await t.json();S(e.actionEntries?.length??0)}}catch{}}t();let r=setInterval(t,6e4);return()=>{e=!1,clearInterval(r)}},[]);let M=(0,r.useCallback)(async()=>{if(!N&&p){y(!0);try{await p()}finally{setTimeout(()=>y(!1),400)}}},[N,p]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("header",{className:"neon-header-border relative z-10 flex-shrink-0 bg-void-50 shadow-[0_4px_12px_-2px_rgba(0,0,0,0.15)] dark:bg-void-800 dark:shadow-[0_4px_12px_-2px_rgba(0,0,0,0.5)]",children:(0,t.jsx)("div",{className:"px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 sm:gap-4",children:[(0,t.jsxs)(a.default,{href:"/",className:"shrink-0 rounded-lg p-0.5",children:[(0,t.jsx)("img",{src:"/slycode_logo_light.webp",alt:"Home",className:"logo-nav h-[40px] w-[40px] sm:h-[52px] sm:w-[52px] object-contain mix-blend-multiply dark:hidden"}),(0,t.jsx)("img",{src:"/slycode_logo.webp",alt:"Home",className:"logo-nav hidden h-[40px] w-[40px] sm:h-[52px] sm:w-[52px] object-contain mix-blend-lighten dark:block"})]}),(0,t.jsxs)("div",{className:"hidden min-w-0 flex-1 sm:block",children:[(0,t.jsx)("h1",{className:"truncate text-xl font-bold text-void-950 dark:text-void-100",children:e}),(0,t.jsx)("p",{className:"truncate text-sm text-void-500 dark:text-void-400",children:o})]}),(0,t.jsx)("button",{onClick:()=>w(!0),className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border border-void-200/40 bg-transparent p-2 text-void-500 transition-all hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400 sm:hidden",children:(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,t.jsx)("div",{className:"hidden w-64 shrink-0 sm:block",children:(0,t.jsx)($.SearchBar,{contextProjectId:i,onResultClick:e=>{L.push(`/project/${e.projectId}?card=${e.cardId}`)}})}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1 sm:gap-2",children:[p&&(0,t.jsx)("button",{onClick:M,title:"Refresh board from disk",className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border border-void-200/40 bg-transparent p-2 text-void-500 transition-all hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400",children:(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform${N?" animate-spin":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,t.jsx)(T.ThemeToggle,{}),(0,t.jsx)(_,{}),(0,t.jsxs)("button",{onClick:()=>v(!0),title:"Sly Actions",className:"relative hidden sm:flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border border-void-200/40 bg-transparent p-2 text-void-500 transition-all hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400",children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),C>0&&(0,t.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-neon-blue-500 px-1 text-[10px] font-bold text-white",children:C})]}),(0,t.jsx)("button",{onClick:h,title:x?"Show kanban board":"Show automations",className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border p-2 transition-all ${x?"border-orange-400/50 bg-orange-400/10 text-orange-500 hover:bg-orange-400/20 dark:text-orange-400":`border-void-200/40 bg-transparent text-void-500 hover:border-orange-400/40 hover:bg-orange-400/5 hover:text-orange-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-orange-400/40 dark:hover:bg-orange-400/5 dark:hover:text-orange-400${m?" active-glow-automation-btn text-orange-400 dark:text-orange-400":""}`}`,children:x?(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,t.jsx)("button",{onClick:u,title:l?"Show active cards":"Show archived cards",className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border p-2 transition-all ${l?"border-neon-orange-400/50 bg-neon-orange-400/8 text-neon-orange-500 hover:bg-neon-orange-400/15 dark:text-neon-orange-400":"border-void-200/40 bg-transparent text-void-500 hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400"}`,children:l?(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"})})})]})]})})}),k&&(0,t.jsx)("div",{className:"fixed inset-x-0 top-0 z-50 bg-void-50 p-3 shadow-lg dark:bg-void-800 sm:hidden",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)($.SearchBar,{contextProjectId:i,onResultClick:e=>{w(!1),L.push(`/project/${e.projectId}?card=${e.cardId}`)}})}),(0,t.jsx)("button",{onClick:()=>w(!1),className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg p-2 text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-200",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),g&&(0,t.jsx)(c,{onClose:()=>{v(!1),fetch("/api/sly-actions/invalidate",{method:"POST"}).catch(()=>{})},projectId:i,projectPath:d,actionUpdateCount:C,onShowActionUpdates:()=>{v(!1),f(!0)}}),b&&(0,t.jsx)(j,{onClose:()=>{f(!1),fetch("/api/cli-assets/updates").then(e=>e.json()).then(e=>S(e.actionEntries?.length??0)).catch(()=>{})}})]})}var M=e.i(21146);class D{channel=null;senderId;listeners=new Set;constructor(){if(this.senderId=`tab-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,"u">typeof BroadcastChannel)try{this.channel=new BroadcastChannel("slycode-tab-sync"),this.channel.onmessage=e=>{e.data.senderId!==this.senderId&&this.listeners.forEach(t=>t(e.data))}}catch{}}broadcast(e,t){if(!this.channel)return;let r={type:e,senderId:this.senderId,projectId:t,timestamp:Date.now()};try{this.channel.postMessage(r)}catch{}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}}let E=new D;var I=e.i(84608),R=e.i(74080);let A={critical:{border:"border-l-[#ff1744]",glowRgb:"255, 23, 68",hoverGlow:"hover:shadow-[var(--shadow-card),inset_5px_0_8px_-6px_rgba(255,23,68,0.5)] dark:hover:shadow-[var(--shadow-card),inset_6px_0_14px_-6px_rgba(255,23,68,0.5),_-4px_0_16px_-3px_rgba(255,23,68,0.55)] hover:before:bg-white/40 dark:hover:before:bg-white/60"},high:{border:"border-l-[#ff9100]",glowRgb:"255, 145, 0",hoverGlow:"hover:shadow-[var(--shadow-card),inset_4px_0_7px_-5px_rgba(255,145,0,0.45)] dark:hover:shadow-[var(--shadow-card),inset_5px_0_12px_-5px_rgba(255,145,0,0.45),_-3px_0_14px_-3px_rgba(255,145,0,0.45)] hover:before:bg-white/35 dark:hover:before:bg-white/50"},medium:{border:"border-l-[#00bfff]",glowRgb:"0, 191, 255",hoverGlow:"hover:shadow-[var(--shadow-card),inset_4px_0_6px_-5px_rgba(0,191,255,0.4)] dark:hover:shadow-[var(--shadow-card),inset_4px_0_10px_-4px_rgba(0,191,255,0.4),_-3px_0_12px_-3px_rgba(0,191,255,0.35)] hover:before:bg-white/30 dark:hover:before:bg-white/45"},low:{border:"border-l-[#00c853]",glowRgb:"0, 200, 83",hoverGlow:"hover:shadow-[var(--shadow-card),inset_4px_0_6px_-5px_rgba(0,200,83,0.35)] dark:hover:shadow-[var(--shadow-card),inset_4px_0_10px_-4px_rgba(0,200,83,0.35),_-3px_0_12px_-3px_rgba(0,200,83,0.3)] hover:before:bg-white/25 dark:hover:before:bg-white/40"}},B={bug:"🪳",feature:"✨",chore:"🔧"};function O({completed:e,total:r}){let a=e===r,n=r>0?e/r:0,o=2*Math.PI*5.75;if(a)return(0,t.jsx)("div",{className:"flex items-center",title:"Checklist complete",children:(0,t.jsxs)("svg",{width:13,height:13,viewBox:"0 0 16 16",className:"text-void-400 dark:text-void-500",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor"}),(0,t.jsx)("path",{d:"M5 8l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})});let s=0===e;return(0,t.jsxs)("div",{className:"flex items-center gap-1",title:`${e}/${r} items complete`,children:[(0,t.jsxs)("svg",{width:13,height:13,className:"-rotate-90",children:[(0,t.jsx)("circle",{cx:6.5,cy:6.5,r:5.75,fill:"none",stroke:"currentColor",strokeWidth:1.5,className:s?"text-red-500":"text-void-200 dark:text-void-600"}),(0,t.jsx)("circle",{cx:6.5,cy:6.5,r:5.75,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:o*(1-n),className:"text-orange-500 dark:text-orange-400"})]}),(0,t.jsxs)("span",{className:"font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-void-500 dark:text-void-400",children:[e,"/",r]})]})}function P({card:e,sessionStatus:a,isActivelyWorking:n=!1,stage:o,onClick:s,onContextMenu:i,onDragStart:d,onDragEnd:l}){var c;let u=e.problems.filter(e=>!e.resolved_at).length,x=e.checklist?.length||0,m=e.checklist?.filter(e=>e.done).length||0,[h,p]=(0,r.useState)(!1),[g,v]=(0,r.useState)({top:0,left:0}),[b,f]=(0,r.useState)(!1),k=(0,r.useRef)(null),j=(0,r.useRef)(null),w=A[e.priority]||A.medium;(0,r.useEffect)(()=>()=>{k.current&&clearTimeout(k.current)},[]);let N="done"!==o&&(e.areas.length>0||e.tags.length>0);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{ref:j,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/plain",e.id),t.dataTransfer.effectAllowed="move",d?.(),p(!1),k.current&&clearTimeout(k.current)},onDragEnd:()=>{l?.()},onClick:s,style:{"--glow-color":w.glowRgb},onContextMenu:e=>{i&&(p(!1),k.current&&clearTimeout(k.current),i(e))},onMouseEnter:()=>{e.description&&(k.current=setTimeout(()=>{if(j.current){let e=j.current.getBoundingClientRect(),t=e.right+8+256<=window.innerWidth,r=t?e.right+8:e.left-8-256;v({top:Math.min(e.top,window.innerHeight-100-8),left:r}),f(!t)}p(!0)},500))},onMouseLeave:()=>{k.current&&(clearTimeout(k.current),k.current=null),p(!1)},className:`group relative cursor-pointer rounded-lg border-l-4 border-t border-t-white/50 backdrop-blur-lg bg-white/55 p-3 shadow-(--shadow-card) ring-1 ring-transparent transition-[transform,ring-color,box-shadow] duration-200 hover:translate-y-0.5 hover:ring-[rgba(var(--glow-color),0.4)] before:pointer-events-none before:absolute before:inset-y-1 before:-left-[3px] before:w-px before:rounded-full before:bg-white/0 before:transition-colors before:duration-200 dark:border-t-white/10 dark:backdrop-blur-xl dark:bg-[#20232a]/55 dark:hover:ring-[rgba(var(--glow-color),0.25)] ${w.border} ${w.hoverGlow} ${n?"active-glow-card":""}`,children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("h4",{className:"text-sm font-medium text-void-900 dark:text-void-100",children:e.title})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[null!=e.number&&(0,t.jsx)("span",{className:"font-[family-name:var(--font-jetbrains-mono)] text-[10px] leading-none text-void-400 dark:text-void-500",children:(c=e.number,`#${String(c).padStart(c>9999?0:4,"0")}`)}),(n||"running"===a)&&(0,t.jsxs)("span",{className:"relative flex h-2.5 w-2.5 -translate-y-px",title:"Session running",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-[#00e676] opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-[#00e676] dark:drop-shadow-[0_0_4px_rgba(0,230,118,0.6)]",style:{boxShadow:"0 0 6px rgba(0,230,118,0.6)"}})]}),!n&&("detached"===a||"resumable"===a)&&(0,t.jsx)("span",{className:"flex h-2.5 w-2.5 -translate-y-px rounded-full bg-neon-orange-400 dark:drop-shadow-[0_0_4px_rgba(255,140,0,0.5)]",title:"Session paused",style:{boxShadow:"0 0 4px rgba(255,140,0,0.4)"}}),!n&&"none"===a&&(0,t.jsx)("span",{className:"flex h-2 w-2 -translate-y-px rounded-full bg-void-300 dark:bg-void-600",title:"No session"})]})]}),u>0&&(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:[(0,t.jsx)("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,t.jsxs)("span",{children:[u," issue",1!==u?"s":""]})]}),(0,t.jsxs)("div",{className:`${N?"mt-2":"mt-1"} flex items-center justify-end gap-2`,children:[N&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 gap-1 overflow-hidden",children:[e.areas.slice(0,1).map(e=>(0,t.jsx)("span",{className:"shrink-0 rounded border border-neon-blue-400/25 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-neon-blue-700 transition-colors group-hover:bg-neon-blue-400/8 dark:border-neon-blue-400/20 dark:text-neon-blue-400/70 dark:group-hover:bg-neon-blue-400/10",children:e},e)),e.areas.length>1&&(0,t.jsxs)("span",{className:"shrink-0 rounded border border-neon-blue-400/25 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-neon-blue-600 transition-colors group-hover:bg-neon-blue-400/8 dark:border-neon-blue-400/20 dark:text-neon-blue-400/50 dark:group-hover:bg-neon-blue-400/10",children:["+",e.areas.length-1]}),e.tags.slice(0,1).map(e=>(0,t.jsx)("span",{className:"shrink-0 rounded border border-void-300 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-void-600 transition-colors group-hover:bg-void-100 dark:border-void-600 dark:text-void-400 dark:group-hover:bg-void-800",children:e},e)),e.tags.length>1&&(0,t.jsxs)("span",{className:"shrink-0 rounded border border-void-300 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-void-600 transition-colors group-hover:bg-void-100 dark:border-void-600 dark:text-void-500 dark:group-hover:bg-void-800",children:["+",e.tags.length-1]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[x>0&&(0,t.jsx)(O,{completed:m,total:x}),(0,t.jsx)("span",{className:"text-base leading-none",children:B[e.type]||B.chore})]})]})]}),h&&e.description&&"u">typeof document&&(0,R.createPortal)((0,t.jsxs)("div",{className:`fixed z-[100] w-64 animate-in fade-in duration-200 ${b?"slide-in-from-right-1":"slide-in-from-left-1"}`,style:{top:g.top,left:g.left},children:[(0,t.jsx)("div",{className:"rounded-lg border border-neon-blue-400/20 bg-void-50 p-3 shadow-(--shadow-overlay) dark:bg-void-850",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-void-700 dark:text-void-300",children:e.description.length>200?e.description.slice(0,200)+"...":e.description})}),(0,t.jsx)("div",{className:`absolute top-3 h-2 w-2 rotate-45 ${b?"-right-1 border-t border-r":"-left-1 border-b border-l"} border-neon-blue-400/20 bg-void-50 dark:bg-void-850`})]}),document.body)]})}let W={zinc:{header:"bg-void-200 dark:bg-void-700 shadow-[inset_0_2px_6px_rgba(100,100,110,0.2),inset_0_-1px_3px_rgba(100,100,110,0.12)] dark:shadow-[inset_0_2px_6px_rgba(30,30,40,0.5),inset_0_-1px_3px_rgba(30,30,40,0.35),inset_0_1px_0_rgba(255,255,255,0.06)]",headerText:"text-void-500 dark:text-void-200",count:"bg-void-300/80 text-void-500 dark:bg-void-600 dark:text-void-200",border:"border-b-[3px] border-void-400 dark:border-void-400",texture:"lane-texture"},purple:{header:"bg-neon-blue-100/80 dark:from-neon-blue-900/60 dark:to-neon-blue-950/40 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(0,120,180,0.18),inset_0_-1px_3px_rgba(0,120,180,0.1)] dark:shadow-[inset_0_2px_6px_rgba(0,60,100,0.55),inset_0_-1px_3px_rgba(0,60,100,0.35),inset_0_1px_0_rgba(0,191,255,0.06)]",headerText:"text-void-600 dark:text-neon-blue-300",count:"bg-neon-blue-200/60 text-void-600 dark:bg-neon-blue-800/60 dark:text-neon-blue-200",border:"border-b-[3px] border-neon-blue-400/70 dark:border-neon-blue-400/70",texture:"lane-texture"},blue:{header:"bg-neon-blue-100 dark:from-neon-blue-800/50 dark:to-neon-blue-900/40 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(0,100,160,0.2),inset_0_-1px_3px_rgba(0,100,160,0.12)] dark:shadow-[inset_0_2px_6px_rgba(0,50,90,0.55),inset_0_-1px_3px_rgba(0,50,90,0.35),inset_0_1px_0_rgba(0,191,255,0.06)]",headerText:"text-void-600 dark:text-neon-blue-200",count:"bg-neon-blue-200/60 text-void-600 dark:bg-neon-blue-700/60 dark:text-neon-blue-100",border:"border-b-[3px] border-neon-blue-500/60 dark:border-neon-blue-400/70",texture:"lane-texture"},yellow:{header:"bg-[#ff6a33]/10 dark:from-[#ff6a33]/15 dark:to-[#ff6a33]/5 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(180,60,0,0.15),inset_0_-1px_3px_rgba(180,60,0,0.08)] dark:shadow-[inset_0_2px_6px_rgba(100,30,0,0.5),inset_0_-1px_3px_rgba(100,30,0,0.3),inset_0_1px_0_rgba(255,106,51,0.06)]",headerText:"text-void-600 dark:text-[#ff8a60]",count:"bg-[#ff6a33]/12 text-void-600 dark:bg-[#ff6a33]/20 dark:text-[#ffc0a0]",border:"border-b-[3px] border-[#ff6a33]/50 dark:border-[#ff6a33]/60",texture:"lane-texture"},green:{header:"bg-green-100/80 dark:from-green-900/50 dark:to-green-950/30 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(0,100,50,0.18),inset_0_-1px_3px_rgba(0,100,50,0.1)] dark:shadow-[inset_0_2px_6px_rgba(0,50,25,0.55),inset_0_-1px_3px_rgba(0,50,25,0.35),inset_0_1px_0_rgba(34,197,94,0.06)]",headerText:"text-void-600 dark:text-green-300",count:"bg-green-200/60 text-void-600 dark:bg-green-800/50 dark:text-green-200",border:"border-b-[3px] border-green-500/60 dark:border-green-400/60",texture:"lane-texture"}};function F({stage:e,cards:a,cardSessions:n,activeCards:o,onCardClick:s,onCardContextMenu:i,onMoveCard:d,onAddCardClick:l}){let c=W[e.color]||W.zinc,[u,x]=(0,r.useState)(null),m=(0,r.useRef)(null),h=(0,r.useRef)(null),p=(0,r.useRef)(0),g=(0,r.useRef)(!1);(0,r.useEffect)(()=>{let e=()=>{let t=m.current;if(!t||!g.current){h.current=null;return}let r=t.getBoundingClientRect(),a=p.current,n=a-r.top,o=r.bottom-a,s=0;n<60&&n>0?s=-8*(1-n/60):o<60&&o>0&&(s=8*(1-o/60)),0!==s&&(t.scrollTop+=s),h.current=requestAnimationFrame(e)};return m.current&&(m.current.startScroll=()=>{h.current||(h.current=requestAnimationFrame(e))}),()=>{h.current&&(cancelAnimationFrame(h.current),h.current=null)}},[]);let v=(0,r.useCallback)(()=>{g.current=!0;let e=m.current;e?.startScroll?.()},[]),b=(0,r.useCallback)(()=>{g.current=!1,h.current&&(cancelAnimationFrame(h.current),h.current=null)},[]),f=e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",p.current=e.clientY,v()};return(0,t.jsxs)("div",{className:"flex min-w-[85vw] sm:min-w-72 max-w-[85vw] sm:max-w-96 flex-1 flex-shrink-0 snap-start flex-col rounded-lg border-2 border-t-[rgba(140,170,220,0.55)] border-l-[rgba(140,170,220,0.55)] border-b-[rgba(80,110,180,0.45)] border-r-[rgba(80,110,180,0.45)] bg-[#d8e1f0] shadow-[0_1px_3px_rgba(0,0,0,0.25),inset_0_3px_6px_-2px_rgba(255,255,255,0.6),inset_3px_0_6px_-2px_rgba(255,255,255,0.4),inset_0_-3px_6px_-2px_rgba(60,90,160,0.2),inset_-3px_0_6px_-2px_rgba(60,90,160,0.15)] dark:border-2 dark:border-void-700 dark:bg-void-850 dark:shadow-[0_1px_3px_rgba(0,0,0,0.6)]",onDragOver:f,onDragLeave:e=>{let t=e.currentTarget.getBoundingClientRect(),r=e.clientX,a=e.clientY;(r<t.left||r>t.right||a<t.top||a>t.bottom)&&(x(null),b())},onDrop:t=>{t.preventDefault(),b();let r=t.dataTransfer.getData("text/plain");r&&d(r,e.id,u??void 0),x(null)},children:[(0,t.jsxs)("div",{className:`light-clean grain depth-glow flex items-center justify-between rounded-t-lg px-3 py-2.5 ${c.header} ${c.border}`,children:[(0,t.jsx)("h3",{className:`font-semibold drop-shadow-[0_1px_2px_rgba(0,0,0,0.4)] dark:drop-shadow-[0_2px_3px_rgba(0,0,0,0.7)] ${c.headerText}`,children:e.label}),(0,t.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-bold ${c.count}`,children:a.length})]}),(0,t.jsx)("div",{ref:m,className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 pb-8 ${c.texture}`,style:{maskImage:"linear-gradient(to bottom, black calc(100% - 3rem), transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black calc(100% - 3rem), transparent 100%)"},children:0===a.length?(0,t.jsx)("div",{className:"rounded-lg border-2 border-dashed border-void-200 p-4 text-center text-sm text-void-400 dark:border-void-700 dark:text-void-600",onDragOver:f,onDrop:t=>{t.preventDefault(),b();let r=t.dataTransfer.getData("text/plain");r&&d(r,e.id,0),x(null)},children:"Drop here"}):(0,t.jsxs)(t.Fragment,{children:[a.map((r,a)=>(0,t.jsxs)("div",{children:[u===a&&(0,t.jsx)("div",{className:"mb-2 h-1 rounded-full bg-neon-blue-400 transition-all"}),(0,t.jsx)("div",{onDragOver:e=>{let t,r;return e.preventDefault(),e.stopPropagation(),p.current=e.clientY,v(),r=(t=e.currentTarget.getBoundingClientRect()).top+t.height/2,void x(e.clientY<r?a:a+1)},children:(0,t.jsx)(P,{card:r,sessionStatus:n.get(r.id)||"none",isActivelyWorking:o.has(r.id),stage:e.id,onClick:()=>s(r),onContextMenu:i?e=>i(r,e):void 0,onDragStart:()=>{},onDragEnd:()=>{x(null),b()}})})]},r.id)),u===a.length&&(0,t.jsx)("div",{className:"mt-2 h-1 rounded-full bg-neon-blue-400 transition-all"})]})}),l&&(0,t.jsx)("div",{className:"p-2 pt-0",children:(0,t.jsxs)("button",{onClick:l,className:"flex w-full items-center justify-center gap-1 rounded-lg border-2 border-dashed border-void-200 py-2 text-sm text-void-400 transition-colors hover:border-neon-blue-400/30 hover:text-neon-blue-400 dark:border-void-700 dark:text-void-500 dark:hover:border-neon-blue-400/30 dark:hover:text-neon-blue-400",children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Card"]})})]})}var H=e.i(9308),z=e.i(7782);let U=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function V(e,t,r="Not set",a){let n=a?` (${a})`:"";if("one-shot"===t)try{let t=new Date(e);if(isNaN(t.getTime()))return e||r;return`Once on ${t.toLocaleDateString()} at ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}${n}`}catch{return e||r}if(!e)return r;let o=e.split(" ");if(5!==o.length)return e;let[s,i,d,,l]=o,c=i.match(/^(\d+)-(\d+)\/(\d+)$/);if(c&&"*"===d&&"*"===l){let[,e,t,r]=c;return`Every ${r}h from ${e.padStart(2,"0")}:${s.padStart(2,"0")} to ${t.padStart(2,"0")}:${s.padStart(2,"0")}${n}`}if(i.includes(",")&&"*"===d&&"*"===l){let e=i.split(",").map(Number);if(e.length>=2){let t=(e[1]-e[0]+24)%24;if(t>0){let r=String(e[0]).padStart(2,"0"),a=String(e[e.length-1]).padStart(2,"0");return`Every ${t}h from ${r}:${s.padStart(2,"0")} to ${a}:${s.padStart(2,"0")}${n}`}}}if("*"===i&&"*"===d&&"*"===l)return`Every hour at :${s.padStart(2,"0")}${n}`;if("*"===d&&"*"===l)return`Daily at ${i}:${s.padStart(2,"0")}${n}`;if("*"===d&&"*"!==l){let e=l.split(",").map(e=>U[parseInt(e)]||e).join(", ");return`Weekly on ${e} at ${i}:${s.padStart(2,"0")}${n}`}return"*"!==d&&"*"===l?`Monthly on day ${d} at ${i}:${s.padStart(2,"0")}${n}`:e}let q=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function J(e){let t={frequency:"daily",hour:"6",minute:"0",days:[],dayOfMonth:"1",intervalHours:"2",startHour:"9",endHour:"20"};if(!e)return t;let r=e.split(" ");if(5!==r.length)return t;let[a,n,o,,s]=r,i=n.match(/^(\d+)-(\d+)\/(\d+)$/);if(i&&"*"===o&&"*"===s)return{...t,frequency:"interval",minute:a,startHour:i[1],endHour:i[2],intervalHours:i[3]};if(n.includes(",")&&"*"===o&&"*"===s){let e=n.split(",").map(Number);if(e.length>=2){let r=(e[1]-e[0]+24)%24;if(r>0&&r<=12)return{...t,frequency:"interval",minute:a,startHour:String(e[0]),endHour:String(e[e.length-1]),intervalHours:String(r)}}}return"*"===n?{...t,frequency:"hourly",minute:a}:"*"!==o?{...t,frequency:"monthly",hour:n,minute:a,dayOfMonth:o}:"*"!==s?{...t,frequency:"weekly",hour:n,minute:a,days:s.split(",").map(Number)}:{...t,frequency:"daily",hour:n,minute:a}}function K(e){switch(e.frequency){case"hourly":return`${e.minute} * * * *`;case"daily":return`${e.minute} ${e.hour} * * *`;case"weekly":return`${e.minute} ${e.hour} * * ${e.days.length?e.days.sort((e,t)=>e-t).join(","):"1"}`;case"monthly":return`${e.minute} ${e.hour} ${e.dayOfMonth} * *`;case"interval":{let t=parseInt(e.startHour),r=parseInt(e.endHour),a=parseInt(e.intervalHours);if(t<=r)return`${e.minute} ${t}-${r}/${a} * * *`;let n=function(e,t,r){let a=[],n=e;if(e<=t)for(;n<=t;)a.push(n),n+=r;else{for(;n<24;)a.push(n),n+=r;for(n-=24;n<=t;)a.push(n),n+=r}return a}(t,r,a);return`${e.minute} ${n.join(",")} * * *`}}}function G({config:e,cardId:a,projectId:n,onChange:o}){let[s,i]=(0,r.useState)(!1),[d,l]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),[x,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(""),g=J(e.schedule),[v,b]=(0,r.useState)(g);(0,r.useEffect)(()=>{fetch("/api/providers").then(e=>e.ok?e.json():null).then(e=>{e?.providers&&l(Object.entries(e.providers).map(([e,t])=>({id:e,displayName:t.displayName||e})))}).catch(()=>{}),fetch("/api/scheduler").then(e=>e.ok?e.json():null).then(e=>{e?.abbreviation&&p(e.abbreviation)}).catch(()=>{})},[]);let f=(t,r,a)=>{"recurring"===r&&t&&fetch("/api/scheduler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"nextRun",schedule:t,scheduleType:r})}).then(e=>e.ok?e.json():null).then(r=>{r?.nextRun&&o({...e,...a,schedule:t,nextRun:r.nextRun})}).catch(()=>{})},k=t=>{let r={...v,...t};b(r);let a=K(r);o({...e,schedule:a,nextRun:void 0}),e.enabled&&f(a,e.scheduleType)},j=V(e.schedule,e.scheduleType,"Not set",h||void 0),w="rounded border border-void-300 bg-white px-2 py-1 text-sm text-void-700 focus:border-orange-400 focus:outline-none focus:ring-1 focus:ring-orange-400/30 dark:border-void-600 dark:bg-void-800 dark:text-void-300",N="text-xs font-medium text-void-500 dark:text-void-400";return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-orange-400/20 bg-orange-50/50 p-3 dark:bg-orange-950/10",children:[(0,t.jsx)("h4",{className:"mb-3 text-sm font-semibold text-orange-700 dark:text-orange-400",children:"Schedule"}),(0,t.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:()=>{let t=K(v);o({...e,scheduleType:"recurring",schedule:t,nextRun:void 0}),e.enabled&&f(t,"recurring")},className:`rounded-l-lg px-3 py-1.5 text-xs font-medium transition-colors ${"recurring"===e.scheduleType?"bg-orange-500 text-white":"bg-void-200 text-void-600 hover:bg-void-300 dark:bg-void-700 dark:text-void-400 dark:hover:bg-void-600"}`,children:"Recurring"}),(0,t.jsx)("button",{onClick:()=>o({...e,scheduleType:"one-shot",schedule:"",nextRun:void 0}),className:`rounded-r-lg px-3 py-1.5 text-xs font-medium transition-colors ${"one-shot"===e.scheduleType?"bg-orange-500 text-white":"bg-void-200 text-void-600 hover:bg-void-300 dark:bg-void-700 dark:text-void-400 dark:hover:bg-void-600"}`,children:"One-shot"})]}),"recurring"===e.scheduleType?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Frequency:"}),(0,t.jsxs)("select",{value:v.frequency,onChange:e=>k({frequency:e.target.value}),className:w,children:[(0,t.jsx)("option",{value:"hourly",children:"Hourly"}),(0,t.jsx)("option",{value:"daily",children:"Daily"}),(0,t.jsx)("option",{value:"weekly",children:"Weekly"}),(0,t.jsx)("option",{value:"monthly",children:"Monthly"}),(0,t.jsx)("option",{value:"interval",children:"Interval (hour range)"})]})]}),"interval"===v.frequency&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Every"}),(0,t.jsx)("select",{value:v.intervalHours,onChange:e=>k({intervalHours:e.target.value}),className:w,children:[1,2,3,4,6,8].map(e=>(0,t.jsxs)("option",{value:String(e),children:[e," hour",e>1?"s":""]},e))}),(0,t.jsx)("span",{className:N,children:"between"}),(0,t.jsx)("select",{value:v.startHour,onChange:e=>k({startHour:e.target.value}),className:w,children:Array.from({length:24},(e,r)=>(0,t.jsxs)("option",{value:String(r),children:[String(r).padStart(2,"0"),":00"]},r))}),(0,t.jsx)("span",{className:N,children:"and"}),(0,t.jsx)("select",{value:v.endHour,onChange:e=>k({endHour:e.target.value}),className:w,children:Array.from({length:24},(e,r)=>(0,t.jsxs)("option",{value:String(r),children:[String(r).padStart(2,"0"),":00"]},r))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"At minute:"}),(0,t.jsx)("select",{value:v.minute,onChange:e=>k({minute:e.target.value}),className:w,children:[0,5,10,15,20,25,30,35,40,45,50,55].map(e=>(0,t.jsxs)("option",{value:String(e),children:[":",String(e).padStart(2,"0")]},e))})]})]}),("daily"===v.frequency||"weekly"===v.frequency||"monthly"===v.frequency)&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"At:"}),(0,t.jsx)("input",{type:"time",value:`${v.hour.padStart(2,"0")}:${v.minute.padStart(2,"0")}`,onChange:e=>{let[t,r]=e.target.value.split(":");k({hour:String(parseInt(t)),minute:String(parseInt(r))})},className:w})]}),"hourly"===v.frequency&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"At minute:"}),(0,t.jsx)("select",{value:v.minute,onChange:e=>k({minute:e.target.value}),className:w,children:[0,5,10,15,20,25,30,35,40,45,50,55].map(e=>(0,t.jsxs)("option",{value:String(e),children:[":",String(e).padStart(2,"0")]},e))})]}),"weekly"===v.frequency&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Days:"}),(0,t.jsx)("div",{className:"flex gap-1",children:q.map((e,r)=>(0,t.jsx)("button",{onClick:()=>{k({days:v.days.includes(r)?v.days.filter(e=>e!==r):[...v.days,r]})},className:`rounded px-2 py-1 text-xs font-medium transition-colors ${v.days.includes(r)?"bg-orange-500 text-white":"bg-void-200 text-void-600 hover:bg-void-300 dark:bg-void-700 dark:text-void-400"}`,children:e},r))})]}),"monthly"===v.frequency&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Day:"}),(0,t.jsx)("select",{value:v.dayOfMonth,onChange:e=>k({dayOfMonth:e.target.value}),className:w,children:Array.from({length:28},(e,t)=>t+1).map(e=>(0,t.jsx)("option",{value:String(e),children:e},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{onClick:()=>i(!s),className:"text-xs text-void-500 hover:text-orange-500 dark:text-void-400",children:[s?"Hide":"Show"," advanced (cron)"]}),s&&(0,t.jsx)("div",{className:"mt-1 flex items-center gap-2",children:(0,t.jsx)("input",{type:"text",value:e.schedule,onChange:t=>{let r=t.target.value;o({...e,schedule:r,nextRun:void 0}),b(J(r)),e.enabled&&f(r,"recurring")},placeholder:"* * * * *",className:`flex-1 font-mono text-xs ${w}`})})]})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Date & Time:"}),(0,t.jsx)("input",{type:"datetime-local",value:e.schedule?e.schedule.slice(0,16):"",onChange:t=>o({...e,schedule:new Date(t.target.value).toISOString(),nextRun:void 0}),className:w}),h&&(0,t.jsxs)("span",{className:"text-xs text-void-500 dark:text-void-400",children:["(",h,")"]})]}),(0,t.jsx)("div",{className:"mt-2 rounded bg-orange-100/50 px-2 py-1 text-xs text-orange-700 dark:bg-orange-900/20 dark:text-orange-300",children:j}),(e.lastRun||e.nextRun)&&(0,t.jsxs)("div",{className:"mt-2 flex gap-4 text-xs text-void-500 dark:text-void-400",children:[e.lastRun&&(0,t.jsxs)("span",{children:["Last run: ",new Date(e.lastRun).toLocaleString(),e.lastResult&&(0,t.jsxs)("span",{className:"success"===e.lastResult?" text-green-600 dark:text-green-400":" text-red-600 dark:text-red-400",children:[" ","(",e.lastResult,")"]})]}),e.nextRun&&(0,t.jsxs)("span",{children:["Next run: ",new Date(e.nextRun).toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-orange-400/20 bg-orange-50/50 p-3 dark:bg-orange-950/10",children:[(0,t.jsx)("h4",{className:"mb-3 text-sm font-semibold text-orange-700 dark:text-orange-400",children:"Execution"}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Provider:"}),(0,t.jsx)("select",{value:e.provider,onChange:t=>o({...e,provider:t.target.value}),className:w,children:d.length>0?d.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName},e.id)):(0,t.jsx)("option",{value:e.provider,children:e.provider})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,t.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Fresh session:"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.freshSession,onClick:()=>o({...e,freshSession:!e.freshSession}),className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors ${e.freshSession?"bg-orange-500":"bg-void-300 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${e.freshSession?"translate-x-4":"translate-x-0"}`})})]}),(0,t.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Report via messaging:"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.reportViaMessaging,onClick:()=>o({...e,reportViaMessaging:!e.reportViaMessaging}),className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors ${e.reportViaMessaging?"bg-orange-500":"bg-void-300 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${e.reportViaMessaging?"translate-x-4":"translate-x-0"}`})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Working dir:"}),(0,t.jsx)("input",{type:"text",value:e.workingDirectory||"",onChange:t=>o({...e,workingDirectory:t.target.value||void 0}),placeholder:"(uses card's project directory)",className:`flex-1 ${w}`})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-orange-400/20 bg-white/50 p-2 dark:bg-void-800/50",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-sm font-medium text-void-700 dark:text-void-300",children:"Enabled"}),!e.enabled&&(0,t.jsx)("p",{className:"text-xs text-orange-600 dark:text-orange-400",children:"This automation won't run until enabled"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",disabled:c,onClick:async()=>{u(!0),m(null);try{let e=await fetch("/api/scheduler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trigger",cardId:a,projectId:n})}),t=await e.json();m(t.success?"success":"error")}catch{m("error")}finally{u(!1),setTimeout(()=>m(null),3e3)}},className:`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all ${"success"===x?"border-green-400/40 bg-green-400/15 text-green-600 dark:text-green-400":"error"===x?"border-red-400/40 bg-red-400/15 text-red-600 dark:text-red-400":"border-orange-400/40 bg-orange-400/15 text-orange-600 hover:bg-orange-400/25 hover:shadow-[0_0_12px_rgba(249,115,22,0.3)] dark:text-orange-400"} disabled:cursor-not-allowed disabled:opacity-50`,children:c?"Running...":"success"===x?"Triggered":"error"===x?"Failed":"Run Now"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.enabled,onClick:()=>{let t=!e.enabled;o({...e,enabled:t}),t&&f(e.schedule,e.scheduleType,{enabled:!0})},className:`relative inline-flex h-6 w-11 flex-shrink-0 rounded-full border-2 border-transparent transition-colors ${e.enabled?"bg-green-500":"bg-void-300 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow transition ${e.enabled?"translate-x-5":"translate-x-0"}`})})]})]})]})]})]})}function X({open:e,onClose:r,onConfirm:a,title:n,message:o,confirmLabel:s="Delete",confirmClassName:i="bg-red-600 hover:bg-red-700"}){return e?(0,t.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60",onClick:r,children:(0,t.jsxs)("div",{className:"w-full max-w-md rounded-xl bg-white p-6 shadow-(--shadow-overlay) dark:bg-void-800",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30",children:(0,t.jsx)("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,t.jsx)("h3",{className:"text-lg font-semibold text-void-900 dark:text-void-100",children:n})]}),(0,t.jsx)("div",{className:"mb-6 text-sm text-void-600 dark:text-void-400",children:o}),(0,t.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,t.jsx)("button",{onClick:r,className:"rounded-lg px-4 py-2 text-sm font-medium text-void-700 hover:bg-void-100 dark:text-void-300 dark:hover:bg-void-700",children:"Cancel"}),(0,t.jsx)("button",{onClick:a,className:`rounded-lg px-4 py-2 text-sm font-medium text-white ${i}`,children:s})]})]})}):null}var Y=e.i(39269),Q=e.i(9083),Z=e.i(49996);let ee=[{id:"backlog",label:"Backlog"},{id:"design",label:"Design"},{id:"implementation",label:"Implementation"},{id:"testing",label:"Testing"},{id:"done",label:"Done"}],et=["critical","high","medium","low"],er={feature:"bg-neon-blue-400/20 text-neon-blue-600 dark:text-neon-blue-400 border border-neon-blue-400/30",chore:"bg-void-200 text-void-600 dark:bg-void-700 dark:text-void-200 border border-void-300 dark:border-void-600",bug:"bg-[#ff3b5c]/20 text-[#ff3b5c] border border-[#ff3b5c]/30"},ea={critical:"bg-[#ff3b5c]/20 text-[#ff3b5c] border border-[#ff3b5c]/30",high:"bg-neon-orange-400/20 text-neon-orange-600 dark:text-neon-orange-400 border border-neon-orange-400/30",medium:"bg-[#ffd600]/15 text-[#b39700] dark:text-[#ffd600]/80 border border-[#ffd600]/25",low:"bg-green-500/15 text-green-700 dark:text-green-400/70 border border-green-500/20"},en={backlog:"border-t border-void-600 bg-void-800",design:"border-t-2 border-neon-blue-400/40 bg-void-800",implementation:"border-t-2 border-neon-blue-400/50 bg-void-800",testing:"border-t-2 border-neon-orange-400/40 bg-void-800",done:"border-t-2 border-green-400/40 bg-void-800"},eo={backlog:"rgba(120, 120, 140, 0.12)",design:"rgba(0, 191, 255, 0.1)",implementation:"rgba(0, 191, 255, 0.12)",testing:"rgba(255, 106, 51, 0.1)",done:"rgba(0, 230, 118, 0.1)"},es={backlog:{header:"bg-gradient-to-r from-void-200 to-void-100 dark:from-void-850 dark:to-void-850/60",tabs:"bg-gradient-to-r from-void-200/50 to-void-100/50 dark:from-void-850/60 dark:to-void-850/30",modalBorder:"dark:border dark:border-void-600",headerBorder:"border-b border-void-300 dark:border-void-600",tabsBorder:"border-b border-void-200 dark:border-void-600"},design:{header:"bg-gradient-to-r from-neon-blue-200/85 to-neon-blue-50/50 dark:from-neon-blue-950/90 dark:to-neon-blue-950/30",tabs:"bg-gradient-to-r from-neon-blue-100/50 to-neon-blue-50/15 dark:from-neon-blue-950/50 dark:to-neon-blue-950/15",modalBorder:"dark:border dark:border-neon-blue-400/25",headerBorder:"border-b border-neon-blue-200/50 dark:border-neon-blue-400/25",tabsBorder:"border-b border-neon-blue-100/50 dark:border-neon-blue-400/20"},implementation:{header:"bg-gradient-to-r from-neon-blue-200/85 to-neon-blue-50/50 dark:from-neon-blue-950/90 dark:to-neon-blue-900/20",tabs:"bg-gradient-to-r from-neon-blue-100/50 to-neon-blue-50/15 dark:from-neon-blue-950/50 dark:to-neon-blue-950/15",modalBorder:"dark:border dark:border-neon-blue-400/30",headerBorder:"border-b border-neon-blue-200/50 dark:border-neon-blue-400/30",tabsBorder:"border-b border-neon-blue-100/50 dark:border-neon-blue-400/20"},testing:{header:"bg-gradient-to-r from-[#ff6a33]/25 to-[#ff6a33]/10 dark:from-[#ff6a33]/15 dark:to-[#ff6a33]/5",tabs:"bg-gradient-to-r from-[#ff6a33]/15 to-[#ff6a33]/5 dark:from-[#ff6a33]/10 dark:to-[#ff6a33]/5",modalBorder:"dark:border dark:border-[#ff6a33]/30",headerBorder:"border-b border-[#ff6a33]/25 dark:border-[#ff6a33]/30",tabsBorder:"border-b border-[#ff6a33]/15 dark:border-[#ff6a33]/25"},done:{header:"bg-gradient-to-r from-green-200/85 to-green-50/50 dark:from-green-950/90 dark:to-green-950/30",tabs:"bg-gradient-to-r from-green-100/50 to-green-50/15 dark:from-green-950/50 dark:to-green-950/15",modalBorder:"dark:border dark:border-green-400/25",headerBorder:"border-b border-green-200/50 dark:border-green-400/25",tabsBorder:"border-b border-green-100/50 dark:border-green-400/20"}},ei={header:"bg-gradient-to-r from-orange-200/85 to-orange-50/50 dark:from-orange-950/90 dark:to-orange-950/30",tabs:"bg-gradient-to-r from-orange-100/50 to-orange-50/15 dark:from-orange-950/50 dark:to-orange-950/15",modalBorder:"dark:border dark:border-orange-400/30",headerBorder:"border-b border-orange-200/50 dark:border-orange-400/30",tabsBorder:"border-b border-orange-100/50 dark:border-orange-400/20"},ed={backlog:"161, 161, 170",design:"129, 140, 248",implementation:"0, 191, 255",testing:"255, 106, 51",done:"74, 222, 128"};function el({anchorRef:e,children:a}){let[n,o]=(0,r.useState)({position:"fixed",opacity:0});return(0,r.useEffect)(()=>{let t=()=>{let t=e.current;if(!t)return;let r=t.getBoundingClientRect();o({position:"fixed",top:r.bottom+8,right:window.innerWidth-r.right,zIndex:9999,opacity:1})};return t(),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[e]),(0,t.jsx)("div",{style:n,children:a})}function ec({card:e,stage:a,projectId:n,projectPath:s,onClose:l,onUpdate:c,onMove:u,onDelete:x,isCreateMode:m,onCreate:h,onAutomationToggle:p,suppressAutoTerminal:g}){let[v,b]=(0,r.useState)("details"),[f,k]=(0,r.useState)(!1),[j,w]=(0,r.useState)(""),[N,y]=(0,r.useState)(m??!1),[C,S]=(0,r.useState)(e.title),[_,$]=(0,r.useState)(e.description),T=(0,r.useRef)(!1),L=(0,r.useRef)(e.description),M=(0,r.useRef)(e.title),D=(0,r.useRef)({}),E=(0,r.useCallback)(e=>{D.current[e]=Date.now()},[]),I=(0,r.useCallback)((e,t=2e3)=>{let r=D.current[e];return void 0!==r&&Date.now()-r<t},[]);(0,r.useEffect)(()=>{e.description!==L.current&&(I("description")||$(t=>t===L.current?e.description:t),L.current=e.description)},[e.description,I]),(0,r.useEffect)(()=>{e.title!==M.current&&(I("title")||S(t=>t===M.current?e.title:t),M.current=e.title)},[e.title,I]);let[A,B]=(0,r.useState)(!1),O=(0,r.useRef)(null),P=(0,r.useRef)(null),[W,F]=(0,r.useState)(null),[U,V]=(0,r.useState)(null),q=(0,z.useSlyActionsConfig)(),[J,K]=(0,r.useState)([]),[ec,eu]=(0,r.useState)(""),[ex,em]=(0,r.useState)(null),[eh,ep]=(0,r.useState)(null),[eg,ev]=(0,r.useState)(e.checklist||[]),eb=(0,r.useRef)(e.checklist||[]),[ef,ek]=(0,r.useState)(e.id),ej=(0,r.useRef)(JSON.stringify(e.checklist||[]));e.id!==ef&&(ev(e.checklist||[]),ek(e.id)),(0,r.useEffect)(()=>{let t=e.checklist||[];eb.current=t,ej.current=JSON.stringify(t)},[e.id]),(0,r.useEffect)(()=>{let t=JSON.stringify(e.checklist||[]);if(t!==ej.current){if(!I("checklist")&&JSON.stringify(eb.current)===ej.current){let t=e.checklist||[];ev(t),eb.current=t}ej.current=t}},[e.checklist,I]);let[ew,eN]=(0,r.useState)(""),[ey,eC]=(0,r.useState)(!1),eS=(0,r.useRef)(null),[e_,e$]=(0,r.useState)(!1),[eT,eL]=(0,r.useState)(!1),eM=(0,r.useRef)(e.agentNotes?.length??0),eD=(0,i.useVoice)(),eE=(0,r.useRef)(0),eI=(0,r.useRef)(null),eR=(0,r.useRef)(null),eA=(0,r.useRef)(null),eB=(0,r.useRef)(v);eB.current=v;let eO=(0,r.useCallback)(e=>{let t=eR.current;if(t){if("input"===t.type&&t.element){if(!document.contains(t.element))return;let r=t.element,a=r.selectionStart??r.value.length,n=r.selectionEnd??r.value.length;r.focus(),r.setSelectionRange(a,n),document.execCommand("insertText",!1,e)}else if("terminal"===t.type&&t.sendInput){let r="auto"===eD.submitModeRef.current&&eD.settings.voice.autoSubmitTerminal,a=t.sendInput;a(e),r&&setTimeout(()=>a("\r"),300)}eD.submitModeRef.current="auto"}},[eD.settings.voice.autoSubmitTerminal]);(0,r.useEffect)(()=>{if(m)return;let e={id:"card-modal",onRecordStart:()=>{let e=document.activeElement;e&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName)&&e.closest("[data-voice-target]")?eR.current={type:"input",element:e}:"terminal"===eB.current&&eA.current?eR.current={type:"terminal",sendInput:eA.current}:eR.current=null},onTranscriptionComplete:eO,onRelease:()=>{eR.current=null}};return eD.claimVoiceControl(e),()=>eD.releaseVoiceControl(e)},[m]),(0,r.useEffect)(()=>{let e=e=>{let t=e.target;"terminal"===eB.current?eD.setHasFieldFocus(!0):t.closest("[data-voice-target]")&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&eD.setHasFieldFocus(!0)},t=()=>{"terminal"!==eB.current&&setTimeout(()=>{if("terminal"===eB.current)return;let e=document.activeElement;e?.closest("[data-voice-target]")&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName)||eD.setHasFieldFocus(!1)},100)};return document.addEventListener("focusin",e),document.addEventListener("focusout",t),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t)}},[eD]),(0,r.useEffect)(()=>{"terminal"===v&&eD.setHasFieldFocus(!0)},[v,eD]);let eP=(0,r.useCallback)(()=>{let e=eS.current;e&&(e$(e.scrollTop>8),eL(e.scrollTop+e.clientHeight<e.scrollHeight-8))},[]),eW=(0,r.useRef)(v);(0,r.useEffect)(()=>{"notes"===v&&"notes"!==eW.current&&requestAnimationFrame(()=>{eS.current&&(eS.current.scrollTop=eS.current.scrollHeight),eP()}),eW.current=v},[v,eP]),(0,r.useEffect)(()=>{let t=e.agentNotes?.length??0;t>eM.current&&"notes"===v&&eS.current&&requestAnimationFrame(()=>{eS.current&&(eS.current.scrollTop=eS.current.scrollHeight),eP()}),eM.current=t,"notes"===v&&requestAnimationFrame(eP)},[e.agentNotes?.length,v,eP]);let eF=t=>{let r=e.agentNotes||[],a={id:r.reduce((e,t)=>Math.max(e,t.id),0)+1,agent:"User",text:t,timestamp:new Date().toISOString()};c({...e,agentNotes:[...r,a],updated_at:new Date().toISOString()})},[eH,ez]=(0,r.useState)(!1),[eU,eV]=(0,r.useState)(!1),eq=`${n}:card:${e.id}`,eJ=W?.status==="running"||W?.status==="detached";W?.hasHistory;let eK=(0,o.getTerminalClassFromStage)(a),eG=(0,o.getActionsForClass)(q.commands,q.classAssignments,eK,{projectId:n,cardType:e.type}),eX=e.problems.filter(e=>!e.resolved_at),eY=e.problems.length-eX.length,eQ=e.checklist||[],eZ=eQ.filter(e=>e.done).length,e0=e.agentNotes?.length??0,e1=[];if(e1.push(`Project: ${n} (${s})`),e1.push(""),e1.push(`Card: ${e.title} [${e.id}]`),e1.push(`Type: ${e.type} | Priority: ${e.priority} | Stage: ${a}`),e.description&&e1.push(`Description: ${e.description}`),e.areas.length>0&&e1.push(`Areas: ${e.areas.join(", ")}`),e.design_ref&&e1.push(`Design Doc: ${e.design_ref}`),e.feature_ref&&e1.push(`Feature Spec: ${e.feature_ref}`),e1.push(eQ.length>0?`Checklist: ${eZ}/${eQ.length} checked`:"Checklist: none"),e1.push(`Notes: ${e0}`),eX.length>0||eY>0){let e=[];for(let t of(eX.length>0&&e.push(`${eX.length} unresolved`),eY>0&&e.push(`${eY} resolved`),e1.push(`Problems: ${e.join(", ")}`),eX.slice(0,10))){let e=t.description.length>100?t.description.slice(0,97)+"...":t.description;e1.push(` - [${t.id}] ${t.severity}: ${e}`)}eX.length>10&&e1.push(` - ... and ${eX.length-10} more`)}else e1.push("Problems: none");let e2={cardContext:e1.join("\n"),card:{id:e.id,title:e.title,description:e.description,type:e.type,priority:e.priority,areas:e.areas,design_ref:e.design_ref,feature_ref:e.feature_ref},stage:a,project:{name:n},projectPath:s};(0,r.useEffect)(()=>{fetch("/api/areas").then(e=>e.ok?e.json():null).then(e=>{e?.areas&&K(e.areas)}).catch(()=>{})},[]),(0,r.useEffect)(()=>{let t=`card:${e.id}`;fetch("/api/bridge/sessions").then(e=>e.ok?e.json():null).then(e=>{if(!e?.sessions)return;let r=e.sessions.filter(e=>e.name?.endsWith(t)&&e.name?.startsWith(`${n}:`));if(0===r.length)return;let a={running:0,detached:1,stopped:2};r.sort((e,t)=>{let r=a[e.status]??3,n=a[t.status]??3;return r!==n?r-n:(t.lastActive??"").localeCompare(e.lastActive??"")});let o=r[0];if(F({status:o.status,hasHistory:o.hasHistory}),o.name){let e=o.name.split(":");2===e.indexOf("card")&&V(e[1])}}).catch(()=>{})},[n,e.id]);let[e5,e4]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e5||g||e7||!W||"running"!==W.status&&"detached"!==W.status||(b("terminal"),e4(!0))},[W,e5,g]);let e3=!!e.design_ref,e6=!!e.feature_ref,e8=!!e.test_ref,e9=eg.length>0,e7=!!e.automation,te=e7?ei:es[a],tt=e7?"border-t-2 border-orange-400/50 bg-void-800":en[a],tr=e7?"rgba(249, 115, 22, 0.12)":eo[a],ta=e7?"251, 146, 60":ed[a],tn="design"===v?e.design_ref:"feature"===v?e.feature_ref:"test"===v?e.test_ref:void 0,[to,ts]=(0,r.useState)({}),[ti,td]=(0,r.useState)({});(0,r.useEffect)(()=>{"design"!==v&&"feature"!==v&&"test"!==v||!tn||to[tn]||f||(k(!0),fetch(`/api/file?path=${encodeURIComponent(tn)}&projectId=${encodeURIComponent(n)}`).then(e=>e.json()).then(e=>{e.error?td(t=>({...t,[tn]:e.error})):ts(t=>({...t,[tn]:e.content}))}).catch(e=>{td(t=>({...t,[tn]:e.message}))}).finally(()=>{k(!1)}))},[v,tn,to,f,n]);let tl=()=>{C.trim()&&C!==e.title&&(M.current=C.trim(),c({...e,title:C.trim(),updated_at:new Date().toISOString()})),y(!1)},tc=()=>{if(!j.trim())return;let t={id:`prob-${Date.now()}`,description:j.trim(),severity:"major",created_at:new Date().toISOString()};c({...e,problems:[...e.problems,t],updated_at:new Date().toISOString()}),w("")},tu=t=>{let r=t.trim().toLowerCase();r&&!e.tags.includes(r)&&c({...e,tags:[...e.tags,r],updated_at:new Date().toISOString()}),eu("")},tx=async e=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}ez(!0),setTimeout(()=>ez(!1),2e3)}catch(e){console.error("Failed to copy:",e),ez(!0),setTimeout(()=>ez(!1),2e3)}},tm=async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e.title);else{let t=document.createElement("textarea");t.value=e.title,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}eV(!0),setTimeout(()=>eV(!1),2e3)}catch(e){console.error("Failed to copy title:",e),eV(!0),setTimeout(()=>eV(!1),2e3)}},th=e.problems.filter(e=>!e.resolved_at),tp=e.problems.filter(e=>e.resolved_at),tg=J.filter(t=>!e.areas.includes(t)),tv=(0,r.useCallback)(()=>{if("recording"!==eD.voiceState&&"paused"!==eD.voiceState&&"transcribing"!==eD.voiceState){if(m&&h){if(!C.trim())return void l();h({title:C.trim(),description:_,type:e.type,priority:e.priority,areas:e.areas,tags:e.tags,problems:e.problems,checklist:eb.current,...e.automation?{automation:e.automation}:{}})}else C.trim()&&C!==e.title&&c({...e,title:C.trim(),updated_at:new Date().toISOString()});l()}},[m,h,C,_,e,l,c,eD.voiceState]);return(0,r.useEffect)(()=>{let e=e=>{if("Escape"!==e.key||"terminal"===v)return;if(e.stopImmediatePropagation(),A)return void B(!1);let t=document.activeElement;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName)?t.blur():tv()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[v,A,tv]),(0,r.useEffect)(()=>{let e=e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;let t=e.target;if("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||t.isContentEditable)return;let r=["details"];e3&&r.push("design"),e6&&r.push("feature"),e8&&r.push("test"),r.push("notes"),e9&&r.push("checklist"),r.push("terminal");let a=r.indexOf(v);if(-1===a)return;let n="ArrowRight"===e.key?(a+1)%r.length:(a-1+r.length)%r.length;e.preventDefault(),b(r[n])};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[v,e3,e6,e8,e9]),(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-hidden lg:overflow-y-auto bg-black/50 p-0 lg:p-4 lg:pb-16 lg:pt-16",onMouseDown:e=>{T.current=e.target===e.currentTarget},onClick:e=>{e.target===e.currentTarget&&T.current&&tv()},children:[(0,t.jsxs)("div",{style:{"--focus-rgb":ta},className:`flex w-full max-w-full h-full lg:h-auto flex-col lg:max-w-4xl overflow-hidden rounded-none lg:rounded-xl bg-void-100 shadow-(--shadow-overlay) dark:bg-void-900 ${te.modalBorder}`,children:[(0,t.jsxs)("div",{className:`grain depth-glow flex items-start justify-between p-3 sm:p-4 ${te.headerBorder} ${te.header}`,children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,t.jsx)("span",{className:`rounded px-2 py-0.5 text-xs font-medium ${er[e.type]}`,children:e.type}),(0,t.jsx)("span",{className:`rounded px-2 py-0.5 text-xs font-medium capitalize ${ea[e.priority]||ea.medium}`,children:e.priority}),e.claude_session?.active&&(0,t.jsxs)("span",{className:"flex items-center gap-1 rounded bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800 dark:bg-green-900 dark:text-green-200",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),"Session Active"]})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[N?(0,t.jsx)("input",{ref:O,type:"text",value:C,"data-voice-target":!0,onChange:e=>{E("title"),M.current=e.target.value,S(e.target.value)},onBlur:()=>!m&&tl(),onFocus:()=>E("title"),onKeyDown:e=>{if((e.ctrlKey||e.metaKey)&&"Enter"===e.key){e.preventDefault(),tv();return}"Enter"===e.key?m?(e.preventDefault(),P.current?.focus()):tl():"Tab"!==e.key||e.shiftKey||(e.preventDefault(),m||tl(),P.current?.focus())},placeholder:m?"Enter card title...":"",className:"w-full rounded border bg-transparent px-1 text-base sm:text-xl font-bold text-void-900 outline-none dark:text-void-100",style:{borderColor:`rgb(${ta})`},autoFocus:!0}):(0,t.jsx)("h2",{onClick:()=>y(!0),className:"cursor-pointer text-base sm:text-xl font-bold text-void-900 hover:text-blue-600 dark:text-void-100 dark:hover:text-blue-400",title:"Click to edit",children:e.title}),!m&&(0,t.jsx)("button",{onClick:tm,className:"mt-1 flex-shrink-0 rounded p-1 text-void-400 hover:bg-void-200/50 hover:text-void-600 dark:hover:bg-void-700/50 dark:hover:text-void-300",title:eU?"Copied!":"Copy title",children:eU?(0,t.jsx)("svg",{className:"h-4 w-4 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),(0,t.jsxs)("div",{className:"flex flex-shrink-0 flex-col items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-3",children:[!m&&(0,t.jsxs)("label",{className:`flex items-center gap-1 sm:gap-2 ${e.archived?"cursor-not-allowed opacity-40":"cursor-pointer"}`,title:e.archived?"Unarchive card before enabling automation":"Toggle automation mode",children:[(0,t.jsx)("span",{className:`hidden sm:inline text-xs font-medium ${e7?"text-orange-600 dark:text-orange-400":"text-void-500 dark:text-void-400"}`,children:"Automation"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e7,disabled:!!e.archived,onClick:()=>{if(!e.archived)if(e7){let{automation:t,...r}=e;c({...r,updated_at:new Date().toISOString()}),p?.(!1)}else c({...e,automation:{enabled:!1,schedule:"",scheduleType:"recurring",provider:"claude",freshSession:!1,reportViaMessaging:!1},updated_at:new Date().toISOString()}),p?.(!0)},className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.archived?"cursor-not-allowed":"cursor-pointer"} ${e7?"bg-orange-500 focus:ring-orange-500":"bg-void-300 focus:ring-void-500 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${e7?"translate-x-4":"translate-x-0"}`})})]}),!m&&(0,t.jsxs)("label",{className:`flex items-center gap-1 sm:gap-2 ${e7?"cursor-not-allowed opacity-40":"cursor-pointer"}`,title:e7?"Automation cards cannot be archived":"Archive card",children:[(0,t.jsx)("span",{className:`hidden sm:inline text-xs font-medium ${e.archived?"text-red-600 dark:text-red-400":"text-void-500 dark:text-void-400"}`,children:"Archived"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.archived||!1,disabled:e7,onClick:()=>{e7||c({...e,archived:!e.archived,updated_at:new Date().toISOString()})},className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 ${e7?"cursor-not-allowed":"cursor-pointer"} ${e.archived?"bg-red-500 focus:ring-red-500":"bg-void-300 focus:ring-void-500 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${e.archived?"translate-x-4":"translate-x-0"}`})})]}),!m&&x&&(0,t.jsx)("button",{onClick:()=>B(!0),className:"rounded-lg p-2 text-void-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:"Delete card permanently",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,t.jsx)("button",{onClick:tv,className:"rounded-lg p-2 text-void-400 hover:bg-void-100 hover:text-void-600 dark:hover:bg-void-800 dark:hover:text-void-300",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),!m&&(0,t.jsx)("div",{ref:eI,children:(0,t.jsx)(Y.VoiceControlBar,{voiceState:eD.voiceState,elapsedSeconds:eD.elapsedSeconds,disabled:!eD.hasFieldFocus&&"idle"===eD.voiceState,error:eD.error,onRecord:eD.startRecording,onPause:eD.pauseRecording,onResume:eD.resumeRecording,onClear:eD.clearRecording,onSubmit:eD.submitRecording,onRetry:eD.retryTranscription,onOpenSettings:()=>{Date.now()-eE.current<200||eD.setShowSettings(!eD.showSettings)}})})]})]}),(0,t.jsxs)("div",{className:`grain grain-soft flex overflow-x-auto scrollbar-hide ${te.tabsBorder} ${te.tabs}`,children:[(0,t.jsx)("button",{onClick:()=>b("details"),className:`shrink-0 px-4 py-2 text-sm font-medium transition-colors ${"details"===v?e7?"border-b-2 border-orange-400 text-orange-500 dark:text-orange-400":"border-b-2 border-neon-blue-400 text-neon-blue-500 dark:text-neon-blue-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:"Details"}),e3&&(0,t.jsxs)("button",{onClick:()=>b("design"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"design"===v?"border-b-2 border-neon-blue-300 text-neon-blue-400 dark:text-neon-blue-300":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Design"]}),e6&&(0,t.jsxs)("button",{onClick:()=>b("feature"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"feature"===v?"border-b-2 border-neon-blue-400 text-neon-blue-500 dark:text-neon-blue-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),"Feature"]}),e8&&(0,t.jsxs)("button",{onClick:()=>b("test"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"test"===v?"border-b-2 border-[#00e676] text-[#00e676]/80 dark:text-[#00e676]/80":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),"Test"]}),(0,t.jsxs)("button",{onClick:()=>b("notes"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"notes"===v?"border-b-2 border-purple-400 text-purple-500 dark:text-purple-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),"Notes",(e.agentNotes?.length??0)>0&&(0,t.jsx)("span",{className:"rounded bg-purple-100 px-1.5 py-0.5 text-xs dark:bg-purple-900/50",children:e.agentNotes.length})]}),e9&&(0,t.jsxs)("button",{onClick:()=>b("checklist"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"checklist"===v?"border-b-2 border-[#ffd600] text-[#ffd600]/80 dark:text-[#ffd600]/80":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Checklist",(0,t.jsxs)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs dark:bg-amber-900/50",children:[eg.filter(e=>e.done).length,"/",eg.length]})]}),(0,t.jsxs)("button",{onClick:()=>b("terminal"),className:`flex shrink-0 items-center gap-2 px-4 py-2 text-sm font-medium transition-colors ${"terminal"===v?"border-b-2 border-neon-orange-400 text-neon-orange-500 dark:text-neon-orange-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("div",{className:`h-2 w-2 rounded-full ${eJ?"bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.6)]":"bg-void-400"}`}),"Terminal",eJ&&(0,t.jsx)("span",{className:"rounded bg-orange-100 px-1.5 py-0.5 text-xs dark:bg-orange-900/50",children:W?.status})]})]}),(0,t.jsx)("div",{className:"terminal"===v||"notes"===v?"min-h-0 flex-1 lg:flex-initial lg:h-[60vh]":"min-h-0 flex-1 overflow-y-auto overscroll-contain lg:flex-initial lg:max-h-[60vh]",children:"details"===v?(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[!e7&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Stage:"}),(0,t.jsx)("select",{value:a,onChange:t=>u(e.id,t.target.value),className:"stage-focus rounded border border-void-300 bg-white px-2 py-1 text-xs font-medium text-void-700 dark:border-void-600 dark:bg-void-800 dark:text-void-300",children:ee.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Priority:"}),(0,t.jsx)("select",{value:e.priority,onChange:t=>c({...e,priority:t.target.value,updated_at:new Date().toISOString()}),className:"stage-focus rounded border border-void-300 bg-white px-2 py-1 text-xs font-medium capitalize text-void-700 dark:border-void-600 dark:bg-void-800 dark:text-void-300",children:et.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsx)("div",{className:"h-4 w-px bg-void-300 dark:bg-void-600"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Areas:"}),e.areas.map(r=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-indigo-100 px-1.5 py-0.5 text-xs text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-300",children:[r,(0,t.jsx)("button",{onClick:()=>{c({...e,areas:e.areas.filter(e=>e!==r),updated_at:new Date().toISOString()})},className:"ml-0.5 hover:text-indigo-900 dark:hover:text-indigo-100",children:(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r)),tg.length>0&&(0,t.jsxs)("select",{value:"",onChange:t=>{var r;t.target.value&&(r=t.target.value,e.areas.includes(r)||c({...e,areas:[...e.areas,r],updated_at:new Date().toISOString()}))},className:"stage-focus rounded border border-dashed border-void-300 bg-transparent px-1.5 py-0.5 text-xs text-void-500 hover:border-void-400 dark:border-void-600 dark:text-void-400",children:[(0,t.jsx)("option",{value:"",children:"+ Add"}),tg.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]}),(0,t.jsx)("div",{className:"h-4 w-px bg-void-300 dark:bg-void-600"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Tags:"}),e.tags.map((r,a)=>(0,t.jsxs)("span",{draggable:!0,onDragStart:e=>{em(a),e.dataTransfer.effectAllowed="move"},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",ep(a)},onDragLeave:()=>ep(null),onDrop:t=>{t.preventDefault(),null!==ex&&((t,r)=>{if(t===r)return;let a=[...e.tags],[n]=a.splice(t,1);a.splice(r,0,n),c({...e,tags:a,updated_at:new Date().toISOString()}),em(null),ep(null)})(ex,a)},onDragEnd:()=>{em(null),ep(null)},className:`inline-flex cursor-grab items-center gap-1 rounded px-1.5 py-0.5 text-xs transition-all active:cursor-grabbing ${ex===a?"opacity-50":eh===a?"bg-orange-200 text-orange-700 ring-1 ring-orange-400/50 dark:bg-orange-900/30 dark:text-orange-300":0===a&&e7?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300":"bg-void-100 text-void-600 dark:bg-void-700 dark:text-void-400"}`,children:[r,(0,t.jsx)("button",{onClick:()=>{c({...e,tags:e.tags.filter(e=>e!==r),updated_at:new Date().toISOString()})},className:"ml-0.5 hover:text-void-900 dark:hover:text-void-100",children:(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r)),(0,t.jsx)("input",{type:"text",value:ec,onChange:e=>eu(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ec.trim()&&(e.preventDefault(),tu(ec))},onBlur:()=>{ec.trim()&&tu(ec)},placeholder:"+ tag",className:"stage-focus w-16 rounded border border-dashed border-void-300 bg-transparent px-1.5 py-0.5 text-xs text-void-500 placeholder-void-400 hover:border-void-400 dark:border-void-600 dark:text-void-400 dark:placeholder-void-500"})]}),(e.design_ref||e.feature_ref||e.test_ref)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"h-4 w-px bg-void-300 dark:bg-void-600"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Docs:"}),e.design_ref&&(0,t.jsx)("button",{onClick:()=>b("design"),className:"rounded p-1.5 text-purple-600 hover:bg-purple-100 dark:text-purple-400 dark:hover:bg-purple-900/30",title:e.design_ref,children:(0,t.jsx)("svg",{className:"h-8 w-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})})}),e.feature_ref&&(0,t.jsx)("button",{onClick:()=>b("feature"),className:"rounded p-1.5 text-blue-600 hover:bg-blue-100 dark:text-blue-400 dark:hover:bg-blue-900/30",title:e.feature_ref,children:(0,t.jsx)("svg",{className:"h-8 w-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})})}),e.test_ref&&(0,t.jsx)("button",{onClick:()=>b("test"),className:"rounded p-1.5 text-green-600 hover:bg-green-100 dark:text-green-400 dark:hover:bg-green-900/30",title:e.test_ref,children:(0,t.jsx)("svg",{className:"h-8 w-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]})]}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("label",{className:"mb-2 block text-sm font-medium text-void-700 dark:text-void-300",children:[e7?"Description / Automation Instructions":"Description",m&&(0,t.jsx)("span",{className:"ml-2 font-normal text-void-400",children:"(Ctrl+Enter to save)"})]}),(0,t.jsx)("textarea",{ref:P,value:_,"data-voice-target":!0,onChange:t=>{var r;return r=t.target.value,void(E("description"),L.current=r,$(r),c({...e,description:r,updated_at:new Date().toISOString()}))},onFocus:()=>E("description"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),tv())},placeholder:"Add a description...",className:"stage-focus h-[235px] w-full resize-none overflow-y-auto rounded-lg border border-void-300 bg-white p-3 text-sm text-void-700 dark:border-void-600 dark:bg-void-800 dark:text-void-300"})]}),e7&&e.automation?(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsx)(G,{config:e.automation,cardId:e.id,projectId:n,onChange:t=>{c({...e,automation:t,updated_at:new Date().toISOString()})}})}):(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,t.jsxs)("label",{className:"text-sm font-medium text-void-700 dark:text-void-300",children:["Problems / Issues (",th.length," open)"]}),th.length>0&&"testing"===a&&(0,t.jsx)("button",{onClick:()=>{let t=e.tags.includes("bug")?e.tags:[...e.tags,"bug"];c({...e,tags:t,type:"bug",updated_at:new Date().toISOString()}),u(e.id,"implementation")},className:"rounded bg-red-600 px-2 py-1 text-xs font-medium text-white hover:bg-red-700",children:"Push to Implementation"})]}),(0,t.jsxs)("div",{className:"mb-2 space-y-2",children:[th.map(r=>(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-2 dark:bg-red-900/20",children:[(0,t.jsx)("svg",{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-red-500",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-sm text-red-800 dark:text-red-200",children:r.description}),(0,t.jsx)("p",{className:"text-xs text-red-600 dark:text-red-400",children:new Date(r.created_at).toLocaleDateString()})]}),(0,t.jsx)("button",{onClick:()=>{var t;return t=r.id,void c({...e,problems:e.problems.map(e=>e.id===t?{...e,resolved_at:new Date().toISOString()}:e),updated_at:new Date().toISOString()})},className:"rounded px-2 py-1 text-xs text-red-600 hover:bg-red-100 dark:text-red-400 dark:hover:bg-red-900/40",children:"Resolve"})]},r.id)),tp.length>0&&(0,t.jsxs)("details",{className:"text-sm",children:[(0,t.jsxs)("summary",{className:"cursor-pointer text-void-500",children:[tp.length," resolved"]}),(0,t.jsx)("div",{className:"mt-2 space-y-1",children:tp.map(e=>(0,t.jsx)("div",{className:"rounded bg-void-100 p-2 text-void-500 line-through dark:bg-void-800",children:e.description},e.id))})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text","data-voice-target":!0,value:j,onChange:e=>w(e.target.value),placeholder:"Describe an issue...",className:"stage-focus flex-1 rounded-lg border border-void-300 bg-white px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 dark:text-void-100",onKeyDown:e=>"Enter"===e.key&&tc()}),(0,t.jsx)("button",{onClick:tc,className:"rounded-lg bg-void-200 px-3 py-2 text-sm font-medium text-void-700 hover:bg-void-300 dark:bg-void-700 dark:text-void-300 dark:hover:bg-void-600",children:"Add"})]})]})]}):"design"===v||"feature"===v||"test"===v?(0,t.jsxs)("div",{className:"relative p-4",children:[tn&&(0,t.jsx)("button",{onClick:()=>tx(tn),className:"absolute right-4 top-4 z-10 rounded p-1.5 text-void-400 hover:bg-void-100 hover:text-void-600 dark:hover:bg-void-800 dark:hover:text-void-300",title:eH?"Copied!":`Copy path: ${tn}`,children:eH?(0,t.jsx)("svg",{className:"h-4 w-4 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),f&&!to[tn]&&(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)("div",{className:"text-void-500",children:"Loading document..."})}),tn&&ti[tn]&&(0,t.jsxs)("div",{className:"rounded-lg bg-red-50 p-4 text-red-700 dark:bg-red-900/20 dark:text-red-300",children:["Error loading document: ",ti[tn]]}),tn&&to[tn]&&(0,t.jsx)(H.MarkdownContent,{children:to[tn]})]}):"checklist"===v?(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,t.jsxs)("h3",{className:"text-lg font-medium text-void-900 dark:text-void-100",children:["Checklist (",eg.filter(e=>e.done).length,"/",eg.length," complete)"]}),(0,t.jsx)("div",{className:"h-2 flex-1 mx-4 rounded-full bg-void-200 dark:bg-void-700",children:(0,t.jsx)("div",{className:"h-2 rounded-full bg-green-500 transition-all",style:{width:`${eg.filter(e=>e.done).length/eg.length*100}%`}})})]}),(0,t.jsx)("div",{className:"space-y-2",children:eg.map(r=>(0,t.jsxs)("label",{className:`flex cursor-pointer select-none items-center gap-3 rounded-lg p-3 transition-colors active:scale-[0.99] ${r.done?"bg-green-50 dark:bg-green-900/20":"bg-void-50 hover:bg-void-100 dark:bg-void-800 dark:hover:bg-void-700"}`,children:[(0,t.jsx)("input",{type:"checkbox",checked:r.done,onChange:()=>{var t;let a;return t=r.id,E("checklist"),a=eb.current.map(e=>e.id===t?{...e,done:!e.done}:e),void(eb.current=a,ej.current=JSON.stringify(a),ev(a),c({...e,checklist:a,updated_at:new Date().toISOString()}))},className:"h-5 w-5 flex-shrink-0 rounded border-void-300 text-green-600 focus:ring-green-500"}),(0,t.jsx)("span",{className:`flex-1 ${r.done?"text-void-500 line-through":"text-void-900 dark:text-void-100"}`,children:r.text})]},r.id))}),(0,t.jsx)("div",{className:"mt-4 flex gap-2",children:(0,t.jsx)("input",{type:"text","data-voice-target":!0,placeholder:"Add checklist item...",className:"stage-focus flex-1 rounded-lg border border-void-300 bg-white px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 dark:text-void-100",onKeyDown:t=>{if("Enter"===t.key&&t.currentTarget.value.trim()){var r;let a,n;r=t.currentTarget.value.trim(),E("checklist"),a={id:`check-${Date.now()}`,text:r,done:!1},n=[...eb.current,a],eb.current=n,ej.current=JSON.stringify(n),ev(n),c({...e,checklist:n,updated_at:new Date().toISOString()}),t.currentTarget.value=""}}})})]}):"notes"===v?(0,t.jsxs)("div",{className:"flex h-full flex-col p-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,t.jsxs)("h3",{className:"text-lg font-medium text-void-900 dark:text-void-100",children:["Notes (",e.agentNotes?.length??0,")"]}),(e.agentNotes?.length??0)>0&&(ey?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-void-500",children:"Clear all notes?"}),(0,t.jsx)("button",{onClick:()=>{c({...e,agentNotes:[],updated_at:new Date().toISOString()}),eC(!1)},className:"rounded px-2 py-1 text-xs font-medium text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:"Confirm"}),(0,t.jsx)("button",{onClick:()=>eC(!1),className:"rounded px-2 py-1 text-xs font-medium text-void-500 hover:bg-void-100 dark:hover:bg-void-800",children:"Cancel"})]}):(0,t.jsx)("button",{onClick:()=>eC(!0),className:"rounded px-2 py-1 text-xs font-medium text-void-500 hover:bg-void-100 hover:text-red-600 dark:hover:bg-void-800 dark:hover:text-red-400",children:"Clear All"}))]}),(0,t.jsxs)("div",{className:"relative min-h-0 flex-1",children:[e_&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-void-100/90 to-transparent dark:from-void-900/90"}),eT&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-void-100/90 to-transparent dark:from-void-900/90"}),(0,t.jsx)("div",{ref:eS,onScroll:eP,className:"h-full overflow-y-auto",children:(e.agentNotes?.length??0)===0?(0,t.jsxs)("div",{className:"py-8 text-center text-sm text-void-400",children:["No notes yet. Add a note below or use the CLI: ",(0,t.jsxs)("code",{className:"rounded bg-void-100 px-1.5 py-0.5 text-xs dark:bg-void-800",children:["sly-kanban notes ",e.id,' add "..."']})]}):(0,t.jsx)("div",{className:"space-y-3",children:e.agentNotes.map(r=>{let a=new Date(r.timestamp),n=new Date().getTime()-a.getTime(),o=Math.floor(n/6e4),s=Math.floor(n/36e5),i=Math.floor(n/864e5),d="just now";return i>0?d=`${i}d ago`:s>0?d=`${s}h ago`:o>0&&(d=`${o}m ago`),(0,t.jsxs)("div",{className:"group rounded-lg bg-void-50 p-3 dark:bg-void-800",children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r.agent&&(0,t.jsx)("span",{className:"rounded bg-purple-100 px-1.5 py-0.5 text-xs font-medium text-purple-700 dark:bg-purple-900/40 dark:text-purple-300",children:r.agent}),r.summary&&(0,t.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs font-medium text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",title:`Summary of ${r.summarizedCount??"?"} notes${r.dateRange?` (${r.dateRange})`:""}`,children:"Summary"}),(0,t.jsx)("span",{className:"text-xs text-void-400",children:d})]}),(0,t.jsx)("button",{onClick:()=>{var t;let a;return t=r.id,a=(e.agentNotes||[]).filter(e=>e.id!==t),void c({...e,agentNotes:a,updated_at:new Date().toISOString()})},className:"rounded p-1 text-void-400 opacity-0 transition-opacity hover:bg-void-200 hover:text-red-500 group-hover:opacity-100 dark:hover:bg-void-700 dark:hover:text-red-400",title:"Delete note",children:(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-void-700 dark:text-void-200",children:r.text})]},r.id)})})})]}),(0,t.jsxs)("div",{className:"mt-4 flex flex-shrink-0 gap-2",children:[(0,t.jsx)("textarea",{value:ew,onChange:e=>eN(e.target.value),"data-voice-target":!0,placeholder:"Type a note... (Shift+Enter for new line)",rows:2,className:"stage-focus flex-1 resize-none rounded-lg border border-void-300 bg-white px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 dark:text-void-100",onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&ew.trim()&&(e.preventDefault(),eF(ew.trim()),eN(""))}}),(0,t.jsx)("button",{onClick:()=>{ew.trim()&&(eF(ew.trim()),eN(""))},disabled:!ew.trim(),className:"rounded-lg bg-purple-500 px-4 py-2 text-sm font-medium text-white hover:bg-purple-600 disabled:opacity-50 disabled:cursor-not-allowed",children:"Add"})]})]}):"terminal"===v?(0,t.jsx)("div",{className:"h-full",children:(0,t.jsx)(d.ClaudeTerminalPanel,{sessionName:eq,cwd:s,actionsConfig:q,actions:eG,context:e2,cardId:e.id,cardAreas:e.areas,stage:e7?"automation":a,initialProvider:U??void 0,footerClassName:tt,tintColor:tr,onSessionChange:e=>F(e?{status:e.status}:null),onProviderChange:e=>V(e),voiceTerminalId:"card-modal",onTerminalReady:e=>{eA.current=e?.sendInput??null,e?eD.registerTerminal("card-modal",e):eD.unregisterTerminal("card-modal")}})}):null}),"terminal"!==v&&(0,t.jsxs)("div",{className:"flex items-center justify-between border-t border-void-200 px-4 py-2 text-xs text-void-500 dark:border-void-700 dark:text-void-400",children:[(0,t.jsxs)("span",{children:["Created: ",new Date(e.created_at).toLocaleDateString()]}),(0,t.jsxs)("span",{children:["Updated: ",new Date(e.updated_at).toLocaleDateString()]})]})]}),(0,t.jsx)(X,{open:A,onClose:()=>B(!1),onConfirm:()=>{x?.(e.id),B(!1)},title:"Delete Card",message:(0,t.jsxs)(t.Fragment,{children:["Are you sure you want to permanently delete ",(0,t.jsxs)("span",{className:"font-medium text-void-900 dark:text-void-200",children:['"',e.title,'"']}),"? This action cannot be undone."]})}),eD.showSettings&&(0,R.createPortal)((0,t.jsx)(el,{anchorRef:eI,children:(0,t.jsx)(Q.VoiceSettingsPopover,{settings:eD.settings.voice,onSave:e=>eD.updateSettings({voice:e}),onClose:()=>{eE.current=Date.now(),eD.setShowSettings(!1)}})}),document.body),"error"===eD.voiceState&&eD.error&&(0,R.createPortal)((0,t.jsx)(el,{anchorRef:eI,children:(0,t.jsx)(Z.VoiceErrorPopup,{error:eD.error,hasRecording:eD.hasRecording,onRetry:()=>eD.retryTranscription(),onClear:()=>eD.clearRecording(),onClose:()=>eD.clearRecording()})}),document.body)]})}var eu=e.i(82721);function ex({nextRun:e,enabled:a}){let n,o,[s,i]=(0,r.useState)(Date.now());if((0,r.useEffect)(()=>{if(!e||!a)return;let t=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(t)},[e,a]),!e||!a)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"font-mono text-2xl font-bold tracking-wider text-void-300 dark:text-void-600",children:"--:--"}),(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] text-void-300 dark:text-void-600",children:"idle"})]});let d=Math.max(0,new Date(e).getTime()-s);if(0===d)return(0,t.jsx)("div",{className:"flex flex-col items-center justify-center",children:(0,t.jsx)("span",{className:"font-mono text-2xl font-bold tracking-wider text-orange-500 animate-pulse",children:"NOW"})});let l=Math.floor(d/1e3),c=Math.floor(l/86400),u=Math.floor(l%86400/3600),x=Math.floor(l%3600/60),m=l%60,h=e=>String(e).padStart(2,"0");return c>0?(n=`${c}d ${h(u)}:${h(x)}`,o="days hrs min"):u>0?(n=`${h(u)}:${h(x)}:${h(m)}`,o="hrs min sec"):(n=`${h(x)}:${h(m)}`,o="min sec"),(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"font-mono text-2xl font-bold tabular-nums tracking-wider text-orange-500 dark:text-orange-400",children:n}),(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] text-void-400 dark:text-void-500",children:o})]})}function em({cards:e,activeCards:a,triggeringCards:n,onCardClick:o,onCardContextMenu:s,onCreateAutomation:i}){let[d,l]=(0,r.useState)(null),[c,u]=(0,r.useState)("");(0,r.useEffect)(()=>{fetch("/api/scheduler").then(e=>e.ok?e.json():null).then(e=>{e&&(l(e.running),e.abbreviation&&u(e.abbreviation))}).catch(()=>{})},[]);let x=e.reduce((e,t)=>{let r=t.tags[0]||"Ungrouped";return e[r]||(e[r]=[]),e[r].push(t),e},{}),m=Object.keys(x).sort((e,t)=>"Ungrouped"===e?1:"Ungrouped"===t?-1:e.localeCompare(t));return(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"mx-auto max-w-5xl",children:[(0,t.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,t.jsxs)("h2",{className:"text-lg font-semibold text-void-900 dark:text-void-100",children:["Automations",(0,t.jsxs)("span",{className:"ml-2 text-sm font-normal text-void-500 dark:text-void-400",children:["(",e.length," card",1!==e.length?"s":"",")"]}),c&&(0,t.jsx)("span",{className:"ml-2 rounded bg-void-100 px-1.5 py-0.5 text-xs font-normal text-void-500 dark:bg-void-700 dark:text-void-400",children:c})]}),(0,t.jsx)("button",{onClick:i,className:"rounded-lg border border-orange-500/50 bg-orange-400/10 px-3 py-1.5 text-sm font-medium text-orange-700 transition-colors hover:bg-orange-400/20 dark:border-orange-400/40 dark:text-orange-400",children:"+ New Automation"})]}),0===e.length?(0,t.jsxs)("div",{className:"py-16 text-center",children:[(0,t.jsx)("div",{className:"mb-3 text-void-300 dark:text-void-600",children:(0,t.jsx)("svg",{className:"mx-auto h-14 w-14",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,t.jsx)("p",{className:"text-sm text-void-500 dark:text-void-400",children:"No automations configured yet."}),(0,t.jsx)("p",{className:"mt-1 text-xs text-void-400 dark:text-void-500",children:"Toggle any card to automation mode, or create a new automation above."})]}):(0,t.jsx)("div",{className:"space-y-6",children:m.map(e=>(0,t.jsx)("div",{children:(0,t.jsxs)("details",{open:!0,children:[(0,t.jsxs)("summary",{className:"mb-3 cursor-pointer text-sm font-medium text-void-600 hover:text-void-800 dark:text-void-400 dark:hover:text-void-200",children:[(0,t.jsx)("span",{className:"ml-1",children:e}),(0,t.jsxs)("span",{className:"ml-1 text-void-400 dark:text-void-500",children:["(",x[e].length,")"]})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:x[e].map(e=>{let r=!!e.automation?.enabled,i=a.has(e.id),d=n?.has(e.id)&&!i;return(0,t.jsxs)("button",{onClick:()=>o(e),onContextMenu:t=>{s&&(t.preventDefault(),s(e,t))},className:`group overflow-hidden rounded-lg text-left transition-all border border-void-200/80 border-l-[3px] border-l-orange-500/70 bg-white shadow-(--shadow-card) transition-[transform,box-shadow,border-color] duration-200 hover:translate-y-0.5 hover:shadow-[0_2px_8px_rgba(249,115,22,0.2)] hover:border-orange-400/60 dark:hover:shadow-[0_2px_8px_rgba(249,115,22,0.15)] dark:border-void-700/60 dark:border-l-orange-400/60 dark:bg-void-800 dark:hover:border-orange-400/40 ${i?"active-glow-automation":""}`,children:[(0,t.jsx)("div",{className:`automation-chevron px-5 py-3 ${i?"automation-chevron-active":""}`,children:(0,t.jsxs)("div",{className:"relative z-10 flex items-stretch gap-4",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 flex flex-col gap-1.5 justify-center",children:[(0,t.jsx)("h3",{className:"text-base font-semibold text-void-900 dark:text-void-100 truncate",children:e.title}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("p",{className:"min-w-0 flex-1 truncate text-sm text-void-600 dark:text-void-400",children:e.automation?V(e.automation.schedule,e.automation.scheduleType,"No schedule",c||void 0):"No schedule"}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.automation?.provider&&(0,t.jsx)("span",{className:"rounded bg-void-100 px-1.5 py-0.5 text-[11px] text-void-600 dark:bg-void-700 dark:text-void-400",children:e.automation.provider}),(0,t.jsx)("span",{className:`rounded px-1.5 py-0.5 text-[11px] font-medium ${r?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,children:r?"Enabled":"Disabled"}),e.automation?.lastResult&&(0,t.jsx)("span",{className:`rounded px-1.5 py-0.5 text-[11px] ${"success"===e.automation.lastResult?"bg-green-50 text-green-600 dark:bg-green-900/20 dark:text-green-400":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"}`,children:"success"===e.automation.lastResult?"OK":"Err"})]})]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 flex-col items-center justify-center border-l border-void-200 pl-4 dark:border-void-700/50 min-h-[52px]",children:[d?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"animate-pulse font-mono text-2xl font-bold tracking-wider text-orange-500",children:"STARTING"}),(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] text-transparent",children:"placeholder"})]}):(0,t.jsx)(ex,{nextRun:e.automation?.nextRun,enabled:e.automation?.enabled}),(0,t.jsx)("div",{className:"mt-0.5 h-4 text-[10px] text-void-350 dark:text-void-600",children:e.automation?.lastRun?`Prev: ${new Date(e.automation.lastRun).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""})]})]})}),(0,t.jsx)("div",{className:"h-[5px] hazard-stripe"})]},e.id)})})]})},e))})]})})}function eh(){return(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})})}function ep(){return(0,t.jsx)("svg",{className:"h-3 w-3 text-void-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function eg({items:e,parentRect:a,onClose:n,onAction:o}){let s=(0,r.useRef)(null),[i,d]=(0,r.useState)(-1),[l,c]=(0,r.useState)({top:a.top,left:a.right+2});(0,r.useEffect)(()=>{if(!s.current)return;let e=s.current.getBoundingClientRect(),t=a.right+2,r=a.top;t+e.width>window.innerWidth-8&&(t=a.left-e.width-2),r+e.height>window.innerHeight-8&&(r=Math.max(8,window.innerHeight-e.height-8)),c({top:r,left:t})},[a]);let u=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>!e.disabled),x=(0,r.useCallback)(t=>{switch(t.stopPropagation(),t.key){case"ArrowDown":{t.preventDefault();let e=u.findIndex(({index:e})=>e===i),r=u[(e+1)%u.length];r&&d(r.index);break}case"ArrowUp":{t.preventDefault();let e=u.findIndex(({index:e})=>e===i),r=u[(e-1+u.length)%u.length];r&&d(r.index);break}case"ArrowLeft":case"Escape":t.preventDefault(),n();break;case"Enter":{t.preventDefault();let r=e[i];r&&!r.disabled&&r.onClick&&(r.onClick(),o())}}},[i,u,e,n,o]);return(0,r.useEffect)(()=>{s.current?.focus()},[]),(0,R.createPortal)((0,t.jsx)("div",{ref:s,tabIndex:-1,onKeyDown:x,"data-context-submenu":!0,className:"context-menu-no-ring fixed z-[52] min-w-[140px] rounded-lg border border-void-200 bg-white py-1 shadow-(--shadow-overlay) dark:border-void-600 dark:bg-void-800",style:{top:l.top,left:l.left},children:e.map((e,r)=>(0,t.jsxs)("div",{role:"menuitem",onMouseEnter:()=>d(r),onMouseLeave:()=>d(-1),onClick:()=>{e.disabled||(e.onClick?.(),o())},className:`flex w-full cursor-default items-center gap-2 px-3 py-1.5 text-left text-xs outline-none transition-colors ${e.disabled?"text-void-400 dark:text-void-500":e.danger?"cursor-pointer text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"cursor-pointer text-void-700 hover:bg-void-100 dark:text-void-300 dark:hover:bg-void-700"} ${i===r&&!e.disabled?"bg-void-100 dark:bg-void-700":""}`,children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0",children:e.checked&&(0,t.jsx)(eh,{})}),(0,t.jsx)("span",{className:"flex-1",children:e.label})]},r))}),document.body)}function ev({open:e,position:a,groups:n,accentColor:o,onClose:s}){let i,d=(0,r.useRef)(null),[l,c]=(0,r.useState)(-1),[u,x]=(0,r.useState)(null),[m,h]=(0,r.useState)(a),p=(0,r.useRef)(null),g=(0,r.useRef)(new Map),v=[];n.forEach((e,t)=>{t>0&&e.items.length>0&&v.push({type:"separator"}),e.items.forEach((e,r)=>{v.push({type:"item",item:e,groupIndex:t,itemIndex:r})})});let b=v.map((e,t)=>({entry:e,flatIndex:t})).filter(e=>"item"===e.entry.type).filter(({entry:e})=>!e.item.disabled||e.item.items);(0,r.useEffect)(()=>{if(!e||!d.current)return;let t=d.current.getBoundingClientRect(),r=a.x,n=a.y;r+t.width>window.innerWidth-8&&(r=Math.max(8,window.innerWidth-t.width-8)),n+t.height>window.innerHeight-8&&(n=Math.max(8,window.innerHeight-t.height-8)),h({x:r,y:n})},[e,a]),(0,r.useEffect)(()=>(e&&(c(-1),x(null),requestAnimationFrame(()=>{d.current?.focus(),b.length>0&&c(b[0].flatIndex)})),()=>{p.current&&clearTimeout(p.current)}),[e]),(0,r.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;if(!d.current?.contains(t)){for(let e of document.querySelectorAll("[data-context-submenu]"))if(e.contains(t))return;s()}},r=setTimeout(()=>document.addEventListener("mousedown",t),0);return()=>{clearTimeout(r),document.removeEventListener("mousedown",t)}},[e,s]);let f=(0,r.useCallback)(()=>{s()},[s]),k=(0,r.useCallback)(e=>{if(null===u)switch(e.key){case"ArrowDown":{e.preventDefault(),e.stopPropagation();let t=b.findIndex(({flatIndex:e})=>e===l),r=b[(t+1)%b.length];r&&c(r.flatIndex);break}case"ArrowUp":{e.preventDefault(),e.stopPropagation();let t=b.findIndex(({flatIndex:e})=>e===l),r=b[(t-1+b.length)%b.length];r&&c(r.flatIndex);break}case"ArrowRight":{e.preventDefault(),e.stopPropagation();let t=v[l];t?.type==="item"&&t.item.items&&x(l);break}case"Escape":e.preventDefault(),e.stopPropagation(),s();break;case"Enter":{e.preventDefault(),e.stopPropagation();let t=v[l];t?.type==="item"&&(t.item.items?x(l):!t.item.disabled&&t.item.onClick&&(t.item.onClick(),f()))}}},[l,b,v,u,s,f]),j=(0,r.useCallback)(e=>{c(e);let t=v[e];t?.type==="item"&&t.item.items?(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{x(e)},150)):(p.current&&clearTimeout(p.current),x(null))},[v]);return!e||"u"<typeof document?null:(0,R.createPortal)((0,t.jsxs)("div",{ref:d,tabIndex:-1,role:"menu",onKeyDown:k,className:"context-menu-no-ring fixed z-[51] min-w-[180px] overflow-hidden rounded-lg border border-void-200 bg-white shadow-(--shadow-overlay) dark:border-void-600 dark:bg-void-800",style:{top:m.y,left:m.x},children:[o&&(0,t.jsx)("div",{className:"h-0.5 w-full",style:{backgroundColor:(i=o.replace("border-t-","")).startsWith("[")&&i.endsWith("]")?i.slice(1,-1):({"void-400":"var(--color-void-400, #9ca3af)","neon-blue-400":"var(--color-neon-blue-400, #60a5fa)","neon-blue-500":"var(--color-neon-blue-500, #3b82f6)","green-400":"var(--color-green-400, #4ade80)","orange-400":"var(--color-orange-400, #fb923c)"})[i]||i}}),(0,t.jsx)("div",{className:"py-1",children:v.map((e,r)=>{if("separator"===e.type)return(0,t.jsx)("div",{className:"my-1 border-t border-void-200 dark:border-void-700"},`sep-${r}`);let{item:a}=e,n=!!a.items,o=a.disabled&&!n;return(0,t.jsxs)("div",{ref:e=>{e&&g.current.set(r,e)},role:"menuitem",onMouseEnter:()=>j(r),onClick:()=>{n?x(r):o||(a.onClick?.(),f())},className:`flex w-full cursor-default items-center gap-2 px-3 py-1.5 text-left text-xs outline-none transition-colors select-none ${o?"text-void-400 dark:text-void-500":a.danger?"cursor-pointer text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"cursor-pointer text-void-700 hover:bg-void-100 dark:text-void-300 dark:hover:bg-void-700"} ${l===r&&!o?"bg-void-100 dark:bg-void-700":""}`,children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0",children:a.checked&&(0,t.jsx)(eh,{})}),(0,t.jsx)("span",{className:"flex-1 truncate",children:a.label}),n&&(0,t.jsx)(ep,{})]},r)})}),v.map((e,r)=>{if("item"!==e.type||!e.item.items||u!==r)return null;let a=g.current.get(r);return a?(0,t.jsx)(eg,{items:e.item.items,parentRect:a.getBoundingClientRect(),onClose:()=>{x(null),d.current?.focus()},onAction:f},`sub-${r}`):null})]}),document.body)}var eb=e.i(68498);let ef=["backlog","design","implementation","testing","done"],ek=[{id:"backlog",label:"Backlog",color:"zinc"},{id:"design",label:"Design",color:"purple"},{id:"implementation",label:"Implementation",color:"blue"},{id:"testing",label:"Testing",color:"yellow"},{id:"done",label:"Done",color:"green"}],ej={backlog:[],design:[],implementation:[],testing:[],done:[]};function ew(e,t){return JSON.stringify(e)===JSON.stringify(t)}function eN({project:e,projectPath:a,showArchived:o=!1,showAutomations:i=!1,onAutomationToggle:d,onActiveAutomationsChange:l,onExitMode:c,onRefreshReady:u}){let x=(0,n.useSearchParams)(),m=(0,n.useRouter)(),h=(0,n.usePathname)(),[p,g]=(0,r.useState)(ej),[v,b]=(0,r.useState)(null),[f,k]=(0,r.useState)(null),[j,w]=(0,r.useState)(!1),[N,y]=(0,r.useState)(null),[C,S]=(0,r.useState)("idle"),[_,$]=(0,r.useState)(!1),[T,L]=(0,r.useState)(!1),D=(0,r.useRef)(null),R=(0,r.useRef)(null),A=(0,r.useRef)(null),B=(0,r.useRef)(!1),O=(0,r.useRef)(null),P=(0,r.useRef)(null),W=(0,r.useRef)(ej),H=(0,r.useRef)(!1),z=(0,r.useRef)(ej),[U,V]=(0,r.useState)(new Map),[q,J]=(0,r.useState)(new Set),K=(0,r.useRef)(new Set),G=(0,r.useRef)(null),[Y,Q]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[et,er]=(0,r.useState)(!1),[ea,en]=(0,r.useState)(new Set),eo=(0,r.useMemo)(()=>{if(j&&N)return N;if(!v)return null;if(f){let e=p[f]?.find(e=>e.id===v);if(e)return e}for(let e of ef){let t=p[e]?.find(e=>e.id===v);if(t)return t}return null},[p,v,f,j,N]);(0,r.useEffect)(()=>{if(v&&f&&!j&&!p[f]?.some(e=>e.id===v)){for(let e of ef)if(p[e]?.some(e=>e.id===v))return void k(e)}},[p,v,f,j]),z.current=p;let es=(0,r.useCallback)(async t=>{try{let r=await fetch("/api/bridge/sessions",{signal:t});if(r.ok){let t=(await r.json()).sessions||[],a=new Map,n=RegExp(`^${e.id}:(?:[^:]+:)?card:(.+)$`);for(let e of t){let t=e.name.match(n);if(t){let r=t[1];"running"===e.status?a.set(r,"running"):"detached"===e.status?a.set(r,"detached"):e.hasHistory&&a.set(r,"resumable")}}V(a)}}catch{}},[e.id]),ei=(0,r.useCallback)(async t=>{try{let r=await fetch("/api/bridge/stats",{signal:t});if(r.ok){let t=await r.json(),a=new Set,n=RegExp(`^${e.id}:(?:[^:]+:)?card:(.+)$`);for(let e of t.sessions)if(e.isActive){let t=e.name.match(n);t&&a.add(t[1])}let o=K.current,s=[...a].filter(e=>!o.has(e)),i=[...o].filter(e=>!a.has(e));s.length>0&&console.log(`[Activity] Cards became active: [${s.join(", ")}]`,t.sessions.filter(e=>e.isActive)),i.length>0&&console.log(`[Activity] Cards became inactive: [${i.join(", ")}]`),K.current=a,J(a),s.length>0&&en(e=>{let t=new Set(e),r=!1;for(let e of s)t.has(e)&&(t.delete(e),r=!0);return r?t:e})}}catch{}},[e.id]);(0,s.usePolling)(es,5e3),(0,s.usePolling)(ei,2e3),(0,r.useEffect)(()=>{if(!l)return;let e=new Set;for(let t of ef)for(let r of p[t])r.automation&&e.add(r.id);l([...q].some(t=>e.has(t)))},[q,p,l]);let ed=(0,r.useCallback)(async(t=!1,r)=>{if(!H.current&&!B.current)try{let a=await fetch(`/api/kanban?projectId=${e.id}`,{signal:r}),n=await a.json();if(t&&P.current===n.last_updated||H.current||B.current)return;P.current=n.last_updated;let o=n.stages||ej;g(o),W.current=o,L(!1)}catch{}},[e.id]),el=(0,r.useCallback)(async()=>{try{let t=await fetch(`/api/kanban?projectId=${e.id}`),r=await t.json();P.current=r.last_updated;let a=r.stages||ej;g(a),W.current=a,H.current=!1,L(!1)}catch{}},[e.id]);(0,r.useEffect)(()=>{u?.(el)},[el,u]),(0,r.useEffect)(()=>{ed().then(()=>$(!0))},[ed]),(0,r.useEffect)(()=>{if(!_)return;let e=x.get("card");if(e&&G.current!==e)for(let t of ef){let r=p[t]?.find(t=>t.id===e);if(r){G.current=e,b(r.id),k(t);break}}},[_,x,p]),(0,r.useEffect)(()=>(A.current=M.connectionManager.createManagedEventSource(`/api/kanban/stream?projectId=${e.id}`,{update:e=>{let t=JSON.parse(e.data);if(O.current){let e=new Date(O.current).getTime();if(new Date(t.timestamp).getTime()-e<2e3)return}B.current||H.current||(L(!0),setTimeout(()=>L(!1),3e3),ed())},onError:()=>{}}),()=>{A.current&&(M.connectionManager.closeConnection(A.current),A.current=null)}),[e.id,ed]),(0,r.useEffect)(()=>E.subscribe(t=>{"kanban-update"!==t.type&&"kanban-reload"!==t.type||t.projectId&&t.projectId!==e.id||B.current||H.current||ed()}),[e.id,ed]);let ex=(0,r.useCallback)(async e=>{B.current||H.current||await ed(!0,e)},[ed]);(0,s.usePolling)(ex,1e4);let eh=(0,r.useCallback)(async t=>{S("saving"),B.current=!0;try{let r=[],a=new Map;for(let e of ef)for(let t of W.current[e]||[])a.set(t.id,JSON.stringify(t)+"|"+e);for(let e of ef)for(let n of t[e]||[]){let t=a.get(n.id),o=JSON.stringify(n)+"|"+e;t!==o&&r.push(n.id),a.delete(n.id)}for(let e of a.keys())r.push(e);let n=await fetch("/api/kanban",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:e.id,stages:t,changedCardIds:r})});n.ok?(O.current=(await n.json()).last_updated,W.current=t,H.current=!ew(z.current,t),S("saved"),E.broadcast("kanban-update",e.id),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{S("idle")},800)):S("error")}catch(e){console.error("Failed to save kanban:",e),S("error")}finally{B.current=!1}},[e.id]);(0,r.useEffect)(()=>{if(_){if(ew(p,W.current)){H.current=!1,D.current&&(clearTimeout(D.current),D.current=null);return}return H.current=!0,D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{eh(p)},2e3),()=>{D.current&&clearTimeout(D.current),R.current&&clearTimeout(R.current)}}},[p,_,eh]);let ep=(e,t,r=!1)=>{er(r),b(e.id),k(t)},eg=()=>{let e=new Date().toISOString(),t={id:`card-${Date.now()}`,title:"",description:"",type:"feature",priority:"medium",areas:[],tags:[],problems:[],checklist:[],order:0,created_at:e,updated_at:e};y(t),b(t.id),k("backlog"),w(!0)},eN=(e,t,r)=>{g(a=>{var n,s;let i=null,d=null;for(let t of ef){let r=a[t].find(t=>t.id===e);if(r){i=t,d=r;break}}if(!i||!d)return a;let l=a[i].filter(t=>t.id!==e),c=[...i===t?l:a[t]].filter(e=>o?!0===e.archived:!e.archived&&!e.automation).sort((e,t)=>e.order-t.order),u=r??c.length;if(i===t&&void 0!==r){let t=[...a[i]].filter(e=>o?!0===e.archived:!e.archived&&!e.automation).sort((e,t)=>e.order-t.order).findIndex(t=>t.id===e);-1!==t&&t<r&&(u=Math.max(0,r-1))}let x=(n=c,s=u,0===n.length?10:0===s?n[0].order/2:s>=n.length?n[n.length-1].order+10:(n[s-1].order+n[s].order)/2),m={...d,order:x,updated_at:new Date().toISOString()};return i===t?{...a,[i]:[...l,m]}:{...a,[i]:l,[t]:[...a[t],m]}}),v===e&&k(t)},ey=(0,r.useCallback)((e,t,r)=>{r.preventDefault(),Q({position:{x:r.clientX,y:r.clientY},card:e,stage:t})},[]),eC=(0,r.useCallback)(()=>{Q(null)},[]),eS=(0,r.useCallback)((e,t)=>{let r={backlog:"Backlog",design:"Design",implementation:"Implementation",testing:"Testing",done:"Done"},a={critical:"Critical",high:"High",medium:"Medium",low:"Low"};return[{items:[{label:"Move to stage",items:["backlog","design","implementation","testing","done"].map(a=>({label:r[a],checked:a===t,disabled:a===t,onClick:()=>{eN(e.id,a)}}))},{label:"Set priority",items:["critical","high","medium","low"].map(r=>({label:a[r],checked:r===e.priority,disabled:r===e.priority,onClick:()=>{g(a=>({...a,[t]:a[t].map(t=>t.id===e.id?{...t,priority:r,updated_at:new Date().toISOString()}:t)}))}}))}]},{items:[{label:"Open details",onClick:()=>{ep(e,t,!0)}},{label:"Copy",items:[{label:"Card ID",onClick:()=>{navigator.clipboard.writeText(e.id)}},{label:"Title",onClick:()=>{navigator.clipboard.writeText(e.title)}},{label:"Description",onClick:()=>{navigator.clipboard.writeText(e.description||"")}}]}]},{items:[{label:e.automation?"Archive (disabled — automation)":e.archived?"Unarchive":"Archive",disabled:!!e.automation,onClick:()=>{e.automation||g(r=>({...r,[t]:r[t].map(t=>t.id===e.id?{...t,archived:!e.archived,updated_at:new Date().toISOString()}:t)}))}},{label:"Delete",danger:!0,onClick:()=>{ee(e)}}]}]},[eN]),e_=(0,r.useCallback)((t,r)=>{let a={critical:"Critical",high:"High",medium:"Medium",low:"Low"},n=[{items:[{label:"Set priority",items:["critical","high","medium","low"].map(e=>({label:a[e],checked:e===t.priority,disabled:e===t.priority,onClick:()=>{g(a=>({...a,[r]:a[r].map(r=>r.id===t.id?{...r,priority:e,updated_at:new Date().toISOString()}:r)}))}}))}]},{items:[{label:"Open details",onClick:()=>{ep(t,r,!0)}},{label:"Copy",items:[{label:"Card ID",onClick:()=>{navigator.clipboard.writeText(t.id)}},{label:"Title",onClick:()=>{navigator.clipboard.writeText(t.title)}},{label:"Description",onClick:()=>{navigator.clipboard.writeText(t.description||"")}}]}]},{items:[{label:"Delete",danger:!0,onClick:()=>{ee(t)}}]}];return t.automation&&n.push({items:[{label:t.automation.enabled?"Disable":"Enable",onClick:()=>{g(e=>({...e,[r]:e[r].map(e=>e.id===t.id&&e.automation?{...e,automation:{...e.automation,enabled:!e.automation.enabled},updated_at:new Date().toISOString()}:e)}))}},{label:"Run now",onClick:()=>{en(e=>new Set(e).add(t.id)),fetch("/api/scheduler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trigger",cardId:t.id,projectId:e.id})}).catch(()=>{en(e=>{let r=new Set(e);return r.delete(t.id),r})}),setTimeout(()=>{en(e=>{let r=new Set(e);return r.delete(t.id),r})},15e3)}}]}),n},[]),e$=(0,r.useCallback)(e=>{for(let t of ef)if(p[t].find(t=>t.id===e)){g(r=>({...r,[t]:r[t].filter(t=>t.id!==e)}));break}ee(null)},[p]);return((0,I.useKeyboardShortcuts)({onEscape:()=>{(o||i)&&c?c():m.push("/")},enabled:!eo}),_)?(0,t.jsxs)("div",{className:"relative flex flex-1 flex-col overflow-hidden",children:[(0,t.jsx)(eu.ConnectionStatusIndicator,{position:"top-right"}),(0,t.jsx)(eb.VersionUpdateToast,{}),(0,t.jsxs)("div",{className:"absolute top-1 right-4 z-10 flex gap-3",children:[T&&(0,t.jsx)("span",{className:"text-xs text-blue-600 dark:text-blue-400",children:"↻ Updated externally"}),(0,t.jsx)("span",{className:`text-xs transition-opacity ${"idle"===C?"opacity-0 duration-500":"saved"===C?"opacity-60 text-green-600 dark:text-green-400 duration-500":"saving"===C?"opacity-60 text-void-500 dark:text-void-400 duration-150":"opacity-100 text-red-600 dark:text-red-400 duration-150"}`,children:"saving"===C?"●":"error"===C?"✗ Save failed":"●"})]}),(0,t.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[i?(0,t.jsx)(em,{cards:ef.flatMap(e=>p[e].filter(e=>!!e.automation&&!e.archived)),activeCards:q,triggeringCards:ea,onCardClick:e=>{let t=ef.find(t=>p[t].some(t=>t.id===e.id));t&&ep(e,t)},onCardContextMenu:(e,t)=>{let r=ef.find(t=>p[t].some(t=>t.id===e.id));r&&ey(e,r,t)},onCreateAutomation:()=>{let e=new Date().toISOString(),t={id:`card-${Date.now()}`,title:"",description:"",type:"chore",priority:"medium",areas:[],tags:[],problems:[],checklist:[],automation:{enabled:!1,schedule:"",scheduleType:"recurring",provider:"claude",freshSession:!1,reportViaMessaging:!1},created_at:e,updated_at:e,order:0};y(t),b(t.id),k("backlog"),w(!0)}}):(0,t.jsx)("div",{className:"flex-1 overflow-x-auto p-4 pt-2 snap-x snap-mandatory sm:snap-none",children:(0,t.jsx)("div",{className:"mx-auto flex h-full w-full max-w-[1984px] gap-4",children:ek.map(e=>(0,t.jsx)(F,{stage:e,cards:[...p[e.id]].filter(e=>o?!0===e.archived:!e.archived&&!e.automation).sort((e,t)=>e.order-t.order),cardSessions:U,activeCards:q,onCardClick:t=>ep(t,e.id),onCardContextMenu:(t,r)=>ey(t,e.id,r),onMoveCard:eN,onAddCardClick:"backlog"!==e.id||o?void 0:eg},e.id))})}),eo&&f&&(0,t.jsx)(ec,{card:eo,stage:f,projectId:e.id,projectPath:a,onClose:()=>{ew(p,W.current)||(D.current&&(clearTimeout(D.current),D.current=null),eh(p)),b(null),k(null),w(!1),y(null),G.current=null,x.get("card")&&m.replace(h,{scroll:!1})},onUpdate:e=>{j&&N&&e.id===N.id?y(e):f&&g(t=>({...t,[f]:t[f].map(t=>t.id===e.id?e:t)}))},onMove:eN,onDelete:e=>{f&&(g(t=>({...t,[f]:t[f].filter(t=>t.id!==e)})),b(null),k(null))},isCreateMode:j,onCreate:j?e=>{let t=new Date().toISOString(),r={...e,id:`card-${Date.now()}`,order:p.backlog.length>0?Math.max(...p.backlog.map(e=>e.order))+10:10,created_at:t,updated_at:t};g(e=>({...e,backlog:[...e.backlog,r]}))}:void 0,onAutomationToggle:d,suppressAutoTerminal:et})]}),(0,t.jsx)(ev,{open:!!Y,position:Y?.position??{x:0,y:0},groups:Y?Y.card.automation&&i?e_(Y.card,Y.stage):eS(Y.card,Y.stage):[],accentColor:Y?Y.card.automation&&i?"border-t-orange-400":({backlog:"border-t-void-400",design:"border-t-neon-blue-400",implementation:"border-t-neon-blue-500",testing:"border-t-[#ff6a33]",done:"border-t-green-400"})[Y.stage]||"border-t-void-400":void 0,onClose:eC}),(0,t.jsx)(X,{open:!!Z,onClose:()=>ee(null),onConfirm:()=>{Z&&e$(Z.id)},title:"Delete Card",message:Z?(0,t.jsxs)(t.Fragment,{children:["Are you sure you want to permanently delete ",(0,t.jsxs)("span",{className:"font-medium text-void-900 dark:text-void-200",children:['"',Z.title,'"']}),"? This action cannot be undone."]}):""}),(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-[1.2px] left-4 w-72 text-center text-[10px] text-void-400 dark:text-void-600",children:"© 2026 SlyCode (slycode.ai). All rights reserved."})]}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,t.jsx)("div",{className:"text-void-500",children:"Loading kanban..."})})}function ey({project:e,projectPath:a}){let[n,o]=(0,r.useState)(!1),[s,i]=(0,r.useState)(!1),[d,l]=(0,r.useState)(!1),c=(0,r.useRef)(null),u=(0,r.useCallback)(async()=>{await c.current?.()},[]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(L,{name:e.name,description:e.description,tags:e.tags,projectId:e.id,projectPath:a,showArchived:n,onToggleArchived:()=>{o(!n),n||i(!1)},showAutomations:s,hasActiveAutomations:d,onToggleAutomations:()=>{i(!s),s||o(!1)},onRefresh:u}),(0,t.jsx)(r.Suspense,{children:(0,t.jsx)(eN,{project:e,projectPath:a,showArchived:n,showAutomations:s,onActiveAutomationsChange:l,onAutomationToggle:e=>{i(e),e&&o(!1)},onExitMode:()=>{o(!1),i(!1)},onRefreshReady:e=>{c.current=e}})})]})}e.s(["ProjectView",()=>ey],72630)},27444,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(64103),n=e.i(79951),o=e.i(1088);function s({projectId:e,projectName:s,projectDescription:i,projectPath:d,children:l}){let[c,u]=(0,r.useState)(!1),[x,m]=(0,r.useState)(!1),h=(0,o.useVoice)(),p=(0,r.useCallback)(async t=>{let r=RegExp(`^${e}:(?:[^:]+:)?global$`);try{let e=await fetch("/api/bridge/stats",{signal:t});if(e.ok){let t=await e.json(),a=t.sessions.find(e=>"global:global"===e.name||/^global:[^:]+:global$/.test(e.name)),n=t.sessions.find(e=>r.test(e.name));u(a?.isActive??!1),m(n?.isActive??!1)}}catch{}},[e]);return(0,a.usePolling)(p,2e3),(0,r.useEffect)(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),(0,t.jsxs)("div",{className:`flex h-svh flex-col overflow-hidden bg-void-50 dark:bg-void-950 ${c?"active-glow-border-left":""}`,children:[l,(0,t.jsx)(n.GlobalClaudePanel,{projectId:e,projectName:s,projectDescription:i,projectPath:d,isActive:x,voiceTerminalId:"project-global",onTerminalReady:e=>{e?h.registerTerminal("project-global",e):h.unregisterTerminal("project-global")}})]})}e.s(["ProjectPageClient",()=>s])}]);
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,72630,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(22016),n=e.i(18566),o=e.i(38307),s=e.i(64103),i=e.i(1088),d=e.i(97480);let l=[{key:"card",label:"Card",template:"{{card.title}} [{{card.id}}]\nType: {{card.type}} | Priority: {{card.priority}}\n{{card.description}}",color:"bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-200"},{key:"project",label:"Project",template:"{{project.name}} ({{projectPath}})",color:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},{key:"stage",label:"Stage",template:"{{stage}}",color:"bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200"},{key:"areas",label:"Areas",template:"{{card.areas}}",color:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200"}];function c({onClose:e,projectId:a="",projectPath:n,actionUpdateCount:l=0,onShowActionUpdates:c}){let u,[h,g]=(0,r.useState)(null),[v,b]=(0,r.useState)(null),[f,k]=(0,r.useState)([]),[j,w]=(0,r.useState)(!0),[N,y]=(0,r.useState)(null),[C,S]=(0,r.useState)("idle"),[_,$]=(0,r.useState)(null),[T,L]=(0,r.useState)(null),[M,D]=(0,r.useState)({level:"list",commandId:null}),[E,I]=(0,r.useState)("commands"),[R,A]=(0,r.useState)(!1),[B,O]=(0,r.useState)(!1),[P,W]=(0,r.useState)(0),F=(0,i.useVoice)(),H=(0,r.useRef)(null),z=(0,r.useRef)(!1),U=(0,r.useCallback)(async(e=!1)=>{try{e||w(!0);let[t,r,a,n]=await Promise.all([fetch("/api/terminal-classes"),fetch("/api/sly-actions"),fetch("/api/dashboard"),fetch("/api/sly-actions")]);if(!t.ok||!r.ok)throw Error("Failed to load configuration");let s=await t.json(),i=await r.json();if(a.ok){let e=((await a.json()).projects||[]).map(e=>e.id);k(e)}n.ok&&$((0,o.normalizeActionsConfig)(await n.json())),g(s),b(i),e&&W(e=>e+1)}catch(t){e||y(t instanceof Error?t.message:"Failed to load configuration")}finally{e||w(!1)}},[]);(0,r.useEffect)(()=>{U()},[U]),(0,r.useEffect)(()=>{B&&!R&&U(!0),O(R)},[R,B,U]);let V=(0,r.useCallback)(async()=>{z.current||U(!0)},[U]);(0,s.usePolling)(V,5e3);let q=(0,r.useCallback)(e=>{z.current=e},[]),J=(0,r.useCallback)(async e=>{S("saving");try{if(!(await fetch("/api/sly-actions",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw Error("Save failed");b(e),S("saved"),setTimeout(()=>S("idle"),2e3)}catch{S("error"),setTimeout(()=>S("idle"),3e3)}},[]),K=(0,r.useCallback)((e,t)=>{v&&J({...v,commands:{...v.commands,[e]:{...v.commands[e],...t}}})},[v,J]),G=(0,r.useCallback)((e,t,r)=>{v&&(J({...v,commands:{...v.commands,[e]:{label:t,description:"New command",group:r||"Ungrouped",placement:"both",prompt:"Enter your command prompt here...",scope:"global",projects:[]}}}),D({level:"edit",commandId:e}))},[v,J]),X=(0,r.useCallback)(e=>{if(!v)return;let{[e]:t,...r}=v.commands,a=Object.fromEntries(Object.entries(v.classAssignments||{}).map(([t,r])=>[t,r.filter(t=>t!==e)]));J({...v,commands:r,classAssignments:a}),D({level:"list",commandId:null})},[v,J]),Y=v?[...new Set(Object.values(v.commands).map(e=>e.group).filter(e=>!!e))].sort():[],Q=e=>D({level:"edit",commandId:e}),Z=(0,r.useCallback)(()=>{D({level:"list",commandId:null})},[]),ee=M.commandId&&v?v.commands[M.commandId]:null;(0,r.useEffect)(()=>{let t=t=>{"Escape"!==t.key||R||(t.stopImmediatePropagation(),"list"!==M.level?Z():e())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[M.level,R,e,Z]);let et=_?(0,o.getActionsForClass)(_.commands,_.classAssignments,"action-assistant"):[];return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t=>{t.target===t.currentTarget&&("idle"===F.voiceState||"disabled"===F.voiceState)&&e()},children:(0,t.jsxs)("div",{className:"flex h-[90vh] w-[90vw] max-w-5xl flex-col overflow-hidden rounded-xl bg-white shadow-(--shadow-overlay) dark:bg-void-900",onClick:e=>e.stopPropagation(),children:[(u="Sly Actions","edit"===M.level&&ee&&(u=ee.label),(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-void-200 px-6 py-4 dark:border-void-700",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["list"!==M.level&&(0,t.jsx)("button",{onClick:Z,className:"rounded p-1 hover:bg-void-100 dark:hover:bg-void-700",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),(0,t.jsx)("h2",{className:"text-lg font-semibold",children:u})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:["saving"===C&&(0,t.jsx)("span",{className:"text-sm text-void-500",children:"Saving..."}),"saved"===C&&(0,t.jsx)("span",{className:"text-sm text-green-600 dark:text-green-400",children:"Saved"}),"error"===C&&(0,t.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400",children:"Save failed"}),(0,t.jsx)("button",{onClick:()=>U(!0),className:"rounded p-1 hover:bg-void-100 dark:hover:bg-void-700",title:"Refresh commands",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,t.jsx)("button",{onClick:e,className:"rounded p-1 hover:bg-void-100 dark:hover:bg-void-700",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})),(0,t.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[(0,t.jsx)("div",{className:`h-full overflow-y-auto ${R?"opacity-30 pointer-events-none":""}`,children:(()=>{if(j)return(0,t.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,t.jsx)("span",{className:"text-void-500",children:"Loading configuration..."})});if(N)return(0,t.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,t.jsx)("span",{className:"text-red-500",children:N})});if(!v||!h)return(0,t.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,t.jsx)("span",{className:"text-void-500",children:"No configuration found"})});switch(M.level){case"list":return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex border-b border-void-200 dark:border-void-700 px-6",children:[(0,t.jsx)("button",{onClick:()=>I("commands"),className:`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors ${"commands"===E?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-void-500 hover:text-void-700 dark:hover:text-void-300"}`,children:"Commands"}),(0,t.jsx)("button",{onClick:()=>I("classes"),className:`px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors ${"classes"===E?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-void-500 hover:text-void-700 dark:hover:text-void-300"}`,children:"Classes"}),l>0&&c&&(0,t.jsxs)("button",{onClick:c,className:"ml-auto px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors border-transparent text-neon-blue-500 hover:text-neon-blue-400 flex items-center gap-1.5",children:["Updates",(0,t.jsx)("span",{className:"flex h-5 min-w-[20px] items-center justify-center rounded-full bg-neon-blue-500 px-1.5 text-[11px] font-bold text-white",children:l})]})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:"commands"===E?(0,t.jsx)(x,{commands:v.commands,onSelectCommand:Q,onCreateCommand:G,existingGroups:Y}):(0,t.jsx)(m,{commands:v.commands,classAssignments:v.classAssignments||{},classes:h,onUpdate:e=>{J({...v,classAssignments:e})}})})]});case"edit":return M.commandId&&ee?(0,t.jsx)(p,{commandId:M.commandId,command:ee,existingGroups:Y,availableProjects:f,onUpdate:e=>K(M.commandId,e),onDelete:()=>X(M.commandId),onEditingChange:q},`${M.commandId}-${P}`):null}})()}),R&&(0,t.jsx)("div",{className:"absolute inset-0",onClick:()=>A(!1)})]}),(0,t.jsxs)("div",{className:`border-t border-void-200 dark:border-void-700 transition-all duration-300 ${R?"h-[60%]":"h-12"}`,children:[(0,t.jsxs)("button",{onClick:()=>A(!R),className:"flex w-full items-center justify-between px-6 py-3 hover:bg-void-50 dark:hover:bg-void-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Action Assistant"}),(0,t.jsx)("span",{className:"text-xs text-void-400",children:"(Terminal for configuring actions)"})]}),(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform ${R?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})]}),R&&_&&(0,t.jsx)("div",{className:"h-[calc(100%-48px)] overflow-hidden",children:(0,t.jsx)(d.ClaudeTerminalPanel,{sessionName:"action-assistant:global",cwd:n,actionsConfig:_,actions:et,context:{project:{name:"SlyCode"},projectPath:n},onSessionChange:e=>L(e?{hasHistory:e.hasHistory}:null),voiceTerminalId:"action-assistant",onTerminalReady:e=>{H.current=e?.sendInput??null,e?F.registerTerminal("action-assistant",e):F.unregisterTerminal("action-assistant")}})})]})]})})}let u={startup:{label:"Startup",color:"bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-200"},toolbar:{label:"Toolbar",color:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},both:{label:"Both",color:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200"}};function x({commands:e,onSelectCommand:a,onCreateCommand:n,existingGroups:o}){let s=Object.entries(e),[i,d]=(0,r.useState)(new Set),[l,c]=(0,r.useState)(!1),[x,m]=(0,r.useState)(""),[h,p]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),b=s.reduce((e,[t,r])=>{let a=r.group||"Ungrouped";return e[a]||(e[a]=[]),e[a].push([t,r]),e},{});Object.values(b).forEach(e=>{e.sort((e,t)=>e[1].label.localeCompare(t[1].label))});let f=Object.keys(b).sort((e,t)=>"Ungrouped"===e?1:"Ungrouped"===t?-1:e.localeCompare(t));return(0,t.jsxs)("div",{className:"p-6",children:[f.map(e=>{let r=b[e],n=i.has(e);return(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("button",{onClick:()=>{d(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},className:"flex items-center gap-2 w-full text-left py-2 px-3 bg-void-100 dark:bg-void-800 rounded-t-lg hover:bg-void-200 dark:hover:bg-void-700",children:[(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform ${n?"":"rotate-90"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,t.jsx)("span",{className:"font-medium text-sm",children:e}),(0,t.jsxs)("span",{className:"text-xs text-void-500",children:["(",r.length,")"]})]}),!n&&(0,t.jsxs)("table",{className:"w-full border border-t-0 border-void-200 dark:border-void-700 rounded-b-lg overflow-hidden",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-void-200 text-left text-xs text-void-500 dark:border-void-700 bg-void-50 dark:bg-void-800/50",children:[(0,t.jsx)("th",{className:"py-2 px-3 font-medium",children:"Name"}),(0,t.jsx)("th",{className:"py-2 px-3 font-medium",children:"Label"}),(0,t.jsx)("th",{className:"py-2 px-3 font-medium",children:"Placement"}),(0,t.jsx)("th",{className:"py-2 px-3 w-8"})]})}),(0,t.jsx)("tbody",{children:r.map(([e,r])=>{let n=u[r.placement]||u.both;return(0,t.jsxs)("tr",{onClick:()=>a(e),className:"cursor-pointer border-b border-void-100 hover:bg-void-50 dark:border-void-800 dark:hover:bg-void-800 last:border-b-0",children:[(0,t.jsx)("td",{className:"py-2 px-3 font-mono text-xs",children:e}),(0,t.jsxs)("td",{className:"py-2 px-3 text-sm relative group",children:[r.label,r.description&&(0,t.jsx)("div",{className:"absolute left-0 top-full z-50 mt-1 hidden w-64 rounded-md bg-void-800 px-3 py-2 text-xs text-void-100 shadow-(--shadow-overlay) group-hover:block dark:bg-void-700",children:r.description})]}),(0,t.jsx)("td",{className:"py-2 px-3",children:(0,t.jsx)("span",{className:`rounded-full px-1.5 py-0.5 text-xs ${n.color}`,children:n.label})}),(0,t.jsx)("td",{className:"py-2 px-3 text-right",children:(0,t.jsx)("svg",{className:"inline h-3 w-3 text-void-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]},e)})})]})]},e)}),l?(0,t.jsxs)("div",{className:"mt-4 p-4 border border-void-300 dark:border-void-600 rounded-lg bg-void-50 dark:bg-void-800",children:[(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Create New Command"}),(0,t.jsxs)("div",{className:"flex gap-3 mb-3",children:[(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"block text-xs text-void-500 mb-1",children:"Command ID"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>m(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"my-command",className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm font-mono dark:border-void-600 dark:bg-void-700","data-voice-target":!0,autoFocus:!0})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"block text-xs text-void-500 mb-1",children:"Label"}),(0,t.jsx)("input",{type:"text",value:h,onChange:e=>p(e.target.value),placeholder:"My Command",className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-700","data-voice-target":!0})]}),(0,t.jsxs)("div",{className:"w-40",children:[(0,t.jsx)("label",{className:"block text-xs text-void-500 mb-1",children:"Group"}),(0,t.jsxs)("select",{value:g,onChange:e=>v(e.target.value),className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-700",children:[(0,t.jsx)("option",{value:"",children:"Ungrouped"}),o.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{onClick:()=>c(!1),className:"rounded px-3 py-1.5 text-sm hover:bg-void-200 dark:hover:bg-void-600",children:"Cancel"}),(0,t.jsx)("button",{onClick:()=>{x.trim()&&h.trim()&&(n(x.trim(),h.trim(),g.trim()),c(!1),m(""),p(""),v(""))},disabled:!x.trim()||!h.trim(),className:"rounded bg-blue-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50",children:"Create"})]})]}):(0,t.jsx)("div",{className:"mt-4 flex justify-end",children:(0,t.jsx)("button",{onClick:()=>c(!0),className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",children:"+ New Command"})})]})}function m({commands:e,classAssignments:a,classes:n,onUpdate:o}){let[s,i]=(0,r.useState)(null),[d,l]=(0,r.useState)(null),[c,x]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),p=Object.keys(e),g=()=>{x(null),h(null)};return(0,t.jsxs)("div",{className:"p-6 space-y-3",children:[(0,t.jsx)("p",{className:"text-xs text-void-400 mb-4",children:"Assign commands to terminal classes and drag to reorder. The order here determines the button order in the UI."}),n.classes.map(r=>{let n,v=a[r.id]||[],b=s===r.id,f=p.filter(e=>!v.includes(e));return(0,t.jsxs)("div",{className:"border border-void-200 dark:border-void-700 rounded-lg overflow-hidden",children:[(0,t.jsxs)("button",{onClick:()=>i(b?null:r.id),className:"flex items-center justify-between w-full px-4 py-3 bg-void-50 dark:bg-void-800 hover:bg-void-100 dark:hover:bg-void-700 text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform ${b?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,t.jsx)("span",{className:"font-medium text-sm",children:r.name}),(0,t.jsxs)("span",{className:"text-xs text-void-400 font-mono",children:["(",r.id,")"]})]}),(0,t.jsxs)("span",{className:"text-xs text-void-500",children:[v.length," command",1!==v.length?"s":""]})]}),b&&(0,t.jsxs)("div",{className:"border-t border-void-200 dark:border-void-700",children:[0===v.length?(0,t.jsx)("div",{className:"px-4 py-3 text-sm text-void-400 italic",children:"No commands assigned"}):(0,t.jsx)("ul",{className:"divide-y divide-void-100 dark:divide-void-800",children:v.map((n,s)=>{let i=e[n],d=c?.classId===r.id&&c.fromIndex===s,l=c?.classId===r.id&&m===s;return(0,t.jsxs)("li",{draggable:!0,onDragStart:()=>{x({classId:r.id,fromIndex:s})},onDragOver:e=>{e.preventDefault(),h(s)},onDrop:()=>{var e;return e=r.id,void(c&&c.classId===e&&((e,t,r)=>{let n=[...a[e]||[]],[s]=n.splice(t,1);n.splice(r,0,s),o({...a,[e]:n})})(e,c.fromIndex,s),x(null),h(null))},onDragEnd:g,className:`flex items-center gap-2 px-4 py-2 text-sm ${d?"opacity-30":""} ${l?"bg-blue-50 dark:bg-blue-900/20":"hover:bg-void-50 dark:hover:bg-void-800"}`,children:[(0,t.jsx)("span",{className:"cursor-grab text-void-400 hover:text-void-600 dark:hover:text-void-300 select-none",children:(0,t.jsxs)("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"9",cy:"6",r:"1.5"}),(0,t.jsx)("circle",{cx:"15",cy:"6",r:"1.5"}),(0,t.jsx)("circle",{cx:"9",cy:"12",r:"1.5"}),(0,t.jsx)("circle",{cx:"15",cy:"12",r:"1.5"}),(0,t.jsx)("circle",{cx:"9",cy:"18",r:"1.5"}),(0,t.jsx)("circle",{cx:"15",cy:"18",r:"1.5"})]})}),(0,t.jsxs)("span",{className:"text-xs text-void-400 w-5 text-right",children:[s+1,"."]}),(0,t.jsx)("span",{className:"font-mono text-xs text-void-500",children:n}),(0,t.jsx)("span",{className:"text-void-300 dark:text-void-600",children:"-"}),(0,t.jsx)("span",{className:"flex-1 truncate",children:i?.label||n}),i&&(0,t.jsx)("span",{className:`rounded-full px-1.5 py-0.5 text-xs ${(u[i.placement]||u.both).color}`,children:(u[i.placement]||u.both).label}),(0,t.jsx)("button",{onClick:()=>{var e;let t;return e=r.id,t=(a[e]||[]).filter(e=>e!==n),void o({...a,[e]:t})},className:"rounded p-0.5 text-void-400 hover:bg-red-100 hover:text-red-600 dark:hover:bg-red-900/30 dark:hover:text-red-400",title:"Remove from this class",children:(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},n)})}),(0,t.jsx)("div",{className:"px-4 py-2 border-t border-void-100 dark:border-void-800",children:d===r.id?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("select",{autoFocus:!0,defaultValue:"",onChange:e=>{var t,n;let s;e.target.value&&(t=r.id,n=e.target.value,s=[...a[t]||[],n],o({...a,[t]:s}),l(null))},onBlur:()=>l(null),className:"flex-1 rounded border border-void-300 px-2 py-1 text-sm dark:border-void-600 dark:bg-void-800",children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select command..."}),Object.keys(n=f.reduce((t,r)=>{let a=e[r]?.group||"Ungrouped";return t[a]||(t[a]=[]),t[a].push(r),t},{})).sort((e,t)=>"Ungrouped"===e?1:"Ungrouped"===t?-1:e.localeCompare(t)).map(r=>(0,t.jsx)("optgroup",{label:r,children:n[r].sort((t,r)=>(e[t]?.label||t).localeCompare(e[r]?.label||r)).map(r=>(0,t.jsx)("option",{value:r,children:e[r]?.label||r},r))},r))]}),(0,t.jsx)("button",{onClick:()=>l(null),className:"text-xs text-void-500 hover:text-void-700 dark:hover:text-void-300",children:"Cancel"})]}):(0,t.jsxs)("button",{onClick:()=>l(r.id),disabled:0===f.length,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400 disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Command"]})})]})]},r.id)})]})}let h=[{id:"startup",label:"Startup"},{id:"toolbar",label:"Toolbar"},{id:"both",label:"Both"}];function p({commandId:e,command:a,existingGroups:n,availableProjects:o,onUpdate:s,onDelete:i,onEditingChange:d}){let[c,u]=(0,r.useState)(!1),[x,m]=(0,r.useState)(a.label),[p,g]=(0,r.useState)(a.description),[v,b]=(0,r.useState)(a.group||""),[f,k]=(0,r.useState)(a.prompt),[j,w]=(0,r.useState)(a.placement||"both"),[N,y]=(0,r.useState)(a.scope||"global"),[C,S]=(0,r.useState)(a.projects||[]),[_,$]=(0,r.useState)(!1),[T,L]=(0,r.useState)(!1),M=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let e=setTimeout(()=>{let e={},t=!1;x!==a.label&&(e.label=x,t=!0),p!==a.description&&(e.description=p,t=!0),(v||void 0)!==a.group&&(e.group=v||void 0,t=!0),j!==(a.placement||"both")&&(e.placement=j,t=!0),N!==(a.scope||"global")&&(e.scope=N,t=!0);let r="specific"===N?C:[];JSON.stringify(r)!==JSON.stringify(a.projects||[])&&(e.projects=r,t=!0),t&&s(e)},500);return()=>clearTimeout(e)},[x,p,v,j,N,C,a,s]),(0,r.useEffect)(()=>{let e=setTimeout(()=>{f!==a.prompt&&s({prompt:f})},500);return()=>clearTimeout(e)},[f,a.prompt,s]),(0,t.jsxs)("div",{className:"p-6 flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex gap-3 mb-3",children:[(0,t.jsxs)("div",{className:"w-36 flex-shrink-0",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Name"}),(0,t.jsx)("input",{type:"text",value:e,readOnly:!0,className:"w-full rounded border border-void-300 bg-void-50 px-2 py-1.5 font-mono text-sm dark:border-void-600 dark:bg-void-800"})]}),(0,t.jsxs)("div",{className:"w-32 flex-shrink-0",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Label"}),(0,t.jsx)("input",{type:"text",value:x,onChange:e=>m(e.target.value),onFocus:()=>d?.(!0),onBlur:()=>d?.(!1),className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-800","data-voice-target":!0})]}),(0,t.jsxs)("div",{className:"w-36 flex-shrink-0 relative",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Group"}),(0,t.jsx)("input",{type:"text",value:v,onChange:e=>b(e.target.value),onFocus:()=>{$(!0),d?.(!0)},onBlur:()=>{setTimeout(()=>$(!1),150),d?.(!1)},placeholder:"Ungrouped",className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-800","data-voice-target":!0}),_&&n.length>0&&(0,t.jsx)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-void-800 border border-void-300 dark:border-void-600 rounded shadow-(--shadow-overlay) z-10 max-h-32 overflow-y-auto",children:n.map(e=>(0,t.jsx)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),b(e),$(!1)},className:"w-full text-left px-2 py-1 text-sm hover:bg-void-100 dark:hover:bg-void-700",children:e},e))})]}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-void-500 mb-1",children:"Description"}),(0,t.jsx)("input",{type:"text",value:p,onChange:e=>g(e.target.value),onFocus:()=>d?.(!0),onBlur:()=>d?.(!1),className:"w-full rounded border border-void-300 px-2 py-1.5 text-sm dark:border-void-600 dark:bg-void-800","data-voice-target":!0})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4 mb-3 py-2 px-3 rounded-lg bg-void-50 dark:bg-void-800/50 border border-void-100 dark:border-void-700/50",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 uppercase tracking-wide",children:"Placement"}),(0,t.jsx)("div",{className:"flex rounded-md border border-void-200 dark:border-void-600 overflow-hidden",children:h.map(e=>(0,t.jsx)("button",{onClick:()=>w(e.id),className:`px-2.5 py-1 text-xs font-medium transition-colors ${j===e.id?"bg-blue-600 text-white":"bg-white hover:bg-void-50 dark:bg-void-800 dark:hover:bg-void-700 text-void-600 dark:text-void-300"}`,children:e.label},e.id))})]}),(0,t.jsx)("div",{className:"h-5 w-px bg-void-200 dark:bg-void-600"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 uppercase tracking-wide",children:"Scope"}),(0,t.jsxs)("div",{className:"flex rounded-md border border-void-200 dark:border-void-600 overflow-hidden",children:[(0,t.jsx)("button",{onClick:()=>y("global"),className:`px-2.5 py-1 text-xs font-medium transition-colors ${"global"===N?"bg-blue-600 text-white":"bg-white hover:bg-void-50 dark:bg-void-800 dark:hover:bg-void-700 text-void-600 dark:text-void-300"}`,children:"All Projects"}),(0,t.jsx)("button",{onClick:()=>y("specific"),className:`px-2.5 py-1 text-xs font-medium transition-colors ${"specific"===N?"bg-blue-600 text-white":"bg-white hover:bg-void-50 dark:bg-void-800 dark:hover:bg-void-700 text-void-600 dark:text-void-300"}`,children:"Specific"})]}),"specific"===N&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("button",{onClick:()=>L(!T),className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 dark:text-blue-400",children:[C.length>0?`${C.length} project${1!==C.length?"s":""}`:"Select...",(0,t.jsx)("svg",{className:`h-3 w-3 transition-transform ${T?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})})]})]}),"specific"===N&&T&&o.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-3 -mt-1 px-3",children:o.map(e=>(0,t.jsxs)("label",{className:`flex items-center gap-1 rounded border px-2 py-0.5 cursor-pointer text-xs ${C.includes(e)?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-void-200 hover:bg-void-50 dark:border-void-700"}`,children:[(0,t.jsx)("input",{type:"checkbox",checked:C.includes(e),onChange:()=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},className:"h-3 w-3 rounded border-void-300"}),(0,t.jsx)("span",{children:e})]},e))}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-void-500",children:"Prompt Template"}),(0,t.jsxs)("div",{className:"flex gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-void-400 mr-1",children:"Insert:"}),l.map(e=>(0,t.jsx)("button",{onClick:()=>(e=>{if(!M.current)return;let t=M.current,r=t.selectionStart,a=t.selectionEnd;k(f.substring(0,r)+e+f.substring(a)),setTimeout(()=>{t.focus(),t.selectionStart=r+e.length,t.selectionEnd=r+e.length},0)})(e.template),className:`rounded px-2 py-0.5 text-xs font-medium min-w-[60px] ${e.color} hover:opacity-80`,children:e.label},e.key))]})]}),(0,t.jsx)("textarea",{ref:M,value:f,onChange:e=>k(e.target.value),onFocus:()=>d?.(!0),onBlur:()=>d?.(!1),className:"flex-1 w-full rounded-lg border border-void-300 px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 resize-none font-mono",placeholder:"Enter the prompt template for this command...","data-voice-target":!0})]}),(0,t.jsx)("div",{className:"flex justify-end pt-3",children:c?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400",children:"Delete this command?"}),(0,t.jsx)("button",{onClick:()=>{i(),u(!1)},className:"rounded bg-red-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-red-700",children:"Yes, Delete"}),(0,t.jsx)("button",{onClick:()=>u(!1),className:"rounded bg-void-200 px-3 py-1.5 text-sm font-medium text-void-700 hover:bg-void-300 dark:bg-void-700 dark:text-void-200 dark:hover:bg-void-600",children:"Cancel"})]}):(0,t.jsxs)("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 rounded-lg border border-red-300 px-3 py-1.5 text-xs font-medium text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/20",children:[(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Delete"]})})]})}var g=e.i(71174);let v={add:"bg-emerald-950/40 text-emerald-300",remove:"bg-red-950/40 text-red-300",context:"text-void-300",header:"bg-neon-blue-950/30 text-neon-blue-300 font-medium"},b={add:"text-emerald-600",remove:"text-red-600",context:"text-void-600",header:"text-neon-blue-600"},f={add:"+",remove:"-",context:" ",header:""};function k({entry:e,currentContent:a,newContent:n,onClose:o}){let[s,i]=(0,r.useState)("diff"),d=null===a;(0,r.useEffect)(()=>{function e(e){"Escape"===e.key&&(e.stopPropagation(),o())}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]);let l=(0,r.useMemo)(()=>{let t=a??"";return function(e){let t=[],r=0,a=0;for(let n of e.split("\n"))if(n.startsWith("@@")){let e=n.match(/@@ -(\d+)/);if(e){r=parseInt(e[1],10)-1;let t=n.match(/\+(\d+)/);t&&(a=parseInt(t[1],10)-1)}t.push({type:"header",content:n})}else n.startsWith("---")||n.startsWith("+++")||n.startsWith("Index:")||n.startsWith("===")||(n.startsWith("+")?(a++,t.push({type:"add",content:n.slice(1),newLineNo:a})):n.startsWith("-")?(r++,t.push({type:"remove",content:n.slice(1),oldLineNo:r})):(n.startsWith(" ")||""===n)&&(r++,a++,t.push({type:"context",content:n.startsWith(" ")?n.slice(1):n,oldLineNo:r,newLineNo:a})));return t}((0,g.createTwoFilesPatch)(`current/${e.name}.md`,`updated/${e.name}.md`,t,n,e.currentVersion??"(none)",e.upstreamVersion,{context:4}))},[a,n,e]),c=(0,r.useMemo)(()=>{let e=0,t=0;for(let r of l)"add"===r.type&&e++,"remove"===r.type&&t++;return{additions:e,deletions:t}},[l]);return(0,t.jsx)("div",{className:"fixed inset-0 z-[55] flex items-center justify-center bg-black/60",onClick:e=>{e.target===e.currentTarget&&o()},children:(0,t.jsxs)("div",{className:"mx-4 flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-lg border border-void-700 bg-void-850 shadow-(--shadow-overlay)",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-void-700 px-5 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-void-100",children:e.name}),d?(0,t.jsx)("span",{className:"rounded bg-emerald-900/40 px-2 py-0.5 text-xs font-medium text-emerald-300",children:"New action"}):(0,t.jsxs)("span",{className:"rounded bg-amber-900/40 px-2 py-0.5 text-xs font-medium text-amber-300",children:["v",e.currentVersion," → v",e.upstreamVersion]}),(0,t.jsxs)("span",{className:"text-xs text-void-500",children:[(0,t.jsxs)("span",{className:"text-emerald-400",children:["+",c.additions]})," ",(0,t.jsxs)("span",{className:"text-red-400",children:["-",c.deletions]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!d&&(0,t.jsxs)("div",{className:"flex gap-1 rounded-md border border-void-700 bg-void-900 p-0.5",children:[(0,t.jsx)("button",{onClick:()=>i("diff"),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${"diff"===s?"bg-void-800 text-void-100 shadow-sm":"text-void-400 hover:text-void-200"}`,children:"Diff"}),(0,t.jsx)("button",{onClick:()=>i("new"),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${"new"===s?"bg-void-800 text-void-100 shadow-sm":"text-void-400 hover:text-void-200"}`,children:"Full"})]}),(0,t.jsx)("button",{onClick:o,className:"rounded p-1 text-void-400 hover:bg-void-800 hover:text-void-200",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]}),(e.changedFields?.length||e.newClasses?.length)&&(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 border-b border-void-700 px-5 py-3",children:[e.changedFields?.map(e=>(0,t.jsxs)("span",{className:"rounded bg-amber-900/40 px-2 py-0.5 text-[10px] font-medium text-amber-300",children:[e," changed"]},e)),e.newClasses?.length?(0,t.jsxs)("span",{className:"rounded bg-neon-blue-900/40 px-2 py-0.5 text-[10px] font-medium text-neon-blue-300",children:["New classes: ",e.newClasses.join(", ")]}):null]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)("div",{className:"font-mono text-xs leading-relaxed",children:"diff"===s||d?l.map((e,r)=>(0,t.jsxs)("div",{className:`flex ${v[e.type]}`,children:[(0,t.jsx)("span",{className:`w-10 flex-shrink-0 select-none px-2 text-right ${b[e.type]}`,children:"header"===e.type?"···":e.oldLineNo??e.newLineNo??""}),(0,t.jsx)("span",{className:`w-10 flex-shrink-0 select-none px-2 text-right ${b[e.type]}`,children:"header"===e.type?"···":e.newLineNo??""}),(0,t.jsx)("span",{className:`w-4 flex-shrink-0 select-none text-center ${b[e.type]}`,children:f[e.type]}),(0,t.jsx)("span",{className:"flex-1 whitespace-pre-wrap break-all px-2",children:e.content})]},r)):n.split("\n").map((e,r)=>(0,t.jsxs)("div",{className:"flex text-void-300",children:[(0,t.jsx)("span",{className:"w-10 flex-shrink-0 select-none px-2 text-right text-void-600",children:r+1}),(0,t.jsx)("span",{className:"flex-1 whitespace-pre-wrap break-all px-2",children:e})]},r))})})]})})}function j({onClose:e}){let[a,n]=(0,r.useState)([]),[o,s]=(0,r.useState)(!0),[i,d]=(0,r.useState)(null),[l,c]=(0,r.useState)(!1),[u,x]=(0,r.useState)(new Set),[m,h]=(0,r.useState)(null),p=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/cli-assets/updates");if(e.ok){let t=await e.json();n(t.actionEntries??[])}}catch{}s(!1)},[]);async function g(e){try{let t=await fetch(`/api/file?${new URLSearchParams({path:`updates/actions/${e.name}.md`})}`),r=t.ok?await t.json():null,a=r?.content??"",n=null;if("update"===e.status){let t=await fetch(`/api/file?${new URLSearchParams({path:`store/actions/${e.name}.md`})}`),r=t.ok?await t.json():null;n=r?.content??null}h({entry:e,currentContent:n,newContent:a})}catch{}}async function v(e){d(e.name);try{(await fetch("/api/cli-assets/updates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetType:"action",assetName:e.name})})).ok&&(x(t=>new Set(t).add(e.name)),fetch("/api/sly-actions/invalidate",{method:"POST"}).catch(()=>{}))}finally{d(null)}}async function b(e){try{await fetch("/api/cli-assets/updates",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetType:"action",assetName:e.name,contentHash:e.contentHash})}),n(t=>t.filter(t=>t.name!==e.name))}catch{}}async function f(){for(let e of(c(!0),a.filter(e=>!u.has(e.name))))await v(e);c(!1)}(0,r.useEffect)(()=>{p()},[p]),(0,r.useEffect)(()=>{function t(t){"Escape"!==t.key||m||e()}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,m]);let j=a.filter(e=>!u.has(e.name)),w=a.filter(e=>u.has(e.name));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:t=>{t.target===t.currentTarget&&e()},children:(0,t.jsxs)("div",{className:"mx-4 flex max-h-[85vh] w-full max-w-2xl flex-col overflow-hidden rounded-lg border border-void-200 bg-white shadow-(--shadow-overlay) dark:border-void-700 dark:bg-void-850",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-void-200 px-5 py-4 dark:border-void-700",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("svg",{className:"h-5 w-5 text-neon-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h7"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold text-void-900 dark:text-void-100",children:"Action Updates"}),j.length>0&&(0,t.jsx)("span",{className:"rounded-full bg-neon-blue-500 px-2 py-0.5 text-[10px] font-bold text-white",children:j.length})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[j.length>1&&(0,t.jsx)("button",{onClick:f,disabled:l,className:"rounded-md border border-emerald-400/40 bg-emerald-400/15 px-3 py-1.5 text-xs font-medium text-emerald-600 transition-colors hover:bg-emerald-400/25 disabled:opacity-50 dark:text-emerald-400",children:l?(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-emerald-600 border-t-emerald-300"}),"Accepting..."]}):`Accept All (${j.length})`}),(0,t.jsx)("button",{onClick:e,className:"rounded p-1 text-void-400 hover:bg-void-100 hover:text-void-700 dark:hover:bg-void-800 dark:hover:text-void-200",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:o?(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-neon-blue-400 border-t-transparent"})}):0===j.length&&0===w.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16",children:[(0,t.jsx)("svg",{className:"mb-3 h-10 w-10 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,t.jsx)("p",{className:"text-sm font-medium text-void-500 dark:text-void-400",children:"All actions are up to date"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-void-400 dark:text-void-500",children:"No updates available"})]}):(0,t.jsxs)("div",{className:"space-y-3",children:[w.map(e=>(0,t.jsx)("div",{className:"rounded-lg border border-emerald-500/30 bg-emerald-50 p-4 dark:bg-emerald-950/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("svg",{className:"h-5 w-5 text-emerald-500 dark:text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),(0,t.jsx)("span",{className:"text-sm font-medium text-emerald-700 dark:text-emerald-300",children:e.name}),(0,t.jsx)("span",{className:"text-xs text-emerald-600/70 dark:text-emerald-400/70",children:"new"===e.status?"Installed":`Updated to v${e.upstreamVersion}`})]})},e.name)),j.map(e=>{let r=i===e.name;return(0,t.jsx)("div",{className:"rounded-lg border border-void-200 bg-white p-4 dark:border-void-700 dark:bg-void-850",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-void-900 dark:text-void-100",children:e.name}),"update"===e.status?(0,t.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",children:"Update"}):(0,t.jsx)("span",{className:"rounded bg-emerald-100 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300",children:"New"})]}),(0,t.jsx)("div",{className:"mt-1 flex items-center gap-2 text-xs text-void-500 dark:text-void-400",children:"update"===e.status?(0,t.jsxs)("span",{children:["v",e.currentVersion," → v",e.upstreamVersion]}):(0,t.jsxs)("span",{children:["v",e.upstreamVersion]})}),e.description&&(0,t.jsx)("p",{className:"mt-1.5 text-xs text-void-500 line-clamp-2 dark:text-void-400",children:e.description}),e.changedFields?.length||e.newClasses?.length?(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[e.changedFields?.map(e=>(0,t.jsxs)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",children:[e," changed"]},e)),e.newClasses?.length?(0,t.jsxs)("span",{className:"rounded bg-neon-blue-100 px-1.5 py-0.5 text-[10px] font-medium text-neon-blue-700 dark:bg-neon-blue-900/40 dark:text-neon-blue-300",children:["+",e.newClasses.length," class",1!==e.newClasses.length?"es":""]}):null]}):null]}),(0,t.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[(0,t.jsx)("button",{onClick:()=>g(e),title:"Preview changes",className:"rounded-md border border-void-300 bg-void-50 p-1.5 text-void-500 transition-colors hover:bg-void-100 hover:text-void-700 dark:border-void-600 dark:bg-void-800 dark:hover:bg-void-700 dark:hover:text-void-200",children:(0,t.jsxs)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),(0,t.jsx)("button",{onClick:()=>v(e),disabled:r||l,title:"update"===e.status?`Update to v${e.upstreamVersion}`:"Install action",className:"rounded-md border border-emerald-400/40 bg-emerald-400/15 p-1.5 text-emerald-500 transition-colors hover:bg-emerald-400/25 disabled:opacity-50 dark:text-emerald-400",children:r?(0,t.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-emerald-600 border-t-emerald-300"}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,t.jsx)("button",{onClick:()=>b(e),title:"Dismiss this version",className:"rounded-md border border-void-300 bg-void-50 p-1.5 text-void-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:border-void-600 dark:bg-void-800 dark:hover:bg-red-950/30 dark:hover:text-red-400",children:(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})},e.name)})]})})]})}),m&&(0,t.jsx)(k,{entry:m.entry,currentContent:m.currentContent,newContent:m.newContent,onClose:()=>h(null)})]})}function w(e){return e>=90?{background:"linear-gradient(90deg, #ff3b5c, #ff6b81)",glow:"0 0 8px rgba(255, 59, 92, 0.5)"}:e>=70?{background:"linear-gradient(90deg, #ff8c00, #ffaa00)",glow:"0 0 8px rgba(255, 140, 0, 0.5)"}:{background:"linear-gradient(90deg, #00e676, #00bfff)",glow:"0 0 8px rgba(0, 191, 255, 0.4)"}}function N(e){let t=e/0x40000000;return t>=1?`${t.toFixed(1)}G`:`${(e/1048576).toFixed(0)}M`}function y({value:e,label:r}){let a=w(e),n=Math.min(100,Math.max(0,e)),o="Memory"===r?"MEM":"Swap"===r?"SWP":r.toUpperCase();return(0,t.jsxs)("div",{className:"relative h-3.5 w-10 overflow-hidden rounded bg-void-200 dark:bg-void-700",title:`${r}: ${e.toFixed(1)}%`,children:[(0,t.jsx)("div",{className:"h-full rounded transition-all duration-300",style:{width:`${n}%`,background:a.background,boxShadow:a.glow}}),(0,t.jsx)("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-bold text-white mix-blend-difference",children:o})]})}function C({value:e,label:r,detail:a}){let n=w(e),o=Math.min(100,Math.max(0,e));return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,t.jsx)("span",{className:"text-void-600 dark:text-void-400",children:r}),(0,t.jsx)("span",{className:"font-mono text-void-800 dark:text-void-200",children:a||`${e.toFixed(1)}%`})]}),(0,t.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-void-200 dark:bg-void-700",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${o}%`,background:n.background,boxShadow:n.glow}})})]})}function S({isOpen:e,terminalCount:r,onConfirm:a,onCancel:n,isLoading:o}){return e?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:(0,t.jsxs)("div",{className:"mx-4 w-full max-w-sm rounded-lg bg-void-50 p-6 shadow-(--shadow-overlay) dark:bg-void-800",children:[(0,t.jsx)("h3",{className:"mb-2 text-lg font-semibold text-void-900 dark:text-void-100",children:"Stop All Terminals?"}),(0,t.jsxs)("p",{className:"mb-4 text-sm text-void-600 dark:text-void-400",children:["This will stop all ",r," running terminal",1!==r?"s":"",". Any active sessions will be terminated."]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{onClick:n,disabled:o,className:"rounded-lg border border-void-300 px-4 py-2 text-sm font-medium text-void-700 hover:bg-void-50 dark:border-void-600 dark:text-void-300 dark:hover:bg-void-700",children:"Cancel"}),(0,t.jsx)("button",{onClick:a,disabled:o,className:"rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50",children:o?"Stopping...":"Stop All"})]})]})}):null}function _(){let[e,a]=(0,r.useState)(null),[n,o]=(0,r.useState)(null),[i,d]=(0,r.useState)(!1),[l,c]=(0,r.useState)(!1),[u,x]=(0,r.useState)(!1),[m,h]=(0,r.useState)(!1),p=(0,r.useRef)(null),g=(0,r.useCallback)(async e=>{try{let t=await fetch("/api/system-stats",{signal:e});if(t.ok){let e=await t.json();a(e)}}catch{}try{let t=await fetch("/api/bridge/stats",{signal:e});if(t.ok){let e=await t.json();o(e),h(!1)}else h(!0)}catch{h(!0)}},[]);(0,s.usePolling)(g,5e3),(0,r.useEffect)(()=>{if(!i)return;let e=e=>{p.current&&!p.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let v=async()=>{x(!0);try{(await fetch("/api/bridge/sessions/stop-all",{method:"POST"})).ok&&await g()}catch(e){console.error("Failed to stop all sessions:",e)}finally{x(!1),c(!1)}},b=e?.cpu??0,f=e?e.memory.used/e.memory.total*100:0,k=e?.swap?.total?e.swap.used/e.swap.total*100:0,j=(e?.swap?.total??0)>0,_=n?.bridgeTerminals??0,$=n?.activelyWorking??0,T=w(Math.max(b,f,j?k:0));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{ref:p,className:"relative cursor-pointer",onClick:()=>d(e=>!e),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-void-200 bg-void-50 px-2 py-1 dark:border-void-700 dark:bg-void-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 sm:hidden",children:[(0,t.jsx)("div",{className:"h-2.5 w-2.5 rounded-full",style:{background:T.background},title:`CPU: ${b.toFixed(0)}% | Mem: ${f.toFixed(0)}%${j?` | Swap: ${k.toFixed(0)}%`:""}`}),(0,t.jsx)("span",{className:"text-[10px] font-mono text-void-600 dark:text-void-400",children:m?"--":_}),$>0&&(0,t.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-green-500"})]})]}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-2",children:[(0,t.jsx)(y,{value:b,label:"CPU"}),(0,t.jsx)(y,{value:f,label:"Memory"}),j&&(0,t.jsx)(y,{value:k,label:"Swap"}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 text-xs text-void-600 dark:text-void-400",title:`${_} terminal${1!==_?"s":""} running`,children:[(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,t.jsx)("span",{className:"font-mono",children:m?"--":_})]}),$>0&&(0,t.jsxs)("div",{className:"flex items-center gap-0.5",title:`${$} actively working`,children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),(0,t.jsx)("span",{className:"text-xs font-mono text-green-600 dark:text-green-400",children:$})]})]})]}),i&&(0,t.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-64 rounded-lg border border-void-200 bg-white p-3 shadow-(--shadow-overlay) dark:border-void-700 dark:bg-void-800",children:[(0,t.jsx)("h4",{className:"mb-3 text-sm font-semibold text-void-900 dark:text-void-100",children:"System Health"}),(0,t.jsxs)("div",{className:"mb-3 space-y-2",children:[(0,t.jsx)(C,{value:b,label:"CPU",detail:`${b.toFixed(1)}%`}),(0,t.jsx)(C,{value:f,label:"Memory",detail:e?`${N(e.memory.used)} / ${N(e.memory.total)}`:"--"}),j&&(0,t.jsx)(C,{value:k,label:"Swap",detail:e?.swap?`${N(e.swap.used)} / ${N(e.swap.total)}`:"--"})]}),(0,t.jsx)("div",{className:"my-3 border-t border-void-200 dark:border-void-700"}),(0,t.jsxs)("div",{className:"mb-3 space-y-1 text-xs",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-void-600 dark:text-void-400",children:"Terminals running"}),(0,t.jsx)("span",{className:"font-mono text-void-800 dark:text-void-200",children:m?"--":_})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-void-600 dark:text-void-400",children:"Actively working"}),(0,t.jsx)("span",{className:`font-mono ${$>0?"text-green-600 dark:text-green-400":"text-void-800 dark:text-void-200"}`,children:m?"--":$})]})]}),_>0&&!m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"my-3 border-t border-void-200 dark:border-void-700"}),(0,t.jsx)("button",{onClick:()=>c(!0),className:"w-full rounded-lg bg-red-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-red-700",children:"Stop All Terminals"})]}),m&&(0,t.jsx)("p",{className:"text-xs text-red-500",children:"Bridge unavailable"})]})]}),(0,t.jsx)(S,{isOpen:l,terminalCount:_,onConfirm:v,onCancel:()=>c(!1),isLoading:u})]})}var $=e.i(5903),T=e.i(22530);function L({name:e,description:o,tags:s,projectId:i,projectPath:d,showArchived:l=!1,onToggleArchived:u,showAutomations:x=!1,hasActiveAutomations:m=!1,onToggleAutomations:h,onRefresh:p}){let[g,v]=(0,r.useState)(!1),[b,f]=(0,r.useState)(!1),[k,w]=(0,r.useState)(!1),[N,y]=(0,r.useState)(!1),[C,S]=(0,r.useState)(0),L=(0,n.useRouter)();(0,r.useEffect)(()=>{let e=!0;async function t(){try{let t=await fetch("/api/cli-assets/updates");if(t.ok&&e){let e=await t.json();S(e.actionEntries?.length??0)}}catch{}}t();let r=setInterval(t,6e4);return()=>{e=!1,clearInterval(r)}},[]);let M=(0,r.useCallback)(async()=>{if(!N&&p){y(!0);try{await p()}finally{setTimeout(()=>y(!1),400)}}},[N,p]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("header",{className:"neon-header-border relative z-10 flex-shrink-0 bg-void-50 shadow-[0_4px_12px_-2px_rgba(0,0,0,0.15)] dark:bg-void-800 dark:shadow-[0_4px_12px_-2px_rgba(0,0,0,0.5)]",children:(0,t.jsx)("div",{className:"px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 sm:gap-4",children:[(0,t.jsxs)(a.default,{href:"/",className:"shrink-0 rounded-lg p-0.5",children:[(0,t.jsx)("img",{src:"/slycode_logo_light.webp",alt:"Home",className:"logo-nav h-[40px] w-[40px] sm:h-[52px] sm:w-[52px] object-contain mix-blend-multiply dark:hidden"}),(0,t.jsx)("img",{src:"/slycode_logo.webp",alt:"Home",className:"logo-nav hidden h-[40px] w-[40px] sm:h-[52px] sm:w-[52px] object-contain mix-blend-lighten dark:block"})]}),(0,t.jsxs)("div",{className:"hidden min-w-0 flex-1 sm:block",children:[(0,t.jsx)("h1",{className:"truncate text-xl font-bold text-void-950 dark:text-void-100",children:e}),(0,t.jsx)("p",{className:"truncate text-sm text-void-500 dark:text-void-400",children:o})]}),(0,t.jsx)("button",{onClick:()=>w(!0),className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border border-void-200/40 bg-transparent p-2 text-void-500 transition-all hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400 sm:hidden",children:(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,t.jsx)("div",{className:"hidden w-64 shrink-0 sm:block",children:(0,t.jsx)($.SearchBar,{contextProjectId:i,onResultClick:e=>{L.push(`/project/${e.projectId}?card=${e.cardId}`)}})}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1 sm:gap-2",children:[p&&(0,t.jsx)("button",{onClick:M,title:"Refresh board from disk",className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border border-void-200/40 bg-transparent p-2 text-void-500 transition-all hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400",children:(0,t.jsx)("svg",{className:`h-4 w-4 transition-transform${N?" animate-spin":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,t.jsx)(T.ThemeToggle,{}),(0,t.jsx)(_,{}),(0,t.jsxs)("button",{onClick:()=>v(!0),title:"Sly Actions",className:"relative hidden sm:flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border border-void-200/40 bg-transparent p-2 text-void-500 transition-all hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400",children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),C>0&&(0,t.jsx)("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-neon-blue-500 px-1 text-[10px] font-bold text-white",children:C})]}),(0,t.jsx)("button",{onClick:h,title:x?"Show kanban board":"Show automations",className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border p-2 transition-all ${x?"border-orange-400/50 bg-orange-400/10 text-orange-500 hover:bg-orange-400/20 dark:text-orange-400":`border-void-200/40 bg-transparent text-void-500 hover:border-orange-400/40 hover:bg-orange-400/5 hover:text-orange-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-orange-400/40 dark:hover:bg-orange-400/5 dark:hover:text-orange-400${m?" active-glow-automation-btn text-orange-400 dark:text-orange-400":""}`}`,children:x?(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,t.jsx)("button",{onClick:u,title:l?"Show active cards":"Show archived cards",className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg border p-2 transition-all ${l?"border-neon-orange-400/50 bg-neon-orange-400/8 text-neon-orange-500 hover:bg-neon-orange-400/15 dark:text-neon-orange-400":"border-void-200/40 bg-transparent text-void-500 hover:border-neon-blue-400/40 hover:bg-neon-blue-400/5 hover:text-neon-blue-400 dark:border-void-700/40 dark:text-void-400 dark:hover:border-neon-blue-400/40 dark:hover:bg-neon-blue-400/5 dark:hover:text-neon-blue-400"}`,children:l?(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"})})})]})]})})}),k&&(0,t.jsx)("div",{className:"fixed inset-x-0 top-0 z-50 bg-void-50 p-3 shadow-lg dark:bg-void-800 sm:hidden",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)($.SearchBar,{contextProjectId:i,onResultClick:e=>{w(!1),L.push(`/project/${e.projectId}?card=${e.cardId}`)}})}),(0,t.jsx)("button",{onClick:()=>w(!1),className:"flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg p-2 text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-200",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),g&&(0,t.jsx)(c,{onClose:()=>{v(!1),fetch("/api/sly-actions/invalidate",{method:"POST"}).catch(()=>{})},projectId:i,projectPath:d,actionUpdateCount:C,onShowActionUpdates:()=>{v(!1),f(!0)}}),b&&(0,t.jsx)(j,{onClose:()=>{f(!1),fetch("/api/cli-assets/updates").then(e=>e.json()).then(e=>S(e.actionEntries?.length??0)).catch(()=>{})}})]})}var M=e.i(21146);class D{channel=null;senderId;listeners=new Set;constructor(){if(this.senderId=`tab-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,"u">typeof BroadcastChannel)try{this.channel=new BroadcastChannel("slycode-tab-sync"),this.channel.onmessage=e=>{e.data.senderId!==this.senderId&&this.listeners.forEach(t=>t(e.data))}}catch{}}broadcast(e,t){if(!this.channel)return;let r={type:e,senderId:this.senderId,projectId:t,timestamp:Date.now()};try{this.channel.postMessage(r)}catch{}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}}let E=new D;var I=e.i(84608),R=e.i(74080);let A={critical:{border:"border-l-[#ff1744]",glowRgb:"255, 23, 68",hoverGlow:"hover:shadow-[var(--shadow-card),inset_5px_0_8px_-6px_rgba(255,23,68,0.5)] dark:hover:shadow-[var(--shadow-card),inset_6px_0_14px_-6px_rgba(255,23,68,0.5),_-4px_0_16px_-3px_rgba(255,23,68,0.55)] hover:before:bg-white/40 dark:hover:before:bg-white/60"},high:{border:"border-l-[#ff9100]",glowRgb:"255, 145, 0",hoverGlow:"hover:shadow-[var(--shadow-card),inset_4px_0_7px_-5px_rgba(255,145,0,0.45)] dark:hover:shadow-[var(--shadow-card),inset_5px_0_12px_-5px_rgba(255,145,0,0.45),_-3px_0_14px_-3px_rgba(255,145,0,0.45)] hover:before:bg-white/35 dark:hover:before:bg-white/50"},medium:{border:"border-l-[#00bfff]",glowRgb:"0, 191, 255",hoverGlow:"hover:shadow-[var(--shadow-card),inset_4px_0_6px_-5px_rgba(0,191,255,0.4)] dark:hover:shadow-[var(--shadow-card),inset_4px_0_10px_-4px_rgba(0,191,255,0.4),_-3px_0_12px_-3px_rgba(0,191,255,0.35)] hover:before:bg-white/30 dark:hover:before:bg-white/45"},low:{border:"border-l-[#00c853]",glowRgb:"0, 200, 83",hoverGlow:"hover:shadow-[var(--shadow-card),inset_4px_0_6px_-5px_rgba(0,200,83,0.35)] dark:hover:shadow-[var(--shadow-card),inset_4px_0_10px_-4px_rgba(0,200,83,0.35),_-3px_0_12px_-3px_rgba(0,200,83,0.3)] hover:before:bg-white/25 dark:hover:before:bg-white/40"}},B={bug:"🪳",feature:"✨",chore:"🔧"};function O({completed:e,total:r}){let a=e===r,n=r>0?e/r:0,o=2*Math.PI*5.75;if(a)return(0,t.jsx)("div",{className:"flex items-center",title:"Checklist complete",children:(0,t.jsxs)("svg",{width:13,height:13,viewBox:"0 0 16 16",className:"text-void-400 dark:text-void-500",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"7",fill:"currentColor"}),(0,t.jsx)("path",{d:"M5 8l2 2 4-4",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})});let s=0===e;return(0,t.jsxs)("div",{className:"flex items-center gap-1",title:`${e}/${r} items complete`,children:[(0,t.jsxs)("svg",{width:13,height:13,className:"-rotate-90",children:[(0,t.jsx)("circle",{cx:6.5,cy:6.5,r:5.75,fill:"none",stroke:"currentColor",strokeWidth:1.5,className:s?"text-red-500":"text-void-200 dark:text-void-600"}),(0,t.jsx)("circle",{cx:6.5,cy:6.5,r:5.75,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:o*(1-n),className:"text-orange-500 dark:text-orange-400"})]}),(0,t.jsxs)("span",{className:"font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-void-500 dark:text-void-400",children:[e,"/",r]})]})}function P({card:e,sessionStatus:a,isActivelyWorking:n=!1,stage:o,onClick:s,onContextMenu:i,onDragStart:d,onDragEnd:l}){var c;let u=e.problems.filter(e=>!e.resolved_at).length,x=e.checklist?.length||0,m=e.checklist?.filter(e=>e.done).length||0,[h,p]=(0,r.useState)(!1),[g,v]=(0,r.useState)({top:0,left:0}),[b,f]=(0,r.useState)(!1),k=(0,r.useRef)(null),j=(0,r.useRef)(null),w=A[e.priority]||A.medium;(0,r.useEffect)(()=>()=>{k.current&&clearTimeout(k.current)},[]);let N="done"!==o&&(e.areas.length>0||e.tags.length>0);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{ref:j,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/plain",e.id),t.dataTransfer.effectAllowed="move",d?.(),p(!1),k.current&&clearTimeout(k.current)},onDragEnd:()=>{l?.()},onClick:s,style:{"--glow-color":w.glowRgb},onContextMenu:e=>{i&&(p(!1),k.current&&clearTimeout(k.current),i(e))},onMouseEnter:()=>{e.description&&(k.current=setTimeout(()=>{if(j.current){let e=j.current.getBoundingClientRect(),t=e.right+8+256<=window.innerWidth,r=t?e.right+8:e.left-8-256;v({top:Math.min(e.top,window.innerHeight-100-8),left:r}),f(!t)}p(!0)},500))},onMouseLeave:()=>{k.current&&(clearTimeout(k.current),k.current=null),p(!1)},className:`group relative cursor-pointer rounded-lg border-l-4 border-t border-t-white/50 backdrop-blur-lg bg-white/55 p-3 shadow-(--shadow-card) ring-1 ring-transparent transition-[transform,ring-color,box-shadow] duration-200 hover:translate-y-0.5 hover:ring-[rgba(var(--glow-color),0.4)] before:pointer-events-none before:absolute before:inset-y-1 before:-left-[3px] before:w-px before:rounded-full before:bg-white/0 before:transition-colors before:duration-200 dark:border-t-white/10 dark:backdrop-blur-xl dark:bg-[#20232a]/55 dark:hover:ring-[rgba(var(--glow-color),0.25)] ${w.border} ${w.hoverGlow} ${n?"active-glow-card":""}`,children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("h4",{className:"text-sm font-medium text-void-900 dark:text-void-100",children:e.title})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[null!=e.number&&(0,t.jsx)("span",{className:"font-[family-name:var(--font-jetbrains-mono)] text-[10px] leading-none text-void-400 dark:text-void-500",children:(c=e.number,`#${String(c).padStart(c>9999?0:4,"0")}`)}),(n||"running"===a)&&(0,t.jsxs)("span",{className:"relative flex h-2.5 w-2.5 -translate-y-px",title:"Session running",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-[#00e676] opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-[#00e676] dark:drop-shadow-[0_0_4px_rgba(0,230,118,0.6)]",style:{boxShadow:"0 0 6px rgba(0,230,118,0.6)"}})]}),!n&&("detached"===a||"resumable"===a)&&(0,t.jsx)("span",{className:"flex h-2.5 w-2.5 -translate-y-px rounded-full bg-neon-orange-400 dark:drop-shadow-[0_0_4px_rgba(255,140,0,0.5)]",title:"Session paused",style:{boxShadow:"0 0 4px rgba(255,140,0,0.4)"}}),!n&&"none"===a&&(0,t.jsx)("span",{className:"flex h-2 w-2 -translate-y-px rounded-full bg-void-300 dark:bg-void-600",title:"No session"})]})]}),u>0&&(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:[(0,t.jsx)("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,t.jsxs)("span",{children:[u," issue",1!==u?"s":""]})]}),(0,t.jsxs)("div",{className:`${N?"mt-2":"mt-1"} flex items-center justify-end gap-2`,children:[N&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 gap-1 overflow-hidden",children:[e.areas.slice(0,1).map(e=>(0,t.jsx)("span",{className:"shrink-0 rounded border border-neon-blue-400/25 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-neon-blue-700 transition-colors group-hover:bg-neon-blue-400/8 dark:border-neon-blue-400/20 dark:text-neon-blue-400/70 dark:group-hover:bg-neon-blue-400/10",children:e},e)),e.areas.length>1&&(0,t.jsxs)("span",{className:"shrink-0 rounded border border-neon-blue-400/25 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-neon-blue-600 transition-colors group-hover:bg-neon-blue-400/8 dark:border-neon-blue-400/20 dark:text-neon-blue-400/50 dark:group-hover:bg-neon-blue-400/10",children:["+",e.areas.length-1]}),e.tags.slice(0,1).map(e=>(0,t.jsx)("span",{className:"shrink-0 rounded border border-void-300 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-void-600 transition-colors group-hover:bg-void-100 dark:border-void-600 dark:text-void-400 dark:group-hover:bg-void-800",children:e},e)),e.tags.length>1&&(0,t.jsxs)("span",{className:"shrink-0 rounded border border-void-300 bg-transparent px-1 py-px font-[family-name:var(--font-jetbrains-mono)] text-[10px] text-void-600 transition-colors group-hover:bg-void-100 dark:border-void-600 dark:text-void-500 dark:group-hover:bg-void-800",children:["+",e.tags.length-1]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[x>0&&(0,t.jsx)(O,{completed:m,total:x}),(0,t.jsx)("span",{className:"text-base leading-none",children:B[e.type]||B.chore})]})]})]}),h&&e.description&&"u">typeof document&&(0,R.createPortal)((0,t.jsxs)("div",{className:`fixed z-[100] w-64 animate-in fade-in duration-200 ${b?"slide-in-from-right-1":"slide-in-from-left-1"}`,style:{top:g.top,left:g.left},children:[(0,t.jsx)("div",{className:"rounded-lg border border-neon-blue-400/20 bg-void-50 p-3 shadow-(--shadow-overlay) dark:bg-void-850",children:(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-void-700 dark:text-void-300",children:e.description.length>200?e.description.slice(0,200)+"...":e.description})}),(0,t.jsx)("div",{className:`absolute top-3 h-2 w-2 rotate-45 ${b?"-right-1 border-t border-r":"-left-1 border-b border-l"} border-neon-blue-400/20 bg-void-50 dark:bg-void-850`})]}),document.body)]})}let W={zinc:{header:"bg-void-200 dark:bg-void-700 shadow-[inset_0_2px_6px_rgba(100,100,110,0.2),inset_0_-1px_3px_rgba(100,100,110,0.12)] dark:shadow-[inset_0_2px_6px_rgba(30,30,40,0.5),inset_0_-1px_3px_rgba(30,30,40,0.35),inset_0_1px_0_rgba(255,255,255,0.06)]",headerText:"text-void-500 dark:text-void-200",count:"bg-void-300/80 text-void-500 dark:bg-void-600 dark:text-void-200",border:"border-b-[3px] border-void-400 dark:border-void-400",texture:"lane-texture"},purple:{header:"bg-neon-blue-100/80 dark:from-neon-blue-900/60 dark:to-neon-blue-950/40 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(0,120,180,0.18),inset_0_-1px_3px_rgba(0,120,180,0.1)] dark:shadow-[inset_0_2px_6px_rgba(0,60,100,0.55),inset_0_-1px_3px_rgba(0,60,100,0.35),inset_0_1px_0_rgba(0,191,255,0.06)]",headerText:"text-void-600 dark:text-neon-blue-300",count:"bg-neon-blue-200/60 text-void-600 dark:bg-neon-blue-800/60 dark:text-neon-blue-200",border:"border-b-[3px] border-neon-blue-400/70 dark:border-neon-blue-400/70",texture:"lane-texture"},blue:{header:"bg-neon-blue-100 dark:from-neon-blue-800/50 dark:to-neon-blue-900/40 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(0,100,160,0.2),inset_0_-1px_3px_rgba(0,100,160,0.12)] dark:shadow-[inset_0_2px_6px_rgba(0,50,90,0.55),inset_0_-1px_3px_rgba(0,50,90,0.35),inset_0_1px_0_rgba(0,191,255,0.06)]",headerText:"text-void-600 dark:text-neon-blue-200",count:"bg-neon-blue-200/60 text-void-600 dark:bg-neon-blue-700/60 dark:text-neon-blue-100",border:"border-b-[3px] border-neon-blue-500/60 dark:border-neon-blue-400/70",texture:"lane-texture"},yellow:{header:"bg-[#ff6a33]/10 dark:from-[#ff6a33]/15 dark:to-[#ff6a33]/5 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(180,60,0,0.15),inset_0_-1px_3px_rgba(180,60,0,0.08)] dark:shadow-[inset_0_2px_6px_rgba(100,30,0,0.5),inset_0_-1px_3px_rgba(100,30,0,0.3),inset_0_1px_0_rgba(255,106,51,0.06)]",headerText:"text-void-600 dark:text-[#ff8a60]",count:"bg-[#ff6a33]/12 text-void-600 dark:bg-[#ff6a33]/20 dark:text-[#ffc0a0]",border:"border-b-[3px] border-[#ff6a33]/50 dark:border-[#ff6a33]/60",texture:"lane-texture"},green:{header:"bg-green-100/80 dark:from-green-900/50 dark:to-green-950/30 dark:bg-gradient-to-r shadow-[inset_0_2px_6px_rgba(0,100,50,0.18),inset_0_-1px_3px_rgba(0,100,50,0.1)] dark:shadow-[inset_0_2px_6px_rgba(0,50,25,0.55),inset_0_-1px_3px_rgba(0,50,25,0.35),inset_0_1px_0_rgba(34,197,94,0.06)]",headerText:"text-void-600 dark:text-green-300",count:"bg-green-200/60 text-void-600 dark:bg-green-800/50 dark:text-green-200",border:"border-b-[3px] border-green-500/60 dark:border-green-400/60",texture:"lane-texture"}};function F({stage:e,cards:a,cardSessions:n,activeCards:o,onCardClick:s,onCardContextMenu:i,onMoveCard:d,onAddCardClick:l}){let c=W[e.color]||W.zinc,[u,x]=(0,r.useState)(null),m=(0,r.useRef)(null),h=(0,r.useRef)(null),p=(0,r.useRef)(0),g=(0,r.useRef)(!1);(0,r.useEffect)(()=>{let e=()=>{let t=m.current;if(!t||!g.current){h.current=null;return}let r=t.getBoundingClientRect(),a=p.current,n=a-r.top,o=r.bottom-a,s=0;n<60&&n>0?s=-8*(1-n/60):o<60&&o>0&&(s=8*(1-o/60)),0!==s&&(t.scrollTop+=s),h.current=requestAnimationFrame(e)};return m.current&&(m.current.startScroll=()=>{h.current||(h.current=requestAnimationFrame(e))}),()=>{h.current&&(cancelAnimationFrame(h.current),h.current=null)}},[]);let v=(0,r.useCallback)(()=>{g.current=!0;let e=m.current;e?.startScroll?.()},[]),b=(0,r.useCallback)(()=>{g.current=!1,h.current&&(cancelAnimationFrame(h.current),h.current=null)},[]),f=e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",p.current=e.clientY,v()};return(0,t.jsxs)("div",{className:"flex min-w-[85vw] sm:min-w-72 max-w-[85vw] sm:max-w-96 flex-1 flex-shrink-0 snap-start flex-col rounded-lg border-2 border-t-[rgba(140,170,220,0.55)] border-l-[rgba(140,170,220,0.55)] border-b-[rgba(80,110,180,0.45)] border-r-[rgba(80,110,180,0.45)] bg-[#d8e1f0] shadow-[0_1px_3px_rgba(0,0,0,0.25),inset_0_3px_6px_-2px_rgba(255,255,255,0.6),inset_3px_0_6px_-2px_rgba(255,255,255,0.4),inset_0_-3px_6px_-2px_rgba(60,90,160,0.2),inset_-3px_0_6px_-2px_rgba(60,90,160,0.15)] dark:border-2 dark:border-void-700 dark:bg-void-850 dark:shadow-[0_1px_3px_rgba(0,0,0,0.6)]",onDragOver:f,onDragLeave:e=>{let t=e.currentTarget.getBoundingClientRect(),r=e.clientX,a=e.clientY;(r<t.left||r>t.right||a<t.top||a>t.bottom)&&(x(null),b())},onDrop:t=>{t.preventDefault(),b();let r=t.dataTransfer.getData("text/plain");r&&d(r,e.id,u??void 0),x(null)},children:[(0,t.jsxs)("div",{className:`light-clean grain depth-glow flex items-center justify-between rounded-t-lg px-3 py-2.5 ${c.header} ${c.border}`,children:[(0,t.jsx)("h3",{className:`font-semibold drop-shadow-[0_1px_2px_rgba(0,0,0,0.4)] dark:drop-shadow-[0_2px_3px_rgba(0,0,0,0.7)] ${c.headerText}`,children:e.label}),(0,t.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-bold ${c.count}`,children:a.length})]}),(0,t.jsx)("div",{ref:m,className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 pb-8 ${c.texture}`,style:{maskImage:"linear-gradient(to bottom, black calc(100% - 3rem), transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black calc(100% - 3rem), transparent 100%)"},children:0===a.length?(0,t.jsx)("div",{className:"rounded-lg border-2 border-dashed border-void-200 p-4 text-center text-sm text-void-400 dark:border-void-700 dark:text-void-600",onDragOver:f,onDrop:t=>{t.preventDefault(),b();let r=t.dataTransfer.getData("text/plain");r&&d(r,e.id,0),x(null)},children:"Drop here"}):(0,t.jsxs)(t.Fragment,{children:[a.map((r,a)=>(0,t.jsxs)("div",{children:[u===a&&(0,t.jsx)("div",{className:"mb-2 h-1 rounded-full bg-neon-blue-400 transition-all"}),(0,t.jsx)("div",{onDragOver:e=>{let t,r;return e.preventDefault(),e.stopPropagation(),p.current=e.clientY,v(),r=(t=e.currentTarget.getBoundingClientRect()).top+t.height/2,void x(e.clientY<r?a:a+1)},children:(0,t.jsx)(P,{card:r,sessionStatus:n.get(r.id)||"none",isActivelyWorking:o.has(r.id),stage:e.id,onClick:()=>s(r),onContextMenu:i?e=>i(r,e):void 0,onDragStart:()=>{},onDragEnd:()=>{x(null),b()}})})]},r.id)),u===a.length&&(0,t.jsx)("div",{className:"mt-2 h-1 rounded-full bg-neon-blue-400 transition-all"})]})}),l&&(0,t.jsx)("div",{className:"p-2 pt-0",children:(0,t.jsxs)("button",{onClick:l,className:"flex w-full items-center justify-center gap-1 rounded-lg border-2 border-dashed border-void-200 py-2 text-sm text-void-400 transition-colors hover:border-neon-blue-400/30 hover:text-neon-blue-400 dark:border-void-700 dark:text-void-500 dark:hover:border-neon-blue-400/30 dark:hover:text-neon-blue-400",children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Card"]})})]})}var H=e.i(9308),z=e.i(7782);let U=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function V(e,t,r="Not set",a){let n=a?` (${a})`:"";if("one-shot"===t)try{let t=new Date(e);if(isNaN(t.getTime()))return e||r;return`Once on ${t.toLocaleDateString()} at ${t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}${n}`}catch{return e||r}if(!e)return r;let o=e.split(" ");if(5!==o.length)return e;let[s,i,d,,l]=o,c=i.match(/^(\d+)-(\d+)\/(\d+)$/);if(c&&"*"===d&&"*"===l){let[,e,t,r]=c;return`Every ${r}h from ${e.padStart(2,"0")}:${s.padStart(2,"0")} to ${t.padStart(2,"0")}:${s.padStart(2,"0")}${n}`}if(i.includes(",")&&"*"===d&&"*"===l){let e=i.split(",").map(Number);if(e.length>=2){let t=(e[1]-e[0]+24)%24;if(t>0){let r=String(e[0]).padStart(2,"0"),a=String(e[e.length-1]).padStart(2,"0");return`Every ${t}h from ${r}:${s.padStart(2,"0")} to ${a}:${s.padStart(2,"0")}${n}`}}}if("*"===i&&"*"===d&&"*"===l)return`Every hour at :${s.padStart(2,"0")}${n}`;if("*"===d&&"*"===l)return`Daily at ${i}:${s.padStart(2,"0")}${n}`;if("*"===d&&"*"!==l){let e=l.split(",").map(e=>U[parseInt(e)]||e).join(", ");return`Weekly on ${e} at ${i}:${s.padStart(2,"0")}${n}`}return"*"!==d&&"*"===l?`Monthly on day ${d} at ${i}:${s.padStart(2,"0")}${n}`:e}let q=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function J(e){let t={frequency:"daily",hour:"6",minute:"0",days:[],dayOfMonth:"1",intervalHours:"2",startHour:"9",endHour:"20"};if(!e)return t;let r=e.split(" ");if(5!==r.length)return t;let[a,n,o,,s]=r,i=n.match(/^(\d+)-(\d+)\/(\d+)$/);if(i&&"*"===o&&"*"===s)return{...t,frequency:"interval",minute:a,startHour:i[1],endHour:i[2],intervalHours:i[3]};if(n.includes(",")&&"*"===o&&"*"===s){let e=n.split(",").map(Number);if(e.length>=2){let r=(e[1]-e[0]+24)%24;if(r>0&&r<=12)return{...t,frequency:"interval",minute:a,startHour:String(e[0]),endHour:String(e[e.length-1]),intervalHours:String(r)}}}return"*"===n?{...t,frequency:"hourly",minute:a}:"*"!==o?{...t,frequency:"monthly",hour:n,minute:a,dayOfMonth:o}:"*"!==s?{...t,frequency:"weekly",hour:n,minute:a,days:s.split(",").map(Number)}:{...t,frequency:"daily",hour:n,minute:a}}function K(e){switch(e.frequency){case"hourly":return`${e.minute} * * * *`;case"daily":return`${e.minute} ${e.hour} * * *`;case"weekly":return`${e.minute} ${e.hour} * * ${e.days.length?e.days.sort((e,t)=>e-t).join(","):"1"}`;case"monthly":return`${e.minute} ${e.hour} ${e.dayOfMonth} * *`;case"interval":{let t=parseInt(e.startHour),r=parseInt(e.endHour),a=parseInt(e.intervalHours);if(t<=r)return`${e.minute} ${t}-${r}/${a} * * *`;let n=function(e,t,r){let a=[],n=e;if(e<=t)for(;n<=t;)a.push(n),n+=r;else{for(;n<24;)a.push(n),n+=r;for(n-=24;n<=t;)a.push(n),n+=r}return a}(t,r,a);return`${e.minute} ${n.join(",")} * * *`}}}function G({config:e,cardId:a,projectId:n,onChange:o}){let[s,i]=(0,r.useState)(!1),[d,l]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),[x,m]=(0,r.useState)(null),[h,p]=(0,r.useState)(""),g=J(e.schedule),[v,b]=(0,r.useState)(g);(0,r.useEffect)(()=>{fetch("/api/providers").then(e=>e.ok?e.json():null).then(e=>{e?.providers&&l(Object.entries(e.providers).map(([e,t])=>({id:e,displayName:t.displayName||e})))}).catch(()=>{}),fetch("/api/scheduler").then(e=>e.ok?e.json():null).then(e=>{e?.abbreviation&&p(e.abbreviation)}).catch(()=>{})},[]);let f=(t,r,a)=>{"recurring"===r&&t&&fetch("/api/scheduler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"nextRun",schedule:t,scheduleType:r})}).then(e=>e.ok?e.json():null).then(r=>{r?.nextRun&&o({...e,...a,schedule:t,nextRun:r.nextRun})}).catch(()=>{})},k=t=>{let r={...v,...t};b(r);let a=K(r);o({...e,schedule:a,nextRun:void 0}),e.enabled&&f(a,e.scheduleType)},j=V(e.schedule,e.scheduleType,"Not set",h||void 0),w="rounded border border-void-300 bg-white px-2 py-1 text-sm text-void-700 focus:border-orange-400 focus:outline-none focus:ring-1 focus:ring-orange-400/30 dark:border-void-600 dark:bg-void-800 dark:text-void-300",N="text-xs font-medium text-void-500 dark:text-void-400";return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-orange-400/20 bg-orange-50/50 p-3 dark:bg-orange-950/10",children:[(0,t.jsx)("h4",{className:"mb-3 text-sm font-semibold text-orange-700 dark:text-orange-400",children:"Schedule"}),(0,t.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:()=>{let t=K(v);o({...e,scheduleType:"recurring",schedule:t,nextRun:void 0}),e.enabled&&f(t,"recurring")},className:`rounded-l-lg px-3 py-1.5 text-xs font-medium transition-colors ${"recurring"===e.scheduleType?"bg-orange-500 text-white":"bg-void-200 text-void-600 hover:bg-void-300 dark:bg-void-700 dark:text-void-400 dark:hover:bg-void-600"}`,children:"Recurring"}),(0,t.jsx)("button",{onClick:()=>o({...e,scheduleType:"one-shot",schedule:"",nextRun:void 0}),className:`rounded-r-lg px-3 py-1.5 text-xs font-medium transition-colors ${"one-shot"===e.scheduleType?"bg-orange-500 text-white":"bg-void-200 text-void-600 hover:bg-void-300 dark:bg-void-700 dark:text-void-400 dark:hover:bg-void-600"}`,children:"One-shot"})]}),"recurring"===e.scheduleType?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Frequency:"}),(0,t.jsxs)("select",{value:v.frequency,onChange:e=>k({frequency:e.target.value}),className:w,children:[(0,t.jsx)("option",{value:"hourly",children:"Hourly"}),(0,t.jsx)("option",{value:"daily",children:"Daily"}),(0,t.jsx)("option",{value:"weekly",children:"Weekly"}),(0,t.jsx)("option",{value:"monthly",children:"Monthly"}),(0,t.jsx)("option",{value:"interval",children:"Interval (hour range)"})]})]}),"interval"===v.frequency&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Every"}),(0,t.jsx)("select",{value:v.intervalHours,onChange:e=>k({intervalHours:e.target.value}),className:w,children:[1,2,3,4,6,8].map(e=>(0,t.jsxs)("option",{value:String(e),children:[e," hour",e>1?"s":""]},e))}),(0,t.jsx)("span",{className:N,children:"between"}),(0,t.jsx)("select",{value:v.startHour,onChange:e=>k({startHour:e.target.value}),className:w,children:Array.from({length:24},(e,r)=>(0,t.jsxs)("option",{value:String(r),children:[String(r).padStart(2,"0"),":00"]},r))}),(0,t.jsx)("span",{className:N,children:"and"}),(0,t.jsx)("select",{value:v.endHour,onChange:e=>k({endHour:e.target.value}),className:w,children:Array.from({length:24},(e,r)=>(0,t.jsxs)("option",{value:String(r),children:[String(r).padStart(2,"0"),":00"]},r))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"At minute:"}),(0,t.jsx)("select",{value:v.minute,onChange:e=>k({minute:e.target.value}),className:w,children:[0,5,10,15,20,25,30,35,40,45,50,55].map(e=>(0,t.jsxs)("option",{value:String(e),children:[":",String(e).padStart(2,"0")]},e))})]})]}),("daily"===v.frequency||"weekly"===v.frequency||"monthly"===v.frequency)&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"At:"}),(0,t.jsx)("input",{type:"time",value:`${v.hour.padStart(2,"0")}:${v.minute.padStart(2,"0")}`,onChange:e=>{let[t,r]=e.target.value.split(":");k({hour:String(parseInt(t)),minute:String(parseInt(r))})},className:w})]}),"hourly"===v.frequency&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"At minute:"}),(0,t.jsx)("select",{value:v.minute,onChange:e=>k({minute:e.target.value}),className:w,children:[0,5,10,15,20,25,30,35,40,45,50,55].map(e=>(0,t.jsxs)("option",{value:String(e),children:[":",String(e).padStart(2,"0")]},e))})]}),"weekly"===v.frequency&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Days:"}),(0,t.jsx)("div",{className:"flex gap-1",children:q.map((e,r)=>(0,t.jsx)("button",{onClick:()=>{k({days:v.days.includes(r)?v.days.filter(e=>e!==r):[...v.days,r]})},className:`rounded px-2 py-1 text-xs font-medium transition-colors ${v.days.includes(r)?"bg-orange-500 text-white":"bg-void-200 text-void-600 hover:bg-void-300 dark:bg-void-700 dark:text-void-400"}`,children:e},r))})]}),"monthly"===v.frequency&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Day:"}),(0,t.jsx)("select",{value:v.dayOfMonth,onChange:e=>k({dayOfMonth:e.target.value}),className:w,children:Array.from({length:28},(e,t)=>t+1).map(e=>(0,t.jsx)("option",{value:String(e),children:e},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{onClick:()=>i(!s),className:"text-xs text-void-500 hover:text-orange-500 dark:text-void-400",children:[s?"Hide":"Show"," advanced (cron)"]}),s&&(0,t.jsx)("div",{className:"mt-1 flex items-center gap-2",children:(0,t.jsx)("input",{type:"text",value:e.schedule,onChange:t=>{let r=t.target.value;o({...e,schedule:r,nextRun:void 0}),b(J(r)),e.enabled&&f(r,"recurring")},placeholder:"* * * * *",className:`flex-1 font-mono text-xs ${w}`})})]})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Date & Time:"}),(0,t.jsx)("input",{type:"datetime-local",value:e.schedule?e.schedule.slice(0,16):"",onChange:t=>o({...e,schedule:new Date(t.target.value).toISOString(),nextRun:void 0}),className:w}),h&&(0,t.jsxs)("span",{className:"text-xs text-void-500 dark:text-void-400",children:["(",h,")"]})]}),(0,t.jsx)("div",{className:"mt-2 rounded bg-orange-100/50 px-2 py-1 text-xs text-orange-700 dark:bg-orange-900/20 dark:text-orange-300",children:j}),(e.lastRun||e.nextRun)&&(0,t.jsxs)("div",{className:"mt-2 flex gap-4 text-xs text-void-500 dark:text-void-400",children:[e.lastRun&&(0,t.jsxs)("span",{children:["Last run: ",new Date(e.lastRun).toLocaleString(),e.lastResult&&(0,t.jsxs)("span",{className:"success"===e.lastResult?" text-green-600 dark:text-green-400":" text-red-600 dark:text-red-400",children:[" ","(",e.lastResult,")"]})]}),e.nextRun&&(0,t.jsxs)("span",{children:["Next run: ",new Date(e.nextRun).toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-orange-400/20 bg-orange-50/50 p-3 dark:bg-orange-950/10",children:[(0,t.jsx)("h4",{className:"mb-3 text-sm font-semibold text-orange-700 dark:text-orange-400",children:"Execution"}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Provider:"}),(0,t.jsx)("select",{value:e.provider,onChange:t=>o({...e,provider:t.target.value}),className:w,children:d.length>0?d.map(e=>(0,t.jsx)("option",{value:e.id,children:e.displayName},e.id)):(0,t.jsx)("option",{value:e.provider,children:e.provider})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,t.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Fresh session:"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.freshSession,onClick:()=>o({...e,freshSession:!e.freshSession}),className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors ${e.freshSession?"bg-orange-500":"bg-void-300 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${e.freshSession?"translate-x-4":"translate-x-0"}`})})]}),(0,t.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Report via messaging:"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.reportViaMessaging,onClick:()=>o({...e,reportViaMessaging:!e.reportViaMessaging}),className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors ${e.reportViaMessaging?"bg-orange-500":"bg-void-300 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${e.reportViaMessaging?"translate-x-4":"translate-x-0"}`})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:N,children:"Working dir:"}),(0,t.jsx)("input",{type:"text",value:e.workingDirectory||"",onChange:t=>o({...e,workingDirectory:t.target.value||void 0}),placeholder:"(uses card's project directory)",className:`flex-1 ${w}`})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-orange-400/20 bg-white/50 p-2 dark:bg-void-800/50",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-sm font-medium text-void-700 dark:text-void-300",children:"Enabled"}),!e.enabled&&(0,t.jsx)("p",{className:"text-xs text-orange-600 dark:text-orange-400",children:"This automation won't run until enabled"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",disabled:c,onClick:async()=>{u(!0),m(null);try{let e=await fetch("/api/scheduler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trigger",cardId:a,projectId:n})}),t=await e.json();m(t.success?"success":"error")}catch{m("error")}finally{u(!1),setTimeout(()=>m(null),3e3)}},className:`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all ${"success"===x?"border-green-400/40 bg-green-400/15 text-green-600 dark:text-green-400":"error"===x?"border-red-400/40 bg-red-400/15 text-red-600 dark:text-red-400":"border-orange-400/40 bg-orange-400/15 text-orange-600 hover:bg-orange-400/25 hover:shadow-[0_0_12px_rgba(249,115,22,0.3)] dark:text-orange-400"} disabled:cursor-not-allowed disabled:opacity-50`,children:c?"Running...":"success"===x?"Triggered":"error"===x?"Failed":"Run Now"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.enabled,onClick:()=>{let t=!e.enabled;o({...e,enabled:t}),t&&f(e.schedule,e.scheduleType,{enabled:!0})},className:`relative inline-flex h-6 w-11 flex-shrink-0 rounded-full border-2 border-transparent transition-colors ${e.enabled?"bg-green-500":"bg-void-300 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow transition ${e.enabled?"translate-x-5":"translate-x-0"}`})})]})]})]})]})]})}function X({open:e,onClose:r,onConfirm:a,title:n,message:o,confirmLabel:s="Delete",confirmClassName:i="bg-red-600 hover:bg-red-700"}){return e?(0,t.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/60",onClick:r,children:(0,t.jsxs)("div",{className:"w-full max-w-md rounded-xl bg-white p-6 shadow-(--shadow-overlay) dark:bg-void-800",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30",children:(0,t.jsx)("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,t.jsx)("h3",{className:"text-lg font-semibold text-void-900 dark:text-void-100",children:n})]}),(0,t.jsx)("div",{className:"mb-6 text-sm text-void-600 dark:text-void-400",children:o}),(0,t.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,t.jsx)("button",{onClick:r,className:"rounded-lg px-4 py-2 text-sm font-medium text-void-700 hover:bg-void-100 dark:text-void-300 dark:hover:bg-void-700",children:"Cancel"}),(0,t.jsx)("button",{onClick:a,className:`rounded-lg px-4 py-2 text-sm font-medium text-white ${i}`,children:s})]})]})}):null}var Y=e.i(39269),Q=e.i(9083),Z=e.i(49996);let ee=[{id:"backlog",label:"Backlog"},{id:"design",label:"Design"},{id:"implementation",label:"Implementation"},{id:"testing",label:"Testing"},{id:"done",label:"Done"}],et=["critical","high","medium","low"],er={feature:"bg-neon-blue-400/20 text-neon-blue-600 dark:text-neon-blue-400 border border-neon-blue-400/30",chore:"bg-void-200 text-void-600 dark:bg-void-700 dark:text-void-200 border border-void-300 dark:border-void-600",bug:"bg-[#ff3b5c]/20 text-[#ff3b5c] border border-[#ff3b5c]/30"},ea={critical:"bg-[#ff3b5c]/20 text-[#ff3b5c] border border-[#ff3b5c]/30",high:"bg-neon-orange-400/20 text-neon-orange-600 dark:text-neon-orange-400 border border-neon-orange-400/30",medium:"bg-[#ffd600]/15 text-[#b39700] dark:text-[#ffd600]/80 border border-[#ffd600]/25",low:"bg-green-500/15 text-green-700 dark:text-green-400/70 border border-green-500/20"},en={backlog:"border-t border-void-600 bg-void-800",design:"border-t-2 border-neon-blue-400/40 bg-void-800",implementation:"border-t-2 border-neon-blue-400/50 bg-void-800",testing:"border-t-2 border-neon-orange-400/40 bg-void-800",done:"border-t-2 border-green-400/40 bg-void-800"},eo={backlog:"rgba(120, 120, 140, 0.12)",design:"rgba(0, 191, 255, 0.1)",implementation:"rgba(0, 191, 255, 0.12)",testing:"rgba(255, 106, 51, 0.1)",done:"rgba(0, 230, 118, 0.1)"},es={backlog:{header:"bg-gradient-to-r from-void-200 to-void-100 dark:from-void-850 dark:to-void-850/60",tabs:"bg-gradient-to-r from-void-200/50 to-void-100/50 dark:from-void-850/60 dark:to-void-850/30",modalBorder:"dark:border dark:border-void-600",headerBorder:"border-b border-void-300 dark:border-void-600",tabsBorder:"border-b border-void-200 dark:border-void-600"},design:{header:"bg-gradient-to-r from-neon-blue-200/85 to-neon-blue-50/50 dark:from-neon-blue-950/90 dark:to-neon-blue-950/30",tabs:"bg-gradient-to-r from-neon-blue-100/50 to-neon-blue-50/15 dark:from-neon-blue-950/50 dark:to-neon-blue-950/15",modalBorder:"dark:border dark:border-neon-blue-400/25",headerBorder:"border-b border-neon-blue-200/50 dark:border-neon-blue-400/25",tabsBorder:"border-b border-neon-blue-100/50 dark:border-neon-blue-400/20"},implementation:{header:"bg-gradient-to-r from-neon-blue-200/85 to-neon-blue-50/50 dark:from-neon-blue-950/90 dark:to-neon-blue-900/20",tabs:"bg-gradient-to-r from-neon-blue-100/50 to-neon-blue-50/15 dark:from-neon-blue-950/50 dark:to-neon-blue-950/15",modalBorder:"dark:border dark:border-neon-blue-400/30",headerBorder:"border-b border-neon-blue-200/50 dark:border-neon-blue-400/30",tabsBorder:"border-b border-neon-blue-100/50 dark:border-neon-blue-400/20"},testing:{header:"bg-gradient-to-r from-[#ff6a33]/25 to-[#ff6a33]/10 dark:from-[#ff6a33]/15 dark:to-[#ff6a33]/5",tabs:"bg-gradient-to-r from-[#ff6a33]/15 to-[#ff6a33]/5 dark:from-[#ff6a33]/10 dark:to-[#ff6a33]/5",modalBorder:"dark:border dark:border-[#ff6a33]/30",headerBorder:"border-b border-[#ff6a33]/25 dark:border-[#ff6a33]/30",tabsBorder:"border-b border-[#ff6a33]/15 dark:border-[#ff6a33]/25"},done:{header:"bg-gradient-to-r from-green-200/85 to-green-50/50 dark:from-green-950/90 dark:to-green-950/30",tabs:"bg-gradient-to-r from-green-100/50 to-green-50/15 dark:from-green-950/50 dark:to-green-950/15",modalBorder:"dark:border dark:border-green-400/25",headerBorder:"border-b border-green-200/50 dark:border-green-400/25",tabsBorder:"border-b border-green-100/50 dark:border-green-400/20"}},ei={header:"bg-gradient-to-r from-orange-200/85 to-orange-50/50 dark:from-orange-950/90 dark:to-orange-950/30",tabs:"bg-gradient-to-r from-orange-100/50 to-orange-50/15 dark:from-orange-950/50 dark:to-orange-950/15",modalBorder:"dark:border dark:border-orange-400/30",headerBorder:"border-b border-orange-200/50 dark:border-orange-400/30",tabsBorder:"border-b border-orange-100/50 dark:border-orange-400/20"},ed={backlog:"161, 161, 170",design:"129, 140, 248",implementation:"0, 191, 255",testing:"255, 106, 51",done:"74, 222, 128"};function el({anchorRef:e,children:a}){let[n,o]=(0,r.useState)({position:"fixed",opacity:0});return(0,r.useEffect)(()=>{let t=()=>{let t=e.current;if(!t)return;let r=t.getBoundingClientRect();o({position:"fixed",top:r.bottom+8,right:window.innerWidth-r.right,zIndex:9999,opacity:1})};return t(),window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[e]),(0,t.jsx)("div",{style:n,children:a})}function ec({card:e,stage:a,projectId:n,projectPath:s,onClose:l,onUpdate:c,onMove:u,onDelete:x,isCreateMode:m,onCreate:h,onAutomationToggle:p,suppressAutoTerminal:g}){let[v,b]=(0,r.useState)("details"),[f,k]=(0,r.useState)(!1),[j,w]=(0,r.useState)(""),[N,y]=(0,r.useState)(m??!1),[C,S]=(0,r.useState)(e.title),[_,$]=(0,r.useState)(e.description),T=(0,r.useRef)(!1),L=(0,r.useRef)(e.description),M=(0,r.useRef)(e.title),D=(0,r.useRef)({}),E=(0,r.useCallback)(e=>{D.current[e]=Date.now()},[]),I=(0,r.useCallback)((e,t=2e3)=>{let r=D.current[e];return void 0!==r&&Date.now()-r<t},[]);(0,r.useEffect)(()=>{e.description!==L.current&&(I("description")||$(t=>t===L.current?e.description:t),L.current=e.description)},[e.description,I]),(0,r.useEffect)(()=>{e.title!==M.current&&(I("title")||S(t=>t===M.current?e.title:t),M.current=e.title)},[e.title,I]);let[A,B]=(0,r.useState)(!1),O=(0,r.useRef)(null),P=(0,r.useRef)(null),[W,F]=(0,r.useState)(null),[U,V]=(0,r.useState)(null),q=(0,z.useSlyActionsConfig)(),[J,K]=(0,r.useState)([]),[ec,eu]=(0,r.useState)(""),[ex,em]=(0,r.useState)(null),[eh,ep]=(0,r.useState)(null),[eg,ev]=(0,r.useState)(e.checklist||[]),eb=(0,r.useRef)(e.checklist||[]),[ef,ek]=(0,r.useState)(e.id),ej=(0,r.useRef)(JSON.stringify(e.checklist||[]));e.id!==ef&&(ev(e.checklist||[]),ek(e.id)),(0,r.useEffect)(()=>{let t=e.checklist||[];eb.current=t,ej.current=JSON.stringify(t)},[e.id]),(0,r.useEffect)(()=>{let t=JSON.stringify(e.checklist||[]);if(t!==ej.current){if(!I("checklist")&&JSON.stringify(eb.current)===ej.current){let t=e.checklist||[];ev(t),eb.current=t}ej.current=t}},[e.checklist,I]);let[ew,eN]=(0,r.useState)(""),[ey,eC]=(0,r.useState)(!1),eS=(0,r.useRef)(null),[e_,e$]=(0,r.useState)(!1),[eT,eL]=(0,r.useState)(!1),eM=(0,r.useRef)(e.agentNotes?.length??0),eD=(0,i.useVoice)(),eE=(0,r.useRef)(0),eI=(0,r.useRef)(null),eR=(0,r.useRef)(null),eA=(0,r.useRef)(null),eB=(0,r.useRef)(v);eB.current=v;let eO=(0,r.useCallback)(e=>{let t=eR.current;if(t){if("input"===t.type&&t.element){if(!document.contains(t.element))return;let r=t.element,a=r.selectionStart??r.value.length,n=r.selectionEnd??r.value.length;r.focus(),r.setSelectionRange(a,n),document.execCommand("insertText",!1,e)}else if("terminal"===t.type&&t.sendInput){let r="auto"===eD.submitModeRef.current&&eD.settings.voice.autoSubmitTerminal,a=t.sendInput;a(e),r&&setTimeout(()=>a("\r"),300)}eD.submitModeRef.current="auto"}},[eD.settings.voice.autoSubmitTerminal]);(0,r.useEffect)(()=>{if(m)return;let e={id:"card-modal",onRecordStart:()=>{let e=document.activeElement;e&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName)&&e.closest("[data-voice-target]")?eR.current={type:"input",element:e}:"terminal"===eB.current&&eA.current?eR.current={type:"terminal",sendInput:eA.current}:eR.current=null},onTranscriptionComplete:eO,onRelease:()=>{eR.current=null}};return eD.claimVoiceControl(e),()=>eD.releaseVoiceControl(e)},[m]),(0,r.useEffect)(()=>{let e=e=>{let t=e.target;"terminal"===eB.current?eD.setHasFieldFocus(!0):t.closest("[data-voice-target]")&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&eD.setHasFieldFocus(!0)},t=()=>{"terminal"!==eB.current&&setTimeout(()=>{if("terminal"===eB.current)return;let e=document.activeElement;e?.closest("[data-voice-target]")&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName)||eD.setHasFieldFocus(!1)},100)};return document.addEventListener("focusin",e),document.addEventListener("focusout",t),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t)}},[eD]),(0,r.useEffect)(()=>{"terminal"===v&&eD.setHasFieldFocus(!0)},[v,eD]);let eP=(0,r.useCallback)(()=>{let e=eS.current;e&&(e$(e.scrollTop>8),eL(e.scrollTop+e.clientHeight<e.scrollHeight-8))},[]),eW=(0,r.useRef)(v);(0,r.useEffect)(()=>{"notes"===v&&"notes"!==eW.current&&requestAnimationFrame(()=>{eS.current&&(eS.current.scrollTop=eS.current.scrollHeight),eP()}),eW.current=v},[v,eP]),(0,r.useEffect)(()=>{let t=e.agentNotes?.length??0;t>eM.current&&"notes"===v&&eS.current&&requestAnimationFrame(()=>{eS.current&&(eS.current.scrollTop=eS.current.scrollHeight),eP()}),eM.current=t,"notes"===v&&requestAnimationFrame(eP)},[e.agentNotes?.length,v,eP]);let eF=t=>{let r=e.agentNotes||[],a={id:r.reduce((e,t)=>Math.max(e,t.id),0)+1,agent:"User",text:t,timestamp:new Date().toISOString()};c({...e,agentNotes:[...r,a],updated_at:new Date().toISOString()})},[eH,ez]=(0,r.useState)(!1),[eU,eV]=(0,r.useState)(!1),eq=`${n}:card:${e.id}`,eJ=W?.status==="running"||W?.status==="detached";W?.hasHistory;let eK=(0,o.getTerminalClassFromStage)(a),eG=(0,o.getActionsForClass)(q.commands,q.classAssignments,eK,{projectId:n,cardType:e.type}),eX=e.problems.filter(e=>!e.resolved_at),eY=e.problems.length-eX.length,eQ=e.checklist||[],eZ=eQ.filter(e=>e.done).length,e0=e.agentNotes?.length??0,e1=[];if(e1.push(`Project: ${n} (${s})`),e1.push(""),e1.push(`Card: ${e.title} [${e.id}]`),e1.push(`Type: ${e.type} | Priority: ${e.priority} | Stage: ${a}`),e.description&&e1.push(`Description: ${e.description}`),e.areas.length>0&&e1.push(`Areas: ${e.areas.join(", ")}`),e.design_ref&&e1.push(`Design Doc: ${e.design_ref}`),e.feature_ref&&e1.push(`Feature Spec: ${e.feature_ref}`),e1.push(eQ.length>0?`Checklist: ${eZ}/${eQ.length} checked`:"Checklist: none"),e1.push(`Notes: ${e0}`),eX.length>0||eY>0){let e=[];for(let t of(eX.length>0&&e.push(`${eX.length} unresolved`),eY>0&&e.push(`${eY} resolved`),e1.push(`Problems: ${e.join(", ")}`),eX.slice(0,10))){let e=t.description.length>100?t.description.slice(0,97)+"...":t.description;e1.push(` - [${t.id}] ${t.severity}: ${e}`)}eX.length>10&&e1.push(` - ... and ${eX.length-10} more`)}else e1.push("Problems: none");let e2={cardContext:e1.join("\n"),card:{id:e.id,title:e.title,description:e.description,type:e.type,priority:e.priority,areas:e.areas,design_ref:e.design_ref,feature_ref:e.feature_ref},stage:a,project:{name:n},projectPath:s};(0,r.useEffect)(()=>{fetch("/api/areas").then(e=>e.ok?e.json():null).then(e=>{e?.areas&&K(e.areas)}).catch(()=>{})},[]),(0,r.useEffect)(()=>{let t=`card:${e.id}`;fetch("/api/bridge/sessions").then(e=>e.ok?e.json():null).then(e=>{if(!e?.sessions)return;let r=e.sessions.filter(e=>e.name?.endsWith(t)&&e.name?.startsWith(`${n}:`));if(0===r.length)return;let a={running:0,detached:1,stopped:2};r.sort((e,t)=>{let r=a[e.status]??3,n=a[t.status]??3;return r!==n?r-n:(t.lastActive??"").localeCompare(e.lastActive??"")});let o=r[0];if(F({status:o.status,hasHistory:o.hasHistory}),o.name){let e=o.name.split(":");2===e.indexOf("card")&&V(e[1])}}).catch(()=>{})},[n,e.id]);let[e5,e4]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e5||g||e7||!W||"running"!==W.status&&"detached"!==W.status||(b("terminal"),e4(!0))},[W,e5,g]);let e3=!!e.design_ref,e6=!!e.feature_ref,e8=!!e.test_ref,e9=eg.length>0,e7=!!e.automation,te=e7?ei:es[a],tt=e7?"border-t-2 border-orange-400/50 bg-void-800":en[a],tr=e7?"rgba(249, 115, 22, 0.12)":eo[a],ta=e7?"251, 146, 60":ed[a],tn="design"===v?e.design_ref:"feature"===v?e.feature_ref:"test"===v?e.test_ref:void 0,[to,ts]=(0,r.useState)({}),[ti,td]=(0,r.useState)({});(0,r.useEffect)(()=>{("design"===v||"feature"===v||"test"===v)&&tn&&(k(!0),fetch(`/api/file?path=${encodeURIComponent(tn)}&projectId=${encodeURIComponent(n)}`).then(e=>e.json()).then(e=>{e.error?td(t=>({...t,[tn]:e.error})):(td(e=>{let t={...e};return delete t[tn],t}),ts(t=>({...t,[tn]:e.content})))}).catch(e=>{td(t=>({...t,[tn]:e.message}))}).finally(()=>{k(!1)}))},[v,tn,n]);let tl=()=>{C.trim()&&C!==e.title&&(M.current=C.trim(),c({...e,title:C.trim(),updated_at:new Date().toISOString()})),y(!1)},tc=()=>{if(!j.trim())return;let t={id:`prob-${Date.now()}`,description:j.trim(),severity:"major",created_at:new Date().toISOString()};c({...e,problems:[...e.problems,t],updated_at:new Date().toISOString()}),w("")},tu=t=>{let r=t.trim().toLowerCase();r&&!e.tags.includes(r)&&c({...e,tags:[...e.tags,r],updated_at:new Date().toISOString()}),eu("")},tx=async e=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}ez(!0),setTimeout(()=>ez(!1),2e3)}catch(e){console.error("Failed to copy:",e),ez(!0),setTimeout(()=>ez(!1),2e3)}},tm=async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e.title);else{let t=document.createElement("textarea");t.value=e.title,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}eV(!0),setTimeout(()=>eV(!1),2e3)}catch(e){console.error("Failed to copy title:",e),eV(!0),setTimeout(()=>eV(!1),2e3)}},th=e.problems.filter(e=>!e.resolved_at),tp=e.problems.filter(e=>e.resolved_at),tg=J.filter(t=>!e.areas.includes(t)),tv=(0,r.useCallback)(()=>{if("recording"!==eD.voiceState&&"paused"!==eD.voiceState&&"transcribing"!==eD.voiceState){if(m&&h){if(!C.trim())return void l();h({title:C.trim(),description:_,type:e.type,priority:e.priority,areas:e.areas,tags:e.tags,problems:e.problems,checklist:eb.current,...e.automation?{automation:e.automation}:{}})}else C.trim()&&C!==e.title&&c({...e,title:C.trim(),updated_at:new Date().toISOString()});l()}},[m,h,C,_,e,l,c,eD.voiceState]);return(0,r.useEffect)(()=>{let e=e=>{if("Escape"!==e.key||"terminal"===v)return;if(e.stopImmediatePropagation(),A)return void B(!1);let t=document.activeElement;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName)?t.blur():tv()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[v,A,tv]),(0,r.useEffect)(()=>{let e=e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;let t=e.target;if("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||t.isContentEditable)return;let r=["details"];e3&&r.push("design"),e6&&r.push("feature"),e8&&r.push("test"),r.push("notes"),e9&&r.push("checklist"),r.push("terminal");let a=r.indexOf(v);if(-1===a)return;let n="ArrowRight"===e.key?(a+1)%r.length:(a-1+r.length)%r.length;e.preventDefault(),b(r[n])};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[v,e3,e6,e8,e9]),(0,t.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-hidden lg:overflow-y-auto bg-black/50 p-0 lg:p-4 lg:pb-16 lg:pt-16",onMouseDown:e=>{T.current=e.target===e.currentTarget},onClick:e=>{e.target===e.currentTarget&&T.current&&tv()},children:[(0,t.jsxs)("div",{style:{"--focus-rgb":ta},className:`flex w-full max-w-full h-full lg:h-auto flex-col lg:max-w-4xl overflow-hidden rounded-none lg:rounded-xl bg-void-100 shadow-(--shadow-overlay) dark:bg-void-900 ${te.modalBorder}`,children:[(0,t.jsxs)("div",{className:`grain depth-glow flex items-start justify-between p-3 sm:p-4 ${te.headerBorder} ${te.header}`,children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,t.jsx)("span",{className:`rounded px-2 py-0.5 text-xs font-medium ${er[e.type]}`,children:e.type}),(0,t.jsx)("span",{className:`rounded px-2 py-0.5 text-xs font-medium capitalize ${ea[e.priority]||ea.medium}`,children:e.priority}),e.claude_session?.active&&(0,t.jsxs)("span",{className:"flex items-center gap-1 rounded bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800 dark:bg-green-900 dark:text-green-200",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),"Session Active"]})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[N?(0,t.jsx)("input",{ref:O,type:"text",value:C,"data-voice-target":!0,onChange:e=>{E("title"),M.current=e.target.value,S(e.target.value)},onBlur:()=>!m&&tl(),onFocus:()=>E("title"),onKeyDown:e=>{if((e.ctrlKey||e.metaKey)&&"Enter"===e.key){e.preventDefault(),tv();return}"Enter"===e.key?m?(e.preventDefault(),P.current?.focus()):tl():"Tab"!==e.key||e.shiftKey||(e.preventDefault(),m||tl(),P.current?.focus())},placeholder:m?"Enter card title...":"",className:"w-full rounded border bg-transparent px-1 text-base sm:text-xl font-bold text-void-900 outline-none dark:text-void-100",style:{borderColor:`rgb(${ta})`},autoFocus:!0}):(0,t.jsx)("h2",{onClick:()=>y(!0),className:"cursor-pointer text-base sm:text-xl font-bold text-void-900 hover:text-blue-600 dark:text-void-100 dark:hover:text-blue-400",title:"Click to edit",children:e.title}),!m&&(0,t.jsx)("button",{onClick:tm,className:"mt-1 flex-shrink-0 rounded p-1 text-void-400 hover:bg-void-200/50 hover:text-void-600 dark:hover:bg-void-700/50 dark:hover:text-void-300",title:eU?"Copied!":"Copy title",children:eU?(0,t.jsx)("svg",{className:"h-4 w-4 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),(0,t.jsxs)("div",{className:"flex flex-shrink-0 flex-col items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-3",children:[!m&&(0,t.jsxs)("label",{className:`flex items-center gap-1 sm:gap-2 ${e.archived?"cursor-not-allowed opacity-40":"cursor-pointer"}`,title:e.archived?"Unarchive card before enabling automation":"Toggle automation mode",children:[(0,t.jsx)("span",{className:`hidden sm:inline text-xs font-medium ${e7?"text-orange-600 dark:text-orange-400":"text-void-500 dark:text-void-400"}`,children:"Automation"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e7,disabled:!!e.archived,onClick:()=>{if(!e.archived)if(e7){let{automation:t,...r}=e;c({...r,updated_at:new Date().toISOString()}),p?.(!1)}else c({...e,automation:{enabled:!1,schedule:"",scheduleType:"recurring",provider:"claude",freshSession:!1,reportViaMessaging:!1},updated_at:new Date().toISOString()}),p?.(!0)},className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.archived?"cursor-not-allowed":"cursor-pointer"} ${e7?"bg-orange-500 focus:ring-orange-500":"bg-void-300 focus:ring-void-500 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${e7?"translate-x-4":"translate-x-0"}`})})]}),!m&&(0,t.jsxs)("label",{className:`flex items-center gap-1 sm:gap-2 ${e7?"cursor-not-allowed opacity-40":"cursor-pointer"}`,title:e7?"Automation cards cannot be archived":"Archive card",children:[(0,t.jsx)("span",{className:`hidden sm:inline text-xs font-medium ${e.archived?"text-red-600 dark:text-red-400":"text-void-500 dark:text-void-400"}`,children:"Archived"}),(0,t.jsx)("button",{type:"button",role:"switch","aria-checked":e.archived||!1,disabled:e7,onClick:()=>{e7||c({...e,archived:!e.archived,updated_at:new Date().toISOString()})},className:`relative inline-flex h-5 w-9 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-2 ${e7?"cursor-not-allowed":"cursor-pointer"} ${e.archived?"bg-red-500 focus:ring-red-500":"bg-void-300 focus:ring-void-500 dark:bg-void-600"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${e.archived?"translate-x-4":"translate-x-0"}`})})]}),!m&&x&&(0,t.jsx)("button",{onClick:()=>B(!0),className:"rounded-lg p-2 text-void-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:"Delete card permanently",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,t.jsx)("button",{onClick:tv,className:"rounded-lg p-2 text-void-400 hover:bg-void-100 hover:text-void-600 dark:hover:bg-void-800 dark:hover:text-void-300",children:(0,t.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),!m&&(0,t.jsx)("div",{ref:eI,children:(0,t.jsx)(Y.VoiceControlBar,{voiceState:eD.voiceState,elapsedSeconds:eD.elapsedSeconds,disabled:!eD.hasFieldFocus&&"idle"===eD.voiceState,error:eD.error,onRecord:eD.startRecording,onPause:eD.pauseRecording,onResume:eD.resumeRecording,onClear:eD.clearRecording,onSubmit:eD.submitRecording,onRetry:eD.retryTranscription,onOpenSettings:()=>{Date.now()-eE.current<200||eD.setShowSettings(!eD.showSettings)}})})]})]}),(0,t.jsxs)("div",{className:`grain grain-soft flex overflow-x-auto scrollbar-hide ${te.tabsBorder} ${te.tabs}`,children:[(0,t.jsx)("button",{onClick:()=>b("details"),className:`shrink-0 px-4 py-2 text-sm font-medium transition-colors ${"details"===v?e7?"border-b-2 border-orange-400 text-orange-500 dark:text-orange-400":"border-b-2 border-neon-blue-400 text-neon-blue-500 dark:text-neon-blue-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:"Details"}),e3&&(0,t.jsxs)("button",{onClick:()=>b("design"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"design"===v?"border-b-2 border-neon-blue-300 text-neon-blue-400 dark:text-neon-blue-300":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Design"]}),e6&&(0,t.jsxs)("button",{onClick:()=>b("feature"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"feature"===v?"border-b-2 border-neon-blue-400 text-neon-blue-500 dark:text-neon-blue-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),"Feature"]}),e8&&(0,t.jsxs)("button",{onClick:()=>b("test"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"test"===v?"border-b-2 border-[#00e676] text-[#00e676]/80 dark:text-[#00e676]/80":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),"Test"]}),(0,t.jsxs)("button",{onClick:()=>b("notes"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"notes"===v?"border-b-2 border-purple-400 text-purple-500 dark:text-purple-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),"Notes",(e.agentNotes?.length??0)>0&&(0,t.jsx)("span",{className:"rounded bg-purple-100 px-1.5 py-0.5 text-xs dark:bg-purple-900/50",children:e.agentNotes.length})]}),e9&&(0,t.jsxs)("button",{onClick:()=>b("checklist"),className:`flex shrink-0 items-center gap-1 px-4 py-2 text-sm font-medium transition-colors ${"checklist"===v?"border-b-2 border-[#ffd600] text-[#ffd600]/80 dark:text-[#ffd600]/80":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Checklist",(0,t.jsxs)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs dark:bg-amber-900/50",children:[eg.filter(e=>e.done).length,"/",eg.length]})]}),(0,t.jsxs)("button",{onClick:()=>b("terminal"),className:`flex shrink-0 items-center gap-2 px-4 py-2 text-sm font-medium transition-colors ${"terminal"===v?"border-b-2 border-neon-orange-400 text-neon-orange-500 dark:text-neon-orange-400":"text-void-500 hover:text-void-700 dark:text-void-400 dark:hover:text-void-300"}`,children:[(0,t.jsx)("div",{className:`h-2 w-2 rounded-full ${eJ?"bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.6)]":"bg-void-400"}`}),"Terminal",eJ&&(0,t.jsx)("span",{className:"rounded bg-orange-100 px-1.5 py-0.5 text-xs dark:bg-orange-900/50",children:W?.status})]})]}),(0,t.jsx)("div",{className:"terminal"===v||"notes"===v?"min-h-0 flex-1 lg:flex-initial lg:h-[60vh]":"min-h-0 flex-1 overflow-y-auto overscroll-contain lg:flex-initial lg:max-h-[60vh]",children:"details"===v?(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[!e7&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Stage:"}),(0,t.jsx)("select",{value:a,onChange:t=>u(e.id,t.target.value),className:"stage-focus rounded border border-void-300 bg-white px-2 py-1 text-xs font-medium text-void-700 dark:border-void-600 dark:bg-void-800 dark:text-void-300",children:ee.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Priority:"}),(0,t.jsx)("select",{value:e.priority,onChange:t=>c({...e,priority:t.target.value,updated_at:new Date().toISOString()}),className:"stage-focus rounded border border-void-300 bg-white px-2 py-1 text-xs font-medium capitalize text-void-700 dark:border-void-600 dark:bg-void-800 dark:text-void-300",children:et.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsx)("div",{className:"h-4 w-px bg-void-300 dark:bg-void-600"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Areas:"}),e.areas.map(r=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-indigo-100 px-1.5 py-0.5 text-xs text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-300",children:[r,(0,t.jsx)("button",{onClick:()=>{c({...e,areas:e.areas.filter(e=>e!==r),updated_at:new Date().toISOString()})},className:"ml-0.5 hover:text-indigo-900 dark:hover:text-indigo-100",children:(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r)),tg.length>0&&(0,t.jsxs)("select",{value:"",onChange:t=>{var r;t.target.value&&(r=t.target.value,e.areas.includes(r)||c({...e,areas:[...e.areas,r],updated_at:new Date().toISOString()}))},className:"stage-focus rounded border border-dashed border-void-300 bg-transparent px-1.5 py-0.5 text-xs text-void-500 hover:border-void-400 dark:border-void-600 dark:text-void-400",children:[(0,t.jsx)("option",{value:"",children:"+ Add"}),tg.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]}),(0,t.jsx)("div",{className:"h-4 w-px bg-void-300 dark:bg-void-600"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Tags:"}),e.tags.map((r,a)=>(0,t.jsxs)("span",{draggable:!0,onDragStart:e=>{em(a),e.dataTransfer.effectAllowed="move"},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",ep(a)},onDragLeave:()=>ep(null),onDrop:t=>{t.preventDefault(),null!==ex&&((t,r)=>{if(t===r)return;let a=[...e.tags],[n]=a.splice(t,1);a.splice(r,0,n),c({...e,tags:a,updated_at:new Date().toISOString()}),em(null),ep(null)})(ex,a)},onDragEnd:()=>{em(null),ep(null)},className:`inline-flex cursor-grab items-center gap-1 rounded px-1.5 py-0.5 text-xs transition-all active:cursor-grabbing ${ex===a?"opacity-50":eh===a?"bg-orange-200 text-orange-700 ring-1 ring-orange-400/50 dark:bg-orange-900/30 dark:text-orange-300":0===a&&e7?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300":"bg-void-100 text-void-600 dark:bg-void-700 dark:text-void-400"}`,children:[r,(0,t.jsx)("button",{onClick:()=>{c({...e,tags:e.tags.filter(e=>e!==r),updated_at:new Date().toISOString()})},className:"ml-0.5 hover:text-void-900 dark:hover:text-void-100",children:(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},r)),(0,t.jsx)("input",{type:"text",value:ec,onChange:e=>eu(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ec.trim()&&(e.preventDefault(),tu(ec))},onBlur:()=>{ec.trim()&&tu(ec)},placeholder:"+ tag",className:"stage-focus w-16 rounded border border-dashed border-void-300 bg-transparent px-1.5 py-0.5 text-xs text-void-500 placeholder-void-400 hover:border-void-400 dark:border-void-600 dark:text-void-400 dark:placeholder-void-500"})]}),(e.design_ref||e.feature_ref||e.test_ref)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"h-4 w-px bg-void-300 dark:bg-void-600"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-void-500 dark:text-void-400",children:"Docs:"}),e.design_ref&&(0,t.jsx)("button",{onClick:()=>b("design"),className:"rounded p-1.5 text-purple-600 hover:bg-purple-100 dark:text-purple-400 dark:hover:bg-purple-900/30",title:e.design_ref,children:(0,t.jsx)("svg",{className:"h-8 w-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})})}),e.feature_ref&&(0,t.jsx)("button",{onClick:()=>b("feature"),className:"rounded p-1.5 text-blue-600 hover:bg-blue-100 dark:text-blue-400 dark:hover:bg-blue-900/30",title:e.feature_ref,children:(0,t.jsx)("svg",{className:"h-8 w-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})})}),e.test_ref&&(0,t.jsx)("button",{onClick:()=>b("test"),className:"rounded p-1.5 text-green-600 hover:bg-green-100 dark:text-green-400 dark:hover:bg-green-900/30",title:e.test_ref,children:(0,t.jsx)("svg",{className:"h-8 w-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]})]}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("label",{className:"mb-2 block text-sm font-medium text-void-700 dark:text-void-300",children:[e7?"Description / Automation Instructions":"Description",m&&(0,t.jsx)("span",{className:"ml-2 font-normal text-void-400",children:"(Ctrl+Enter to save)"})]}),(0,t.jsx)("textarea",{ref:P,value:_,"data-voice-target":!0,onChange:t=>{var r;return r=t.target.value,void(E("description"),L.current=r,$(r),c({...e,description:r,updated_at:new Date().toISOString()}))},onFocus:()=>E("description"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),tv())},placeholder:"Add a description...",className:"stage-focus h-[235px] w-full resize-none overflow-y-auto rounded-lg border border-void-300 bg-white p-3 text-sm text-void-700 dark:border-void-600 dark:bg-void-800 dark:text-void-300"})]}),e7&&e.automation?(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsx)(G,{config:e.automation,cardId:e.id,projectId:n,onChange:t=>{c({...e,automation:t,updated_at:new Date().toISOString()})}})}):(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,t.jsxs)("label",{className:"text-sm font-medium text-void-700 dark:text-void-300",children:["Problems / Issues (",th.length," open)"]}),th.length>0&&"testing"===a&&(0,t.jsx)("button",{onClick:()=>{let t=e.tags.includes("bug")?e.tags:[...e.tags,"bug"];c({...e,tags:t,type:"bug",updated_at:new Date().toISOString()}),u(e.id,"implementation")},className:"rounded bg-red-600 px-2 py-1 text-xs font-medium text-white hover:bg-red-700",children:"Push to Implementation"})]}),(0,t.jsxs)("div",{className:"mb-2 space-y-2",children:[th.map(r=>(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-lg bg-red-50 p-2 dark:bg-red-900/20",children:[(0,t.jsx)("svg",{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-red-500",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"text-sm text-red-800 dark:text-red-200",children:r.description}),(0,t.jsx)("p",{className:"text-xs text-red-600 dark:text-red-400",children:new Date(r.created_at).toLocaleDateString()})]}),(0,t.jsx)("button",{onClick:()=>{var t;return t=r.id,void c({...e,problems:e.problems.map(e=>e.id===t?{...e,resolved_at:new Date().toISOString()}:e),updated_at:new Date().toISOString()})},className:"rounded px-2 py-1 text-xs text-red-600 hover:bg-red-100 dark:text-red-400 dark:hover:bg-red-900/40",children:"Resolve"})]},r.id)),tp.length>0&&(0,t.jsxs)("details",{className:"text-sm",children:[(0,t.jsxs)("summary",{className:"cursor-pointer text-void-500",children:[tp.length," resolved"]}),(0,t.jsx)("div",{className:"mt-2 space-y-1",children:tp.map(e=>(0,t.jsx)("div",{className:"rounded bg-void-100 p-2 text-void-500 line-through dark:bg-void-800",children:e.description},e.id))})]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{type:"text","data-voice-target":!0,value:j,onChange:e=>w(e.target.value),placeholder:"Describe an issue...",className:"stage-focus flex-1 rounded-lg border border-void-300 bg-white px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 dark:text-void-100",onKeyDown:e=>"Enter"===e.key&&tc()}),(0,t.jsx)("button",{onClick:tc,className:"rounded-lg bg-void-200 px-3 py-2 text-sm font-medium text-void-700 hover:bg-void-300 dark:bg-void-700 dark:text-void-300 dark:hover:bg-void-600",children:"Add"})]})]})]}):"design"===v||"feature"===v||"test"===v?(0,t.jsxs)("div",{className:"relative p-4",children:[tn&&(0,t.jsx)("button",{onClick:()=>tx(tn),className:"absolute right-4 top-4 z-10 rounded p-1.5 text-void-400 hover:bg-void-100 hover:text-void-600 dark:hover:bg-void-800 dark:hover:text-void-300",title:eH?"Copied!":`Copy path: ${tn}`,children:eH?(0,t.jsx)("svg",{className:"h-4 w-4 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):(0,t.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})})}),f&&!to[tn]&&!ti[tn]&&(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)("div",{className:"text-void-500",children:"Loading document..."})}),tn&&ti[tn]&&!to[tn]&&(0,t.jsxs)("div",{className:"rounded-lg bg-red-50 p-4 text-red-700 dark:bg-red-900/20 dark:text-red-300",children:["Error loading document: ",ti[tn]]}),tn&&to[tn]&&(0,t.jsx)(H.MarkdownContent,{children:to[tn]})]}):"checklist"===v?(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,t.jsxs)("h3",{className:"text-lg font-medium text-void-900 dark:text-void-100",children:["Checklist (",eg.filter(e=>e.done).length,"/",eg.length," complete)"]}),(0,t.jsx)("div",{className:"h-2 flex-1 mx-4 rounded-full bg-void-200 dark:bg-void-700",children:(0,t.jsx)("div",{className:"h-2 rounded-full bg-green-500 transition-all",style:{width:`${eg.filter(e=>e.done).length/eg.length*100}%`}})})]}),(0,t.jsx)("div",{className:"space-y-2",children:eg.map(r=>(0,t.jsxs)("label",{className:`flex cursor-pointer select-none items-center gap-3 rounded-lg p-3 transition-colors active:scale-[0.99] ${r.done?"bg-green-50 dark:bg-green-900/20":"bg-void-50 hover:bg-void-100 dark:bg-void-800 dark:hover:bg-void-700"}`,children:[(0,t.jsx)("input",{type:"checkbox",checked:r.done,onChange:()=>{var t;let a;return t=r.id,E("checklist"),a=eb.current.map(e=>e.id===t?{...e,done:!e.done}:e),void(eb.current=a,ej.current=JSON.stringify(a),ev(a),c({...e,checklist:a,updated_at:new Date().toISOString()}))},className:"h-5 w-5 flex-shrink-0 rounded border-void-300 text-green-600 focus:ring-green-500"}),(0,t.jsx)("span",{className:`flex-1 ${r.done?"text-void-500 line-through":"text-void-900 dark:text-void-100"}`,children:r.text})]},r.id))}),(0,t.jsx)("div",{className:"mt-4 flex gap-2",children:(0,t.jsx)("input",{type:"text","data-voice-target":!0,placeholder:"Add checklist item...",className:"stage-focus flex-1 rounded-lg border border-void-300 bg-white px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 dark:text-void-100",onKeyDown:t=>{if("Enter"===t.key&&t.currentTarget.value.trim()){var r;let a,n;r=t.currentTarget.value.trim(),E("checklist"),a={id:`check-${Date.now()}`,text:r,done:!1},n=[...eb.current,a],eb.current=n,ej.current=JSON.stringify(n),ev(n),c({...e,checklist:n,updated_at:new Date().toISOString()}),t.currentTarget.value=""}}})})]}):"notes"===v?(0,t.jsxs)("div",{className:"flex h-full flex-col p-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,t.jsxs)("h3",{className:"text-lg font-medium text-void-900 dark:text-void-100",children:["Notes (",e.agentNotes?.length??0,")"]}),(e.agentNotes?.length??0)>0&&(ey?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-void-500",children:"Clear all notes?"}),(0,t.jsx)("button",{onClick:()=>{c({...e,agentNotes:[],updated_at:new Date().toISOString()}),eC(!1)},className:"rounded px-2 py-1 text-xs font-medium text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:"Confirm"}),(0,t.jsx)("button",{onClick:()=>eC(!1),className:"rounded px-2 py-1 text-xs font-medium text-void-500 hover:bg-void-100 dark:hover:bg-void-800",children:"Cancel"})]}):(0,t.jsx)("button",{onClick:()=>eC(!0),className:"rounded px-2 py-1 text-xs font-medium text-void-500 hover:bg-void-100 hover:text-red-600 dark:hover:bg-void-800 dark:hover:text-red-400",children:"Clear All"}))]}),(0,t.jsxs)("div",{className:"relative min-h-0 flex-1",children:[e_&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-void-100/90 to-transparent dark:from-void-900/90"}),eT&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-void-100/90 to-transparent dark:from-void-900/90"}),(0,t.jsx)("div",{ref:eS,onScroll:eP,className:"h-full overflow-y-auto",children:(e.agentNotes?.length??0)===0?(0,t.jsxs)("div",{className:"py-8 text-center text-sm text-void-400",children:["No notes yet. Add a note below or use the CLI: ",(0,t.jsxs)("code",{className:"rounded bg-void-100 px-1.5 py-0.5 text-xs dark:bg-void-800",children:["sly-kanban notes ",e.id,' add "..."']})]}):(0,t.jsx)("div",{className:"space-y-3",children:e.agentNotes.map(r=>{let a=new Date(r.timestamp),n=new Date().getTime()-a.getTime(),o=Math.floor(n/6e4),s=Math.floor(n/36e5),i=Math.floor(n/864e5),d="just now";return i>0?d=`${i}d ago`:s>0?d=`${s}h ago`:o>0&&(d=`${o}m ago`),(0,t.jsxs)("div",{className:"group rounded-lg bg-void-50 p-3 dark:bg-void-800",children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r.agent&&(0,t.jsx)("span",{className:"rounded bg-purple-100 px-1.5 py-0.5 text-xs font-medium text-purple-700 dark:bg-purple-900/40 dark:text-purple-300",children:r.agent}),r.summary&&(0,t.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs font-medium text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",title:`Summary of ${r.summarizedCount??"?"} notes${r.dateRange?` (${r.dateRange})`:""}`,children:"Summary"}),(0,t.jsx)("span",{className:"text-xs text-void-400",children:d})]}),(0,t.jsx)("button",{onClick:()=>{var t;let a;return t=r.id,a=(e.agentNotes||[]).filter(e=>e.id!==t),void c({...e,agentNotes:a,updated_at:new Date().toISOString()})},className:"rounded p-1 text-void-400 opacity-0 transition-opacity hover:bg-void-200 hover:text-red-500 group-hover:opacity-100 dark:hover:bg-void-700 dark:hover:text-red-400",title:"Delete note",children:(0,t.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-void-700 dark:text-void-200",children:r.text})]},r.id)})})})]}),(0,t.jsxs)("div",{className:"mt-4 flex flex-shrink-0 gap-2",children:[(0,t.jsx)("textarea",{value:ew,onChange:e=>eN(e.target.value),"data-voice-target":!0,placeholder:"Type a note... (Shift+Enter for new line)",rows:2,className:"stage-focus flex-1 resize-none rounded-lg border border-void-300 bg-white px-3 py-2 text-sm dark:border-void-600 dark:bg-void-800 dark:text-void-100",onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&ew.trim()&&(e.preventDefault(),eF(ew.trim()),eN(""))}}),(0,t.jsx)("button",{onClick:()=>{ew.trim()&&(eF(ew.trim()),eN(""))},disabled:!ew.trim(),className:"rounded-lg bg-purple-500 px-4 py-2 text-sm font-medium text-white hover:bg-purple-600 disabled:opacity-50 disabled:cursor-not-allowed",children:"Add"})]})]}):"terminal"===v?(0,t.jsx)("div",{className:"h-full",children:(0,t.jsx)(d.ClaudeTerminalPanel,{sessionName:eq,cwd:s,actionsConfig:q,actions:eG,context:e2,cardId:e.id,cardAreas:e.areas,stage:e7?"automation":a,initialProvider:U??void 0,footerClassName:tt,tintColor:tr,onSessionChange:e=>F(e?{status:e.status}:null),onProviderChange:e=>V(e),voiceTerminalId:"card-modal",onTerminalReady:e=>{eA.current=e?.sendInput??null,e?eD.registerTerminal("card-modal",e):eD.unregisterTerminal("card-modal")}})}):null}),"terminal"!==v&&(0,t.jsxs)("div",{className:"flex items-center justify-between border-t border-void-200 px-4 py-2 text-xs text-void-500 dark:border-void-700 dark:text-void-400",children:[(0,t.jsxs)("span",{children:["Created: ",new Date(e.created_at).toLocaleDateString()]}),(0,t.jsxs)("span",{children:["Updated: ",new Date(e.updated_at).toLocaleDateString()]})]})]}),(0,t.jsx)(X,{open:A,onClose:()=>B(!1),onConfirm:()=>{x?.(e.id),B(!1)},title:"Delete Card",message:(0,t.jsxs)(t.Fragment,{children:["Are you sure you want to permanently delete ",(0,t.jsxs)("span",{className:"font-medium text-void-900 dark:text-void-200",children:['"',e.title,'"']}),"? This action cannot be undone."]})}),eD.showSettings&&(0,R.createPortal)((0,t.jsx)(el,{anchorRef:eI,children:(0,t.jsx)(Q.VoiceSettingsPopover,{settings:eD.settings.voice,onSave:e=>eD.updateSettings({voice:e}),onClose:()=>{eE.current=Date.now(),eD.setShowSettings(!1)}})}),document.body),"error"===eD.voiceState&&eD.error&&(0,R.createPortal)((0,t.jsx)(el,{anchorRef:eI,children:(0,t.jsx)(Z.VoiceErrorPopup,{error:eD.error,hasRecording:eD.hasRecording,onRetry:()=>eD.retryTranscription(),onClear:()=>eD.clearRecording(),onClose:()=>eD.clearRecording()})}),document.body)]})}var eu=e.i(82721);function ex({nextRun:e,enabled:a}){let n,o,[s,i]=(0,r.useState)(Date.now());if((0,r.useEffect)(()=>{if(!e||!a)return;let t=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(t)},[e,a]),!e||!a)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"font-mono text-2xl font-bold tracking-wider text-void-300 dark:text-void-600",children:"--:--"}),(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] text-void-300 dark:text-void-600",children:"idle"})]});let d=Math.max(0,new Date(e).getTime()-s);if(0===d)return(0,t.jsx)("div",{className:"flex flex-col items-center justify-center",children:(0,t.jsx)("span",{className:"font-mono text-2xl font-bold tracking-wider text-orange-500 animate-pulse",children:"NOW"})});let l=Math.floor(d/1e3),c=Math.floor(l/86400),u=Math.floor(l%86400/3600),x=Math.floor(l%3600/60),m=l%60,h=e=>String(e).padStart(2,"0");return c>0?(n=`${c}d ${h(u)}:${h(x)}`,o="days hrs min"):u>0?(n=`${h(u)}:${h(x)}:${h(m)}`,o="hrs min sec"):(n=`${h(x)}:${h(m)}`,o="min sec"),(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"font-mono text-2xl font-bold tabular-nums tracking-wider text-orange-500 dark:text-orange-400",children:n}),(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] text-void-400 dark:text-void-500",children:o})]})}function em({cards:e,activeCards:a,triggeringCards:n,onCardClick:o,onCardContextMenu:s,onCreateAutomation:i}){let[d,l]=(0,r.useState)(null),[c,u]=(0,r.useState)("");(0,r.useEffect)(()=>{fetch("/api/scheduler").then(e=>e.ok?e.json():null).then(e=>{e&&(l(e.running),e.abbreviation&&u(e.abbreviation))}).catch(()=>{})},[]);let x=e.reduce((e,t)=>{let r=t.tags[0]||"Ungrouped";return e[r]||(e[r]=[]),e[r].push(t),e},{}),m=Object.keys(x).sort((e,t)=>"Ungrouped"===e?1:"Ungrouped"===t?-1:e.localeCompare(t));return(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"mx-auto max-w-5xl",children:[(0,t.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,t.jsxs)("h2",{className:"text-lg font-semibold text-void-900 dark:text-void-100",children:["Automations",(0,t.jsxs)("span",{className:"ml-2 text-sm font-normal text-void-500 dark:text-void-400",children:["(",e.length," card",1!==e.length?"s":"",")"]}),c&&(0,t.jsx)("span",{className:"ml-2 rounded bg-void-100 px-1.5 py-0.5 text-xs font-normal text-void-500 dark:bg-void-700 dark:text-void-400",children:c})]}),(0,t.jsx)("button",{onClick:i,className:"rounded-lg border border-orange-500/50 bg-orange-400/10 px-3 py-1.5 text-sm font-medium text-orange-700 transition-colors hover:bg-orange-400/20 dark:border-orange-400/40 dark:text-orange-400",children:"+ New Automation"})]}),0===e.length?(0,t.jsxs)("div",{className:"py-16 text-center",children:[(0,t.jsx)("div",{className:"mb-3 text-void-300 dark:text-void-600",children:(0,t.jsx)("svg",{className:"mx-auto h-14 w-14",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,t.jsx)("p",{className:"text-sm text-void-500 dark:text-void-400",children:"No automations configured yet."}),(0,t.jsx)("p",{className:"mt-1 text-xs text-void-400 dark:text-void-500",children:"Toggle any card to automation mode, or create a new automation above."})]}):(0,t.jsx)("div",{className:"space-y-6",children:m.map(e=>(0,t.jsx)("div",{children:(0,t.jsxs)("details",{open:!0,children:[(0,t.jsxs)("summary",{className:"mb-3 cursor-pointer text-sm font-medium text-void-600 hover:text-void-800 dark:text-void-400 dark:hover:text-void-200",children:[(0,t.jsx)("span",{className:"ml-1",children:e}),(0,t.jsxs)("span",{className:"ml-1 text-void-400 dark:text-void-500",children:["(",x[e].length,")"]})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:x[e].map(e=>{let r=!!e.automation?.enabled,i=a.has(e.id),d=n?.has(e.id)&&!i;return(0,t.jsxs)("button",{onClick:()=>o(e),onContextMenu:t=>{s&&(t.preventDefault(),s(e,t))},className:`group overflow-hidden rounded-lg text-left transition-all border border-void-200/80 border-l-[3px] border-l-orange-500/70 bg-white shadow-(--shadow-card) transition-[transform,box-shadow,border-color] duration-200 hover:translate-y-0.5 hover:shadow-[0_2px_8px_rgba(249,115,22,0.2)] hover:border-orange-400/60 dark:hover:shadow-[0_2px_8px_rgba(249,115,22,0.15)] dark:border-void-700/60 dark:border-l-orange-400/60 dark:bg-void-800 dark:hover:border-orange-400/40 ${i?"active-glow-automation":""}`,children:[(0,t.jsx)("div",{className:`automation-chevron px-5 py-3 ${i?"automation-chevron-active":""}`,children:(0,t.jsxs)("div",{className:"relative z-10 flex items-stretch gap-4",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 flex flex-col gap-1.5 justify-center",children:[(0,t.jsx)("h3",{className:"text-base font-semibold text-void-900 dark:text-void-100 truncate",children:e.title}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("p",{className:"min-w-0 flex-1 truncate text-sm text-void-600 dark:text-void-400",children:e.automation?V(e.automation.schedule,e.automation.scheduleType,"No schedule",c||void 0):"No schedule"}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.automation?.provider&&(0,t.jsx)("span",{className:"rounded bg-void-100 px-1.5 py-0.5 text-[11px] text-void-600 dark:bg-void-700 dark:text-void-400",children:e.automation.provider}),(0,t.jsx)("span",{className:`rounded px-1.5 py-0.5 text-[11px] font-medium ${r?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}`,children:r?"Enabled":"Disabled"}),e.automation?.lastResult&&(0,t.jsx)("span",{className:`rounded px-1.5 py-0.5 text-[11px] ${"success"===e.automation.lastResult?"bg-green-50 text-green-600 dark:bg-green-900/20 dark:text-green-400":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"}`,children:"success"===e.automation.lastResult?"OK":"Err"})]})]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 flex-col items-center justify-center border-l border-void-200 pl-4 dark:border-void-700/50 min-h-[52px]",children:[d?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"animate-pulse font-mono text-2xl font-bold tracking-wider text-orange-500",children:"STARTING"}),(0,t.jsx)("span",{className:"text-[9px] uppercase tracking-[0.2em] text-transparent",children:"placeholder"})]}):(0,t.jsx)(ex,{nextRun:e.automation?.nextRun,enabled:e.automation?.enabled}),(0,t.jsx)("div",{className:"mt-0.5 h-4 text-[10px] text-void-350 dark:text-void-600",children:e.automation?.lastRun?`Prev: ${new Date(e.automation.lastRun).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""})]})]})}),(0,t.jsx)("div",{className:"h-[5px] hazard-stripe"})]},e.id)})})]})},e))})]})})}function eh(){return(0,t.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})})}function ep(){return(0,t.jsx)("svg",{className:"h-3 w-3 text-void-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function eg({items:e,parentRect:a,onClose:n,onAction:o}){let s=(0,r.useRef)(null),[i,d]=(0,r.useState)(-1),[l,c]=(0,r.useState)({top:a.top,left:a.right+2});(0,r.useEffect)(()=>{if(!s.current)return;let e=s.current.getBoundingClientRect(),t=a.right+2,r=a.top;t+e.width>window.innerWidth-8&&(t=a.left-e.width-2),r+e.height>window.innerHeight-8&&(r=Math.max(8,window.innerHeight-e.height-8)),c({top:r,left:t})},[a]);let u=e.map((e,t)=>({item:e,index:t})).filter(({item:e})=>!e.disabled),x=(0,r.useCallback)(t=>{switch(t.stopPropagation(),t.key){case"ArrowDown":{t.preventDefault();let e=u.findIndex(({index:e})=>e===i),r=u[(e+1)%u.length];r&&d(r.index);break}case"ArrowUp":{t.preventDefault();let e=u.findIndex(({index:e})=>e===i),r=u[(e-1+u.length)%u.length];r&&d(r.index);break}case"ArrowLeft":case"Escape":t.preventDefault(),n();break;case"Enter":{t.preventDefault();let r=e[i];r&&!r.disabled&&r.onClick&&(r.onClick(),o())}}},[i,u,e,n,o]);return(0,r.useEffect)(()=>{s.current?.focus()},[]),(0,R.createPortal)((0,t.jsx)("div",{ref:s,tabIndex:-1,onKeyDown:x,"data-context-submenu":!0,className:"context-menu-no-ring fixed z-[52] min-w-[140px] rounded-lg border border-void-200 bg-white py-1 shadow-(--shadow-overlay) dark:border-void-600 dark:bg-void-800",style:{top:l.top,left:l.left},children:e.map((e,r)=>(0,t.jsxs)("div",{role:"menuitem",onMouseEnter:()=>d(r),onMouseLeave:()=>d(-1),onClick:()=>{e.disabled||(e.onClick?.(),o())},className:`flex w-full cursor-default items-center gap-2 px-3 py-1.5 text-left text-xs outline-none transition-colors ${e.disabled?"text-void-400 dark:text-void-500":e.danger?"cursor-pointer text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"cursor-pointer text-void-700 hover:bg-void-100 dark:text-void-300 dark:hover:bg-void-700"} ${i===r&&!e.disabled?"bg-void-100 dark:bg-void-700":""}`,children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0",children:e.checked&&(0,t.jsx)(eh,{})}),(0,t.jsx)("span",{className:"flex-1",children:e.label})]},r))}),document.body)}function ev({open:e,position:a,groups:n,accentColor:o,onClose:s}){let i,d=(0,r.useRef)(null),[l,c]=(0,r.useState)(-1),[u,x]=(0,r.useState)(null),[m,h]=(0,r.useState)(a),p=(0,r.useRef)(null),g=(0,r.useRef)(new Map),v=[];n.forEach((e,t)=>{t>0&&e.items.length>0&&v.push({type:"separator"}),e.items.forEach((e,r)=>{v.push({type:"item",item:e,groupIndex:t,itemIndex:r})})});let b=v.map((e,t)=>({entry:e,flatIndex:t})).filter(e=>"item"===e.entry.type).filter(({entry:e})=>!e.item.disabled||e.item.items);(0,r.useEffect)(()=>{if(!e||!d.current)return;let t=d.current.getBoundingClientRect(),r=a.x,n=a.y;r+t.width>window.innerWidth-8&&(r=Math.max(8,window.innerWidth-t.width-8)),n+t.height>window.innerHeight-8&&(n=Math.max(8,window.innerHeight-t.height-8)),h({x:r,y:n})},[e,a]),(0,r.useEffect)(()=>(e&&(c(-1),x(null),requestAnimationFrame(()=>{d.current?.focus(),b.length>0&&c(b[0].flatIndex)})),()=>{p.current&&clearTimeout(p.current)}),[e]),(0,r.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;if(!d.current?.contains(t)){for(let e of document.querySelectorAll("[data-context-submenu]"))if(e.contains(t))return;s()}},r=setTimeout(()=>document.addEventListener("mousedown",t),0);return()=>{clearTimeout(r),document.removeEventListener("mousedown",t)}},[e,s]);let f=(0,r.useCallback)(()=>{s()},[s]),k=(0,r.useCallback)(e=>{if(null===u)switch(e.key){case"ArrowDown":{e.preventDefault(),e.stopPropagation();let t=b.findIndex(({flatIndex:e})=>e===l),r=b[(t+1)%b.length];r&&c(r.flatIndex);break}case"ArrowUp":{e.preventDefault(),e.stopPropagation();let t=b.findIndex(({flatIndex:e})=>e===l),r=b[(t-1+b.length)%b.length];r&&c(r.flatIndex);break}case"ArrowRight":{e.preventDefault(),e.stopPropagation();let t=v[l];t?.type==="item"&&t.item.items&&x(l);break}case"Escape":e.preventDefault(),e.stopPropagation(),s();break;case"Enter":{e.preventDefault(),e.stopPropagation();let t=v[l];t?.type==="item"&&(t.item.items?x(l):!t.item.disabled&&t.item.onClick&&(t.item.onClick(),f()))}}},[l,b,v,u,s,f]),j=(0,r.useCallback)(e=>{c(e);let t=v[e];t?.type==="item"&&t.item.items?(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{x(e)},150)):(p.current&&clearTimeout(p.current),x(null))},[v]);return!e||"u"<typeof document?null:(0,R.createPortal)((0,t.jsxs)("div",{ref:d,tabIndex:-1,role:"menu",onKeyDown:k,className:"context-menu-no-ring fixed z-[51] min-w-[180px] overflow-hidden rounded-lg border border-void-200 bg-white shadow-(--shadow-overlay) dark:border-void-600 dark:bg-void-800",style:{top:m.y,left:m.x},children:[o&&(0,t.jsx)("div",{className:"h-0.5 w-full",style:{backgroundColor:(i=o.replace("border-t-","")).startsWith("[")&&i.endsWith("]")?i.slice(1,-1):({"void-400":"var(--color-void-400, #9ca3af)","neon-blue-400":"var(--color-neon-blue-400, #60a5fa)","neon-blue-500":"var(--color-neon-blue-500, #3b82f6)","green-400":"var(--color-green-400, #4ade80)","orange-400":"var(--color-orange-400, #fb923c)"})[i]||i}}),(0,t.jsx)("div",{className:"py-1",children:v.map((e,r)=>{if("separator"===e.type)return(0,t.jsx)("div",{className:"my-1 border-t border-void-200 dark:border-void-700"},`sep-${r}`);let{item:a}=e,n=!!a.items,o=a.disabled&&!n;return(0,t.jsxs)("div",{ref:e=>{e&&g.current.set(r,e)},role:"menuitem",onMouseEnter:()=>j(r),onClick:()=>{n?x(r):o||(a.onClick?.(),f())},className:`flex w-full cursor-default items-center gap-2 px-3 py-1.5 text-left text-xs outline-none transition-colors select-none ${o?"text-void-400 dark:text-void-500":a.danger?"cursor-pointer text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"cursor-pointer text-void-700 hover:bg-void-100 dark:text-void-300 dark:hover:bg-void-700"} ${l===r&&!o?"bg-void-100 dark:bg-void-700":""}`,children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0",children:a.checked&&(0,t.jsx)(eh,{})}),(0,t.jsx)("span",{className:"flex-1 truncate",children:a.label}),n&&(0,t.jsx)(ep,{})]},r)})}),v.map((e,r)=>{if("item"!==e.type||!e.item.items||u!==r)return null;let a=g.current.get(r);return a?(0,t.jsx)(eg,{items:e.item.items,parentRect:a.getBoundingClientRect(),onClose:()=>{x(null),d.current?.focus()},onAction:f},`sub-${r}`):null})]}),document.body)}var eb=e.i(68498);let ef=["backlog","design","implementation","testing","done"],ek=[{id:"backlog",label:"Backlog",color:"zinc"},{id:"design",label:"Design",color:"purple"},{id:"implementation",label:"Implementation",color:"blue"},{id:"testing",label:"Testing",color:"yellow"},{id:"done",label:"Done",color:"green"}],ej={backlog:[],design:[],implementation:[],testing:[],done:[]};function ew(e,t){return JSON.stringify(e)===JSON.stringify(t)}function eN({project:e,projectPath:a,showArchived:o=!1,showAutomations:i=!1,onAutomationToggle:d,onActiveAutomationsChange:l,onExitMode:c,onRefreshReady:u}){let x=(0,n.useSearchParams)(),m=(0,n.useRouter)(),h=(0,n.usePathname)(),[p,g]=(0,r.useState)(ej),[v,b]=(0,r.useState)(null),[f,k]=(0,r.useState)(null),[j,w]=(0,r.useState)(!1),[N,y]=(0,r.useState)(null),[C,S]=(0,r.useState)("idle"),[_,$]=(0,r.useState)(!1),[T,L]=(0,r.useState)(!1),D=(0,r.useRef)(null),R=(0,r.useRef)(null),A=(0,r.useRef)(null),B=(0,r.useRef)(!1),O=(0,r.useRef)(null),P=(0,r.useRef)(null),W=(0,r.useRef)(ej),H=(0,r.useRef)(!1),z=(0,r.useRef)(ej),[U,V]=(0,r.useState)(new Map),[q,J]=(0,r.useState)(new Set),K=(0,r.useRef)(new Set),G=(0,r.useRef)(null),[Y,Q]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(null),[et,er]=(0,r.useState)(!1),[ea,en]=(0,r.useState)(new Set),eo=(0,r.useMemo)(()=>{if(j&&N)return N;if(!v)return null;if(f){let e=p[f]?.find(e=>e.id===v);if(e)return e}for(let e of ef){let t=p[e]?.find(e=>e.id===v);if(t)return t}return null},[p,v,f,j,N]);(0,r.useEffect)(()=>{if(v&&f&&!j&&!p[f]?.some(e=>e.id===v)){for(let e of ef)if(p[e]?.some(e=>e.id===v))return void k(e)}},[p,v,f,j]),z.current=p;let es=(0,r.useCallback)(async t=>{try{let r=await fetch("/api/bridge/sessions",{signal:t});if(r.ok){let t=(await r.json()).sessions||[],a=new Map,n=RegExp(`^${e.id}:(?:[^:]+:)?card:(.+)$`);for(let e of t){let t=e.name.match(n);if(t){let r=t[1];"running"===e.status?a.set(r,"running"):"detached"===e.status?a.set(r,"detached"):e.hasHistory&&a.set(r,"resumable")}}V(a)}}catch{}},[e.id]),ei=(0,r.useCallback)(async t=>{try{let r=await fetch("/api/bridge/stats",{signal:t});if(r.ok){let t=await r.json(),a=new Set,n=RegExp(`^${e.id}:(?:[^:]+:)?card:(.+)$`);for(let e of t.sessions)if(e.isActive){let t=e.name.match(n);t&&a.add(t[1])}let o=K.current,s=[...a].filter(e=>!o.has(e)),i=[...o].filter(e=>!a.has(e));s.length>0&&console.log(`[Activity] Cards became active: [${s.join(", ")}]`,t.sessions.filter(e=>e.isActive)),i.length>0&&console.log(`[Activity] Cards became inactive: [${i.join(", ")}]`),K.current=a,J(a),s.length>0&&en(e=>{let t=new Set(e),r=!1;for(let e of s)t.has(e)&&(t.delete(e),r=!0);return r?t:e})}}catch{}},[e.id]);(0,s.usePolling)(es,5e3),(0,s.usePolling)(ei,2e3),(0,r.useEffect)(()=>{if(!l)return;let e=new Set;for(let t of ef)for(let r of p[t])r.automation&&e.add(r.id);l([...q].some(t=>e.has(t)))},[q,p,l]);let ed=(0,r.useCallback)(async(t=!1,r)=>{if(!H.current&&!B.current)try{let a=await fetch(`/api/kanban?projectId=${e.id}`,{signal:r}),n=await a.json();if(t&&P.current===n.last_updated||H.current||B.current)return;P.current=n.last_updated;let o=n.stages||ej;g(o),W.current=o,L(!1)}catch{}},[e.id]),el=(0,r.useCallback)(async()=>{try{let t=await fetch(`/api/kanban?projectId=${e.id}`),r=await t.json();P.current=r.last_updated;let a=r.stages||ej;g(a),W.current=a,H.current=!1,L(!1)}catch{}},[e.id]);(0,r.useEffect)(()=>{u?.(el)},[el,u]),(0,r.useEffect)(()=>{ed().then(()=>$(!0))},[ed]),(0,r.useEffect)(()=>{if(!_)return;let e=x.get("card");if(e&&G.current!==e)for(let t of ef){let r=p[t]?.find(t=>t.id===e);if(r){G.current=e,b(r.id),k(t);break}}},[_,x,p]),(0,r.useEffect)(()=>(A.current=M.connectionManager.createManagedEventSource(`/api/kanban/stream?projectId=${e.id}`,{update:e=>{let t=JSON.parse(e.data);if(O.current){let e=new Date(O.current).getTime();if(new Date(t.timestamp).getTime()-e<2e3)return}B.current||H.current||(L(!0),setTimeout(()=>L(!1),3e3),ed())},onError:()=>{}}),()=>{A.current&&(M.connectionManager.closeConnection(A.current),A.current=null)}),[e.id,ed]),(0,r.useEffect)(()=>E.subscribe(t=>{"kanban-update"!==t.type&&"kanban-reload"!==t.type||t.projectId&&t.projectId!==e.id||B.current||H.current||ed()}),[e.id,ed]);let ex=(0,r.useCallback)(async e=>{B.current||H.current||await ed(!0,e)},[ed]);(0,s.usePolling)(ex,1e4);let eh=(0,r.useCallback)(async t=>{S("saving"),B.current=!0;try{let r=[],a=new Map;for(let e of ef)for(let t of W.current[e]||[])a.set(t.id,JSON.stringify(t)+"|"+e);for(let e of ef)for(let n of t[e]||[]){let t=a.get(n.id),o=JSON.stringify(n)+"|"+e;t!==o&&r.push(n.id),a.delete(n.id)}for(let e of a.keys())r.push(e);let n=await fetch("/api/kanban",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:e.id,stages:t,changedCardIds:r})});n.ok?(O.current=(await n.json()).last_updated,W.current=t,H.current=!ew(z.current,t),S("saved"),E.broadcast("kanban-update",e.id),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{S("idle")},800)):S("error")}catch(e){console.error("Failed to save kanban:",e),S("error")}finally{B.current=!1}},[e.id]);(0,r.useEffect)(()=>{if(_){if(ew(p,W.current)){H.current=!1,D.current&&(clearTimeout(D.current),D.current=null);return}return H.current=!0,D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{eh(p)},2e3),()=>{D.current&&clearTimeout(D.current),R.current&&clearTimeout(R.current)}}},[p,_,eh]);let ep=(e,t,r=!1)=>{er(r),b(e.id),k(t)},eg=()=>{let e=new Date().toISOString(),t={id:`card-${Date.now()}`,title:"",description:"",type:"feature",priority:"medium",areas:[],tags:[],problems:[],checklist:[],order:0,created_at:e,updated_at:e};y(t),b(t.id),k("backlog"),w(!0)},eN=(e,t,r)=>{g(a=>{var n,s;let i=null,d=null;for(let t of ef){let r=a[t].find(t=>t.id===e);if(r){i=t,d=r;break}}if(!i||!d)return a;let l=a[i].filter(t=>t.id!==e),c=[...i===t?l:a[t]].filter(e=>o?!0===e.archived:!e.archived&&!e.automation).sort((e,t)=>e.order-t.order),u=r??c.length;if(i===t&&void 0!==r){let t=[...a[i]].filter(e=>o?!0===e.archived:!e.archived&&!e.automation).sort((e,t)=>e.order-t.order).findIndex(t=>t.id===e);-1!==t&&t<r&&(u=Math.max(0,r-1))}let x=(n=c,s=u,0===n.length?10:0===s?n[0].order/2:s>=n.length?n[n.length-1].order+10:(n[s-1].order+n[s].order)/2),m={...d,order:x,updated_at:new Date().toISOString()};return i===t?{...a,[i]:[...l,m]}:{...a,[i]:l,[t]:[...a[t],m]}}),v===e&&k(t)},ey=(0,r.useCallback)((e,t,r)=>{r.preventDefault(),Q({position:{x:r.clientX,y:r.clientY},card:e,stage:t})},[]),eC=(0,r.useCallback)(()=>{Q(null)},[]),eS=(0,r.useCallback)((e,t)=>{let r={backlog:"Backlog",design:"Design",implementation:"Implementation",testing:"Testing",done:"Done"},a={critical:"Critical",high:"High",medium:"Medium",low:"Low"};return[{items:[{label:"Move to stage",items:["backlog","design","implementation","testing","done"].map(a=>({label:r[a],checked:a===t,disabled:a===t,onClick:()=>{eN(e.id,a)}}))},{label:"Set priority",items:["critical","high","medium","low"].map(r=>({label:a[r],checked:r===e.priority,disabled:r===e.priority,onClick:()=>{g(a=>({...a,[t]:a[t].map(t=>t.id===e.id?{...t,priority:r,updated_at:new Date().toISOString()}:t)}))}}))}]},{items:[{label:"Open details",onClick:()=>{ep(e,t,!0)}},{label:"Copy",items:[{label:"Card ID",onClick:()=>{navigator.clipboard.writeText(e.id)}},{label:"Title",onClick:()=>{navigator.clipboard.writeText(e.title)}},{label:"Description",onClick:()=>{navigator.clipboard.writeText(e.description||"")}}]}]},{items:[{label:e.automation?"Archive (disabled — automation)":e.archived?"Unarchive":"Archive",disabled:!!e.automation,onClick:()=>{e.automation||g(r=>({...r,[t]:r[t].map(t=>t.id===e.id?{...t,archived:!e.archived,updated_at:new Date().toISOString()}:t)}))}},{label:"Delete",danger:!0,onClick:()=>{ee(e)}}]}]},[eN]),e_=(0,r.useCallback)((t,r)=>{let a={critical:"Critical",high:"High",medium:"Medium",low:"Low"},n=[{items:[{label:"Set priority",items:["critical","high","medium","low"].map(e=>({label:a[e],checked:e===t.priority,disabled:e===t.priority,onClick:()=>{g(a=>({...a,[r]:a[r].map(r=>r.id===t.id?{...r,priority:e,updated_at:new Date().toISOString()}:r)}))}}))}]},{items:[{label:"Open details",onClick:()=>{ep(t,r,!0)}},{label:"Copy",items:[{label:"Card ID",onClick:()=>{navigator.clipboard.writeText(t.id)}},{label:"Title",onClick:()=>{navigator.clipboard.writeText(t.title)}},{label:"Description",onClick:()=>{navigator.clipboard.writeText(t.description||"")}}]}]},{items:[{label:"Delete",danger:!0,onClick:()=>{ee(t)}}]}];return t.automation&&n.push({items:[{label:t.automation.enabled?"Disable":"Enable",onClick:()=>{g(e=>({...e,[r]:e[r].map(e=>e.id===t.id&&e.automation?{...e,automation:{...e.automation,enabled:!e.automation.enabled},updated_at:new Date().toISOString()}:e)}))}},{label:"Run now",onClick:()=>{en(e=>new Set(e).add(t.id)),fetch("/api/scheduler",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trigger",cardId:t.id,projectId:e.id})}).catch(()=>{en(e=>{let r=new Set(e);return r.delete(t.id),r})}),setTimeout(()=>{en(e=>{let r=new Set(e);return r.delete(t.id),r})},15e3)}}]}),n},[]),e$=(0,r.useCallback)(e=>{for(let t of ef)if(p[t].find(t=>t.id===e)){g(r=>({...r,[t]:r[t].filter(t=>t.id!==e)}));break}ee(null)},[p]);return((0,I.useKeyboardShortcuts)({onEscape:()=>{(o||i)&&c?c():m.push("/")},enabled:!eo}),_)?(0,t.jsxs)("div",{className:"relative flex flex-1 flex-col overflow-hidden",children:[(0,t.jsx)(eu.ConnectionStatusIndicator,{position:"top-right"}),(0,t.jsx)(eb.VersionUpdateToast,{}),(0,t.jsxs)("div",{className:"absolute top-1 right-4 z-10 flex gap-3",children:[T&&(0,t.jsx)("span",{className:"text-xs text-blue-600 dark:text-blue-400",children:"↻ Updated externally"}),(0,t.jsx)("span",{className:`text-xs transition-opacity ${"idle"===C?"opacity-0 duration-500":"saved"===C?"opacity-60 text-green-600 dark:text-green-400 duration-500":"saving"===C?"opacity-60 text-void-500 dark:text-void-400 duration-150":"opacity-100 text-red-600 dark:text-red-400 duration-150"}`,children:"saving"===C?"●":"error"===C?"✗ Save failed":"●"})]}),(0,t.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[i?(0,t.jsx)(em,{cards:ef.flatMap(e=>p[e].filter(e=>!!e.automation&&!e.archived)),activeCards:q,triggeringCards:ea,onCardClick:e=>{let t=ef.find(t=>p[t].some(t=>t.id===e.id));t&&ep(e,t)},onCardContextMenu:(e,t)=>{let r=ef.find(t=>p[t].some(t=>t.id===e.id));r&&ey(e,r,t)},onCreateAutomation:()=>{let e=new Date().toISOString(),t={id:`card-${Date.now()}`,title:"",description:"",type:"chore",priority:"medium",areas:[],tags:[],problems:[],checklist:[],automation:{enabled:!1,schedule:"",scheduleType:"recurring",provider:"claude",freshSession:!1,reportViaMessaging:!1},created_at:e,updated_at:e,order:0};y(t),b(t.id),k("backlog"),w(!0)}}):(0,t.jsx)("div",{className:"flex-1 overflow-x-auto p-4 pt-2 snap-x snap-mandatory sm:snap-none",children:(0,t.jsx)("div",{className:"mx-auto flex h-full w-full max-w-[1984px] gap-4",children:ek.map(e=>(0,t.jsx)(F,{stage:e,cards:[...p[e.id]].filter(e=>o?!0===e.archived:!e.archived&&!e.automation).sort((e,t)=>e.order-t.order),cardSessions:U,activeCards:q,onCardClick:t=>ep(t,e.id),onCardContextMenu:(t,r)=>ey(t,e.id,r),onMoveCard:eN,onAddCardClick:"backlog"!==e.id||o?void 0:eg},e.id))})}),eo&&f&&(0,t.jsx)(ec,{card:eo,stage:f,projectId:e.id,projectPath:a,onClose:()=>{ew(p,W.current)||(D.current&&(clearTimeout(D.current),D.current=null),eh(p)),b(null),k(null),w(!1),y(null),G.current=null,x.get("card")&&m.replace(h,{scroll:!1})},onUpdate:e=>{j&&N&&e.id===N.id?y(e):f&&g(t=>({...t,[f]:t[f].map(t=>t.id===e.id?e:t)}))},onMove:eN,onDelete:e=>{f&&(g(t=>({...t,[f]:t[f].filter(t=>t.id!==e)})),b(null),k(null))},isCreateMode:j,onCreate:j?e=>{let t=new Date().toISOString(),r={...e,id:`card-${Date.now()}`,order:p.backlog.length>0?Math.max(...p.backlog.map(e=>e.order))+10:10,created_at:t,updated_at:t};g(e=>({...e,backlog:[...e.backlog,r]}))}:void 0,onAutomationToggle:d,suppressAutoTerminal:et})]}),(0,t.jsx)(ev,{open:!!Y,position:Y?.position??{x:0,y:0},groups:Y?Y.card.automation&&i?e_(Y.card,Y.stage):eS(Y.card,Y.stage):[],accentColor:Y?Y.card.automation&&i?"border-t-orange-400":({backlog:"border-t-void-400",design:"border-t-neon-blue-400",implementation:"border-t-neon-blue-500",testing:"border-t-[#ff6a33]",done:"border-t-green-400"})[Y.stage]||"border-t-void-400":void 0,onClose:eC}),(0,t.jsx)(X,{open:!!Z,onClose:()=>ee(null),onConfirm:()=>{Z&&e$(Z.id)},title:"Delete Card",message:Z?(0,t.jsxs)(t.Fragment,{children:["Are you sure you want to permanently delete ",(0,t.jsxs)("span",{className:"font-medium text-void-900 dark:text-void-200",children:['"',Z.title,'"']}),"? This action cannot be undone."]}):""}),(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-[1.2px] left-4 w-72 text-center text-[10px] text-void-400 dark:text-void-600",children:"© 2026 SlyCode (slycode.ai). All rights reserved."})]}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,t.jsx)("div",{className:"text-void-500",children:"Loading kanban..."})})}function ey({project:e,projectPath:a}){let[n,o]=(0,r.useState)(!1),[s,i]=(0,r.useState)(!1),[d,l]=(0,r.useState)(!1),c=(0,r.useRef)(null),u=(0,r.useCallback)(async()=>{await c.current?.()},[]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(L,{name:e.name,description:e.description,tags:e.tags,projectId:e.id,projectPath:a,showArchived:n,onToggleArchived:()=>{o(!n),n||i(!1)},showAutomations:s,hasActiveAutomations:d,onToggleAutomations:()=>{i(!s),s||o(!1)},onRefresh:u}),(0,t.jsx)(r.Suspense,{children:(0,t.jsx)(eN,{project:e,projectPath:a,showArchived:n,showAutomations:s,onActiveAutomationsChange:l,onAutomationToggle:e=>{i(e),e&&o(!1)},onExitMode:()=>{o(!1),i(!1)},onRefreshReady:e=>{c.current=e}})})]})}e.s(["ProjectView",()=>ey],72630)},27444,e=>{"use strict";var t=e.i(18050),r=e.i(71645),a=e.i(64103),n=e.i(79951),o=e.i(1088);function s({projectId:e,projectName:s,projectDescription:i,projectPath:d,children:l}){let[c,u]=(0,r.useState)(!1),[x,m]=(0,r.useState)(!1),h=(0,o.useVoice)(),p=(0,r.useCallback)(async t=>{let r=RegExp(`^${e}:(?:[^:]+:)?global$`);try{let e=await fetch("/api/bridge/stats",{signal:t});if(e.ok){let t=await e.json(),a=t.sessions.find(e=>"global:global"===e.name||/^global:[^:]+:global$/.test(e.name)),n=t.sessions.find(e=>r.test(e.name));u(a?.isActive??!1),m(n?.isActive??!1)}}catch{}},[e]);return(0,a.usePolling)(p,2e3),(0,r.useEffect)(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),(0,t.jsxs)("div",{className:`flex h-svh flex-col overflow-hidden bg-void-50 dark:bg-void-950 ${c?"active-glow-border-left":""}`,children:[l,(0,t.jsx)(n.GlobalClaudePanel,{projectId:e,projectName:s,projectDescription:i,projectPath:d,isActive:x,voiceTerminalId:"project-global",onTerminalReady:e=>{e?h.registerTerminal("project-global",e):h.unregisterTerminal("project-global")}})]})}e.s(["ProjectPageClient",()=>s])}]);
|