import{l as y,d as z,Q as x,R as h,k as B,U as D,z as d,r as j,j as t,M as c,V as E,S as g,G as u,W as G,X as N,Y as R,N as w,E as W,Z as A,_ as F}from"./index-DTC0Ed21.js";import{G as l}from"./Grid-Vs4zvCUU.js";import{I as U}from"./IconArrowRight-BEyjYI9V.js";import"./get-base-value-JqT_q0U7.js";const b=()=>W.dispatch(A.actions.close()),Y=()=>{var f,m;const{t:n}=y(),{tasks:a,sprintId:I}=z(s=>s.diffStatusesModal),v=x((f=a==null?void 0:a.at(0))==null?void 0:f.SprintId),o=x(I),{statuses:i}=h(v),{statuses:C}=h(o),p=B((m=a??[])==null?void 0:m.map(s=>D(s.newStatus)?s.Status:void 0).filter(d).filter(s=>i.some(e=>e.Id===s))),[r,M]=j.useState({}),S=j.useMemo(()=>!!(a!=null&&a.filter(s=>i.some(e=>e.Id===s.Status)).every(s=>d(s.newStatus)||d(r[s.Status]))),[a,i,r]),T=()=>{!a||!o||!S||(F({tasks:a.map(({newStatus:s,...e})=>({...e,Status:s??r[e.Status]??e.Status})),sprint:o}),b())};return t.jsxs(t.Fragment,{children:[t.jsx(c,{children:n("diffStatus.description")}),t.jsx(E,{flex:1,py:32,children:t.jsxs(l,{children:[t.jsx(l.Col,{span:{base:12,md:6},children:t.jsxs(g,{gap:16,children:[t.jsx(c,{fw:"bold",children:n("diffStatus.current")}),p.map(s=>t.jsxs(u,{gap:8,justify:"space-between",children:[t.jsx(G,{status:N(i,["Id",s])}),t.jsx(U,{color:"var(--mantine-color-gray-5)",size:20})]},s))]})}),t.jsx(l.Col,{span:{base:12,md:6},children:t.jsxs(g,{gap:16,children:[t.jsx(c,{fw:"bold",children:n("diffStatus.new")}),p.map(s=>t.jsx(u,{children:t.jsx(R,{placeholder:n("diffStatus.choose"),value:r[s],onChange:e=>M(k=>({...k,[s]:e.Id})),statuses:C||[]})},s))]})})]})}),t.jsxs(u,{gap:16,children:[t.jsx(w,{size:"md",fullWidth:!0,radius:"md",variant:"subtle",color:"dark.3",onClick:b,children:n("common.action.cancel")}),t.jsx(w,{size:"md",fullWidth:!0,radius:"md",onClick:T,disabled:!S,children:n("common.action.save")})]})]})};export{Y as default};
