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