import{Q as E,bb as F,j as s,G as M,J as B,M as p,l as u,aR as P,bc as Q,bd as G,f as h,r as A,aF as i,H as f,be as S,bf as g,S as v,aE as b,ap as U}from"./index-DTC0Ed21.js";import{c as x,u as O,H as W,a as Y,b as q}from"./HistoryCreate-DmLtlI9_.js";import{u as V}from"./useActivityData-B5503wCJ.js";import"./useTaskTypesData-DEDxUwkB.js";import"./IconArrowRight-BEyjYI9V.js";const l=({task:t})=>{const e=E(t.SprintId),{types:n}=F(e==null?void 0:e.rootProjectId),a=n.find(d=>d.Id===t.TypeId);return s.jsxs(M,{align:"center",gap:6,children:[a&&s.jsx(B,{name:a.Name,color:a.Color,icon:a==null?void 0:a.IconId,size:16}),s.jsx(p,{size:"xs",children:t.Key})]})},X=({activity:t})=>{var n;const{t:e}=u();return s.jsx(x,{name:(n=t.Author)==null?void 0:n.Name,action:e("taskAction.cloned"),predicate:e("taskActivity.SprintId"),timestamp:t.Timestamp,nextState:s.jsx(l,{task:t.Json.OriginalTask})})},Z=({activity:t})=>{var n;const{t:e}=u();return s.jsx(x,{name:(n=t.Author)==null?void 0:n.Name,action:e("taskAction.addedSubtask"),predicate:e("taskActivity.Subtask"),timestamp:t.Timestamp,nextState:s.jsx(l,{task:t.Json.Subtask})})},_=({activity:t})=>{var n;const{t:e}=u();return s.jsx(x,{name:(n=t.Author)==null?void 0:n.Name,action:e("taskAction.deletedSubtask"),predicate:e("taskActivity.Subtask"),timestamp:t.Timestamp,nextState:s.jsx(l,{task:t.Json.Subtask})})},k=i.IActivityType,$=t=>{const{t:e}=u(),{formatDate:n}=P(),a=Q(),d=G(),{activity:y}=t,{Type:o}=y,{FromId:C,ToId:L}=y.Json,{data:r}=h.endpoints.getTaskById.useQuery(C),{data:c}=h.endpoints.getTaskById.useQuery(L),H=A.useMemo(()=>o===k.AddLink?e("taskAction.link"):o===k.RemoveLink?e("taskAction.unlink"):"",[o,e]),z=A.useMemo(()=>o===k.AddLink?e("taskAction.linkTo"):o===k.RemoveLink?e("taskAction.unlinkFrom"):"",[o,e]),{Author:m,Timestamp:I,TaskId:j}=y,w=m==null?void 0:m.Name,N=a?"white":"dark.6",T=a?"gray.6":"gray.7",D=()=>{c&&d(()=>g(c.Key))},R=()=>{r&&d(()=>g(r.Key))},J=j===(r==null?void 0:r.Id)?"blue.6":"gray.6",K=j===(c==null?void 0:c.Id)?"blue.6":"gray.6";return s.jsxs(f,{justify:"space-between",px:8,children:[s.jsxs(f,{gap:4,c:N,children:[s.jsx(p,{fz:"xs",children:w}),s.jsx(p,{fz:"xs",c:T,children:H}),s.jsx(S,{c:J,fz:"xs",onClick:D,children:c==null?void 0:c.Key}),s.jsx(p,{fz:"xs",c:T,children:z}),s.jsx(S,{c:K,fz:"xs",onClick:R,children:r==null?void 0:r.Key})]}),s.jsx(p,{fz:"xs",c:T,children:I&&n(I,{useTimezone:!0,format:"longWithTime"})})]})},ot=({task:t})=>{const{t:e}=u(),{data:n,isLoading:a}=V(t.Id,[i.IActivityType.AddTask,i.IActivityType.ChangeStatus,i.IActivityType.AssignTask,i.IActivityType.ChangeTask,i.IActivityType.AddLink,i.IActivityType.RemoveLink,i.IActivityType.TaskCloned,i.IActivityType.SubtaskAdd,i.IActivityType.SubtaskDeleted]),{statuses:d,isLoading:y}=O({sprintId:t.SprintId,activityData:n});return a||y?s.jsxs(v,{gap:16,mt:12,children:[s.jsx(b.Comment,{}),s.jsx(b.Comment,{})]}):n.length?s.jsx(v,{gap:16,mt:12,children:n==null?void 0:n.map(o=>s.jsx(A.Fragment,{children:tt({activity:o,sprintId:t.SprintId,statuses:d})},o.Id))}):s.jsx(U,{description:e("nodata.emptyYet"),p:20})},tt=({activity:t,sprintId:e,statuses:n})=>{switch(t.Type){case i.IActivityType.ChangeStatus:case i.IActivityType.ChangeTask:case i.IActivityType.AssignTask:return s.jsx(q,{sprintId:e,activity:t,showType:!1,statuses:n});case i.IActivityType.AddLink:case i.IActivityType.RemoveLink:return s.jsx($,{activity:t});case i.IActivityType.UploadAttachments:return s.jsx(Y,{activity:t,showType:!1});case i.IActivityType.AddTask:return s.jsx(W,{activity:t,showType:!1});case i.IActivityType.TaskCloned:return s.jsx(X,{activity:t});case i.IActivityType.SubtaskAdd:return s.jsx(Z,{activity:t});case i.IActivityType.SubtaskDeleted:return s.jsx(_,{activity:t})}};export{ot as default};
