profclaw 0.0.1-beta.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -38
- package/CONTRIBUTING.md +3 -5
- package/README.md +128 -63
- package/dist/chat/execution/tools/index.d.ts +1 -1
- package/dist/chat/execution/tools/index.js +41 -2
- package/dist/chat/providers/slack/index.d.ts +2 -2
- package/dist/cli/commands/models.js +39 -26
- package/dist/cli/commands/onboard.js +64 -79
- package/dist/cli/commands/setup.js +293 -90
- package/dist/cli/index.js +0 -6
- package/dist/cli/providers.d.ts +15 -0
- package/dist/cli/providers.js +41 -0
- package/dist/core/deployment.js +2 -0
- package/dist/providers/ai-sdk.js +26 -6
- package/dist/routes/channels.d.ts +12 -0
- package/dist/routes/channels.js +166 -0
- package/dist/server/route-loader.js +1 -0
- package/dist/server.js +115 -109
- package/package.json +1 -1
- package/skills/git-workflow/SKILL.md +3 -3
- package/ui/dist/assets/{ActivityView-DIPQSJ_d.js → ActivityView-BeshZXmE.js} +1 -1
- package/ui/dist/assets/{AgentList-CqyaYrcq.js → AgentList-QVHeldPi.js} +1 -1
- package/ui/dist/assets/{AnalyticsDashboard-C-mjuGHT.js → AnalyticsDashboard-C9R97dXE.js} +1 -1
- package/ui/dist/assets/{AreaChart-CfYWmbtr.js → AreaChart-B73gaiVQ.js} +1 -1
- package/ui/dist/assets/{CartesianChart-BaQ3It0c.js → CartesianChart-CXYL2R-A.js} +1 -1
- package/ui/dist/assets/{ChatView-DxxQy6pl.js → ChatView-qjZErlrp.js} +1 -1
- package/ui/dist/assets/{CostsDashboard-CDBBcGkg.js → CostsDashboard-O4DCLy1i.js} +1 -1
- package/ui/dist/assets/{EstimateSelect-CDjf5qKl.js → EstimateSelect-1hQf4Osk.js} +1 -1
- package/ui/dist/assets/{FloatingChatbot-CZHjvJIe.js → FloatingChatbot-BZBzrJxd.js} +1 -1
- package/ui/dist/assets/{InviteCodeManagement-DTm-IPTm.js → InviteCodeManagement-LEoGqYeA.js} +1 -1
- package/ui/dist/assets/{ProjectDetail-DlYUcOss.js → ProjectDetail--gPfvATB.js} +1 -1
- package/ui/dist/assets/{ProjectIcon-BMRpnM04.js → ProjectIcon-Chd_ofsw.js} +1 -1
- package/ui/dist/assets/{ProjectList-D85TN0i0.js → ProjectList-BvUfVB6c.js} +1 -1
- package/ui/dist/assets/{Settings-CgPqzUvj.js → Settings-1kaf7VHE.js} +1 -1
- package/ui/dist/assets/{StatusIndicator-yig0uZEA.js → StatusIndicator-pRfkNcdV.js} +1 -1
- package/ui/dist/assets/{SummaryDetail-CwLAfHgJ.js → SummaryDetail-DV3AmONk.js} +1 -1
- package/ui/dist/assets/{SummaryList-BvS5Idnu.js → SummaryList-B6kXiTxL.js} +1 -1
- package/ui/dist/assets/{TaskDetail-zarC1fOt.js → TaskDetail-CV6CzbOS.js} +1 -1
- package/ui/dist/assets/{TaskList-CyJq3ANE.js → TaskList-DL7brQKd.js} +1 -1
- package/ui/dist/assets/{TicketBoard-BlWr3-iH.js → TicketBoard-CrkkFj7C.js} +1 -1
- package/ui/dist/assets/{TicketDetail-DmqWKj2W.js → TicketDetail-hnnYclpD.js} +1 -1
- package/ui/dist/assets/{TicketList-Scj4pMWa.js → TicketList-CsDAyQCL.js} +1 -1
- package/ui/dist/assets/{UserManagement-BH7uG7dw.js → UserManagement-BGFQyTSr.js} +1 -1
- package/ui/dist/assets/{ViewSwitcher-3HzZUdWn.js → ViewSwitcher-CnL0OqA8.js} +1 -1
- package/ui/dist/assets/{alert-dialog-DWPb2IfQ.js → alert-dialog-SKM6Gjz4.js} +1 -1
- package/ui/dist/assets/{archive-CGck7gxR.js → archive-BsLa7brF.js} +1 -1
- package/ui/dist/assets/{badge-DEmc3Z_l.js → badge-CVHH1a-v.js} +1 -1
- package/ui/dist/assets/{brain-CfFdLVqb.js → brain-6o_RHVpe.js} +1 -1
- package/ui/dist/assets/{bug-DqSGPUUE.js → bug-CmZI7jqM.js} +1 -1
- package/ui/dist/assets/{calendar-BuZ4zbPW.js → calendar-Bf0t2B82.js} +1 -1
- package/ui/dist/assets/{chevron-up-DcJ4LL_N.js → chevron-up-CoUsOvZj.js} +1 -1
- package/ui/dist/assets/{circle-x-C78PNZjF.js → circle-x-Dgw11LgT.js} +1 -1
- package/ui/dist/assets/{constants-DhDjZe4P.js → constants-Q5Zivl-a.js} +1 -1
- package/ui/dist/assets/{cpu-Ck6AoG8c.js → cpu-DiPMQICV.js} +1 -1
- package/ui/dist/assets/{database-CA2w8Lvt.js → database-BwTfupDi.js} +1 -1
- package/ui/dist/assets/{dialog-BOdGWhgE.js → dialog-BUqN9Psj.js} +1 -1
- package/ui/dist/assets/{ellipsis-FhHKRbfl.js → ellipsis-UJx4Xnf6.js} +1 -1
- package/ui/dist/assets/{ellipsis-vertical-CO0UqE4-.js → ellipsis-vertical-DoULYEKn.js} +1 -1
- package/ui/dist/assets/{file-code-ChnhYYj1.js → file-code-B2UrJLwi.js} +1 -1
- package/ui/dist/assets/{folder-open-CHwA1-ve.js → folder-open-BJi577JH.js} +1 -1
- package/ui/dist/assets/{funnel-ByEjRFNB.js → funnel-PkaD_HSR.js} +1 -1
- package/ui/dist/assets/{git-branch-GTOPQgU4.js → git-branch-C_K30am0.js} +1 -1
- package/ui/dist/assets/{git-commit-horizontal-F5M84Kut.js → git-commit-horizontal-IT6ecxWQ.js} +1 -1
- package/ui/dist/assets/{globe-CQWfr7hT.js → globe-f-jjCa_g.js} +1 -1
- package/ui/dist/assets/{hash-nKC9gtLg.js → hash-DNEv8Elo.js} +1 -1
- package/ui/dist/assets/{history-DfFSA9xJ.js → history-BQSBo_1Q.js} +1 -1
- package/ui/dist/assets/{index-DHGvP9mp.js → index-BUmnwPQr.js} +1 -1
- package/ui/dist/assets/{index-Z4-RtZcs.js → index-BfF5G4Cw.js} +1 -1
- package/ui/dist/assets/{index-DeI8lKRR.js → index-C8N375c2.js} +1 -1
- package/ui/dist/assets/index-CuxnqVVz.css +1 -0
- package/ui/dist/assets/{index-Ca3vk7Gq.js → index-CzMM3QOk.js} +1 -1
- package/ui/dist/assets/{index--JkIxVXb.js → index-lJlNPFVJ.js} +3 -3
- package/ui/dist/assets/{index-a4Fxq0Hb.js → index-nS3EErDg.js} +1 -1
- package/ui/dist/assets/{layers-DFeLExSa.js → layers-jFqVrWMD.js} +1 -1
- package/ui/dist/assets/{layout-dashboard-WmgjMhWF.js → layout-dashboard-CcKt1hXw.js} +1 -1
- package/ui/dist/assets/{lightbulb-Bo8hEr7B.js → lightbulb-Jhp7FvbU.js} +1 -1
- package/ui/dist/assets/{link-2-YqrpQXBH.js → link-2-DdO7ostF.js} +1 -1
- package/ui/dist/assets/{markdown-renderer-Croje6Xe.js → markdown-renderer-n1ToC4XQ.js} +1 -1
- package/ui/dist/assets/{message-square-CD0H5hot.js → message-square-CBgH65X7.js} +1 -1
- package/ui/dist/assets/{pencil-DpFnj5dn.js → pencil-CYXCEPQh.js} +1 -1
- package/ui/dist/assets/{play-DVgea_jT.js → play-d1ONaH0-.js} +1 -1
- package/ui/dist/assets/{popover-JXecfWG5.js → popover-CrmZgoWu.js} +1 -1
- package/ui/dist/assets/{progress-C1ghf1Fu.js → progress-uv4SPkL5.js} +1 -1
- package/ui/dist/assets/{rocket-BFxPYGx9.js → rocket-DhvUetsk.js} +1 -1
- package/ui/dist/assets/{select-MADP8m6Q.js → select-CeQ8AHGy.js} +1 -1
- package/ui/dist/assets/{send-eYnW_7n-.js → send-P0r5D7td.js} +1 -1
- package/ui/dist/assets/{server-CPMaysH8.js → server-CVHTZB72.js} +1 -1
- package/ui/dist/assets/{settings-2-scXUOuE_.js → settings-2-ocj5uHGx.js} +1 -1
- package/ui/dist/assets/{sheet-r6NSOxi-.js → sheet-DuQExSho.js} +1 -1
- package/ui/dist/assets/{shield-check-PEr7nmVw.js → shield-check-DfVdE34l.js} +1 -1
- package/ui/dist/assets/{shield-off-CLtXio62.js → shield-off-8l0J6R-8.js} +1 -1
- package/ui/dist/assets/{skeleton-C9oEzNlU.js → skeleton-TFiFJ3nB.js} +1 -1
- package/ui/dist/assets/{smartphone-DusFfY0U.js → smartphone-77_g3SQn.js} +1 -1
- package/ui/dist/assets/{square-e1yxB2eR.js → square-Ckzsr3Rn.js} +1 -1
- package/ui/dist/assets/{switch-tNs0n-kz.js → switch-CAePkd6k.js} +1 -1
- package/ui/dist/assets/{table-CXxtLicg.js → table-ZjAZ7hkt.js} +1 -1
- package/ui/dist/assets/{tag-tAwMmQ9G.js → tag-C35mgoEv.js} +1 -1
- package/ui/dist/assets/{textarea-BjiEeIWh.js → textarea-DsVPnSgR.js} +1 -1
- package/ui/dist/assets/{timer-Vel1N3RP.js → timer-DHJBS2w1.js} +1 -1
- package/ui/dist/assets/{tooltip-ZMwtfr1J.js → tooltip-BYmQ331W.js} +1 -1
- package/ui/dist/assets/{trash-2-eM-CNwsZ.js → trash-2-keO5tKPE.js} +1 -1
- package/ui/dist/assets/{trending-up-BGafmjRo.js → trending-up-BBv8KbrY.js} +1 -1
- package/ui/dist/assets/{wand-sparkles-DPvcd9Pi.js → wand-sparkles-BusQ52ZK.js} +1 -1
- package/ui/dist/assets/{wrench-B8s3zYVV.js → wrench-02YaOSiK.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/dist/chat/auto-reply.d.ts +0 -90
- package/dist/chat/auto-reply.js +0 -272
- package/dist/chat/execution/pty.d.ts +0 -92
- package/dist/chat/execution/pty.js +0 -285
- package/dist/chat/execution/tools/glinr-ops.d.ts +0 -202
- package/dist/chat/execution/tools/glinr-ops.js +0 -694
- package/dist/cli/commands/browser.d.ts +0 -3
- package/dist/cli/commands/browser.js +0 -138
- package/dist/cli/commands/canvas.d.ts +0 -3
- package/dist/cli/commands/canvas.js +0 -155
- package/dist/cli/commands/nodes.d.ts +0 -3
- package/dist/cli/commands/nodes.js +0 -193
- package/dist/diagnostics/exporters.d.ts +0 -21
- package/dist/diagnostics/exporters.js +0 -138
- package/dist/diagnostics/index.d.ts +0 -10
- package/dist/diagnostics/index.js +0 -9
- package/dist/diagnostics/middleware.d.ts +0 -12
- package/dist/diagnostics/middleware.js +0 -58
- package/dist/diagnostics/tracer.d.ts +0 -133
- package/dist/diagnostics/tracer.js +0 -257
- package/dist/discovery/index.d.ts +0 -8
- package/dist/discovery/index.js +0 -7
- package/dist/discovery/mdns.d.ts +0 -40
- package/dist/discovery/mdns.js +0 -249
- package/dist/plugins/registry.d.ts +0 -122
- package/dist/plugins/registry.js +0 -352
- package/dist/plugins/sandbox.d.ts +0 -77
- package/dist/plugins/sandbox.js +0 -287
- package/dist/plugins/search/brave.d.ts +0 -9
- package/dist/plugins/search/brave.js +0 -157
- package/dist/plugins/search/duckduckgo.d.ts +0 -9
- package/dist/plugins/search/duckduckgo.js +0 -171
- package/dist/plugins/search/index.d.ts +0 -13
- package/dist/plugins/search/index.js +0 -23
- package/dist/plugins/search/searxng.d.ts +0 -9
- package/dist/plugins/search/searxng.js +0 -170
- package/dist/plugins/search/serper.d.ts +0 -9
- package/dist/plugins/search/serper.js +0 -135
- package/dist/plugins/search/tavily.d.ts +0 -9
- package/dist/plugins/search/tavily.js +0 -146
- package/dist/providers/adapters/anthropic.d.ts +0 -26
- package/dist/providers/adapters/anthropic.js +0 -306
- package/dist/providers/adapters/base.d.ts +0 -53
- package/dist/providers/adapters/base.js +0 -99
- package/dist/providers/adapters/ollama.d.ts +0 -30
- package/dist/providers/adapters/ollama.js +0 -292
- package/dist/utils/ai-cache.d.ts +0 -72
- package/dist/utils/ai-cache.js +0 -204
- package/dist/utils/file-lock.d.ts +0 -85
- package/dist/utils/file-lock.js +0 -204
- package/ui/dist/assets/index-WclMPci1.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,i as l}from"./index
|
|
1
|
+
import{j as s,i as l}from"./index-lJlNPFVJ.js";function h({status:e,label:a,size:n="md",pulse:r=!0,showLabel:d=!0,className:t}){const o={online:{color:"bg-green-500",shadow:"shadow-[0_0_10px_oklch(0.6_0.2_150)]",defaultLabel:"Online"},processing:{color:"bg-blue-500",shadow:"shadow-[0_0_10px_oklch(0.6_0.2_250)]",defaultLabel:"Processing"},error:{color:"bg-red-500",shadow:"shadow-[0_0_10px_oklch(0.6_0.2_20)]",defaultLabel:"Error"},offline:{color:"bg-slate-400",shadow:"shadow-none",defaultLabel:"Offline"}}[e],c={sm:"h-1.5 w-1.5",md:"h-2 w-2",lg:"h-3 w-3"};return s.jsxs("div",{className:l("flex items-center gap-2",t),children:[s.jsx("div",{className:l(c[n],"rounded-full",o.color,o.shadow,r&&e!=="offline"&&"animate-pulse")}),d&&s.jsx("span",{className:l("text-[10px] font-bold uppercase tracking-widest",e==="offline"?"text-muted-foreground":"text-foreground/80"),children:a||o.defaultLabel})]})}export{h as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{E as k,r as $,u as L,j as e,h as o,k as u,G as S,l as j,O as T,Q as B,b as r,f as l,B as F,g as I,d as i,e as n,U as N,J as A,t as D,i as f,m as E}from"./index
|
|
1
|
+
import{E as k,r as $,u as L,j as e,h as o,k as u,G as S,l as j,O as T,Q as B,b as r,f as l,B as F,g as I,d as i,e as n,U as N,J as A,t as D,i as f,m as E}from"./index-lJlNPFVJ.js";import{B as d}from"./badge-CVHH1a-v.js";import{S as x}from"./skeleton-TFiFJ3nB.js";import{F as g}from"./file-code-B2UrJLwi.js";import{C as b}from"./cpu-DiPMQICV.js";import{L as W}from"./link-2-DdO7ostF.js";import{L as w}from"./lightbulb-Jhp7FvbU.js";function G(){const{id:c}=k(),[m,h]=$.useState(!1),{data:s,isLoading:y,error:v}=L({queryKey:["summaries",c],queryFn:()=>E.summaries.get(c),enabled:!!c}),C=async()=>{if(!s)return;const t=`# ${s.title}
|
|
2
2
|
|
|
3
3
|
## What Changed
|
|
4
4
|
${s.whatChanged}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,u as f,j as e,b as l,f as i,d as N,e as v,w,I as b,L as C,N as x,h as S,B as L,l as A,m as k}from"./index
|
|
1
|
+
import{r as m,u as f,j as e,b as l,f as i,d as N,e as v,w,I as b,L as C,N as x,h as S,B as L,l as A,m as k}from"./index-lJlNPFVJ.js";import{B as r}from"./badge-CVHH1a-v.js";import{S as F,a as y,b as B,c as I,d as h}from"./select-CeQ8AHGy.js";import{C as q}from"./cpu-DiPMQICV.js";import"./chevron-up-CoUsOvZj.js";function V(){const[t,u]=m.useState("all"),[a,j]=m.useState(""),{data:g,isLoading:p,error:n}=f({queryKey:["summaries",{agent:t==="all"?void 0:t,limit:50}],queryFn:()=>k.summaries.list({agent:t==="all"?void 0:t,limit:50})}),c=g?.summaries??[],d=Array.from(new Set(c.map(s=>s.agent))),o=c.filter(s=>a?s.title.toLowerCase().includes(a.toLowerCase())||s.whatChanged.toLowerCase().includes(a.toLowerCase()):!0);return n?e.jsx(l,{children:e.jsx(i,{className:"p-6",children:e.jsxs("p",{className:"text-center text-destructive",children:["Error loading summaries: ",n.message]})})}):e.jsx("div",{className:"space-y-4",children:e.jsxs(l,{children:[e.jsx(N,{children:e.jsx(v,{children:"AI Summaries"})}),e.jsxs(i,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(w,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(b,{placeholder:"Search summaries...",value:a,onChange:s=>j(s.target.value),className:"pl-8"})]}),d.length>0&&e.jsxs(F,{value:t,onValueChange:u,children:[e.jsx(y,{className:"w-[180px]",children:e.jsx(B,{placeholder:"Filter by agent"})}),e.jsxs(I,{children:[e.jsx(h,{value:"all",children:"All Agents"}),d.map(s=>e.jsx(h,{value:s,children:s},s))]})]})]}),p?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):o.length===0?e.jsxs("div",{className:"flex h-40 flex-col items-center justify-center",children:[e.jsx(x,{className:"h-12 w-12 text-muted-foreground mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No summaries found"})]}):e.jsx("div",{className:"space-y-3",children:o.map(s=>e.jsx(S,{to:`/summaries/${s.id}`,className:"block",children:e.jsx(l,{className:"glass rounded-[16px] hover-lift transition-liquid group border-white/5",children:e.jsx(i,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold truncate group-hover:text-primary transition-colors",children:s.title}),e.jsxs(r,{className:"bg-indigo-500/10 text-indigo-400 border-indigo-500/20",children:[e.jsx(L,{className:"h-3 w-3 mr-1"}),s.agent]}),s.model&&e.jsxs(r,{variant:"outline",className:"text-xs border-white/10",children:[e.jsx(q,{className:"h-3 w-3 mr-1"}),s.model]})]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.whatChanged}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[s.filesChanged?.length>0&&e.jsxs(r,{variant:"outline",className:"text-[10px] border-white/10",children:[e.jsx(x,{className:"h-3 w-3 mr-1"}),s.filesChanged.length," files"]}),s.blockers?.length>0&&e.jsxs(r,{className:"text-[10px] bg-red-500/10 text-red-400 border-red-500/20",children:[s.blockers.length," blockers"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date(s.createdAt).toLocaleDateString()}),e.jsx(A,{className:"h-4 w-4 text-muted-foreground group-hover:translate-x-1 transition-transform"})]})]})})})},s.id))})]})]})})}export{V as SummaryList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as b,E as w,s as k,n as y,o as g,t as o,m as f,j as e,h as m,k as c,G as T,l as _,i as N,L as x,H as A,J as S,K as C,M as P}from"./index
|
|
1
|
+
import{u as b,E as w,s as k,n as y,o as g,t as o,m as f,j as e,h as m,k as c,G as T,l as _,i as N,L as x,H as A,J as S,K as C,M as P}from"./index-lJlNPFVJ.js";import{S as L}from"./StatusIndicator-pRfkNcdV.js";import{H as j}from"./hash-DNEv8Elo.js";import{S as D}from"./square-Ckzsr3Rn.js";import{P as F}from"./play-d1ONaH0-.js";import{C as q}from"./calendar-Bf0t2B82.js";import{H as E}from"./history-BQSBo_1Q.js";const M="http://localhost:3000";function I(t){return b({queryKey:["tasks",t],queryFn:async()=>{const a=await fetch(`${M}/api/tasks/${t}`);if(!a.ok)throw new Error("Task not found");return(await a.json()).task},enabled:!!t})}function U(){const{id:t}=w(),a=k(),r=y(),{data:s,isLoading:n,error:v}=I(t||""),d=g({mutationFn:()=>f.tasks.cancel(t),onSuccess:()=>{o.success("Task cancelled"),r.invalidateQueries({queryKey:["tasks"]})},onError:l=>{o.error(l.message||"Failed to cancel task")}}),i=g({mutationFn:()=>f.tasks.retry(t),onSuccess:l=>{o.success("Task queued for retry"),r.invalidateQueries({queryKey:["tasks"]}),a(`/tasks/${l.task.id}`)},onError:l=>{o.error(l.message||"Failed to retry task")}});return n?e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-8 w-32 glass animate-pulse rounded-lg"}),e.jsx("div",{className:"h-64 glass animate-pulse rounded-[24px]"})]}):v||!s?e.jsxs("div",{className:"max-w-5xl mx-auto glass rounded-[24px] p-20 text-center",children:[e.jsx(j,{className:"h-16 w-16 mx-auto text-red-500 mb-4 opacity-20"}),e.jsx("h3",{className:"text-xl font-bold",children:"Task Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The task you're looking for doesn't exist or has been archived."}),e.jsx(m,{to:"/tasks",children:e.jsx(c,{variant:"outline",className:"rounded-xl px-6",children:"Back to Tasks"})})]}):e.jsxs("div",{className:"max-w-6xl mx-auto flex flex-col gap-8",children:[e.jsxs("nav",{className:"flex items-center gap-2",children:[e.jsx(m,{to:"/tasks",className:"p-2 hover:bg-white/5 rounded-full transition-colors group",children:e.jsx(T,{className:"h-4 w-4 group-hover:-translate-x-1 transition-transform"})}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:[e.jsx(m,{to:"/tasks",className:"hover:text-foreground transition-colors",children:"Tasks"}),e.jsx(_,{className:"h-3 w-3"}),e.jsx("span",{className:"text-foreground truncate max-w-[200px]",children:s.title})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 items-start",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-8",children:[e.jsxs("div",{className:"glass rounded-[32px] p-8 relative overflow-hidden",children:[e.jsx("div",{className:N("absolute -top-24 -right-24 w-64 h-64 rounded-full blur-[100px] opacity-10",s.status==="completed"?"bg-green-500":s.status==="failed"?"bg-red-500":"bg-blue-500")}),e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(L,{status:s.status==="completed"?"online":s.status==="failed"?"error":s.status==="in_progress"?"processing":"offline",label:s.status,size:"md"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground opacity-50",children:["#",s.id.split("-")[0]]})]}),e.jsx("h1",{className:"text-3xl font-extrabold tracking-tight leading-tight",children:s.title})]}),e.jsxs("div",{className:"flex gap-2",children:[(s.status==="failed"||s.status==="completed")&&e.jsx(c,{variant:"outline",size:"icon",onClick:()=>i.mutate(),disabled:i.isPending,title:"Retry task",children:i.isPending?e.jsx(x,{className:"h-4 w-4 animate-spin"}):e.jsx(A,{className:"h-4 w-4"})}),(s.status==="in_progress"||s.status==="pending")&&e.jsxs(c,{variant:"destructive",onClick:()=>d.mutate(),disabled:d.isPending,children:[d.isPending?e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(D,{className:"mr-2 h-4 w-4 fill-current"}),"Cancel"]}),(s.status==="failed"||s.status==="completed")&&e.jsxs(c,{onClick:()=>i.mutate(),disabled:i.isPending,children:[i.isPending?e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(F,{className:"mr-2 h-4 w-4 fill-current"}),"Run Again"]})]})]}),e.jsx("p",{className:"text-muted-foreground leading-relaxed mb-6",children:s.description||"No description provided for this task."}),e.jsxs("div",{className:"flex flex-wrap gap-4 pt-6 border-t border-white/5",children:[e.jsx(u,{label:"Source",value:s.source,icon:S,...s.sourceUrl?{href:s.sourceUrl}:{}}),e.jsx(u,{label:"Priority",value:`P${s.priority}`,icon:j}),e.jsx(u,{label:"Created",value:new Date(s.createdAt).toLocaleDateString(),icon:q})]})]}),e.jsxs("div",{className:"glass rounded-[24px] overflow-hidden shadow-inner",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 bg-primary/5",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg glass-heavy flex items-center justify-center shadow-sm",children:e.jsx(C,{className:"h-4 w-4 text-primary"})}),e.jsx("h3",{className:"text-sm font-black uppercase tracking-[0.2em] text-foreground/80",children:"Instruction Prompt"})]}),e.jsx("div",{className:"p-6 recessed-card font-mono text-xs leading-relaxed text-foreground/80 overflow-x-auto whitespace-pre-wrap selection:bg-primary/20",children:s.prompt})]})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"glass rounded-[28px] p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(E,{className:"h-4 w-4 text-indigo-400"}),e.jsx("h3",{className:"text-sm font-bold uppercase tracking-widest",children:"Task Timeline"})]}),e.jsxs("div",{className:"relative pl-6 space-y-8 before:absolute before:left-[11px] before:top-2 before:bottom-2 before:w-[2px] before:bg-white/5",children:[e.jsx(p,{title:"Task Created",time:new Date(s.createdAt).toLocaleTimeString(),status:"completed"}),s.startedAt&&e.jsx(p,{title:"Optimization Started",time:new Date(s.startedAt).toLocaleTimeString(),status:"completed"}),e.jsx(p,{title:s.status==="pending"?"Queued":s.status==="in_progress"?"In Progress":s.status==="completed"?"Success":"Failed",time:s.completedAt?new Date(s.completedAt).toLocaleTimeString():"Current Step",status:s.status==="completed"?"completed":s.status==="failed"?"error":"processing"})]})]}),e.jsxs("div",{className:"glass rounded-[28px] p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(P,{className:"h-4 w-4 text-emerald-400"}),e.jsx("h3",{className:"text-sm font-bold uppercase tracking-widest",children:"Work Metrics"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(h,{label:"Status",value:s.status.toUpperCase()}),e.jsx(h,{label:"Duration",value:s.completedAt?`${((new Date(s.completedAt).getTime()-new Date(s.startedAt||s.createdAt).getTime())/1e3).toFixed(1)}s`:"--"}),e.jsx(h,{label:"Assigned Agent",value:s.assignedAgent??"Unassigned"})]})]})]})]})]})}function u({label:t,value:a,icon:r,href:s}){const n=e.jsxs("div",{className:"flex items-center gap-2 group/meta cursor-default",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg glass-heavy flex items-center justify-center border-white/5",children:e.jsx(r,{className:"h-3.5 w-3.5 text-muted-foreground group-hover/meta:text-[var(--primary)] transition-colors"})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"premium-label",children:t}),e.jsx("span",{className:"text-[11px] font-bold truncate max-w-[120px]",children:a})]})]});return s?e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80 transition-opacity",children:n}):n}function p({title:t,time:a,status:r}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:N("absolute -left-[23px] top-1.5 h-3.5 w-3.5 rounded-full border-2 border-background z-10",r==="completed"?"bg-green-500 shadow-[0_0_8px_oklch(0.6_0.2_150)]":r==="error"?"bg-red-500 shadow-[0_0_8px_oklch(0.6_0.2_20)]":"bg-blue-500 shadow-[0_0_8px_oklch(0.6_0.2_250)] animate-pulse")}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[13px] font-bold",children:t}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:a})]})]})}function h({label:t,value:a}){return e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:t}),e.jsx("span",{className:"text-[11px] font-extrabold uppercase tracking-tight",children:a})]})}export{U as TaskDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,n as K,o as J,t as D,m as Q,j as e,k as p,P as X,p as S,I as R,q as W,s as Y,u as Z,v as M,w as ee,a as O,g as q,C as U,X as se,L as ae,D as te,x as re,y as le,z as ie}from"./index--JkIxVXb.js";import{B as _}from"./badge-DEmc3Z_l.js";import{S as T,a as P,b as k,c as A,d as i}from"./select-MADP8m6Q.js";import{T as ne,a as oe,b as B,c as f,d as ce,e as v}from"./table-CXxtLicg.js";import{D as de,a as xe,b as ue,c as me,d as he,e as ge,f as pe}from"./dialog-BOdGWhgE.js";import{T as H}from"./textarea-BjiEeIWh.js";import{P as E}from"./play-DVgea_jT.js";import{F as je}from"./funnel-ByEjRFNB.js";import{E as Ne}from"./ellipsis-FhHKRbfl.js";import"./chevron-up-DcJ4LL_N.js";function fe(){const[u,j]=d.useState(!1),[N,r]=d.useState(""),[n,l]=d.useState(""),[t,b]=d.useState(""),[o,m]=d.useState("manual"),[c,h]=d.useState("3"),F=K(),{mutate:w,isPending:C}=J({mutationFn:a=>Q.tasks.create(a),onSuccess:()=>{D.success("Task created successfully!"),F.invalidateQueries({queryKey:["tasks"]}),j(!1),r(""),l(""),b(""),m("manual"),h("3")},onError:a=>{D.error(`Failed to create task: ${a.message}`)}}),L=a=>{if(a.preventDefault(),!N.trim()){D.error("Title is required");return}if(!t.trim()){D.error("Prompt is required");return}w({title:N,description:n||void 0,prompt:t,source:o,priority:parseInt(c),labels:[]})};return e.jsxs(de,{open:u,onOpenChange:j,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(p,{children:[e.jsx(X,{className:"mr-2 h-4 w-4"}),"Create Task"]})}),e.jsx(ue,{className:"sm:max-w-[525px] glass rounded-[24px] border-white/10",children:e.jsxs("form",{onSubmit:L,children:[e.jsxs(me,{children:[e.jsx(he,{className:"text-xl font-bold",children:"Create New Task"}),e.jsx(ge,{className:"text-muted-foreground",children:"Create a new task for the AI agents to execute"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"title",className:"text-sm font-semibold",children:"Title *"}),e.jsx(R,{id:"title",value:N,onChange:a=>r(a.target.value),placeholder:"Fix bug in authentication",className:"bg-white/5 border-white/10 rounded-xl"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"description",className:"text-sm font-semibold",children:"Description"}),e.jsx(H,{id:"description",value:n,onChange:a=>l(a.target.value),placeholder:"Optional description...",rows:3,className:"bg-white/5 border-white/10 rounded-xl resize-none"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"prompt",className:"text-sm font-semibold",children:"AI Prompt *"}),e.jsx(H,{id:"prompt",value:t,onChange:a=>b(a.target.value),placeholder:"Detailed instructions for the AI agent...",rows:4,className:"bg-white/5 border-white/10 rounded-xl resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"source",className:"text-sm font-semibold",children:"Source"}),e.jsxs(T,{value:o,onValueChange:m,children:[e.jsx(P,{id:"source",className:"bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{})}),e.jsxs(A,{className:"glass-heavy rounded-xl border-white/10",children:[e.jsx(i,{value:"manual",children:"Manual"}),e.jsx(i,{value:"github_issue",children:"GitHub Issue"}),e.jsx(i,{value:"jira",children:"Jira"}),e.jsx(i,{value:"linear",children:"Linear"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"priority",className:"text-sm font-semibold",children:"Priority"}),e.jsxs(T,{value:c,onValueChange:h,children:[e.jsx(P,{id:"priority",className:"bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{})}),e.jsxs(A,{className:"glass-heavy rounded-xl border-white/10",children:[e.jsx(i,{value:"1",children:"Critical (P1)"}),e.jsx(i,{value:"2",children:"High (P2)"}),e.jsx(i,{value:"3",children:"Medium (P3)"}),e.jsx(i,{value:"4",children:"Low (P4)"})]})]})]})]})]}),e.jsxs(pe,{className:"gap-2",children:[e.jsx(p,{type:"button",variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(p,{type:"submit",disabled:C,children:C?"Creating...":"Create Task"})]})]})})]})}const ve=[{value:"all",label:"All Status",icon:O},{value:"pending",label:"Pending",icon:q},{value:"in_progress",label:"Running",icon:E},{value:"completed",label:"Completed",icon:U},{value:"failed",label:"Failed",icon:M}],be=["all","github","jira","linear","manual","webhook"],we=["all","openclaw","claude-code","auto"];function ze(){const[u,j]=W(),N=Y(),r=u.get("status")||"all",n=u.get("source")||"all",l=u.get("agent")||"all",[t,b]=d.useState(u.get("q")||""),[o,m]=d.useState(0),c=20,h=(s,x)=>{const g=new URLSearchParams(u);x==="all"||x===""?g.delete(s):g.set(s,x),j(g),m(0)},F=()=>{j({}),b(""),m(0)},w=r!=="all"||n!=="all"||l!=="all"||t,{data:C,isLoading:L,error:a}=Z({queryKey:["tasks",{status:r==="all"?void 0:r,limit:c,offset:o*c}],queryFn:()=>Q.tasks.list({status:r==="all"?void 0:r,limit:c,offset:o*c})}),V=C?.tasks??[],z=C?.total??0,y=d.useMemo(()=>V.filter(s=>{const x=!t||s.title.toLowerCase().includes(t.toLowerCase())||s.description?.toLowerCase().includes(t.toLowerCase()),g=n==="all"||s.source.toLowerCase()===n,I=l==="all"||s.assignedAgent?.toLowerCase()===l||l==="auto"&&!s.assignedAgent;return x&&g&&I}),[V,t,n,l]),$=s=>{const g={completed:{variant:"success",icon:U},failed:{variant:"destructive",icon:M},running:{variant:"info",icon:E},pending:{variant:"secondary",icon:q},in_progress:{variant:"info",icon:E}}[s]||{variant:"secondary",icon:q},{variant:I,icon:G}=g;return e.jsxs(_,{variant:I,className:"gap-1.5 px-2 py-0.5 font-medium",children:[e.jsx(G,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:s.replace("_"," ")})]})};return a?e.jsxs("div",{className:"glass rounded-[28px] p-12 text-center",children:[e.jsx(M,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:"Error loading tasks"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.message})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[z," total tasks • ",y.length," showing"]})]}),e.jsx(fe,{})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ee,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(R,{placeholder:"Search tasks...",value:t,onChange:s=>{b(s.target.value),h("q",s.target.value)},className:"pl-10 bg-white/5 border-white/10 rounded-xl h-10"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(T,{value:r,onValueChange:s=>h("status",s),children:[e.jsx(P,{className:"w-[140px] bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{placeholder:"Status"})}),e.jsx(A,{className:"glass-heavy rounded-xl border-white/10",children:ve.map(s=>e.jsx(i,{value:s.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(s.icon,{className:"h-3.5 w-3.5"}),s.label]})},s.value))})]}),e.jsxs(T,{value:n,onValueChange:s=>h("source",s),children:[e.jsx(P,{className:"w-[130px] bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{placeholder:"Source"})}),e.jsx(A,{className:"glass-heavy rounded-xl border-white/10",children:be.map(s=>e.jsx(i,{value:s,className:"capitalize",children:s==="all"?"All Sources":s},s))})]}),e.jsxs(T,{value:l,onValueChange:s=>h("agent",s),children:[e.jsx(P,{className:"w-[140px] bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{placeholder:"Agent"})}),e.jsx(A,{className:"glass-heavy rounded-xl border-white/10",children:we.map(s=>e.jsx(i,{value:s,className:"capitalize",children:s==="all"?"All Agents":s},s))})]}),w&&e.jsxs(p,{variant:"ghost",size:"sm",onClick:F,className:"rounded-xl text-muted-foreground hover:text-foreground",children:[e.jsx(se,{className:"h-4 w-4 mr-1"}),"Clear"]})]})]}),w&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3 pt-3 border-t border-white/5",children:[e.jsx(je,{className:"h-4 w-4 text-muted-foreground"}),r!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-blue-500/10 text-blue-400 text-xs font-medium",children:["Status: ",r]}),n!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-indigo-500/10 text-indigo-400 text-xs font-medium capitalize",children:["Source: ",n]}),l!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-green-500/10 text-green-400 text-xs font-medium capitalize",children:["Agent: ",l]}),t&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-orange-500/10 text-orange-400 text-xs font-medium",children:['Search: "',t,'"']})]})]}),e.jsx("div",{className:"glass-heavy rounded-[24px] overflow-hidden border border-white/10 shadow-float",children:L?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ae,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):y.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(O,{className:"h-12 w-12 mx-auto text-muted-foreground/40 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-muted-foreground",children:"No tasks found"}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mt-1",children:w?"Try adjusting your filters":"Create a task to get started"})]}):e.jsxs(ne,{children:[e.jsx(oe,{className:"bg-muted/30",children:e.jsxs(B,{className:"hover:bg-transparent border-white/5",children:[e.jsx(f,{className:"w-[400px]",children:"Task"}),e.jsx(f,{className:"w-[140px]",children:"Status"}),e.jsx(f,{children:"Agent"}),e.jsx(f,{children:"Source"}),e.jsx(f,{className:"text-right",children:"Created"}),e.jsx(f,{className:"w-[50px]"})]})}),e.jsx(ce,{children:y.map(s=>e.jsxs(B,{className:"group cursor-pointer hover:bg-white/5 border-white/5",onClick:()=>N(`/tasks/${s.id}`),children:[e.jsx(v,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:e.jsx(O,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-semibold text-foreground group-hover:text-primary transition-colors",children:s.title}),s.description&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:s.description})]})]})}),e.jsx(v,{children:$(s.status)}),e.jsx(v,{children:s.assignedAgent?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-gradient-to-br from-indigo-500 to-purple-500 flex items-center justify-center text-[10px] uppercase text-white font-bold",children:s.assignedAgent[0]}),e.jsx("span",{className:"text-sm capitalize",children:s.assignedAgent})]}):e.jsx("span",{className:"text-sm text-muted-foreground italic",children:"Unassigned"})}),e.jsx(v,{children:e.jsx(_,{variant:"outline",className:"capitalize bg-muted/50",children:s.source})}),e.jsx(v,{className:"text-right text-muted-foreground text-sm font-mono",children:new Date(s.createdAt).toLocaleDateString()}),e.jsx(v,{onClick:x=>x.stopPropagation(),children:e.jsxs(te,{children:[e.jsx(re,{asChild:!0,children:e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ne,{className:"h-4 w-4"})})}),e.jsx(le,{align:"end",children:e.jsx(ie,{onClick:()=>N(`/tasks/${s.id}`),children:"View Details"})})]})})]},s.id))})]})}),y.length>0&&e.jsxs("div",{className:"flex items-center justify-between border-t border-white/10 pt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",o+1," • Showing ",Math.min(y.length,c)," of ",z]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:()=>m(o-1),disabled:o===0,className:"rounded-xl border-white/10",children:"Previous"}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>m(o+1),disabled:(o+1)*c>=z,className:"rounded-xl border-white/10",children:"Next"})]})]})]})}export{ze as TaskList};
|
|
1
|
+
import{r as d,n as K,o as J,t as D,m as Q,j as e,k as p,P as X,p as S,I as R,q as W,s as Y,u as Z,v as M,w as ee,a as O,g as q,C as U,X as se,L as ae,D as te,x as re,y as le,z as ie}from"./index-lJlNPFVJ.js";import{B as _}from"./badge-CVHH1a-v.js";import{S as T,a as P,b as k,c as A,d as i}from"./select-CeQ8AHGy.js";import{T as ne,a as oe,b as B,c as f,d as ce,e as v}from"./table-ZjAZ7hkt.js";import{D as de,a as xe,b as ue,c as me,d as he,e as ge,f as pe}from"./dialog-BUqN9Psj.js";import{T as H}from"./textarea-DsVPnSgR.js";import{P as E}from"./play-d1ONaH0-.js";import{F as je}from"./funnel-PkaD_HSR.js";import{E as Ne}from"./ellipsis-UJx4Xnf6.js";import"./chevron-up-CoUsOvZj.js";function fe(){const[u,j]=d.useState(!1),[N,r]=d.useState(""),[n,l]=d.useState(""),[t,b]=d.useState(""),[o,m]=d.useState("manual"),[c,h]=d.useState("3"),F=K(),{mutate:w,isPending:C}=J({mutationFn:a=>Q.tasks.create(a),onSuccess:()=>{D.success("Task created successfully!"),F.invalidateQueries({queryKey:["tasks"]}),j(!1),r(""),l(""),b(""),m("manual"),h("3")},onError:a=>{D.error(`Failed to create task: ${a.message}`)}}),L=a=>{if(a.preventDefault(),!N.trim()){D.error("Title is required");return}if(!t.trim()){D.error("Prompt is required");return}w({title:N,description:n||void 0,prompt:t,source:o,priority:parseInt(c),labels:[]})};return e.jsxs(de,{open:u,onOpenChange:j,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(p,{children:[e.jsx(X,{className:"mr-2 h-4 w-4"}),"Create Task"]})}),e.jsx(ue,{className:"sm:max-w-[525px] glass rounded-[24px] border-white/10",children:e.jsxs("form",{onSubmit:L,children:[e.jsxs(me,{children:[e.jsx(he,{className:"text-xl font-bold",children:"Create New Task"}),e.jsx(ge,{className:"text-muted-foreground",children:"Create a new task for the AI agents to execute"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"title",className:"text-sm font-semibold",children:"Title *"}),e.jsx(R,{id:"title",value:N,onChange:a=>r(a.target.value),placeholder:"Fix bug in authentication",className:"bg-white/5 border-white/10 rounded-xl"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"description",className:"text-sm font-semibold",children:"Description"}),e.jsx(H,{id:"description",value:n,onChange:a=>l(a.target.value),placeholder:"Optional description...",rows:3,className:"bg-white/5 border-white/10 rounded-xl resize-none"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"prompt",className:"text-sm font-semibold",children:"AI Prompt *"}),e.jsx(H,{id:"prompt",value:t,onChange:a=>b(a.target.value),placeholder:"Detailed instructions for the AI agent...",rows:4,className:"bg-white/5 border-white/10 rounded-xl resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"source",className:"text-sm font-semibold",children:"Source"}),e.jsxs(T,{value:o,onValueChange:m,children:[e.jsx(P,{id:"source",className:"bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{})}),e.jsxs(A,{className:"glass-heavy rounded-xl border-white/10",children:[e.jsx(i,{value:"manual",children:"Manual"}),e.jsx(i,{value:"github_issue",children:"GitHub Issue"}),e.jsx(i,{value:"jira",children:"Jira"}),e.jsx(i,{value:"linear",children:"Linear"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"priority",className:"text-sm font-semibold",children:"Priority"}),e.jsxs(T,{value:c,onValueChange:h,children:[e.jsx(P,{id:"priority",className:"bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{})}),e.jsxs(A,{className:"glass-heavy rounded-xl border-white/10",children:[e.jsx(i,{value:"1",children:"Critical (P1)"}),e.jsx(i,{value:"2",children:"High (P2)"}),e.jsx(i,{value:"3",children:"Medium (P3)"}),e.jsx(i,{value:"4",children:"Low (P4)"})]})]})]})]})]}),e.jsxs(pe,{className:"gap-2",children:[e.jsx(p,{type:"button",variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(p,{type:"submit",disabled:C,children:C?"Creating...":"Create Task"})]})]})})]})}const ve=[{value:"all",label:"All Status",icon:O},{value:"pending",label:"Pending",icon:q},{value:"in_progress",label:"Running",icon:E},{value:"completed",label:"Completed",icon:U},{value:"failed",label:"Failed",icon:M}],be=["all","github","jira","linear","manual","webhook"],we=["all","openclaw","claude-code","auto"];function ze(){const[u,j]=W(),N=Y(),r=u.get("status")||"all",n=u.get("source")||"all",l=u.get("agent")||"all",[t,b]=d.useState(u.get("q")||""),[o,m]=d.useState(0),c=20,h=(s,x)=>{const g=new URLSearchParams(u);x==="all"||x===""?g.delete(s):g.set(s,x),j(g),m(0)},F=()=>{j({}),b(""),m(0)},w=r!=="all"||n!=="all"||l!=="all"||t,{data:C,isLoading:L,error:a}=Z({queryKey:["tasks",{status:r==="all"?void 0:r,limit:c,offset:o*c}],queryFn:()=>Q.tasks.list({status:r==="all"?void 0:r,limit:c,offset:o*c})}),V=C?.tasks??[],z=C?.total??0,y=d.useMemo(()=>V.filter(s=>{const x=!t||s.title.toLowerCase().includes(t.toLowerCase())||s.description?.toLowerCase().includes(t.toLowerCase()),g=n==="all"||s.source.toLowerCase()===n,I=l==="all"||s.assignedAgent?.toLowerCase()===l||l==="auto"&&!s.assignedAgent;return x&&g&&I}),[V,t,n,l]),$=s=>{const g={completed:{variant:"success",icon:U},failed:{variant:"destructive",icon:M},running:{variant:"info",icon:E},pending:{variant:"secondary",icon:q},in_progress:{variant:"info",icon:E}}[s]||{variant:"secondary",icon:q},{variant:I,icon:G}=g;return e.jsxs(_,{variant:I,className:"gap-1.5 px-2 py-0.5 font-medium",children:[e.jsx(G,{className:"h-3 w-3"}),e.jsx("span",{className:"capitalize",children:s.replace("_"," ")})]})};return a?e.jsxs("div",{className:"glass rounded-[28px] p-12 text-center",children:[e.jsx(M,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:"Error loading tasks"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.message})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[z," total tasks • ",y.length," showing"]})]}),e.jsx(fe,{})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ee,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(R,{placeholder:"Search tasks...",value:t,onChange:s=>{b(s.target.value),h("q",s.target.value)},className:"pl-10 bg-white/5 border-white/10 rounded-xl h-10"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(T,{value:r,onValueChange:s=>h("status",s),children:[e.jsx(P,{className:"w-[140px] bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{placeholder:"Status"})}),e.jsx(A,{className:"glass-heavy rounded-xl border-white/10",children:ve.map(s=>e.jsx(i,{value:s.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(s.icon,{className:"h-3.5 w-3.5"}),s.label]})},s.value))})]}),e.jsxs(T,{value:n,onValueChange:s=>h("source",s),children:[e.jsx(P,{className:"w-[130px] bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{placeholder:"Source"})}),e.jsx(A,{className:"glass-heavy rounded-xl border-white/10",children:be.map(s=>e.jsx(i,{value:s,className:"capitalize",children:s==="all"?"All Sources":s},s))})]}),e.jsxs(T,{value:l,onValueChange:s=>h("agent",s),children:[e.jsx(P,{className:"w-[140px] bg-white/5 border-white/10 rounded-xl",children:e.jsx(k,{placeholder:"Agent"})}),e.jsx(A,{className:"glass-heavy rounded-xl border-white/10",children:we.map(s=>e.jsx(i,{value:s,className:"capitalize",children:s==="all"?"All Agents":s},s))})]}),w&&e.jsxs(p,{variant:"ghost",size:"sm",onClick:F,className:"rounded-xl text-muted-foreground hover:text-foreground",children:[e.jsx(se,{className:"h-4 w-4 mr-1"}),"Clear"]})]})]}),w&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3 pt-3 border-t border-white/5",children:[e.jsx(je,{className:"h-4 w-4 text-muted-foreground"}),r!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-blue-500/10 text-blue-400 text-xs font-medium",children:["Status: ",r]}),n!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-indigo-500/10 text-indigo-400 text-xs font-medium capitalize",children:["Source: ",n]}),l!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-green-500/10 text-green-400 text-xs font-medium capitalize",children:["Agent: ",l]}),t&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-orange-500/10 text-orange-400 text-xs font-medium",children:['Search: "',t,'"']})]})]}),e.jsx("div",{className:"glass-heavy rounded-[24px] overflow-hidden border border-white/10 shadow-float",children:L?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ae,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):y.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(O,{className:"h-12 w-12 mx-auto text-muted-foreground/40 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-muted-foreground",children:"No tasks found"}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mt-1",children:w?"Try adjusting your filters":"Create a task to get started"})]}):e.jsxs(ne,{children:[e.jsx(oe,{className:"bg-muted/30",children:e.jsxs(B,{className:"hover:bg-transparent border-white/5",children:[e.jsx(f,{className:"w-[400px]",children:"Task"}),e.jsx(f,{className:"w-[140px]",children:"Status"}),e.jsx(f,{children:"Agent"}),e.jsx(f,{children:"Source"}),e.jsx(f,{className:"text-right",children:"Created"}),e.jsx(f,{className:"w-[50px]"})]})}),e.jsx(ce,{children:y.map(s=>e.jsxs(B,{className:"group cursor-pointer hover:bg-white/5 border-white/5",onClick:()=>N(`/tasks/${s.id}`),children:[e.jsx(v,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:e.jsx(O,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-semibold text-foreground group-hover:text-primary transition-colors",children:s.title}),s.description&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:s.description})]})]})}),e.jsx(v,{children:$(s.status)}),e.jsx(v,{children:s.assignedAgent?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-gradient-to-br from-indigo-500 to-purple-500 flex items-center justify-center text-[10px] uppercase text-white font-bold",children:s.assignedAgent[0]}),e.jsx("span",{className:"text-sm capitalize",children:s.assignedAgent})]}):e.jsx("span",{className:"text-sm text-muted-foreground italic",children:"Unassigned"})}),e.jsx(v,{children:e.jsx(_,{variant:"outline",className:"capitalize bg-muted/50",children:s.source})}),e.jsx(v,{className:"text-right text-muted-foreground text-sm font-mono",children:new Date(s.createdAt).toLocaleDateString()}),e.jsx(v,{onClick:x=>x.stopPropagation(),children:e.jsxs(te,{children:[e.jsx(re,{asChild:!0,children:e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ne,{className:"h-4 w-4"})})}),e.jsx(le,{align:"end",children:e.jsx(ie,{onClick:()=>N(`/tasks/${s.id}`),children:"View Details"})})]})})]},s.id))})]})}),y.length>0&&e.jsxs("div",{className:"flex items-center justify-between border-t border-white/10 pt-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",o+1," • Showing ",Math.min(y.length,c)," of ",z]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:()=>m(o-1),disabled:o===0,className:"rounded-xl border-white/10",children:"Previous"}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>m(o+1),disabled:(o+1)*c>=z,className:"rounded-xl border-white/10",children:"Next"})]})]})]})}export{ze as TaskList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as O,r as m,S as I,C as k,j as e,i as x,h as R,B as _,s as $,n as z,q as U,u as S,o as V,m as N,a1 as G,v as W,D as H,x as J,k as Q,a5 as X,y as Y,z as w,aw as B,w as Z,I as ee,L as P,P as se}from"./index
|
|
1
|
+
import{c as O,r as m,S as I,C as k,j as e,i as x,h as R,B as _,s as $,n as z,q as U,u as S,o as V,m as N,a1 as G,v as W,D as H,x as J,k as Q,a5 as X,y as Y,z as w,aw as B,w as Z,I as ee,L as P,P as se}from"./index-lJlNPFVJ.js";import{d as re,a as ae}from"./element-adapter-DL0DQilL.js";import{a as L,B as te}from"./bug-CmZI7jqM.js";import{C,L as oe,I as ne}from"./layers-jFqVrWMD.js";import{V as ce,C as ie}from"./ViewSwitcher-CnL0OqA8.js";import{P as le}from"./play-d1ONaH0-.js";import{F as q}from"./folder-open-BJi577JH.js";import"./defineProperty-CoXUr7_6.js";import"./textarea-DsVPnSgR.js";import"./badge-CVHH1a-v.js";import"./dialog-BUqN9Psj.js";import"./select-CeQ8AHGy.js";import"./chevron-up-CoUsOvZj.js";import"./EstimateSelect-1hQf4Osk.js";import"./hash-DNEv8Elo.js";import"./brain-6o_RHVpe.js";import"./wand-sparkles-BusQ52ZK.js";import"./link-2-DdO7ostF.js";import"./lightbulb-Jhp7FvbU.js";const de=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],me=O("grip-vertical",de),M={task:{icon:k,color:"text-blue-400"},bug:{icon:te,color:"text-red-400"},feature:{icon:I,color:"text-cyan-400"},epic:{icon:oe,color:"text-orange-400"},story:{icon:L,color:"text-green-400"},subtask:{icon:C,color:"text-gray-400"},enhancement:{icon:I,color:"text-indigo-400"},documentation:{icon:L,color:"text-cyan-400"}},xe={urgent:"bg-red-500",high:"bg-orange-500",medium:"bg-yellow-500",low:"bg-blue-500",none:"bg-gray-400"};function pe({ticket:r,isDragging:i}){const l=m.useRef(null),[g,o]=m.useState(!1);m.useEffect(()=>{const n=l.current;if(n)return re({element:n,getInitialData:()=>({ticketId:r.id,status:r.status}),onDragStart:()=>o(!0),onDrop:()=>o(!1)})},[r.id,r.status]);const p=M[r.type]?.icon||C,a=M[r.type]?.color||"text-gray-400",h=r.projectKey||"PROFCLAW";return e.jsxs("div",{ref:l,className:x("group relative rounded-xl bg-[var(--card)] border border-[var(--border)] p-3 cursor-grab active:cursor-grabbing transition-all duration-200",(g||i)&&"opacity-50 scale-95 rotate-2","hover:border-[var(--primary)]/30 hover:shadow-lg hover:shadow-[var(--primary)]/5"),children:[e.jsx("div",{className:"absolute left-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-50 transition-opacity",children:e.jsx(me,{className:"h-4 w-4 text-[var(--muted-foreground)]"})}),e.jsx("div",{className:x("absolute top-0 left-3 w-6 h-1 rounded-b-full",xe[r.priority]),title:r.priority}),e.jsxs(R,{to:`/tickets/${r.id}`,className:"block space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"text-[10px] font-mono text-[var(--muted-foreground)]",children:[h,"-",r.sequence]}),e.jsx(p,{className:x("h-3.5 w-3.5 shrink-0",a)})]}),e.jsx("h4",{className:"text-sm font-medium leading-tight line-clamp-2 group-hover:text-[var(--primary)] transition-colors",children:r.title}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[r.assigneeAgent&&e.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider text-[var(--primary)]/80 px-1.5 py-0.5 rounded bg-[var(--primary)]/10",children:[e.jsx(_,{className:"h-2.5 w-2.5"}),r.assigneeAgent]}),r.labels.slice(0,1).map(n=>e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-[var(--muted)]/50 text-[var(--muted-foreground)] truncate max-w-[60px]",children:n},n))]}),r.createdBy==="ai"&&e.jsx("span",{className:"text-[8px] font-bold uppercase tracking-wider text-blue-400",children:"AI"})]})]})]})}const E=[{status:"backlog",label:"Backlog",icon:ne,color:"text-gray-400",bgColor:"bg-gray-500/10"},{status:"todo",label:"Todo",icon:C,color:"text-blue-400",bgColor:"bg-blue-500/10"},{status:"in_progress",label:"In Progress",icon:le,color:"text-amber-400",bgColor:"bg-amber-500/10"},{status:"in_review",label:"In Review",icon:G,color:"text-indigo-400",bgColor:"bg-indigo-500/10"},{status:"done",label:"Done",icon:k,color:"text-green-400",bgColor:"bg-green-500/10"}];function ue({status:r,label:i,icon:l,color:g,bgColor:o,tickets:p,onDrop:a}){const h=m.useRef(null),[n,u]=m.useState(!1);return m.useEffect(()=>{const c=h.current;if(c)return ae({element:c,getData:()=>({status:r}),canDrop:({source:j})=>j.data.status!==r,onDragEnter:()=>u(!0),onDragLeave:()=>u(!1),onDrop:({source:j})=>{u(!1);const y=j.data.ticketId;y&&a(y,r)}})},[r,a]),e.jsxs("div",{ref:h,className:x("flex flex-col min-w-[280px] max-w-[320px] rounded-2xl border transition-all duration-200",n?"border-[var(--primary)] bg-[var(--primary)]/5 scale-[1.02]":"border-[var(--border)] bg-[var(--card)]/50"),children:[e.jsxs("div",{className:x("flex items-center justify-between px-4 py-3 rounded-t-2xl",o),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{className:x("h-4 w-4",g)}),e.jsx("span",{className:"text-sm font-semibold",children:i}),e.jsx("span",{className:"flex items-center justify-center h-5 min-w-5 px-1.5 rounded-full bg-[var(--background)]/50 text-[10px] font-bold",children:p.length})]}),e.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg opacity-0 group-hover:opacity-100",children:e.jsx(se,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"flex-1 p-2 space-y-2 overflow-y-auto max-h-[calc(100vh-280px)] scrollbar-thin",children:p.length===0?e.jsxs("div",{className:x("flex flex-col items-center justify-center py-8 px-4 rounded-xl border-2 border-dashed transition-colors",n?"border-[var(--primary)] bg-[var(--primary)]/5":"border-[var(--border)]/50"),children:[e.jsx(l,{className:x("h-8 w-8 mb-2 opacity-30",g)}),e.jsx("span",{className:"text-xs text-[var(--muted-foreground)]",children:n?"Drop here":"No tickets"})]}):p.map(c=>e.jsx(pe,{ticket:c},c.id))})]})}function Ee(){const r=$(),i=z(),[l,g]=U(),[o,p]=m.useState(l.get("q")||""),[a,h]=m.useState(l.get("projectId")||void 0),{data:n}=S({queryKey:["projects"],queryFn:()=>N.projects.list({limit:50})}),u=n?.projects||[],c=u.find(s=>s.id===a),j=s=>{h(s);const t=new URLSearchParams(l);s?t.set("projectId",s):t.delete("projectId"),g(t)},{data:y,isLoading:F,error:D}=S({queryKey:["tickets","board",{search:o||void 0,projectId:a}],queryFn:()=>N.tickets.list({search:o||void 0,projectId:a||void 0,limit:200})}),b=V({mutationFn:({id:s,status:t})=>N.tickets.update(s,{status:t}),onMutate:async({id:s,status:t})=>{await i.cancelQueries({queryKey:["tickets","board"]});const d=i.getQueryData(["tickets","board",{search:o||void 0,projectId:a}]);return i.setQueryData(["tickets","board",{search:o||void 0,projectId:a}],f=>f?.tickets?{...f,tickets:f.tickets.map(v=>v.id===s?{...v,status:t}:v)}:f),{previousData:d}},onError:(s,t,d)=>{d?.previousData&&i.setQueryData(["tickets","board",{search:o||void 0,projectId:a}],d.previousData)},onSettled:()=>{i.invalidateQueries({queryKey:["tickets"]})}}),A=m.useCallback((s,t)=>{b.mutate({id:s,status:t})},[b]),T=y?.tickets??[],K=E.reduce((s,t)=>(s[t.status]=T.filter(d=>d.status===t.status).map(d=>({...d,createdBy:d.createdBy??"human"})),s),{});return D?e.jsxs("div",{className:"premium-card rounded-[28px] p-12 text-center",children:[e.jsx(W,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:"Error loading board"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:D.message})]}):e.jsxs("div",{className:"space-y-6 h-full",children:[e.jsxs("header",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Ticket Board"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:a?`Showing ${c?.name||"Project"} tickets`:"Showing all tickets across projects"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(H,{children:[e.jsx(J,{asChild:!0,children:e.jsxs(Q,{variant:"outline",size:"sm",className:"gap-2 h-9",children:[e.jsx(q,{className:"h-4 w-4"}),c?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:c.icon}),e.jsx("span",{className:"max-w-[120px] truncate",children:c.name})]}):"All Projects",e.jsx(X,{className:"h-3 w-3"})]})}),e.jsxs(Y,{align:"end",className:"w-56",children:[e.jsx(w,{onClick:()=>j(void 0),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4"}),"All Projects"]})}),e.jsx(B,{}),u.map(s=>e.jsxs(w,{onClick:()=>j(s.id),children:[e.jsx("span",{className:"mr-2",children:s.icon}),e.jsx("span",{className:"truncate",children:s.name}),s.id===a&&e.jsx(k,{className:"h-4 w-4 ml-auto text-primary"})]},s.id)),u.length>0&&c&&e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx(w,{onClick:()=>r(`/projects/${a}`),children:e.jsx("span",{className:"text-primary",children:"Go to Project Board →"})})]})]})]}),e.jsxs("div",{className:"relative w-48 sm:w-64",children:[e.jsx(Z,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ee,{placeholder:"Search tickets...",value:o,onChange:s=>p(s.target.value),className:"pl-10 h-9"})]}),e.jsx(ce,{view:"board",onChange:s=>{if(s==="list"){const t=a?`?projectId=${a}`:"";r(`/tickets${t}`)}}}),e.jsx(ie,{})]})]}),F?e.jsx("div",{className:"premium-card rounded-[28px] p-12 flex items-center justify-center",children:e.jsx(P,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 -mx-4 px-4 scrollbar-thin",children:E.map(s=>e.jsx(ue,{...s,tickets:K[s.status]??[],onDrop:A},s.status))}),b.isPending&&e.jsxs("div",{className:"fixed bottom-4 right-4 flex items-center gap-2 px-4 py-2 rounded-xl glass-heavy text-sm",children:[e.jsx(P,{className:"h-4 w-4 animate-spin"}),"Updating..."]})]})}export{Ee as TicketBoard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ye,r as l,ao as ds,j as e,ap as ve,aq as ms,ar as xs,as as us,at as hs,au as ps,av as js,n as be,u as K,o as q,m as f,X as G,k as h,P as te,I as we,O as gs,i as H,L as D,t as x,a5 as fs,l as Ns,h as V,Q as ze,A as Ae,w as ys,E as vs,s as bs,G as Le,v as ws,D as oe,x as de,y as me,z as Q,J as Re,aw as ks,an as xe,B as ue,a1 as Qe,C as J,T as De,S as Fe}from"./index--JkIxVXb.js";import{B}from"./badge-DEmc3Z_l.js";import{T as Ee}from"./textarea-BjiEeIWh.js";import{S as X,a as Y,b as Z,c as ee,d as P}from"./select-MADP8m6Q.js";import{D as Ve,b as He,c as Ge,d as Ue,e as We,f as Je}from"./dialog-BOdGWhgE.js";import{A as Cs,a as Ss,b as Ts,c as Ps,d as As,e as Ls,f as Rs,g as Ds}from"./alert-dialog-DWPb2IfQ.js";import{P as Fs,a as Es,b as Is}from"./popover-JXecfWG5.js";import{T as Xe}from"./tag-tAwMmQ9G.js";import{a as Ie}from"./EstimateSelect-CDjf5qKl.js";import{L as fe}from"./link-2-YqrpQXBH.js";import{P as qs}from"./pencil-DpFnj5dn.js";import{E as Ms}from"./ellipsis-vertical-CO0UqE4-.js";import{T as Os}from"./trash-2-eM-CNwsZ.js";import{G as qe}from"./git-branch-GTOPQgU4.js";import{G as _s}from"./git-commit-horizontal-F5M84Kut.js";import{M as Me}from"./message-square-CD0H5hot.js";import{H as he}from"./history-DfFSA9xJ.js";import{B as pe}from"./brain-CfFdLVqb.js";import{S as Oe}from"./send-eYnW_7n-.js";import{I as Ye,C as se,L as je}from"./layers-DFeLExSa.js";import{P as Ne}from"./play-DVgea_jT.js";import{C as $s}from"./calendar-BuZ4zbPW.js";import{L as Bs}from"./lightbulb-Bo8hEr7B.js";import{a as _e,B as Ks}from"./bug-DqSGPUUE.js";import"./chevron-up-DcJ4LL_N.js";import"./hash-nKC9gtLg.js";const zs=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],$e=ye("ban",zs);const Qs=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Be=ye("folder-input",Qs);const Vs=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],ge=ye("link",Vs);var ne="Collapsible",[Hs]=js(ne),[Gs,ke]=Hs(ne),Ze=l.forwardRef((a,o)=>{const{__scopeCollapsible:m,open:c,defaultOpen:u,disabled:y,onOpenChange:j,...L}=a,[g,N]=ds({prop:c,defaultProp:u??!1,onChange:j,caller:ne});return e.jsx(Gs,{scope:m,disabled:y,contentId:ms(),open:g,onOpenToggle:l.useCallback(()=>N(F=>!F),[N]),children:e.jsx(ve.div,{"data-state":Se(g),"data-disabled":y?"":void 0,...L,ref:o})})});Ze.displayName=ne;var es="CollapsibleTrigger",ss=l.forwardRef((a,o)=>{const{__scopeCollapsible:m,...c}=a,u=ke(es,m);return e.jsx(ve.button,{type:"button","aria-controls":u.contentId,"aria-expanded":u.open||!1,"data-state":Se(u.open),"data-disabled":u.disabled?"":void 0,disabled:u.disabled,...c,ref:o,onClick:xs(a.onClick,u.onOpenToggle)})});ss.displayName=es;var Ce="CollapsibleContent",ts=l.forwardRef((a,o)=>{const{forceMount:m,...c}=a,u=ke(Ce,a.__scopeCollapsible);return e.jsx(us,{present:m||u.open,children:({present:y})=>e.jsx(Us,{...c,ref:o,present:y})})});ts.displayName=Ce;var Us=l.forwardRef((a,o)=>{const{__scopeCollapsible:m,present:c,children:u,...y}=a,j=ke(Ce,m),[L,g]=l.useState(c),N=l.useRef(null),F=hs(o,N),d=l.useRef(0),w=d.current,r=l.useRef(0),M=r.current,k=j.open||L,R=l.useRef(k),C=l.useRef(void 0);return l.useEffect(()=>{const v=requestAnimationFrame(()=>R.current=!1);return()=>cancelAnimationFrame(v)},[]),ps(()=>{const v=N.current;if(v){C.current=C.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const O=v.getBoundingClientRect();d.current=O.height,r.current=O.width,R.current||(v.style.transitionDuration=C.current.transitionDuration,v.style.animationName=C.current.animationName),g(c)}},[j.open,c]),e.jsx(ve.div,{"data-state":Se(j.open),"data-disabled":j.disabled?"":void 0,id:j.contentId,hidden:!k,...y,ref:F,style:{"--radix-collapsible-content-height":w?`${w}px`:void 0,"--radix-collapsible-content-width":M?`${M}px`:void 0,...a.style},children:k&&u})});function Se(a){return a?"open":"closed"}var Ws=Ze;const Ke=["#EF4444","#F97316","#EAB308","#22C55E","#06B6D4","#3B82F6","#8B5CF6","#EC4899"];function Js({ticketId:a,projectId:o,selectedLabels:m=[],onChange:c,disabled:u=!1,className:y}){const[j,L]=l.useState(!1),[g,N]=l.useState(""),[F,d]=l.useState(!1),[w,r]=l.useState(""),[M,k]=l.useState(Ke[0]),R=be(),{data:C,isLoading:v}=K({queryKey:["labels",o],queryFn:()=>f.labels.list(o,{includeGlobal:!0}),enabled:!!o}),{data:O}=K({queryKey:["ticket-labels",a],queryFn:()=>f.labels.getTicketLabels(a),enabled:!!a}),_=q({mutationFn:i=>f.labels.setTicketLabels(a,i),onSuccess:()=>{R.invalidateQueries({queryKey:["ticket-labels",a]}),R.invalidateQueries({queryKey:["tickets"]})}}),n=q({mutationFn:()=>f.labels.create(o,{name:w,color:M}),onSuccess:i=>{R.invalidateQueries({queryKey:["labels",o]});const p=i.label,I=b.map(z=>z.id);c?c([...b,p]):_.mutate([...I,p.id]),d(!1),N(""),r(""),L(!1)}}),A=C?.labels??[],b=O?.labels??m,S=new Set(b.map(i=>i.id)),E=A.filter(i=>i.name.toLowerCase().includes(g.toLowerCase())||i.description?.toLowerCase().includes(g.toLowerCase())),ie=i=>{const p=new Set(S);p.has(i.id)?p.delete(i.id):p.add(i.id);const I=A.filter(z=>p.has(z.id));c?c(I):_.mutate([...p])},$=i=>{const p=new Set(S);p.delete(i);const I=A.filter(z=>p.has(z.id));c?c(I):_.mutate([...p])};return e.jsxs("div",{className:H("flex flex-wrap items-center gap-1",y),children:[b.map(i=>e.jsxs(B,{variant:"outline",className:"gap-1 pr-1",style:{backgroundColor:`${i.color}20`,borderColor:i.color,color:i.color},children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i.color}}),i.name,!u&&e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),$(i.id)},className:"ml-1 rounded-full hover:bg-muted/50",children:e.jsx(G,{className:"h-3 w-3"})})]},i.id)),!u&&e.jsxs(Fs,{open:j,onOpenChange:i=>{L(i),i||(d(!1),N(""))},children:[e.jsx(Es,{asChild:!0,children:e.jsxs(h,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-muted-foreground hover:text-foreground",children:[e.jsx(te,{className:"h-3 w-3"}),e.jsx(Xe,{className:"h-3 w-3"})]})}),e.jsxs(Is,{className:"w-64 p-0",align:"start",children:[e.jsx("div",{className:"p-2",children:e.jsx(we,{type:"text",placeholder:"Search labels...",value:g,onChange:i=>N(i.target.value),className:"h-8 text-xs px-2"})}),e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:v?e.jsx("div",{className:"p-2 text-center text-sm text-muted-foreground",children:"Loading..."}):E.length===0&&!g?e.jsx("div",{className:"p-2 text-center text-sm text-muted-foreground",children:"No labels found"}):e.jsxs(e.Fragment,{children:[E.map(i=>e.jsxs("button",{type:"button",onClick:()=>ie(i),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-muted",children:[e.jsx("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:i.color}}),e.jsx("span",{className:"flex-1 text-left",children:i.name}),S.has(i.id)&&e.jsx(gs,{className:"h-4 w-4 text-primary"})]},i.id)),g&&e.jsx("div",{className:"mt-1 border-t pt-1",children:F?e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("div",{className:"flex gap-1.5",children:Ke.map(i=>e.jsx("button",{type:"button",onClick:()=>k(i),className:H("h-4 w-4 rounded-full transition-transform hover:scale-110",M===i&&"ring-1 ring-primary ring-offset-1 ring-offset-background"),style:{backgroundColor:i}},i))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{size:"sm",className:"h-7 text-[10px] flex-1",onClick:()=>n.mutate(),disabled:n.isPending,children:n.isPending?e.jsx(D,{className:"h-3 w-3 animate-spin"}):"Create"}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 text-[10px]",onClick:()=>{d(!1),N("")},children:"Cancel"})]})]}):e.jsxs("button",{type:"button",onClick:()=>{d(!0),r(g)},className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-primary hover:bg-primary/5",children:[e.jsx(te,{className:"h-3 w-3"}),e.jsxs("span",{children:['Create "',g,'"']})]})})]})})]})]})]})}const Xs=Ws,Ys=ss,Zs=ts,ae=[{value:"blocks",label:"Blocks",icon:$e,color:"text-red-400",description:"This ticket blocks another"},{value:"blocked_by",label:"Blocked by",icon:$e,color:"text-orange-400",description:"This ticket is blocked by another"},{value:"relates_to",label:"Relates to",icon:fe,color:"text-blue-400",description:"Related tickets"},{value:"duplicates",label:"Duplicates",icon:ze,color:"text-purple-400",description:"This ticket duplicates another"},{value:"start_before",label:"Start before",icon:Ae,color:"text-cyan-400",description:"Must start before another ticket"},{value:"finish_before",label:"Finish before",icon:Ae,color:"text-emerald-400",description:"Must finish before another ticket"}];function et(a){return ae.find(o=>o.value===a)||ae[2]}function st({ticketId:a,relations:o=[]}){const m=be(),[c,u]=l.useState(!0),[y,j]=l.useState(!1),[L,g]=l.useState("relates_to"),[N,F]=l.useState(""),[d,w]=l.useState(null),{data:r,isLoading:M}=K({queryKey:["tickets-search",N],queryFn:()=>f.tickets.list({search:N,limit:10}),enabled:N.length>=2,staleTime:1e4}),k=r?.tickets?.filter(n=>n.id!==a)||[],R=q({mutationFn:({targetTicketId:n,type:A})=>f.tickets.addRelation(a,n,A),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),j(!1),F(""),w(null),x.success("Relation added")},onError:n=>{x.error(`Failed to add relation: ${n.message}`)}}),C=q({mutationFn:n=>f.tickets.removeRelation(a,n),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),x.success("Relation removed")},onError:n=>{x.error(`Failed to remove relation: ${n.message}`)}}),v=()=>{if(!d){x.error("Please select a ticket");return}R.mutate({targetTicketId:d,type:L})},O=o.reduce((n,A)=>{const b=A.relationType;return n[b]||(n[b]=[]),n[b].push(A),n},{}),_=o.length;return e.jsxs("div",{className:"glass rounded-[20px] p-4",children:[e.jsxs(Xs,{open:c,onOpenChange:u,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ys,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-2 text-sm font-semibold hover:text-primary transition-colors",children:[c?e.jsx(fs,{className:"h-4 w-4"}):e.jsx(Ns,{className:"h-4 w-4"}),e.jsx(fe,{className:"h-4 w-4"}),"Relations",_>0&&e.jsx(B,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:_})]})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 w-7 p-0 rounded-lg",children:e.jsx(te,{className:"h-4 w-4"})})]}),e.jsx(Zs,{className:"pt-3 space-y-3",children:_===0?e.jsxs("div",{className:"text-center py-4",children:[e.jsx(fe,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relations"}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>j(!0),className:"mt-2 h-7 text-xs gap-1",children:[e.jsx(te,{className:"h-3 w-3"}),"Add relation"]})]}):Object.entries(O).map(([n,A])=>{const b=et(n);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:H("flex items-center gap-1.5 text-xs font-medium",b.color),children:[e.jsx(b.icon,{className:"h-3 w-3"}),b.label]}),e.jsx("div",{className:"space-y-1",children:A.map(S=>{const E=S.sourceTicketId===a?S.targetTicket:S.sourceTicket;return E?e.jsxs("div",{className:"flex items-center justify-between gap-2 p-2 rounded-lg bg-white/5 group",children:[e.jsx(V,{to:`/tickets/${E.id}`,className:"flex-1 min-w-0 hover:text-primary transition-colors",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:[E.projectKey||"PROFCLAW","-",E.sequence]}),e.jsx("span",{className:"text-xs truncate",children:E.title})]})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>C.mutate(S.id),disabled:C.isPending,className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:C.isPending?e.jsx(D,{className:"h-3 w-3 animate-spin"}):e.jsx(G,{className:"h-3 w-3 text-muted-foreground hover:text-red-400"})})]},S.id):null})})]},n)})})]}),e.jsx(Ve,{open:y,onOpenChange:j,children:e.jsxs(He,{className:"sm:max-w-[425px]",children:[e.jsxs(Ge,{children:[e.jsx(Ue,{children:"Add Relation"}),e.jsx(We,{children:"Link this ticket to another ticket."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Relation Type"}),e.jsxs(X,{value:L,onValueChange:n=>g(n),children:[e.jsx(Y,{children:e.jsx(Z,{})}),e.jsx(ee,{children:ae.map(n=>e.jsx(P,{value:n.value,children:e.jsxs("span",{className:H("flex items-center gap-2",n.color),children:[e.jsx(n.icon,{className:"h-4 w-4"}),n.label]})},n.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ae.find(n=>n.value===L)?.description})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Search Ticket"}),e.jsxs("div",{className:"relative",children:[e.jsx(ys,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(we,{placeholder:"Search by title or ID...",value:N,onChange:n=>F(n.target.value),className:"pl-9"})]})]}),N.length>=2&&e.jsx("div",{className:"bg-muted/30 rounded-lg divide-y divide-border/20 max-h-48 overflow-y-auto",children:M?e.jsx("div",{className:"p-4 text-center",children:e.jsx(D,{className:"h-4 w-4 animate-spin mx-auto"})}):k.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No tickets found"}):k.map(n=>e.jsx("button",{type:"button",onClick:()=>w(n.id),className:H("w-full text-left p-3 hover:bg-muted/50 transition-colors",d===n.id&&"bg-primary/10"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[n.projectKey||"PROFCLAW","-",n.sequence]}),e.jsx("span",{className:"text-sm truncate",children:n.title})]})},n.id))}),d&&e.jsxs("div",{className:"p-3 rounded-lg bg-primary/10 border border-primary/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Selected:"}),e.jsx("p",{className:"text-sm font-medium",children:k.find(n=>n.id===d)?.title||"Ticket selected"})]})]}),e.jsxs(Je,{children:[e.jsx(h,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsxs(h,{onClick:v,disabled:!d||R.isPending,children:[R.isPending&&e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Add Relation"]})]})]})})]})}const tt=[{value:"backlog",label:"Backlog",icon:Ye},{value:"todo",label:"Todo",icon:se},{value:"in_progress",label:"In Progress",icon:Ne},{value:"in_review",label:"In Review",icon:Qe},{value:"done",label:"Done",icon:J},{value:"cancelled",label:"Cancelled",icon:G}];function At(){const{id:a}=vs(),o=bs(),m=be(),[c,u]=l.useState(""),[y,j]=l.useState("comments"),[L,g]=l.useState(!1),[N,F]=l.useState(!1),[d,w]=l.useState({title:"",description:"",priority:"medium",type:"task",estimate:null}),{data:r,isLoading:M,error:k}=K({queryKey:["ticket",a],queryFn:()=>f.tickets.get(a,!0),enabled:!!a}),{data:R}=K({queryKey:["projects"],queryFn:()=>f.projects.list({limit:50})}),{data:C,isLoading:v}=K({queryKey:["ticket-similar",a],queryFn:()=>f.tickets.ai.similar(a,5),enabled:!!a&&!!r}),{data:O,isLoading:_}=K({queryKey:["ticket-summary",a],queryFn:()=>f.tickets.ai.summary(a),enabled:!!a&&!!r,staleTime:3e5}),{data:n}=K({queryKey:["ai-status"],queryFn:()=>f.tickets.ai.status(),staleTime:6e4}),A=n?.available??!1,b=q({mutationFn:s=>f.tickets.transition(a,s),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),m.invalidateQueries({queryKey:["tickets"]}),x.success("Status updated")},onError:s=>{x.error(`Failed to update status: ${s.message}`)}}),S=q({mutationFn:s=>f.tickets.update(a,s),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),m.invalidateQueries({queryKey:["tickets"]}),g(!1),x.success("Ticket updated")},onError:s=>{x.error(`Failed to update ticket: ${s.message}`)}}),E=q({mutationFn:()=>f.tickets.delete(a),onSuccess:()=>{m.invalidateQueries({queryKey:["tickets"]}),x.success("Ticket deleted"),o("/tickets")},onError:s=>{x.error(`Failed to delete ticket: ${s.message}`)}}),ie=q({mutationFn:s=>f.tickets.update(a,{projectId:s}),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),m.invalidateQueries({queryKey:["tickets"]}),x.success("Ticket moved to project")},onError:s=>{x.error(`Failed to move ticket: ${s.message}`)}}),$=q({mutationFn:s=>f.tickets.addComment(a,s),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),u(""),x.success("Comment added")},onError:s=>{x.error(`Failed to add comment: ${s.message}`)}}),i=q({mutationFn:s=>f.tickets.ai.respond(a,s),onSuccess:s=>{s.posted&&s.comment?(m.invalidateQueries({queryKey:["ticket",a]}),x.success("AI response posted")):s.response?(I(s.response),U(s.confidence),x.success(`AI generated response (${Math.round(s.confidence*100)}% confidence)`)):s.skipped&&x.info(s.reason||"AI chose not to respond")},onError:s=>{x.error(`AI response failed: ${s.message}`)}}),[p,I]=l.useState(null),[z,U]=l.useState(0),as=async()=>{p&&(await $.mutateAsync(p),I(null),U(0))},ns=()=>{c.trim()&&$.mutate(c)},is=()=>{r&&(w({title:r.title,description:r.description||"",priority:r.priority,type:r.type,estimate:r.estimate??null}),g(!0))},ls=()=>{S.mutate({...d,estimate:d.estimate??void 0,estimateUnit:d.estimate!==null?"points":void 0})},Te=s=>{ie.mutate(s)},rs=async()=>{if(r)try{const s=await f.tickets.create({title:`${r.title} (Copy)`,description:r.description,type:r.type,priority:r.priority,labels:r.labels,projectId:r.projectId});x.success("Ticket duplicated"),o(`/tickets/${s.ticket.id}`)}catch{x.error("Failed to duplicate ticket")}},cs=s=>{const le={done:{variant:"success",icon:J},cancelled:{variant:"destructive",icon:G},in_progress:{variant:"info",icon:Ne},in_review:{variant:"warning",icon:Qe},todo:{variant:"secondary",icon:se},backlog:{variant:"secondary",icon:Ye}}[s],{variant:re,icon:ce}=le;return e.jsxs(B,{variant:re,className:"gap-1 text-sm px-3 py-1",children:[e.jsx(ce,{className:"h-4 w-4"}),s.replace("_"," ")]})},Pe=s=>{const le={task:{icon:J,color:"text-blue-500"},bug:{icon:Ks,color:"text-red-500"},feature:{icon:Fe,color:"text-cyan-500"},enhancement:{icon:Fe,color:"text-indigo-500"},documentation:{icon:_e,color:"text-cyan-500"},epic:{icon:je,color:"text-orange-500"},story:{icon:_e,color:"text-green-500"},subtask:{icon:se,color:"text-gray-500"}}[s],{icon:re,color:ce}=le;return e.jsxs("span",{className:`flex items-center gap-1.5 text-sm ${ce}`,children:[e.jsx(re,{className:"h-4 w-4"}),s]})},os=s=>({urgent:"text-red-500",high:"text-orange-500",medium:"text-yellow-500",low:"text-blue-500",none:"text-gray-400"})[s]||"text-gray-400";if(M)return e.jsx("div",{className:"glass rounded-[28px] p-12 flex items-center justify-center",children:e.jsx(D,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(k||!r)return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(h,{variant:"ghost",onClick:()=>o("/tickets"),className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),"Back to Tickets"]}),e.jsxs("div",{className:"glass rounded-[28px] p-12 text-center",children:[e.jsx(ws,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:k?"Error loading ticket":"Ticket not found"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:k?k.message:`No ticket found with ID: ${a}`})]})]});const t=r,W=R?.projects||[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(h,{variant:"ghost",onClick:()=>o("/tickets"),className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),"Back to Tickets"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:is,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Edit"]}),e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"Move to Project"]})}),e.jsx(me,{align:"end",className:"w-56",children:W.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No projects available"}):W.map(s=>e.jsxs(Q,{onClick:()=>Te(s.id),disabled:s.id===t.projectId,children:[e.jsx("span",{className:"mr-2",children:s.icon}),s.name,s.id===t.projectId&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"(current)"})]},s.id))})]}),e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",className:"h-9 w-9",children:e.jsx(Ms,{className:"h-4 w-4"})})}),e.jsxs(me,{align:"end",children:[e.jsxs(Q,{onClick:rs,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Duplicate Ticket"]}),e.jsxs(Q,{onClick:()=>{const s=t.externalLinks?.find(T=>T.platform==="jira");s?.externalUrl?window.open(s.externalUrl,"_blank"):x.info("No Jira link found. Link this ticket to Jira first.")},children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Open in Jira"]}),e.jsx(ks,{}),e.jsxs(Q,{className:"text-red-500 focus:text-red-500",onClick:()=>F(!0),children:[e.jsx(Os,{className:"h-4 w-4 mr-2"}),"Delete Ticket"]})]})]})]})]}),e.jsx(Ve,{open:L,onOpenChange:g,children:e.jsxs(He,{className:"sm:max-w-[500px]",children:[e.jsxs(Ge,{children:[e.jsx(Ue,{children:"Edit Ticket"}),e.jsx(We,{children:"Make changes to the ticket details."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Title"}),e.jsx(we,{value:d.title,onChange:s=>w(T=>({...T,title:s.target.value})),placeholder:"Ticket title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Ee,{value:d.description,onChange:s=>w(T=>({...T,description:s.target.value})),placeholder:"Ticket description",rows:4})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Priority"}),e.jsxs(X,{value:d.priority,onValueChange:s=>w(T=>({...T,priority:s})),children:[e.jsx(Y,{children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(P,{value:"urgent",children:"Urgent"}),e.jsx(P,{value:"high",children:"High"}),e.jsx(P,{value:"medium",children:"Medium"}),e.jsx(P,{value:"low",children:"Low"}),e.jsx(P,{value:"none",children:"None"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Type"}),e.jsxs(X,{value:d.type,onValueChange:s=>w(T=>({...T,type:s})),children:[e.jsx(Y,{children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(P,{value:"task",children:"Task"}),e.jsx(P,{value:"bug",children:"Bug"}),e.jsx(P,{value:"feature",children:"Feature"}),e.jsx(P,{value:"enhancement",children:"Enhancement"}),e.jsx(P,{value:"epic",children:"Epic"}),e.jsx(P,{value:"story",children:"Story"}),e.jsx(P,{value:"subtask",children:"Subtask"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Estimate"}),e.jsx(Ie,{value:d.estimate,onChange:s=>w(T=>({...T,estimate:s})),placeholder:"Points"})]})]})]}),e.jsxs(Je,{children:[e.jsx(h,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),e.jsxs(h,{onClick:ls,disabled:S.isPending,children:[S.isPending&&e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})}),e.jsx(Cs,{open:N,onOpenChange:F,children:e.jsxs(Ss,{children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:"Delete Ticket"}),e.jsxs(As,{children:['Are you sure you want to delete "',t.title,'"? This action cannot be undone.']})]}),e.jsxs(Ls,{children:[e.jsx(Rs,{children:"Cancel"}),e.jsxs(Ds,{onClick:()=>E.mutate(),className:"bg-red-500 hover:bg-red-600",children:[E.isPending&&e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Delete"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"glass rounded-[20px] p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-mono text-muted-foreground bg-white/5 px-2 py-1 rounded-md",children:[t.projectKey||"PROFCLAW","-",t.sequence]}),!t.projectId&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-amber-400 px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20",children:"No Project"}),Pe(t.type)]}),cs(t.status)]}),e.jsx("h1",{className:"text-2xl font-bold mb-4",children:t.title}),t.description&&e.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.description})}),(t.linkedPRs.length>0||t.linkedCommits.length>0||t.linkedBranch)&&e.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t border-white/5",children:[t.linkedBranch&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),t.linkedBranch]}),t.linkedPRs.length>0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),t.linkedPRs.length," PR(s)"]}),t.linkedCommits.length>0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(_s,{className:"h-3.5 w-3.5"}),t.linkedCommits.length," commit(s)"]})]})]}),e.jsxs("div",{className:"glass rounded-[20px] overflow-hidden",children:[e.jsxs("div",{className:"flex border-b border-white/5",children:[e.jsxs("button",{onClick:()=>j("comments"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${y==="comments"?"bg-white/5 text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Me,{className:"h-4 w-4"}),"Comments (",t.comments?.length||0,")"]}),e.jsxs("button",{onClick:()=>j("history"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${y==="history"?"bg-white/5 text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(he,{className:"h-4 w-4"}),"History (",t.history?.length||0,")"]}),e.jsxs("button",{onClick:()=>j("links"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${y==="links"?"bg-white/5 text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ge,{className:"h-4 w-4"}),"Links (",t.externalLinks?.length||0,")"]})]}),e.jsxs("div",{className:"p-4",children:[y==="comments"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/20 flex items-center justify-center shrink-0",children:e.jsx(xe,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Ee,{placeholder:"Add a comment...",value:c,onChange:s=>u(s.target.value),className:"min-h-20"}),e.jsxs("div",{className:"flex justify-end mt-2 gap-2",children:[A&&t.comments&&t.comments.length>0&&e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>i.mutate({}),disabled:i.isPending,className:"gap-2",children:[i.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),"AI Respond"]}),e.jsxs(h,{size:"sm",variant:"black",onClick:ns,disabled:!c.trim()||$.isPending,className:"gap-2",children:[$.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):e.jsx(Oe,{className:"h-4 w-4"}),"Comment"]})]})]})]}),p&&e.jsxs("div",{className:"rounded-xl bg-primary/5 border border-primary/20 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[e.jsx(pe,{className:"h-4 w-4"}),"AI Generated Response",e.jsxs(B,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[Math.round(z*100),"% confidence"]})]}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{I(null),U(0)},className:"h-6 w-6 p-0 rounded-lg",children:e.jsx(G,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:p}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",onClick:()=>{u(p),I(null),U(0)},className:"gap-1 rounded-xl border-white/10 text-xs",children:"Edit First"}),e.jsxs(h,{size:"sm",onClick:as,disabled:$.isPending,className:"gap-1 rounded-xl text-xs",children:[$.isPending?e.jsx(D,{className:"h-3 w-3 animate-spin"}):e.jsx(Oe,{className:"h-3 w-3"}),"Post Response"]})]})]}),t.comments&&t.comments.length>0?e.jsx("div",{className:"space-y-4 pt-4 border-t border-white/5",children:t.comments.map(s=>e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`h-8 w-8 rounded-full flex items-center justify-center flex-shrink-0 ${s.author.type==="ai","bg-blue-500/20"}`,children:s.author.type==="ai"?e.jsx(ue,{className:"h-4 w-4 text-blue-500"}):e.jsx(xe,{className:"h-4 w-4 text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:s.author.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.createdAt).toLocaleString()}),s.source!=="profclaw"&&e.jsx(B,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:s.source})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:s.content})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Me,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No comments yet"})]})]}),y==="history"&&e.jsx("div",{className:"space-y-3",children:t.history&&t.history.length>0?t.history.map(s=>e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-white/5 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(he,{className:"h-3 w-3 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:s.changedBy.name}),e.jsx("span",{className:"text-muted-foreground",children:" changed "}),e.jsx("span",{className:"font-medium",children:s.field}),s.oldValue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:" from "}),e.jsx("span",{className:"text-red-400/80",children:s.oldValue})]}),s.newValue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:" to "}),e.jsx("span",{className:"text-green-400/80",children:s.newValue})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:new Date(s.timestamp).toLocaleString()})]})]},s.id)):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(he,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No history yet"})]})}),y==="links"&&e.jsx("div",{className:"space-y-3",children:t.externalLinks&&t.externalLinks.length>0?t.externalLinks.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-white/5 flex items-center justify-center",children:e.jsx(ge,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm capitalize",children:s.platform}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.externalId})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{variant:s.syncEnabled?"success":"secondary",className:"text-[10px]",children:s.syncDirection}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"p-2 hover:bg-white/5 rounded-lg transition-colors",children:e.jsx(Re,{className:"h-4 w-4 text-muted-foreground"})})]})]},s.id)):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ge,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No external links yet"})]})})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"glass rounded-[20px] p-4",children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Status"}),e.jsxs(X,{value:t.status,onValueChange:s=>b.mutate(s),disabled:b.isPending,children:[e.jsx(Y,{className:"w-full bg-white/5 border-white/10 rounded-xl",children:e.jsx(Z,{})}),e.jsx(ee,{className:"glass-heavy rounded-xl border-white/10",children:tt.map(s=>e.jsx(P,{value:s.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(s.icon,{className:"h-4 w-4"}),s.label]})},s.value))})]})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Details"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Project"}),t.projectId?e.jsx(V,{to:`/projects/${t.projectId}`,className:"text-sm font-medium text-primary hover:underline",children:t.projectName||t.projectKey||"View Project"}):e.jsx("span",{className:"text-sm text-muted-foreground italic",children:"No project"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Priority"}),e.jsx("span",{className:`text-sm font-medium capitalize ${os(t.priority)}`,children:t.priority})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Type"}),Pe(t.type)]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Created By"}),e.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:t.createdBy==="ai"?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-indigo-400"}),"AI"]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 text-blue-400"}),"Human"]})})]}),t.assigneeAgent&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Assigned Agent"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-primary",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),t.assigneeAgent]})]}),t.aiAgent&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"AI Agent"}),e.jsx("span",{className:"text-sm",children:t.aiAgent})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Estimate"}),e.jsx(Ie,{value:t.estimate??null,onChange:s=>{S.mutate({estimate:s??void 0,estimateUnit:s!==null?"points":void 0})},compact:!0,placeholder:"—",className:"w-[90px] h-8 text-xs"})]}),t.dueDate&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Due Date"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx($s,{className:"h-3.5 w-3.5"}),new Date(t.dueDate).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Xe,{className:"h-4 w-4"}),"Labels"]}),t.projectId?e.jsx(Js,{ticketId:t.id,projectId:t.projectId}):e.jsxs("div",{className:"text-center py-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Assign to a project to add labels"}),e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[e.jsx(Be,{className:"h-3 w-3"}),"Select Project"]})}),e.jsx(me,{align:"center",className:"w-48",children:W.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No projects available"}):W.map(s=>e.jsxs(Q,{onClick:()=>Te(s.id),className:"text-sm",children:[e.jsx("span",{className:"mr-2",children:s.icon}),s.name]},s.id))})]})]})]}),e.jsx(st,{ticketId:t.id,relations:t.relations||[]}),t.parent&&e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-amber-400"}),"Parent Ticket"]}),e.jsxs(V,{to:`/tickets/${t.parent.id}`,className:"block p-3 rounded-xl bg-white/5 hover:bg-white/10 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.parent.projectKey||"PROFCLAW","-",t.parent.sequence]}),t.parent.type==="epic"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 font-medium",children:"EPIC"})]}),e.jsx("p",{className:"text-sm font-medium group-hover:text-primary transition-colors",children:t.parent.title})]})]}),t.children&&t.children.length>0&&e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-primary"}),"Child Tickets (",t.children.length,")",e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[t.children.filter(s=>s.status==="done").length,"/",t.children.length," done"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-green-500 to-emerald-400 transition-all",style:{width:`${t.children.filter(s=>s.status==="done").length/t.children.length*100}%`}})}),e.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:t.children.map(s=>e.jsxs(V,{to:`/tickets/${s.id}`,className:"flex items-center gap-3 p-2 rounded-lg bg-white/5 hover:bg-white/10 transition-colors group",children:[e.jsx("div",{className:`flex-shrink-0 ${s.status==="done"?"text-green-500":s.status==="in_progress"?"text-blue-500":"text-muted-foreground"}`,children:s.status==="done"?e.jsx(J,{className:"h-4 w-4"}):s.status==="in_progress"?e.jsx(Ne,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-mono text-muted-foreground mb-0.5",children:[s.projectKey||"PROFCLAW","-",s.sequence]}),e.jsx("p",{className:`text-sm truncate group-hover:text-primary transition-colors ${s.status==="done"?"line-through text-muted-foreground":""}`,children:s.title})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground capitalize",children:s.type})]},s.id))})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Timestamps"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Created"}),e.jsx("span",{className:"text-xs",children:new Date(t.createdAt).toLocaleString()})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Updated"}),e.jsx("span",{className:"text-xs",children:new Date(t.updatedAt).toLocaleString()})]}),t.startedAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Started"}),e.jsx("span",{className:"text-xs",children:new Date(t.startedAt).toLocaleString()})]}),t.completedAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Completed"}),e.jsx("span",{className:"text-xs",children:new Date(t.completedAt).toLocaleString()})]})]})]}),A&&e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4 text-primary"}),"AI Summary"]}),_?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(D,{className:"h-3 w-3 animate-spin"}),"Generating summary..."]}):O?.summary?e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:O.summary}):e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Summary not available"})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(pe,{className:"h-4 w-4 text-primary"}),"Similar Tickets"]}),v?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(D,{className:"h-3 w-3 animate-spin"}),"Finding similar tickets..."]}):C?.similar&&C.similar.length>0?e.jsx("div",{className:"space-y-2",children:C.similar.map(s=>e.jsxs(V,{to:`/tickets/${s.id}`,className:"block p-2 rounded-lg bg-white/5 hover:bg-white/10 transition-colors group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx(De,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:[s.projectKey||"PROFCLAW","-",s.sequence]})]}),e.jsx("p",{className:"text-xs font-medium truncate group-hover:text-primary transition-colors",children:s.title})]}),e.jsxs(B,{variant:"outline",className:"text-[10px] px-1.5 py-0 flex-shrink-0 tabular-nums",children:[Math.round(s.similarity*100),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[e.jsx(B,{variant:s.status==="done"?"success":s.status==="in_progress"?"info":"secondary",className:"text-[9px] px-1 py-0",children:s.status.replace("_"," ")}),e.jsx("span",{className:"text-[10px] text-muted-foreground capitalize",children:s.type})]})]},s.id))}):e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(De,{className:"h-6 w-6 mx-auto mb-1 opacity-40"}),e.jsx("p",{className:"text-xs",children:"No similar tickets found"})]})]})]})]})]})}export{At as TicketDetail};
|
|
1
|
+
import{c as ye,r as l,ao as ds,j as e,ap as ve,aq as ms,ar as xs,as as us,at as hs,au as ps,av as js,n as be,u as K,o as q,m as f,X as G,k as h,P as te,I as we,O as gs,i as H,L as D,t as x,a5 as fs,l as Ns,h as V,Q as ze,A as Ae,w as ys,E as vs,s as bs,G as Le,v as ws,D as oe,x as de,y as me,z as Q,J as Re,aw as ks,an as xe,B as ue,a1 as Qe,C as J,T as De,S as Fe}from"./index-lJlNPFVJ.js";import{B}from"./badge-CVHH1a-v.js";import{T as Ee}from"./textarea-DsVPnSgR.js";import{S as X,a as Y,b as Z,c as ee,d as P}from"./select-CeQ8AHGy.js";import{D as Ve,b as He,c as Ge,d as Ue,e as We,f as Je}from"./dialog-BUqN9Psj.js";import{A as Cs,a as Ss,b as Ts,c as Ps,d as As,e as Ls,f as Rs,g as Ds}from"./alert-dialog-SKM6Gjz4.js";import{P as Fs,a as Es,b as Is}from"./popover-CrmZgoWu.js";import{T as Xe}from"./tag-C35mgoEv.js";import{a as Ie}from"./EstimateSelect-1hQf4Osk.js";import{L as fe}from"./link-2-DdO7ostF.js";import{P as qs}from"./pencil-CYXCEPQh.js";import{E as Ms}from"./ellipsis-vertical-DoULYEKn.js";import{T as Os}from"./trash-2-keO5tKPE.js";import{G as qe}from"./git-branch-C_K30am0.js";import{G as _s}from"./git-commit-horizontal-IT6ecxWQ.js";import{M as Me}from"./message-square-CBgH65X7.js";import{H as he}from"./history-BQSBo_1Q.js";import{B as pe}from"./brain-6o_RHVpe.js";import{S as Oe}from"./send-P0r5D7td.js";import{I as Ye,C as se,L as je}from"./layers-jFqVrWMD.js";import{P as Ne}from"./play-d1ONaH0-.js";import{C as $s}from"./calendar-Bf0t2B82.js";import{L as Bs}from"./lightbulb-Jhp7FvbU.js";import{a as _e,B as Ks}from"./bug-CmZI7jqM.js";import"./chevron-up-CoUsOvZj.js";import"./hash-DNEv8Elo.js";const zs=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],$e=ye("ban",zs);const Qs=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Be=ye("folder-input",Qs);const Vs=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],ge=ye("link",Vs);var ne="Collapsible",[Hs]=js(ne),[Gs,ke]=Hs(ne),Ze=l.forwardRef((a,o)=>{const{__scopeCollapsible:m,open:c,defaultOpen:u,disabled:y,onOpenChange:j,...L}=a,[g,N]=ds({prop:c,defaultProp:u??!1,onChange:j,caller:ne});return e.jsx(Gs,{scope:m,disabled:y,contentId:ms(),open:g,onOpenToggle:l.useCallback(()=>N(F=>!F),[N]),children:e.jsx(ve.div,{"data-state":Se(g),"data-disabled":y?"":void 0,...L,ref:o})})});Ze.displayName=ne;var es="CollapsibleTrigger",ss=l.forwardRef((a,o)=>{const{__scopeCollapsible:m,...c}=a,u=ke(es,m);return e.jsx(ve.button,{type:"button","aria-controls":u.contentId,"aria-expanded":u.open||!1,"data-state":Se(u.open),"data-disabled":u.disabled?"":void 0,disabled:u.disabled,...c,ref:o,onClick:xs(a.onClick,u.onOpenToggle)})});ss.displayName=es;var Ce="CollapsibleContent",ts=l.forwardRef((a,o)=>{const{forceMount:m,...c}=a,u=ke(Ce,a.__scopeCollapsible);return e.jsx(us,{present:m||u.open,children:({present:y})=>e.jsx(Us,{...c,ref:o,present:y})})});ts.displayName=Ce;var Us=l.forwardRef((a,o)=>{const{__scopeCollapsible:m,present:c,children:u,...y}=a,j=ke(Ce,m),[L,g]=l.useState(c),N=l.useRef(null),F=hs(o,N),d=l.useRef(0),w=d.current,r=l.useRef(0),M=r.current,k=j.open||L,R=l.useRef(k),C=l.useRef(void 0);return l.useEffect(()=>{const v=requestAnimationFrame(()=>R.current=!1);return()=>cancelAnimationFrame(v)},[]),ps(()=>{const v=N.current;if(v){C.current=C.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const O=v.getBoundingClientRect();d.current=O.height,r.current=O.width,R.current||(v.style.transitionDuration=C.current.transitionDuration,v.style.animationName=C.current.animationName),g(c)}},[j.open,c]),e.jsx(ve.div,{"data-state":Se(j.open),"data-disabled":j.disabled?"":void 0,id:j.contentId,hidden:!k,...y,ref:F,style:{"--radix-collapsible-content-height":w?`${w}px`:void 0,"--radix-collapsible-content-width":M?`${M}px`:void 0,...a.style},children:k&&u})});function Se(a){return a?"open":"closed"}var Ws=Ze;const Ke=["#EF4444","#F97316","#EAB308","#22C55E","#06B6D4","#3B82F6","#8B5CF6","#EC4899"];function Js({ticketId:a,projectId:o,selectedLabels:m=[],onChange:c,disabled:u=!1,className:y}){const[j,L]=l.useState(!1),[g,N]=l.useState(""),[F,d]=l.useState(!1),[w,r]=l.useState(""),[M,k]=l.useState(Ke[0]),R=be(),{data:C,isLoading:v}=K({queryKey:["labels",o],queryFn:()=>f.labels.list(o,{includeGlobal:!0}),enabled:!!o}),{data:O}=K({queryKey:["ticket-labels",a],queryFn:()=>f.labels.getTicketLabels(a),enabled:!!a}),_=q({mutationFn:i=>f.labels.setTicketLabels(a,i),onSuccess:()=>{R.invalidateQueries({queryKey:["ticket-labels",a]}),R.invalidateQueries({queryKey:["tickets"]})}}),n=q({mutationFn:()=>f.labels.create(o,{name:w,color:M}),onSuccess:i=>{R.invalidateQueries({queryKey:["labels",o]});const p=i.label,I=b.map(z=>z.id);c?c([...b,p]):_.mutate([...I,p.id]),d(!1),N(""),r(""),L(!1)}}),A=C?.labels??[],b=O?.labels??m,S=new Set(b.map(i=>i.id)),E=A.filter(i=>i.name.toLowerCase().includes(g.toLowerCase())||i.description?.toLowerCase().includes(g.toLowerCase())),ie=i=>{const p=new Set(S);p.has(i.id)?p.delete(i.id):p.add(i.id);const I=A.filter(z=>p.has(z.id));c?c(I):_.mutate([...p])},$=i=>{const p=new Set(S);p.delete(i);const I=A.filter(z=>p.has(z.id));c?c(I):_.mutate([...p])};return e.jsxs("div",{className:H("flex flex-wrap items-center gap-1",y),children:[b.map(i=>e.jsxs(B,{variant:"outline",className:"gap-1 pr-1",style:{backgroundColor:`${i.color}20`,borderColor:i.color,color:i.color},children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i.color}}),i.name,!u&&e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),$(i.id)},className:"ml-1 rounded-full hover:bg-muted/50",children:e.jsx(G,{className:"h-3 w-3"})})]},i.id)),!u&&e.jsxs(Fs,{open:j,onOpenChange:i=>{L(i),i||(d(!1),N(""))},children:[e.jsx(Es,{asChild:!0,children:e.jsxs(h,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-muted-foreground hover:text-foreground",children:[e.jsx(te,{className:"h-3 w-3"}),e.jsx(Xe,{className:"h-3 w-3"})]})}),e.jsxs(Is,{className:"w-64 p-0",align:"start",children:[e.jsx("div",{className:"p-2",children:e.jsx(we,{type:"text",placeholder:"Search labels...",value:g,onChange:i=>N(i.target.value),className:"h-8 text-xs px-2"})}),e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:v?e.jsx("div",{className:"p-2 text-center text-sm text-muted-foreground",children:"Loading..."}):E.length===0&&!g?e.jsx("div",{className:"p-2 text-center text-sm text-muted-foreground",children:"No labels found"}):e.jsxs(e.Fragment,{children:[E.map(i=>e.jsxs("button",{type:"button",onClick:()=>ie(i),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-muted",children:[e.jsx("span",{className:"h-3 w-3 rounded-full",style:{backgroundColor:i.color}}),e.jsx("span",{className:"flex-1 text-left",children:i.name}),S.has(i.id)&&e.jsx(gs,{className:"h-4 w-4 text-primary"})]},i.id)),g&&e.jsx("div",{className:"mt-1 border-t pt-1",children:F?e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("div",{className:"flex gap-1.5",children:Ke.map(i=>e.jsx("button",{type:"button",onClick:()=>k(i),className:H("h-4 w-4 rounded-full transition-transform hover:scale-110",M===i&&"ring-1 ring-primary ring-offset-1 ring-offset-background"),style:{backgroundColor:i}},i))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{size:"sm",className:"h-7 text-[10px] flex-1",onClick:()=>n.mutate(),disabled:n.isPending,children:n.isPending?e.jsx(D,{className:"h-3 w-3 animate-spin"}):"Create"}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 text-[10px]",onClick:()=>{d(!1),N("")},children:"Cancel"})]})]}):e.jsxs("button",{type:"button",onClick:()=>{d(!0),r(g)},className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-primary hover:bg-primary/5",children:[e.jsx(te,{className:"h-3 w-3"}),e.jsxs("span",{children:['Create "',g,'"']})]})})]})})]})]})]})}const Xs=Ws,Ys=ss,Zs=ts,ae=[{value:"blocks",label:"Blocks",icon:$e,color:"text-red-400",description:"This ticket blocks another"},{value:"blocked_by",label:"Blocked by",icon:$e,color:"text-orange-400",description:"This ticket is blocked by another"},{value:"relates_to",label:"Relates to",icon:fe,color:"text-blue-400",description:"Related tickets"},{value:"duplicates",label:"Duplicates",icon:ze,color:"text-purple-400",description:"This ticket duplicates another"},{value:"start_before",label:"Start before",icon:Ae,color:"text-cyan-400",description:"Must start before another ticket"},{value:"finish_before",label:"Finish before",icon:Ae,color:"text-emerald-400",description:"Must finish before another ticket"}];function et(a){return ae.find(o=>o.value===a)||ae[2]}function st({ticketId:a,relations:o=[]}){const m=be(),[c,u]=l.useState(!0),[y,j]=l.useState(!1),[L,g]=l.useState("relates_to"),[N,F]=l.useState(""),[d,w]=l.useState(null),{data:r,isLoading:M}=K({queryKey:["tickets-search",N],queryFn:()=>f.tickets.list({search:N,limit:10}),enabled:N.length>=2,staleTime:1e4}),k=r?.tickets?.filter(n=>n.id!==a)||[],R=q({mutationFn:({targetTicketId:n,type:A})=>f.tickets.addRelation(a,n,A),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),j(!1),F(""),w(null),x.success("Relation added")},onError:n=>{x.error(`Failed to add relation: ${n.message}`)}}),C=q({mutationFn:n=>f.tickets.removeRelation(a,n),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),x.success("Relation removed")},onError:n=>{x.error(`Failed to remove relation: ${n.message}`)}}),v=()=>{if(!d){x.error("Please select a ticket");return}R.mutate({targetTicketId:d,type:L})},O=o.reduce((n,A)=>{const b=A.relationType;return n[b]||(n[b]=[]),n[b].push(A),n},{}),_=o.length;return e.jsxs("div",{className:"glass rounded-[20px] p-4",children:[e.jsxs(Xs,{open:c,onOpenChange:u,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ys,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-2 text-sm font-semibold hover:text-primary transition-colors",children:[c?e.jsx(fs,{className:"h-4 w-4"}):e.jsx(Ns,{className:"h-4 w-4"}),e.jsx(fe,{className:"h-4 w-4"}),"Relations",_>0&&e.jsx(B,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:_})]})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 w-7 p-0 rounded-lg",children:e.jsx(te,{className:"h-4 w-4"})})]}),e.jsx(Zs,{className:"pt-3 space-y-3",children:_===0?e.jsxs("div",{className:"text-center py-4",children:[e.jsx(fe,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relations"}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>j(!0),className:"mt-2 h-7 text-xs gap-1",children:[e.jsx(te,{className:"h-3 w-3"}),"Add relation"]})]}):Object.entries(O).map(([n,A])=>{const b=et(n);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:H("flex items-center gap-1.5 text-xs font-medium",b.color),children:[e.jsx(b.icon,{className:"h-3 w-3"}),b.label]}),e.jsx("div",{className:"space-y-1",children:A.map(S=>{const E=S.sourceTicketId===a?S.targetTicket:S.sourceTicket;return E?e.jsxs("div",{className:"flex items-center justify-between gap-2 p-2 rounded-lg bg-white/5 group",children:[e.jsx(V,{to:`/tickets/${E.id}`,className:"flex-1 min-w-0 hover:text-primary transition-colors",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:[E.projectKey||"PROFCLAW","-",E.sequence]}),e.jsx("span",{className:"text-xs truncate",children:E.title})]})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>C.mutate(S.id),disabled:C.isPending,className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:C.isPending?e.jsx(D,{className:"h-3 w-3 animate-spin"}):e.jsx(G,{className:"h-3 w-3 text-muted-foreground hover:text-red-400"})})]},S.id):null})})]},n)})})]}),e.jsx(Ve,{open:y,onOpenChange:j,children:e.jsxs(He,{className:"sm:max-w-[425px]",children:[e.jsxs(Ge,{children:[e.jsx(Ue,{children:"Add Relation"}),e.jsx(We,{children:"Link this ticket to another ticket."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Relation Type"}),e.jsxs(X,{value:L,onValueChange:n=>g(n),children:[e.jsx(Y,{children:e.jsx(Z,{})}),e.jsx(ee,{children:ae.map(n=>e.jsx(P,{value:n.value,children:e.jsxs("span",{className:H("flex items-center gap-2",n.color),children:[e.jsx(n.icon,{className:"h-4 w-4"}),n.label]})},n.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ae.find(n=>n.value===L)?.description})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Search Ticket"}),e.jsxs("div",{className:"relative",children:[e.jsx(ys,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(we,{placeholder:"Search by title or ID...",value:N,onChange:n=>F(n.target.value),className:"pl-9"})]})]}),N.length>=2&&e.jsx("div",{className:"bg-muted/30 rounded-lg divide-y divide-border/20 max-h-48 overflow-y-auto",children:M?e.jsx("div",{className:"p-4 text-center",children:e.jsx(D,{className:"h-4 w-4 animate-spin mx-auto"})}):k.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No tickets found"}):k.map(n=>e.jsx("button",{type:"button",onClick:()=>w(n.id),className:H("w-full text-left p-3 hover:bg-muted/50 transition-colors",d===n.id&&"bg-primary/10"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[n.projectKey||"PROFCLAW","-",n.sequence]}),e.jsx("span",{className:"text-sm truncate",children:n.title})]})},n.id))}),d&&e.jsxs("div",{className:"p-3 rounded-lg bg-primary/10 border border-primary/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Selected:"}),e.jsx("p",{className:"text-sm font-medium",children:k.find(n=>n.id===d)?.title||"Ticket selected"})]})]}),e.jsxs(Je,{children:[e.jsx(h,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsxs(h,{onClick:v,disabled:!d||R.isPending,children:[R.isPending&&e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Add Relation"]})]})]})})]})}const tt=[{value:"backlog",label:"Backlog",icon:Ye},{value:"todo",label:"Todo",icon:se},{value:"in_progress",label:"In Progress",icon:Ne},{value:"in_review",label:"In Review",icon:Qe},{value:"done",label:"Done",icon:J},{value:"cancelled",label:"Cancelled",icon:G}];function At(){const{id:a}=vs(),o=bs(),m=be(),[c,u]=l.useState(""),[y,j]=l.useState("comments"),[L,g]=l.useState(!1),[N,F]=l.useState(!1),[d,w]=l.useState({title:"",description:"",priority:"medium",type:"task",estimate:null}),{data:r,isLoading:M,error:k}=K({queryKey:["ticket",a],queryFn:()=>f.tickets.get(a,!0),enabled:!!a}),{data:R}=K({queryKey:["projects"],queryFn:()=>f.projects.list({limit:50})}),{data:C,isLoading:v}=K({queryKey:["ticket-similar",a],queryFn:()=>f.tickets.ai.similar(a,5),enabled:!!a&&!!r}),{data:O,isLoading:_}=K({queryKey:["ticket-summary",a],queryFn:()=>f.tickets.ai.summary(a),enabled:!!a&&!!r,staleTime:3e5}),{data:n}=K({queryKey:["ai-status"],queryFn:()=>f.tickets.ai.status(),staleTime:6e4}),A=n?.available??!1,b=q({mutationFn:s=>f.tickets.transition(a,s),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),m.invalidateQueries({queryKey:["tickets"]}),x.success("Status updated")},onError:s=>{x.error(`Failed to update status: ${s.message}`)}}),S=q({mutationFn:s=>f.tickets.update(a,s),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),m.invalidateQueries({queryKey:["tickets"]}),g(!1),x.success("Ticket updated")},onError:s=>{x.error(`Failed to update ticket: ${s.message}`)}}),E=q({mutationFn:()=>f.tickets.delete(a),onSuccess:()=>{m.invalidateQueries({queryKey:["tickets"]}),x.success("Ticket deleted"),o("/tickets")},onError:s=>{x.error(`Failed to delete ticket: ${s.message}`)}}),ie=q({mutationFn:s=>f.tickets.update(a,{projectId:s}),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),m.invalidateQueries({queryKey:["tickets"]}),x.success("Ticket moved to project")},onError:s=>{x.error(`Failed to move ticket: ${s.message}`)}}),$=q({mutationFn:s=>f.tickets.addComment(a,s),onSuccess:()=>{m.invalidateQueries({queryKey:["ticket",a]}),u(""),x.success("Comment added")},onError:s=>{x.error(`Failed to add comment: ${s.message}`)}}),i=q({mutationFn:s=>f.tickets.ai.respond(a,s),onSuccess:s=>{s.posted&&s.comment?(m.invalidateQueries({queryKey:["ticket",a]}),x.success("AI response posted")):s.response?(I(s.response),U(s.confidence),x.success(`AI generated response (${Math.round(s.confidence*100)}% confidence)`)):s.skipped&&x.info(s.reason||"AI chose not to respond")},onError:s=>{x.error(`AI response failed: ${s.message}`)}}),[p,I]=l.useState(null),[z,U]=l.useState(0),as=async()=>{p&&(await $.mutateAsync(p),I(null),U(0))},ns=()=>{c.trim()&&$.mutate(c)},is=()=>{r&&(w({title:r.title,description:r.description||"",priority:r.priority,type:r.type,estimate:r.estimate??null}),g(!0))},ls=()=>{S.mutate({...d,estimate:d.estimate??void 0,estimateUnit:d.estimate!==null?"points":void 0})},Te=s=>{ie.mutate(s)},rs=async()=>{if(r)try{const s=await f.tickets.create({title:`${r.title} (Copy)`,description:r.description,type:r.type,priority:r.priority,labels:r.labels,projectId:r.projectId});x.success("Ticket duplicated"),o(`/tickets/${s.ticket.id}`)}catch{x.error("Failed to duplicate ticket")}},cs=s=>{const le={done:{variant:"success",icon:J},cancelled:{variant:"destructive",icon:G},in_progress:{variant:"info",icon:Ne},in_review:{variant:"warning",icon:Qe},todo:{variant:"secondary",icon:se},backlog:{variant:"secondary",icon:Ye}}[s],{variant:re,icon:ce}=le;return e.jsxs(B,{variant:re,className:"gap-1 text-sm px-3 py-1",children:[e.jsx(ce,{className:"h-4 w-4"}),s.replace("_"," ")]})},Pe=s=>{const le={task:{icon:J,color:"text-blue-500"},bug:{icon:Ks,color:"text-red-500"},feature:{icon:Fe,color:"text-cyan-500"},enhancement:{icon:Fe,color:"text-indigo-500"},documentation:{icon:_e,color:"text-cyan-500"},epic:{icon:je,color:"text-orange-500"},story:{icon:_e,color:"text-green-500"},subtask:{icon:se,color:"text-gray-500"}}[s],{icon:re,color:ce}=le;return e.jsxs("span",{className:`flex items-center gap-1.5 text-sm ${ce}`,children:[e.jsx(re,{className:"h-4 w-4"}),s]})},os=s=>({urgent:"text-red-500",high:"text-orange-500",medium:"text-yellow-500",low:"text-blue-500",none:"text-gray-400"})[s]||"text-gray-400";if(M)return e.jsx("div",{className:"glass rounded-[28px] p-12 flex items-center justify-center",children:e.jsx(D,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(k||!r)return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(h,{variant:"ghost",onClick:()=>o("/tickets"),className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),"Back to Tickets"]}),e.jsxs("div",{className:"glass rounded-[28px] p-12 text-center",children:[e.jsx(ws,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:k?"Error loading ticket":"Ticket not found"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:k?k.message:`No ticket found with ID: ${a}`})]})]});const t=r,W=R?.projects||[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(h,{variant:"ghost",onClick:()=>o("/tickets"),className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),"Back to Tickets"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:is,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Edit"]}),e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"Move to Project"]})}),e.jsx(me,{align:"end",className:"w-56",children:W.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No projects available"}):W.map(s=>e.jsxs(Q,{onClick:()=>Te(s.id),disabled:s.id===t.projectId,children:[e.jsx("span",{className:"mr-2",children:s.icon}),s.name,s.id===t.projectId&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"(current)"})]},s.id))})]}),e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",className:"h-9 w-9",children:e.jsx(Ms,{className:"h-4 w-4"})})}),e.jsxs(me,{align:"end",children:[e.jsxs(Q,{onClick:rs,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Duplicate Ticket"]}),e.jsxs(Q,{onClick:()=>{const s=t.externalLinks?.find(T=>T.platform==="jira");s?.externalUrl?window.open(s.externalUrl,"_blank"):x.info("No Jira link found. Link this ticket to Jira first.")},children:[e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Open in Jira"]}),e.jsx(ks,{}),e.jsxs(Q,{className:"text-red-500 focus:text-red-500",onClick:()=>F(!0),children:[e.jsx(Os,{className:"h-4 w-4 mr-2"}),"Delete Ticket"]})]})]})]})]}),e.jsx(Ve,{open:L,onOpenChange:g,children:e.jsxs(He,{className:"sm:max-w-[500px]",children:[e.jsxs(Ge,{children:[e.jsx(Ue,{children:"Edit Ticket"}),e.jsx(We,{children:"Make changes to the ticket details."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Title"}),e.jsx(we,{value:d.title,onChange:s=>w(T=>({...T,title:s.target.value})),placeholder:"Ticket title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Ee,{value:d.description,onChange:s=>w(T=>({...T,description:s.target.value})),placeholder:"Ticket description",rows:4})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Priority"}),e.jsxs(X,{value:d.priority,onValueChange:s=>w(T=>({...T,priority:s})),children:[e.jsx(Y,{children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(P,{value:"urgent",children:"Urgent"}),e.jsx(P,{value:"high",children:"High"}),e.jsx(P,{value:"medium",children:"Medium"}),e.jsx(P,{value:"low",children:"Low"}),e.jsx(P,{value:"none",children:"None"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Type"}),e.jsxs(X,{value:d.type,onValueChange:s=>w(T=>({...T,type:s})),children:[e.jsx(Y,{children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(P,{value:"task",children:"Task"}),e.jsx(P,{value:"bug",children:"Bug"}),e.jsx(P,{value:"feature",children:"Feature"}),e.jsx(P,{value:"enhancement",children:"Enhancement"}),e.jsx(P,{value:"epic",children:"Epic"}),e.jsx(P,{value:"story",children:"Story"}),e.jsx(P,{value:"subtask",children:"Subtask"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Estimate"}),e.jsx(Ie,{value:d.estimate,onChange:s=>w(T=>({...T,estimate:s})),placeholder:"Points"})]})]})]}),e.jsxs(Je,{children:[e.jsx(h,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),e.jsxs(h,{onClick:ls,disabled:S.isPending,children:[S.isPending&&e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Changes"]})]})]})}),e.jsx(Cs,{open:N,onOpenChange:F,children:e.jsxs(Ss,{children:[e.jsxs(Ts,{children:[e.jsx(Ps,{children:"Delete Ticket"}),e.jsxs(As,{children:['Are you sure you want to delete "',t.title,'"? This action cannot be undone.']})]}),e.jsxs(Ls,{children:[e.jsx(Rs,{children:"Cancel"}),e.jsxs(Ds,{onClick:()=>E.mutate(),className:"bg-red-500 hover:bg-red-600",children:[E.isPending&&e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Delete"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"glass rounded-[20px] p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-mono text-muted-foreground bg-white/5 px-2 py-1 rounded-md",children:[t.projectKey||"PROFCLAW","-",t.sequence]}),!t.projectId&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-amber-400 px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20",children:"No Project"}),Pe(t.type)]}),cs(t.status)]}),e.jsx("h1",{className:"text-2xl font-bold mb-4",children:t.title}),t.description&&e.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.description})}),(t.linkedPRs.length>0||t.linkedCommits.length>0||t.linkedBranch)&&e.jsxs("div",{className:"flex flex-wrap gap-4 mt-4 pt-4 border-t border-white/5",children:[t.linkedBranch&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),t.linkedBranch]}),t.linkedPRs.length>0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),t.linkedPRs.length," PR(s)"]}),t.linkedCommits.length>0&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(_s,{className:"h-3.5 w-3.5"}),t.linkedCommits.length," commit(s)"]})]})]}),e.jsxs("div",{className:"glass rounded-[20px] overflow-hidden",children:[e.jsxs("div",{className:"flex border-b border-white/5",children:[e.jsxs("button",{onClick:()=>j("comments"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${y==="comments"?"bg-white/5 text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Me,{className:"h-4 w-4"}),"Comments (",t.comments?.length||0,")"]}),e.jsxs("button",{onClick:()=>j("history"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${y==="history"?"bg-white/5 text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(he,{className:"h-4 w-4"}),"History (",t.history?.length||0,")"]}),e.jsxs("button",{onClick:()=>j("links"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${y==="links"?"bg-white/5 text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ge,{className:"h-4 w-4"}),"Links (",t.externalLinks?.length||0,")"]})]}),e.jsxs("div",{className:"p-4",children:[y==="comments"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/20 flex items-center justify-center shrink-0",children:e.jsx(xe,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Ee,{placeholder:"Add a comment...",value:c,onChange:s=>u(s.target.value),className:"min-h-20"}),e.jsxs("div",{className:"flex justify-end mt-2 gap-2",children:[A&&t.comments&&t.comments.length>0&&e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>i.mutate({}),disabled:i.isPending,className:"gap-2",children:[i.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):e.jsx(pe,{className:"h-4 w-4"}),"AI Respond"]}),e.jsxs(h,{size:"sm",variant:"black",onClick:ns,disabled:!c.trim()||$.isPending,className:"gap-2",children:[$.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):e.jsx(Oe,{className:"h-4 w-4"}),"Comment"]})]})]})]}),p&&e.jsxs("div",{className:"rounded-xl bg-primary/5 border border-primary/20 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[e.jsx(pe,{className:"h-4 w-4"}),"AI Generated Response",e.jsxs(B,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[Math.round(z*100),"% confidence"]})]}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{I(null),U(0)},className:"h-6 w-6 p-0 rounded-lg",children:e.jsx(G,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:p}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",onClick:()=>{u(p),I(null),U(0)},className:"gap-1 rounded-xl border-white/10 text-xs",children:"Edit First"}),e.jsxs(h,{size:"sm",onClick:as,disabled:$.isPending,className:"gap-1 rounded-xl text-xs",children:[$.isPending?e.jsx(D,{className:"h-3 w-3 animate-spin"}):e.jsx(Oe,{className:"h-3 w-3"}),"Post Response"]})]})]}),t.comments&&t.comments.length>0?e.jsx("div",{className:"space-y-4 pt-4 border-t border-white/5",children:t.comments.map(s=>e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`h-8 w-8 rounded-full flex items-center justify-center flex-shrink-0 ${s.author.type==="ai","bg-blue-500/20"}`,children:s.author.type==="ai"?e.jsx(ue,{className:"h-4 w-4 text-blue-500"}):e.jsx(xe,{className:"h-4 w-4 text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:s.author.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.createdAt).toLocaleString()}),s.source!=="profclaw"&&e.jsx(B,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:s.source})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:s.content})]})]},s.id))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Me,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No comments yet"})]})]}),y==="history"&&e.jsx("div",{className:"space-y-3",children:t.history&&t.history.length>0?t.history.map(s=>e.jsxs("div",{className:"flex items-start gap-3 py-2",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-white/5 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(he,{className:"h-3 w-3 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:s.changedBy.name}),e.jsx("span",{className:"text-muted-foreground",children:" changed "}),e.jsx("span",{className:"font-medium",children:s.field}),s.oldValue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:" from "}),e.jsx("span",{className:"text-red-400/80",children:s.oldValue})]}),s.newValue&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:" to "}),e.jsx("span",{className:"text-green-400/80",children:s.newValue})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:new Date(s.timestamp).toLocaleString()})]})]},s.id)):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(he,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No history yet"})]})}),y==="links"&&e.jsx("div",{className:"space-y-3",children:t.externalLinks&&t.externalLinks.length>0?t.externalLinks.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-white/5 flex items-center justify-center",children:e.jsx(ge,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm capitalize",children:s.platform}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.externalId})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{variant:s.syncEnabled?"success":"secondary",className:"text-[10px]",children:s.syncDirection}),s.externalUrl&&e.jsx("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer",className:"p-2 hover:bg-white/5 rounded-lg transition-colors",children:e.jsx(Re,{className:"h-4 w-4 text-muted-foreground"})})]})]},s.id)):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ge,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No external links yet"})]})})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"glass rounded-[20px] p-4",children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Status"}),e.jsxs(X,{value:t.status,onValueChange:s=>b.mutate(s),disabled:b.isPending,children:[e.jsx(Y,{className:"w-full bg-white/5 border-white/10 rounded-xl",children:e.jsx(Z,{})}),e.jsx(ee,{className:"glass-heavy rounded-xl border-white/10",children:tt.map(s=>e.jsx(P,{value:s.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(s.icon,{className:"h-4 w-4"}),s.label]})},s.value))})]})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Details"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Project"}),t.projectId?e.jsx(V,{to:`/projects/${t.projectId}`,className:"text-sm font-medium text-primary hover:underline",children:t.projectName||t.projectKey||"View Project"}):e.jsx("span",{className:"text-sm text-muted-foreground italic",children:"No project"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Priority"}),e.jsx("span",{className:`text-sm font-medium capitalize ${os(t.priority)}`,children:t.priority})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Type"}),Pe(t.type)]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Created By"}),e.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:t.createdBy==="ai"?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-indigo-400"}),"AI"]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 text-blue-400"}),"Human"]})})]}),t.assigneeAgent&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Assigned Agent"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-sm text-primary",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),t.assigneeAgent]})]}),t.aiAgent&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"AI Agent"}),e.jsx("span",{className:"text-sm",children:t.aiAgent})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Estimate"}),e.jsx(Ie,{value:t.estimate??null,onChange:s=>{S.mutate({estimate:s??void 0,estimateUnit:s!==null?"points":void 0})},compact:!0,placeholder:"—",className:"w-[90px] h-8 text-xs"})]}),t.dueDate&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Due Date"}),e.jsxs("span",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx($s,{className:"h-3.5 w-3.5"}),new Date(t.dueDate).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Xe,{className:"h-4 w-4"}),"Labels"]}),t.projectId?e.jsx(Js,{ticketId:t.id,projectId:t.projectId}):e.jsxs("div",{className:"text-center py-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Assign to a project to add labels"}),e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[e.jsx(Be,{className:"h-3 w-3"}),"Select Project"]})}),e.jsx(me,{align:"center",className:"w-48",children:W.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No projects available"}):W.map(s=>e.jsxs(Q,{onClick:()=>Te(s.id),className:"text-sm",children:[e.jsx("span",{className:"mr-2",children:s.icon}),s.name]},s.id))})]})]})]}),e.jsx(st,{ticketId:t.id,relations:t.relations||[]}),t.parent&&e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-amber-400"}),"Parent Ticket"]}),e.jsxs(V,{to:`/tickets/${t.parent.id}`,className:"block p-3 rounded-xl bg-white/5 hover:bg-white/10 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.parent.projectKey||"PROFCLAW","-",t.parent.sequence]}),t.parent.type==="epic"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 font-medium",children:"EPIC"})]}),e.jsx("p",{className:"text-sm font-medium group-hover:text-primary transition-colors",children:t.parent.title})]})]}),t.children&&t.children.length>0&&e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4 text-primary"}),"Child Tickets (",t.children.length,")",e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[t.children.filter(s=>s.status==="done").length,"/",t.children.length," done"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-green-500 to-emerald-400 transition-all",style:{width:`${t.children.filter(s=>s.status==="done").length/t.children.length*100}%`}})}),e.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:t.children.map(s=>e.jsxs(V,{to:`/tickets/${s.id}`,className:"flex items-center gap-3 p-2 rounded-lg bg-white/5 hover:bg-white/10 transition-colors group",children:[e.jsx("div",{className:`flex-shrink-0 ${s.status==="done"?"text-green-500":s.status==="in_progress"?"text-blue-500":"text-muted-foreground"}`,children:s.status==="done"?e.jsx(J,{className:"h-4 w-4"}):s.status==="in_progress"?e.jsx(Ne,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-mono text-muted-foreground mb-0.5",children:[s.projectKey||"PROFCLAW","-",s.sequence]}),e.jsx("p",{className:`text-sm truncate group-hover:text-primary transition-colors ${s.status==="done"?"line-through text-muted-foreground":""}`,children:s.title})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground capitalize",children:s.type})]},s.id))})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Timestamps"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Created"}),e.jsx("span",{className:"text-xs",children:new Date(t.createdAt).toLocaleString()})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Updated"}),e.jsx("span",{className:"text-xs",children:new Date(t.updatedAt).toLocaleString()})]}),t.startedAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Started"}),e.jsx("span",{className:"text-xs",children:new Date(t.startedAt).toLocaleString()})]}),t.completedAt&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Completed"}),e.jsx("span",{className:"text-xs",children:new Date(t.completedAt).toLocaleString()})]})]})]}),A&&e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4 text-primary"}),"AI Summary"]}),_?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(D,{className:"h-3 w-3 animate-spin"}),"Generating summary..."]}):O?.summary?e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:O.summary}):e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Summary not available"})]}),e.jsxs("div",{className:"glass rounded-[20px] p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(pe,{className:"h-4 w-4 text-primary"}),"Similar Tickets"]}),v?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(D,{className:"h-3 w-3 animate-spin"}),"Finding similar tickets..."]}):C?.similar&&C.similar.length>0?e.jsx("div",{className:"space-y-2",children:C.similar.map(s=>e.jsxs(V,{to:`/tickets/${s.id}`,className:"block p-2 rounded-lg bg-white/5 hover:bg-white/10 transition-colors group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx(De,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:[s.projectKey||"PROFCLAW","-",s.sequence]})]}),e.jsx("p",{className:"text-xs font-medium truncate group-hover:text-primary transition-colors",children:s.title})]}),e.jsxs(B,{variant:"outline",className:"text-[10px] px-1.5 py-0 flex-shrink-0 tabular-nums",children:[Math.round(s.similarity*100),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[e.jsx(B,{variant:s.status==="done"?"success":s.status==="in_progress"?"info":"secondary",className:"text-[9px] px-1 py-0",children:s.status.replace("_"," ")}),e.jsx("span",{className:"text-[10px] text-muted-foreground capitalize",children:s.type})]})]},s.id))}):e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(De,{className:"h-6 w-6 mx-auto mb-1 opacity-40"}),e.jsx("p",{className:"text-xs",children:"No similar tickets found"})]})]})]})]})]})}export{At as TicketDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as oe,q as ie,r as L,u as O,j as e,v as ce,w as de,I as U,T as k,a1 as Y,C as N,X as P,S as E,F as xe,an as M,B as H,k as S,L as me,h as ue,g as pe,m as q}from"./index--JkIxVXb.js";import{B as Q}from"./badge-DEmc3Z_l.js";import{S as j,a as b,b as v,c as f,d as h}from"./select-MADP8m6Q.js";import{P as he,a as ge,b as je}from"./popover-JXecfWG5.js";import{V as be,C as ve}from"./ViewSwitcher-3HzZUdWn.js";import{E as fe}from"./EstimateSelect-CDjf5qKl.js";import{I as G,C as T,L as W}from"./layers-DFeLExSa.js";import{P as X}from"./play-DVgea_jT.js";import{B as J,a as _}from"./bug-DqSGPUUE.js";import{T as Ne}from"./tag-tAwMmQ9G.js";import{F as ye}from"./funnel-ByEjRFNB.js";import"./chevron-up-DcJ4LL_N.js";import"./textarea-BjiEeIWh.js";import"./dialog-BOdGWhgE.js";import"./brain-CfFdLVqb.js";import"./wand-sparkles-DPvcd9Pi.js";import"./folder-open-CHwA1-ve.js";import"./link-2-YqrpQXBH.js";import"./hash-nKC9gtLg.js";import"./lightbulb-Bo8hEr7B.js";const we=[{value:"all",label:"All Status",icon:k},{value:"backlog",label:"Backlog",icon:G},{value:"todo",label:"Todo",icon:T},{value:"in_progress",label:"In Progress",icon:X},{value:"in_review",label:"In Review",icon:Y},{value:"done",label:"Done",icon:N},{value:"cancelled",label:"Cancelled",icon:P}],Ce=[{value:"all",label:"All Types",icon:k},{value:"task",label:"Task",icon:N},{value:"bug",label:"Bug",icon:J},{value:"feature",label:"Feature",icon:E},{value:"epic",label:"Epic",icon:W},{value:"story",label:"Story",icon:_},{value:"subtask",label:"Subtask",icon:T}],Se=[{value:"all",label:"All Priorities",color:"text-muted-foreground"},{value:"urgent",label:"Urgent",color:"text-red-500"},{value:"high",label:"High",color:"text-orange-500"},{value:"medium",label:"Medium",color:"text-yellow-500"},{value:"low",label:"Low",color:"text-blue-500"},{value:"none",label:"None",color:"text-gray-500"}],Pe=[{value:"all",label:"All Authors",icon:M},{value:"human",label:"Human",icon:M},{value:"ai",label:"AI",icon:H}];function Ye(){const Z=oe(),[r,V]=ie(),n=r.get("status")||"all",o=r.get("type")||"all",i=r.get("priority")||"all",l=r.get("project")||"all",c=r.get("createdBy")||"all",t=r.get("label")||"",[u,z]=L.useState(r.get("q")||""),[R,y]=L.useState(""),[x,w]=L.useState(0),p=20,{data:ee}=O({queryKey:["projects-list"],queryFn:()=>q.projects.list({limit:100})}),C=ee?.projects??[],{data:ae}=O({queryKey:["labels-global"],queryFn:async()=>{const a=C[0];return a?q.labels.list(a.id,{includeGlobal:!0}):{labels:[],total:0}},enabled:C.length>0}),D=ae?.labels??[],d=(a,s)=>{const m=new URLSearchParams(r);s==="all"||s===""?m.delete(a):m.set(a,s),V(m),w(0)},se=()=>{V({}),z(""),y(""),w(0)},I=n!=="all"||o!=="all"||i!=="all"||l!=="all"||c!=="all"||t||u,{data:$,isLoading:le,error:K}=O({queryKey:["tickets",{status:n==="all"?void 0:n,type:o==="all"?void 0:o,priority:i==="all"?void 0:i,projectId:l==="all"?void 0:l,createdBy:c==="all"?void 0:c,label:t||void 0,search:u||void 0,limit:p,offset:x*p}],queryFn:()=>q.tickets.list({status:n==="all"?void 0:n,type:o==="all"?void 0:o,priority:i==="all"?void 0:i,projectId:l==="all"?void 0:l,createdBy:c==="all"?void 0:c,label:t||void 0,search:u||void 0,limit:p,offset:x*p})}),g=$?.tickets??[],B=$?.total??0,te=a=>{const m={done:{variant:"success",icon:N},cancelled:{variant:"destructive",icon:P},in_progress:{variant:"info",icon:X},in_review:{variant:"warning",icon:Y},todo:{variant:"secondary",icon:T},backlog:{variant:"secondary",icon:G}}[a]||{variant:"secondary",icon:pe},{variant:A,icon:F}=m;return e.jsxs(Q,{variant:A,className:"gap-1",children:[e.jsx(F,{className:"h-3 w-3"}),a.replace("_"," ")]})},re=a=>{const m={task:{icon:N,color:"text-blue-500"},bug:{icon:J,color:"text-red-500"},feature:{icon:E,color:"text-cyan-500"},enhancement:{icon:E,color:"text-indigo-500"},documentation:{icon:_,color:"text-cyan-500"},epic:{icon:W,color:"text-orange-500"},story:{icon:_,color:"text-green-500"},subtask:{icon:T,color:"text-gray-500"}}[a]||{icon:k,color:"text-gray-500"},{icon:A,color:F}=m;return e.jsxs("span",{className:`flex items-center gap-1 text-xs ${F}`,children:[e.jsx(A,{className:"h-3 w-3"}),a]})},ne=a=>{const s={urgent:"bg-red-500",high:"bg-orange-500",medium:"bg-yellow-500",low:"bg-blue-500",none:"bg-gray-400"};return e.jsx("div",{className:`h-2 w-2 rounded-full ${s[a]}`,title:a})};return K?e.jsxs("div",{className:"premium-card rounded-[24px] p-12 text-center",children:[e.jsx(ce,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:"Error loading tickets"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:K.message})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tickets"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[B," total tickets • ",g.length," showing"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(be,{view:"list",onChange:a=>{a==="board"&&Z("/tickets/board")}}),e.jsx(ve,{})]})]}),e.jsxs("div",{className:"premium-card rounded-[20px] p-4 bg-muted/20",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:"Search tickets by title or description...",value:u,onChange:a=>{z(a.target.value),d("q",a.target.value)},className:"pl-10 h-10"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(j,{value:n,onValueChange:a=>d("status",a),children:[e.jsx(b,{className:"w-[140px]",children:e.jsx(v,{placeholder:"Status"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:we.map(a=>e.jsx(h,{value:a.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(a.icon,{className:"h-3.5 w-3.5"}),a.label]})},a.value))})]}),e.jsxs(j,{value:o,onValueChange:a=>d("type",a),children:[e.jsx(b,{className:"w-[130px]",children:e.jsx(v,{placeholder:"Type"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:Ce.map(a=>e.jsx(h,{value:a.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(a.icon,{className:"h-3.5 w-3.5"}),a.label]})},a.value))})]}),e.jsxs(j,{value:i,onValueChange:a=>d("priority",a),children:[e.jsx(b,{className:"w-[140px]",children:e.jsx(v,{placeholder:"Priority"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:Se.map(a=>e.jsx(h,{value:a.value,children:e.jsx("span",{className:`flex items-center gap-2 ${a.color}`,children:a.label})},a.value))})]}),e.jsxs(j,{value:l,onValueChange:a=>d("project",a),children:[e.jsx(b,{className:"w-[150px]",children:e.jsx(v,{placeholder:"Project"})}),e.jsxs(f,{className:"glass-heavy rounded-xl border-white/10",children:[e.jsx(h,{value:"all",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"All Projects"]})}),C.map(a=>e.jsx(h,{value:a.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{children:a.icon}),a.name]})},a.id))]})]}),e.jsxs(j,{value:c,onValueChange:a=>d("createdBy",a),children:[e.jsx(b,{className:"w-[130px]",children:e.jsx(v,{placeholder:"Author"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:Pe.map(a=>e.jsx(h,{value:a.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(a.icon,{className:"h-3.5 w-3.5"}),a.label]})},a.value))})]}),e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",className:`w-[130px] justify-start ${t?"text-primary":""}`,children:[e.jsx(Ne,{className:"h-3.5 w-3.5 mr-2"}),t||"Label"]})}),e.jsxs(je,{className:"w-64 p-0 glass-heavy rounded-xl border-white/10",align:"start",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsx(U,{placeholder:"Search labels...",value:R,onChange:a=>y(a.target.value),className:"h-8 bg-transparent border-white/10"})}),e.jsxs("div",{className:"max-h-64 overflow-y-auto p-1",children:[e.jsxs("button",{type:"button",onClick:()=>{d("label",""),y("")},className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-sm hover:bg-white/5",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:"Clear label filter"})]}),D.filter(a=>a.name.toLowerCase().includes(R.toLowerCase())).map(a=>e.jsxs("button",{type:"button",onClick:()=>{d("label",a.name),y("")},className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-sm hover:bg-white/5 ${t===a.name?"bg-primary/10":""}`,children:[e.jsx("span",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:a.color}}),e.jsx("span",{className:"truncate",children:a.name}),t===a.name&&e.jsx(N,{className:"h-3.5 w-3.5 ml-auto text-primary"})]},a.id)),D.length===0&&e.jsx("p",{className:"p-2 text-sm text-muted-foreground text-center",children:"No labels available"})]})]})]}),I&&e.jsxs(S,{variant:"ghost",size:"sm",onClick:se,className:"rounded-xl text-muted-foreground hover:text-foreground",children:[e.jsx(P,{className:"h-4 w-4 mr-1"}),"Clear"]})]})]}),I&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3 pt-3 border-t border-white/5",children:[e.jsx(ye,{className:"h-4 w-4 text-muted-foreground"}),n!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-blue-500/10 text-blue-400 text-xs font-medium",children:["Status: ",n]}),o!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-indigo-500/10 text-indigo-400 text-xs font-medium capitalize",children:["Type: ",o]}),i!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-orange-500/10 text-orange-400 text-xs font-medium capitalize",children:["Priority: ",i]}),l!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-indigo-500/10 text-indigo-400 text-xs font-medium",children:["Project: ",C.find(a=>a.id===l)?.name||l]}),c!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-cyan-500/10 text-cyan-400 text-xs font-medium capitalize",children:["Author: ",c]}),t&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-pink-500/10 text-pink-400 text-xs font-medium",children:["Label: ",t]}),u&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-green-500/10 text-green-400 text-xs font-medium",children:['Search: "',u,'"']})]})]}),le?e.jsx("div",{className:"premium-card rounded-[28px] p-12 flex items-center justify-center",children:e.jsx(me,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):g.length===0?e.jsxs("div",{className:"premium-card rounded-[24px] p-12 text-center",children:[e.jsx(k,{className:"h-12 w-12 mx-auto text-muted-foreground/40 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-muted-foreground",children:"No tickets found"}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mt-1",children:I?"Try adjusting your filters":"Create a ticket to get started"})]}):e.jsx("div",{className:"space-y-2",children:g.map(a=>e.jsx(ue,{to:`/tickets/${a.id}`,className:"block premium-card border-none hover:bg-muted/30 transition-all group",children:e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"pt-1",children:ne(a.priority)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[a.projectKey||"PROFCLAW","-",a.sequence]}),!a.projectId&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-amber-400 px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20",children:"No Project"}),e.jsx("h3",{className:"font-semibold truncate group-hover:text-primary transition-colors",children:a.title})]}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1 mb-2",children:a.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[re(a.type),te(a.status),a.assigneeAgent&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-bold uppercase tracking-wider text-primary/80 px-2 py-0.5 rounded-md bg-primary/10",children:[e.jsx(H,{className:"h-3 w-3"}),a.assigneeAgent]}),a.createdBy==="ai"&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-blue-400 px-2 py-0.5 rounded-md bg-blue-500/10",children:"AI Created"}),a.labels.slice(0,3).map(s=>e.jsx(Q,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:s},s)),a.estimate!=null&&e.jsx(fe,{value:a.estimate}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-auto",children:new Date(a.createdAt).toLocaleDateString()})]})]})]})})},a.id))}),g.length>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",x+1," • Showing ",Math.min(g.length,p)," of ",B]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>w(x-1),disabled:x===0,className:"rounded-xl border-white/10",children:"Previous"}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>w(x+1),disabled:(x+1)*p>=B,className:"rounded-xl border-white/10",children:"Next"})]})]})]})}export{Ye as TicketList};
|
|
1
|
+
import{s as oe,q as ie,r as L,u as O,j as e,v as ce,w as de,I as U,T as k,a1 as Y,C as N,X as P,S as E,F as xe,an as M,B as H,k as S,L as me,h as ue,g as pe,m as q}from"./index-lJlNPFVJ.js";import{B as Q}from"./badge-CVHH1a-v.js";import{S as j,a as b,b as v,c as f,d as h}from"./select-CeQ8AHGy.js";import{P as he,a as ge,b as je}from"./popover-CrmZgoWu.js";import{V as be,C as ve}from"./ViewSwitcher-CnL0OqA8.js";import{E as fe}from"./EstimateSelect-1hQf4Osk.js";import{I as G,C as T,L as W}from"./layers-jFqVrWMD.js";import{P as X}from"./play-d1ONaH0-.js";import{B as J,a as _}from"./bug-CmZI7jqM.js";import{T as Ne}from"./tag-C35mgoEv.js";import{F as ye}from"./funnel-PkaD_HSR.js";import"./chevron-up-CoUsOvZj.js";import"./textarea-DsVPnSgR.js";import"./dialog-BUqN9Psj.js";import"./brain-6o_RHVpe.js";import"./wand-sparkles-BusQ52ZK.js";import"./folder-open-BJi577JH.js";import"./link-2-DdO7ostF.js";import"./hash-DNEv8Elo.js";import"./lightbulb-Jhp7FvbU.js";const we=[{value:"all",label:"All Status",icon:k},{value:"backlog",label:"Backlog",icon:G},{value:"todo",label:"Todo",icon:T},{value:"in_progress",label:"In Progress",icon:X},{value:"in_review",label:"In Review",icon:Y},{value:"done",label:"Done",icon:N},{value:"cancelled",label:"Cancelled",icon:P}],Ce=[{value:"all",label:"All Types",icon:k},{value:"task",label:"Task",icon:N},{value:"bug",label:"Bug",icon:J},{value:"feature",label:"Feature",icon:E},{value:"epic",label:"Epic",icon:W},{value:"story",label:"Story",icon:_},{value:"subtask",label:"Subtask",icon:T}],Se=[{value:"all",label:"All Priorities",color:"text-muted-foreground"},{value:"urgent",label:"Urgent",color:"text-red-500"},{value:"high",label:"High",color:"text-orange-500"},{value:"medium",label:"Medium",color:"text-yellow-500"},{value:"low",label:"Low",color:"text-blue-500"},{value:"none",label:"None",color:"text-gray-500"}],Pe=[{value:"all",label:"All Authors",icon:M},{value:"human",label:"Human",icon:M},{value:"ai",label:"AI",icon:H}];function Ye(){const Z=oe(),[r,V]=ie(),n=r.get("status")||"all",o=r.get("type")||"all",i=r.get("priority")||"all",l=r.get("project")||"all",c=r.get("createdBy")||"all",t=r.get("label")||"",[u,z]=L.useState(r.get("q")||""),[R,y]=L.useState(""),[x,w]=L.useState(0),p=20,{data:ee}=O({queryKey:["projects-list"],queryFn:()=>q.projects.list({limit:100})}),C=ee?.projects??[],{data:ae}=O({queryKey:["labels-global"],queryFn:async()=>{const a=C[0];return a?q.labels.list(a.id,{includeGlobal:!0}):{labels:[],total:0}},enabled:C.length>0}),D=ae?.labels??[],d=(a,s)=>{const m=new URLSearchParams(r);s==="all"||s===""?m.delete(a):m.set(a,s),V(m),w(0)},se=()=>{V({}),z(""),y(""),w(0)},I=n!=="all"||o!=="all"||i!=="all"||l!=="all"||c!=="all"||t||u,{data:$,isLoading:le,error:K}=O({queryKey:["tickets",{status:n==="all"?void 0:n,type:o==="all"?void 0:o,priority:i==="all"?void 0:i,projectId:l==="all"?void 0:l,createdBy:c==="all"?void 0:c,label:t||void 0,search:u||void 0,limit:p,offset:x*p}],queryFn:()=>q.tickets.list({status:n==="all"?void 0:n,type:o==="all"?void 0:o,priority:i==="all"?void 0:i,projectId:l==="all"?void 0:l,createdBy:c==="all"?void 0:c,label:t||void 0,search:u||void 0,limit:p,offset:x*p})}),g=$?.tickets??[],B=$?.total??0,te=a=>{const m={done:{variant:"success",icon:N},cancelled:{variant:"destructive",icon:P},in_progress:{variant:"info",icon:X},in_review:{variant:"warning",icon:Y},todo:{variant:"secondary",icon:T},backlog:{variant:"secondary",icon:G}}[a]||{variant:"secondary",icon:pe},{variant:A,icon:F}=m;return e.jsxs(Q,{variant:A,className:"gap-1",children:[e.jsx(F,{className:"h-3 w-3"}),a.replace("_"," ")]})},re=a=>{const m={task:{icon:N,color:"text-blue-500"},bug:{icon:J,color:"text-red-500"},feature:{icon:E,color:"text-cyan-500"},enhancement:{icon:E,color:"text-indigo-500"},documentation:{icon:_,color:"text-cyan-500"},epic:{icon:W,color:"text-orange-500"},story:{icon:_,color:"text-green-500"},subtask:{icon:T,color:"text-gray-500"}}[a]||{icon:k,color:"text-gray-500"},{icon:A,color:F}=m;return e.jsxs("span",{className:`flex items-center gap-1 text-xs ${F}`,children:[e.jsx(A,{className:"h-3 w-3"}),a]})},ne=a=>{const s={urgent:"bg-red-500",high:"bg-orange-500",medium:"bg-yellow-500",low:"bg-blue-500",none:"bg-gray-400"};return e.jsx("div",{className:`h-2 w-2 rounded-full ${s[a]}`,title:a})};return K?e.jsxs("div",{className:"premium-card rounded-[24px] p-12 text-center",children:[e.jsx(ce,{className:"h-12 w-12 mx-auto text-red-400 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-red-400",children:"Error loading tickets"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:K.message})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tickets"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[B," total tickets • ",g.length," showing"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(be,{view:"list",onChange:a=>{a==="board"&&Z("/tickets/board")}}),e.jsx(ve,{})]})]}),e.jsxs("div",{className:"premium-card rounded-[20px] p-4 bg-muted/20",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:"Search tickets by title or description...",value:u,onChange:a=>{z(a.target.value),d("q",a.target.value)},className:"pl-10 h-10"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(j,{value:n,onValueChange:a=>d("status",a),children:[e.jsx(b,{className:"w-[140px]",children:e.jsx(v,{placeholder:"Status"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:we.map(a=>e.jsx(h,{value:a.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(a.icon,{className:"h-3.5 w-3.5"}),a.label]})},a.value))})]}),e.jsxs(j,{value:o,onValueChange:a=>d("type",a),children:[e.jsx(b,{className:"w-[130px]",children:e.jsx(v,{placeholder:"Type"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:Ce.map(a=>e.jsx(h,{value:a.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(a.icon,{className:"h-3.5 w-3.5"}),a.label]})},a.value))})]}),e.jsxs(j,{value:i,onValueChange:a=>d("priority",a),children:[e.jsx(b,{className:"w-[140px]",children:e.jsx(v,{placeholder:"Priority"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:Se.map(a=>e.jsx(h,{value:a.value,children:e.jsx("span",{className:`flex items-center gap-2 ${a.color}`,children:a.label})},a.value))})]}),e.jsxs(j,{value:l,onValueChange:a=>d("project",a),children:[e.jsx(b,{className:"w-[150px]",children:e.jsx(v,{placeholder:"Project"})}),e.jsxs(f,{className:"glass-heavy rounded-xl border-white/10",children:[e.jsx(h,{value:"all",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"All Projects"]})}),C.map(a=>e.jsx(h,{value:a.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{children:a.icon}),a.name]})},a.id))]})]}),e.jsxs(j,{value:c,onValueChange:a=>d("createdBy",a),children:[e.jsx(b,{className:"w-[130px]",children:e.jsx(v,{placeholder:"Author"})}),e.jsx(f,{className:"glass-heavy rounded-xl border-white/10",children:Pe.map(a=>e.jsx(h,{value:a.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(a.icon,{className:"h-3.5 w-3.5"}),a.label]})},a.value))})]}),e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",className:`w-[130px] justify-start ${t?"text-primary":""}`,children:[e.jsx(Ne,{className:"h-3.5 w-3.5 mr-2"}),t||"Label"]})}),e.jsxs(je,{className:"w-64 p-0 glass-heavy rounded-xl border-white/10",align:"start",children:[e.jsx("div",{className:"p-2 border-b border-white/5",children:e.jsx(U,{placeholder:"Search labels...",value:R,onChange:a=>y(a.target.value),className:"h-8 bg-transparent border-white/10"})}),e.jsxs("div",{className:"max-h-64 overflow-y-auto p-1",children:[e.jsxs("button",{type:"button",onClick:()=>{d("label",""),y("")},className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-sm hover:bg-white/5",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:"Clear label filter"})]}),D.filter(a=>a.name.toLowerCase().includes(R.toLowerCase())).map(a=>e.jsxs("button",{type:"button",onClick:()=>{d("label",a.name),y("")},className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-sm hover:bg-white/5 ${t===a.name?"bg-primary/10":""}`,children:[e.jsx("span",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:a.color}}),e.jsx("span",{className:"truncate",children:a.name}),t===a.name&&e.jsx(N,{className:"h-3.5 w-3.5 ml-auto text-primary"})]},a.id)),D.length===0&&e.jsx("p",{className:"p-2 text-sm text-muted-foreground text-center",children:"No labels available"})]})]})]}),I&&e.jsxs(S,{variant:"ghost",size:"sm",onClick:se,className:"rounded-xl text-muted-foreground hover:text-foreground",children:[e.jsx(P,{className:"h-4 w-4 mr-1"}),"Clear"]})]})]}),I&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3 pt-3 border-t border-white/5",children:[e.jsx(ye,{className:"h-4 w-4 text-muted-foreground"}),n!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-blue-500/10 text-blue-400 text-xs font-medium",children:["Status: ",n]}),o!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-indigo-500/10 text-indigo-400 text-xs font-medium capitalize",children:["Type: ",o]}),i!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-orange-500/10 text-orange-400 text-xs font-medium capitalize",children:["Priority: ",i]}),l!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-indigo-500/10 text-indigo-400 text-xs font-medium",children:["Project: ",C.find(a=>a.id===l)?.name||l]}),c!=="all"&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-cyan-500/10 text-cyan-400 text-xs font-medium capitalize",children:["Author: ",c]}),t&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-pink-500/10 text-pink-400 text-xs font-medium",children:["Label: ",t]}),u&&e.jsxs("span",{className:"px-2 py-0.5 rounded-lg bg-green-500/10 text-green-400 text-xs font-medium",children:['Search: "',u,'"']})]})]}),le?e.jsx("div",{className:"premium-card rounded-[28px] p-12 flex items-center justify-center",children:e.jsx(me,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):g.length===0?e.jsxs("div",{className:"premium-card rounded-[24px] p-12 text-center",children:[e.jsx(k,{className:"h-12 w-12 mx-auto text-muted-foreground/40 mb-4"}),e.jsx("p",{className:"text-lg font-bold text-muted-foreground",children:"No tickets found"}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mt-1",children:I?"Try adjusting your filters":"Create a ticket to get started"})]}):e.jsx("div",{className:"space-y-2",children:g.map(a=>e.jsx(ue,{to:`/tickets/${a.id}`,className:"block premium-card border-none hover:bg-muted/30 transition-all group",children:e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"pt-1",children:ne(a.priority)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[a.projectKey||"PROFCLAW","-",a.sequence]}),!a.projectId&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider text-amber-400 px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20",children:"No Project"}),e.jsx("h3",{className:"font-semibold truncate group-hover:text-primary transition-colors",children:a.title})]}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1 mb-2",children:a.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[re(a.type),te(a.status),a.assigneeAgent&&e.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-bold uppercase tracking-wider text-primary/80 px-2 py-0.5 rounded-md bg-primary/10",children:[e.jsx(H,{className:"h-3 w-3"}),a.assigneeAgent]}),a.createdBy==="ai"&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-blue-400 px-2 py-0.5 rounded-md bg-blue-500/10",children:"AI Created"}),a.labels.slice(0,3).map(s=>e.jsx(Q,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:s},s)),a.estimate!=null&&e.jsx(fe,{value:a.estimate}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-auto",children:new Date(a.createdAt).toLocaleDateString()})]})]})]})})},a.id))}),g.length>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",x+1," • Showing ",Math.min(g.length,p)," of ",B]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>w(x-1),disabled:x===0,className:"rounded-xl border-white/10",children:"Previous"}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>w(x+1),disabled:(x+1)*p>=B,className:"rounded-xl border-white/10",children:"Next"})]})]})]})}export{Ye as TicketList};
|