import{bk as D,aG as b,w as f,bl as I,bm as k,x as F,p as V,bn as z,b9 as C,aQ as g,j as e,G as x,bo as P,q as o,bp as H,b as h,bq as L,br as O,bs as c,H as S,E as $,bt as E,bu as v,bv as B,F as G,a4 as R,bw as q,V as J,aE as M,S as W}from"./index-n-59FgrC.js";import{u as Q}from"./useTaskTypesData-CgG6u01U.js";import{A as _}from"./useActivityData-C8TvooLi.js";import{I as K}from"./IconArrowRight-DlXTlKKx.js";var U=D.isFinite;function X(s){return typeof s=="number"&&U(s)}const Y=s=>[b.IActivityType.ChangeStatus,b.IActivityType.ChangeTask].includes(s.Type),Z=s=>s.FieldName==="Performers",ss=s=>s.FieldName==="Labels",ls=({sprintId:s,activityData:t})=>{const a=f(s),i=I(k(t,Y),r=>r.Json.Changes).filter(r=>(r==null?void 0:r.FieldName)==="Status"),{statuses:n,isLoading:d}=F(a),{data:l,isLoading:u}=V.useGetAvailableStatusesQuery({ids:i.map(r=>Number(r==null?void 0:r.NewValue)).filter(X),IsDeleted:!0},{skip:!i.length});return{statuses:z([...n,...l??[]],"Id"),isLoading:d||u}},A=({name:s,email:t,action:a,predicate:i,timestamp:n,nextState:d})=>{const l=C(),u=l?"white":"dark.6",r=l?"gray.6":"gray.7",{formatDate:m}=g();return e.jsxs(x,{justify:"space-between",px:8,children:[e.jsxs(x,{gap:4,c:u,children:[e.jsx(P,{email:t,name:s,hoverCardProps:{position:"bottom-start"},children:e.jsx(o,{fz:"xs",children:s})}),e.jsx(o,{fz:"xs",c:r,children:a}),e.jsx(o,{fz:"xs",fw:500,children:i}),d&&e.jsx(H,{variant:"transparent",size:16,c:r,children:e.jsx(K,{style:{width:"80%",height:"80%"}})}),d]}),e.jsx(o,{fz:"xs",c:r,children:n&&m(n,{useTimezone:!0,format:"longWithTime"})})]})},cs=({sprintId:s,activity:t,statuses:a})=>{const{t:i}=h(),n=f(s),{taskTypes:d}=Q(n==null?void 0:n.ProjectId,!0),{formatDate:l}=g();return t.Json.Changes.filter(r=>as.includes(r.FieldName)).map((r,m)=>{var j,y;const{action:N,predicate:T}=ts(r),w=!!r.OldValue&&!r.NewValue,p=Z(r)?L(r.OldValue,r.NewValue,"Id"):ss(r)?O(r.OldValue,r.NewValue):w?r.OldValue:r.NewValue;return e.jsx(A,{name:(j=t.Author)==null?void 0:j.Name,email:(y=t.Author)==null?void 0:y.Email,action:i(`taskAction.${N}`),predicate:i(`taskActivity.${T}`,{count:p==null?void 0:p.length}),timestamp:t.Timestamp,nextState:es({predicate:r.FieldName,value:p,statuses:a,types:d,emptyValue:i("activities.empty"),formatDate:l})},`${t.Id}${m}`)})},ts=s=>{var t,a;return s.FieldName==="SprintId"?{action:"move",predicate:"SprintId"}:["Performers","Labels"].includes(s.FieldName)?{action:(((t=s.OldValue)==null?void 0:t.length)||0)<(((a=s.NewValue)==null?void 0:a.length)||0)?"add":"remove",predicate:`${s.FieldName}`}:!s.OldValue&&s.NewValue?{action:"add",predicate:`${s.FieldName}`}:s.OldValue&&s.NewValue?{action:"edit",predicate:`${s.FieldName}`}:s.OldValue&&!s.NewValue?{action:"remove",predicate:`${s.FieldName}`}:{action:"",predicate:""}},es=({predicate:s,value:t,statuses:a,types:i,emptyValue:n,formatDate:d})=>{if(!t)return e.jsx(o,{td:"line-through",style:{wordBreak:"normal"},children:n});if(s==="Title"&&c(t))return t;if(s==="Description")return e.jsx("div",{dangerouslySetInnerHTML:{__html:t.toString()},style:{wordBreak:"normal"}});if(s==="Status"){const l=S(a,["Id",t]);return e.jsx($,{status:l,fz:"xs",lh:"16px",mih:20,style:{borderRadius:3}})}if(s==="Performers"&&!c(t)&&!c(t[0]))return e.jsx(E,{value:t,showCount:7});if(s==="Priority")return e.jsx(v,{priority:t,iconSize:16,gap:4,textSize:"xs"});if(s==="SprintId")return e.jsx(rs,{sprintId:Number(t)});if(s==="TypeId")return e.jsx(B,{type:S(i,["Id",t]),iconSize:16,gap:4,textSize:"xs"});if(["StartDate","EndDate","DueDate"].includes(s)&&c(t))return e.jsx(o,{fz:"xs",children:d(t)});if(s==="Labels"&&c(t[0]))return e.jsx(o,{fz:"xs",children:t.join(", ")})},rs=({sprintId:s})=>{const t=f(s);return t?e.jsxs(G,{align:"center",gap:4,visibleFrom:"xs",children:[e.jsx(R,{variant:"transparent",radius:"sm",size:16,color:t.Color||"gray.5",children:e.jsx(q,{size:14})}),e.jsx(J,{label:t.Name,openDelay:400,children:e.jsx(o,{size:"xs",truncate:"end",maw:150,children:t.Name})})]}):null},as=["Priority","StartDate","EndDate","DueDate","Performers","Status","SprintId","TypeId","Labels"],us=({activity:s,showType:t=!0})=>{const{t:a}=h(),i=s.Description.startsWith("Add");return e.jsxs(x,{wrap:"nowrap",align:"start",py:4,px:8,children:[e.jsx(M,{size:32,user:s.Author}),e.jsxs(W,{gap:6,w:"100%",children:[e.jsx(_,{activity:s,description:{action:a(`taskAction.${i?"add":"remove"}`),predicate:a("activities.typeOptions.attach"),type:t?a("activities.typeOptions.history"):void 0}}),e.jsx(o,{children:s.Json.Name})]})]})},ps=({activity:s})=>{var a;const{t}=h();return e.jsx(A,{name:(a=s.Author)==null?void 0:a.Name,action:t("taskAction.create"),predicate:t("taskActivity.SprintId"),timestamp:s.Timestamp})};export{ps as H,us as a,cs as b,A as c,ls as u};
