1import{k as ge,Y as fe,a as be,r as h,j as e,m as je,A as F,Z as ve,q as B,$ as Y,a0 as he}from"./index-CyIZ4gbo.js";const ne=s=>he(s,{icon:"â ï¸",style:{background:"#FFFBEB",color:"#92400E",border:"1px solid #FCD34D"}}),we=s=>({userId:s?.userId||s?.uid||s?.id||"",name:s?.name||s?.displayName||s?.email||"You",email:s?.email||"",logo:s?.logo||s?.avatar||s?.photoURL||""}),ye=({className:s="w-5 h-5",...a})=>e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...a,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})}),J=({className:s="w-5 h-5",...a})=>e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,...a,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),Ne=()=>e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})}),q=()=>e.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),ee=({className:s="w-3 h-3 text-white"})=>e.jsx("svg",{className:s,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),ke=({className:s="w-3.5 h-3.5"})=>e.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})}),Te=({className:s="w-4 h-4"})=>e.jsxs("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),Ce=({className:s="w-4 h-4"})=>e.jsxs("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Ae=({className:s="w-4 h-4"})=>e.jsxs("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"4",rx:"1"}),e.jsx("path",{d:"M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8"}),e.jsx("path",{d:"M10 12h4"})]}),De=({className:s="w-4 h-4"})=>e.jsxs("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M19 8v6"}),e.jsx("path",{d:"M22 11h-6"})]}),Le=({className:s="w-4 h-4"})=>e.jsxs("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("path",{d:"M12 17h.01"})]}),re=({className:s="w-4 h-4"})=>e.jsxs("svg",{className:s,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]}),ie=({priority:s})=>{const a=s?s.charAt(0).toUpperCase()+s.slice(1).toLowerCase():"Medium",o={Low:"border-slate-200 bg-white text-slate-600 before:bg-slate-300",Medium:"border-slate-200 bg-white text-slate-700 before:bg-amber-400",High:"border-slate-200 bg-white text-slate-800 before:bg-rose-400"}[a]||"border-slate-200 bg-white text-slate-600 before:bg-slate-300";return e.jsx("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold before:h-1.5 before:w-1.5 before:rounded-full ${o}`,children:a})},oe=({user:s})=>{if(!s)return null;const a=s.name||s.email||"User";
1return e.jsx("img",{src:s.logo||s.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(a)}`,alt:a,title:a,className:"w-7 h-7 rounded-full object-cover"})},le=({members:s})=>!s||s.length===0?e.jsx("span",{className:"text-xs text-gray-400",children:"-"}):e.jsxs("div",{className:"flex -space-x-2 overflow-hidden",children:[s.slice(0,3).map((a,o)=>e.jsx("img",{src:a.logo||a.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(a.name||a.email||"User")}`,alt:a.name||"Assigned member",title:a.name||a.email||"Assigned member",className:"w-7 h-7 rounded-full ring-2 ring-white object-cover"},`${a.userId||a.id||a.email||a.name||"member"}-${o}`)),s.length>3&&e.jsxs("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-gray-100 text-[10px] font-bold text-gray-500 ring-2 ring-white",children:["+",s.length-3]})]}),Q=({label:s,icon:a,onClick:o,tone:n="slate"})=>{const l=n==="danger"?"text-rose-600 hover:bg-rose-50":"text-slate-700 hover:bg-slate-50";return e.jsxs("button",{type:"button",onClick:u=>{u.stopPropagation(),o?.()},className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors ${l}`,children:[e.jsx(a,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:s})]})},se=s=>{if(!s)return"-";let a;return s&&typeof s.toDate=="function"?a=s.toDate():s&&s._seconds?a=new Date(s._seconds*1e3):a=new Date(s),isNaN(a.getTime())?"-":a.toLocaleDateString(void 0,{month:"short",day:"numeric"})},te=s=>{if(!s)return null;if(s&&typeof s.toDate=="function")return s.toDate();if(s&&s._seconds)return new Date(s._seconds*1e3);const a=new Date(s);return isNaN(a.getTime())?null:a},de=s=>s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null,ae=(s,a)=>{const o=de(te(s));if(!o)return{label:"No deadline",tone:"muted",isOverdue:!1};const n=de(new Date),l=Math.round((o-n)/864e5);return!a&&l<0?{label:"Overdue",tone:"danger",isOverdue:!0}:l===0?{label:"Due today",tone:"brand",isOverdue:!1}:l===1?{label:"Tomorrow",tone:"info",isOverdue:!1}:{label:se(s),tone:"muted",isOverdue:!1}},ce={High:1,high:1,Medium:2,medium:2,Low:3,low:3},Me=(s,a)=>{const o=[...s];return a==="deadline"?o.sort((n,l)=>{const u=te(n.deadline)?.getTime()??Number.MAX_SAFE_INTEGER,j=te(l.deadline)?.getTime()??Number.MAX_SAFE_INTEGER;return u-j||(n.pos||0)-(l.pos||0)}):a==="priority"?o.sort((n,l)=>{const u=ce[n.priority]||2,j=ce[l.priority]||2;return u-j||(n.pos||0)-(l.pos||0)}):o.sort((n,l)=>(n.pos||0)-(l.pos||0))},xe=({task:s,onToggleComplete:a,onUpdateTaskName:o,onAssignUser:n,onArchiveTask:l,projectMembers:u,onOpenTask:j})=>{const[O,T]=h.useState(!1),[w,C]=h.useState(s.name||s.title),[k,y]=h.useState(!1),[d,m]=h.useState(!1),A=h.useRef(null),S=h.useRef(null),R=h.useRef(null),D=h.useRef(null);h.useEffect(()=>{C(s.name||s.title)},[s.name,s.title]);const I=()=>{T(!1);const t=s.name||s.title;w.trim()&&w!==t?o(s.id,w):C(t)},U=t=>{t.key==="Enter"&&I(),t.key==="Escape"&&(C(s.name||s.title),T(!1))},N=s.complete||s.isCompleted||!1,L=s.assignedBy||null,_=Array.isArray(s.attachments)?s.attachments.length:0;h.useEffect(()=>{const t=$=>{const K=A.current?.contains($.target),r=S.current?.contains($.target),x=R.current?.contains($.target),g=D.current?.contains($.target);!K&&!r&&y(!1),!x&&!g&&m(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const E=Array.isArray(s.assignedTo)?s.assignedTo.map(t=>t.userId||t.id):[],P=(u||[]).filter(t=>!E.includes(t.userId||t.id)),b=se(s.deadline),H=se(s.startDate),z=ae(s.deadline,N),G=t=>{t.stopPropagation(),m($=>!$)},X=()=>{y(!0),m(!1)},V=()=>e.jsx(F,{children:d&&e.jsxs(B.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.12},className:"absolute right-0 top-full z-50 mt-1 w-44 rounded-xl border border-slate-200 bg-white p-1 shadow-xl shadow-slate-900/10",onClick:t=>t.stopPropagation(),children:[e.jsx(Q,{label:"Open details",icon:Ce,onClick:()=>{m(!1),j(s.id)}}),e.jsx(Q,{label:"Rename Task",icon:Te,onClick:()=>{m(!1),T(!0)}}),e.jsx(Q,{label:"Assign to",icon:De,onClick:X}),e.jsx("div",{className:"my-1 h-px bg-slate-100"}),e.jsx(Q,{label:"Archive Task",icon:Ae,tone:"danger",onClick:()=>{m(!1),l(s.id)}})]})});return e.jsxs(B.div,{layout:!0,initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"group contents",children:[e.jsxs("div",{className:`hidden md:table-row transition-colors ${N?"bg-slate-50/60 text-slate-500":"hover:bg-slate-50"}`,onClick:()=>j(s.id),children:[e.jsx("div",{className:"table-cell max-w-0 p-3 pl-4 text-sm align-middle border-b border-gray-200",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("button",{onClick:t=>{t.stopPropagation(),a(s.id,!N)},className:`flex-shrink-0 w-4 h-4 rounded-sm border-2 flex items-center justify-center transition-all ${N?"bg-brand-600 border-brand-600":"border-gray-300 group-hover:border-brand-500"}`,children:N&&e.jsx(ee,{})}),O?e.jsx("input",{type:"text",value:w,onClick:t=>t.stopPropagation(),onChange:t=>C(t.target.value),onBlur:I,onKeyDown:U,className:`min-w-0 w-full p-1 -m-1 border rounded bg-white ${N?"line-through":""}`,autoFocus:!0}):e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{onClick:t=>{t.stopPropagation(),T(!0)},className:`block min-w-0 flex-1 cursor-text truncate font-medium ${N?"text-slate-400 line-through":"text-slate-900"}`,title:w,children:w}),_>0&&e.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 px-1.5 py-0.5 text-[10px] font-semibold rounded-full border border-brand-200 bg-brand-50 text-brand-700",children:[e.jsx(ke,{className:"w-3 h-3"}),_]})]})]})}),e.jsx("div",{className:"table-cell p-3 text-sm align-middle border-b border-gray-200 whitespace-nowrap",children:e.jsx(ie,{priority:s.priority})}),e.jsx("div",{className:"table-cell max-w-0 p-3 text-sm align-middle border-b border-gray-200",children:e.jsxs("div",{className:"relative flex min-w-0 items-center gap-2",onClick:t=>t.stopPropagation(),children:[L?e.jsx(oe,{user:L}):e.jsx("div",{className:"w-7 h-7 rounded-full bg-slate-100 border border-slate-200 flex items-center justify-center text-[10px] text-slate-400",children:"-"}),e.jsx("span",{className:"min-w-0 truncate text-slate-600",children:L?.name||"Not recorded"}),e.jsx(F,{children:k&&e.jsxs(B.div,{ref:A,initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute z-10 top-full left-0 mt-1 w-60 bg-white border border-gray-200 rounded-lg shadow-xl",children:[e.jsx("div",{className:"p-2 text-xs font-semibold text-gray-500",children:"Assign to..."}),e.jsxs("div",{className:"max-h-40 overflow-y-auto",children:[P.length===0&&e.jsx("div",{className:"p-2 text-xs text-gray-400",children:"All members assigned"}),P.map(t=>e.jsxs("button",{onClick:()=>{n(s.id,t),y(!1)},className:"w-full flex items-center gap-2 p-2 text-sm text-left hover:bg-gray-100",children:[e.jsx("img",{src:t.logo||t.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name||t.email||"User")}`,className:"w-6 h-6 rounded-full",alt:""}),e.jsx("span",{className:"min-w-0 truncate text-gray-800",children:t.name||t.email||"Unnamed member"})]},t.userId||t.id||t.email||t.name))]})]})})]})}),e.jsx("div",{className:"table-cell p-3 text-sm align-middle border-b border-gray-200 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(q,{})," ",H]})}),e.jsx("div",{className:"table-cell p-3 text-sm align-middle border-b border-gray-200 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.deadline&&e.jsx(q,{}),e.jsx("span",{className:z.tone==="danger"?"text-rose-600":"",children:b}),z.isOverdue&&e.jsx("span",{className:"rounded-full bg-rose-50 px-1.5 py-0.5 text-[10px] font-semibold text-rose-600",children:"Late"})]})}),e.jsx("div",{className:"table-cell p-3 text-sm align-middle border-b border-gray-200",children:e.jsx(le,{members:s.assignedTo})}),e.jsx("div",{className:"table-cell p-2 text-sm align-middle border-b border-gray-200",children:e.jsxs("div",{ref:R,className:"relative flex items-center justify-end",children:[e.jsx("button",{type:"button",title:"Task actions","aria-label":"Task actions","aria-expanded":d,onClick:G,className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border transition-colors ${d?"border-slate-300 bg-slate-100 text-slate-900":"border-transparent text-slate-400 hover:border-slate-200 hover:bg-white hover:text-slate-800"}`,children:e.jsx(re,{className:"h-4 w-4"})}),V()]})})]}),e.jsxs(B.div,{layout:!0,className:"md:hidden block p-4 border-b border-gray-200 bg-white group-hover:bg-gray-50",onClick:()=>j?.(s.id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3 overflow-hidden",children:[e.jsx("button",{onClick:t=>{t.stopPropagation(),a(s.id,!N)},className:`flex-shrink-0 w-4 h-4 rounded-sm border-2 flex items-center justify-center transition-all ${N?"bg-brand-600 border-brand-600":"border-gray-300 group-hover:border-brand-500"}`,children:N&&e.jsx(ee,{})}),O?e.jsx("input",{type:"text",value:w,onClick:t=>t.stopPropagation(),onChange:t=>
1C(t.target.value),onBlur:I,onKeyDown:U,className:`min-w-0 w-full p-1 -m-1 border rounded bg-white ${N?"line-through":""}`,autoFocus:!0}):e.jsx("span",{onClick:t=>{t.stopPropagation(),T(!0)},className:`min-w-0 cursor-text text-sm font-semibold leading-5 text-gray-800 ${N?"line-through text-gray-500":""}`,title:w,children:w})]}),e.jsxs("div",{ref:D,className:"relative flex-shrink-0",children:[e.jsx("button",{type:"button",title:"Task actions","aria-label":"Task actions","aria-expanded":d,onClick:G,className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border transition-colors ${d?"border-slate-300 bg-slate-100 text-slate-900":"border-slate-200 bg-white text-slate-500 hover:bg-slate-50"}`,children:e.jsx(re,{className:"h-4 w-4"})}),V()]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-3 pl-7",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 uppercase font-bold mb-1",children:"Priority"}),e.jsx(ie,{priority:s.priority})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 uppercase font-bold mb-1",children:"Assigned by"}),e.jsx("div",{className:"flex items-center gap-2",children:L?e.jsxs(e.Fragment,{children:[e.jsx(oe,{user:L}),e.jsx("span",{className:"min-w-0 truncate text-xs text-slate-600",children:L.name})]}):e.jsx("span",{className:"text-xs text-gray-500",children:"Not recorded"})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 uppercase font-bold mb-1",children:"Deadline"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-600",children:[s.deadline&&e.jsx(q,{}),e.jsx("span",{className:z.tone==="danger"?"text-rose-600":"",children:b})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 uppercase font-bold mb-1",children:"Assigned to"}),e.jsx(le,{members:s.assignedTo})]})]}),e.jsx(F,{children:k&&e.jsxs(B.div,{ref:S,initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},onClick:t=>t.stopPropagation(),className:"mt-2 overflow-hidden rounded-xl border border-slate-200 bg-white shadow-lg",children:[e.jsx("div",{className:"border-b border-slate-100 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Assign to"}),e.jsxs("div",{className:"max-h-44 overflow-y-auto p-1",children:[P.length===0&&e.jsx("div",{className:"p-2 text-xs text-gray-400",children:"All members assigned"}),P.map(t=>e.jsxs("button",{onClick:()=>{n(s.id,t),y(!1)},className:"flex w-full items-center gap-2 rounded-lg p-2 text-left text-sm hover:bg-slate-50",children:[e.jsx("img",{src:t.logo||t.avatar||`https://ui-avatars.com/api/?name=${encodeURIComponent(t.name||t.email||"User")}`,className:"h-7 w-7 rounded-full",alt:""}),e.jsx("span",{className:"min-w-0 truncate text-gray-800",children:t.name||t.email||"Unnamed member"})]},t.userId||t.id||t.email||t.name))]})]})})]})]})},Se=({section:s,tasks:a,onToggleComplete:o,onUpdateTaskName:n,onAddTask:l,onAssignUser:u,onArchiveTask:j,projectMembers:O,onOpenTask:T,shouldStartAdd:w,onAddStarted:C})=>{const[k,y]=h.useState(!0),[d,m]=h.useState(!1),[A,S]=h.useState(""),[R,D]=h.useState(!1),I=h.useRef(null),U=b=>{b.key==="Enter"&&A.trim()&&(l(s.id,A.trim()),S(""),m(!1)),b.key==="Escape"&&(m(!1),S(""))};h.useEffect(()=>{d&&I.current?.focus()},[d]),h.useEffect(()=>{w&&(y(!0),m(!0),C?.())},[w,C]);const N=s.name||s.title||"Untitled Section",L=a.filter(b=>b.complete||b.isCompleted).length,_=Math.max(a.length-L,0),E=a.filter(b=>ae(b.deadline,b.complete||b.isCompleted).isOverdue).length,P=a.length>0?Math.round(L/a.length*100):0;return e.jsxs(B.div,{layout:!0,className:"mb-5 overflow-visible rounded-2xl border border-slate-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-3 border-b border-slate-100 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(B.button,{onClick:()=>y(!k),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-gray-400 transition-colors hover:bg-slate-100 hover:text-slate-700",animate:{rotate:k?0:-90},children:e.jsx(ye,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("h2",{className:"min-w-0 truncate text-base font-bold text-slate-900",title:N,children:N}),e.jsx("span",{className:"flex-shrink-0 rounded-full bg-slate-100 px-2 py-0.5 text-xs font-semibold text-slate-500",children:a.length})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs font-medium text-slate-500",children:[e.jsxs("span",{children:[_," open"]}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-slate-300"}),e.jsxs("span",{children:[L," complete"]}),E>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-1 w-1 rounded-full bg-slate-300"}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-slate-700",children:[e.jsx(Le,{className:"h-3.5 w-3.5 text-rose-500"})," ",E," late"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"hidden w-28 sm:block",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-[10px] font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx("span",{children:"Progress"}),e.jsxs("span",{children:[P,"%"]})]}),e.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:"h-full rounded-full bg-slate-700 transition-all duration-500",style:{width:`${P}%`}})})]}),e.jsxs("button",{type:"button",onClick:()=>{y(!0),m(!0)},className:"inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 transition-colors hover:bg-slate-100",children:[e.jsx(J,{className:"h-3.5 w-3.5"})," Add Task"]})]})]}),e.jsx(F,{initial:!1,onExitComplete:()=>D(!1),children:k&&e.jsx(B.div,{layout:!0,initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto",transition:{duration:.3}},exit:{opacity:0,height:0,transition:{duration:.2}},onAnimationStart:()=>D(!0),onAnimationComplete:()=>D(!1),style:{overflow:R?"hidden":"visible"},className:"",children:e.jsxs("div",{className:"bg-white",children:[e.jsxs("div",{className:"hidden md:table table-fixed w-full",children:[e.jsx("div",{className:"table-header-group",children:e.jsxs("div",{className:"table-row bg-slate-50/80 border-b border-slate-100 text-[11px] font-semibold text-slate-500 uppercase tracking-wider",children:[e.jsx("div",{className:"table-cell w-[42%] p-3 pl-4",children:"Name"}),e.jsx("div",{className:"table-cell w-[10%] p-3",children:"Priority"}),e.jsx("div",{className:"table-cell w-[16%] p-3",children:"Assigned by"}),e.jsx("div",{className:"table-cell w-[10%] p-3",children:"Start date"}),e.jsx("div",{className:"table-cell w-[10%] p-3",children:"Deadline"}),e.jsx("div",{className:"table-cell w-[9%] p-3",children:"Assigned to"}),e.jsx("div",{className:"table-cell w-[3%] p-3"})]})}),e.jsx("div",{className:"table-row-group",children:e.jsx(F,{initial:!1,children:a.map(b=>e.jsx(xe,{task:b,onToggleComplete:o,onUpdateTaskName:n,onAssignUser:u,onArchiveTask:j,projectMembers:O,onOpenTask:T},b.id))})})]}),e.jsx("div",{className:"block md:hidden",children:e.jsx(F,{initial:!1,children:a.map(b=>e.jsx(xe,{task:b,onToggleComplete:o,onUpdateTaskName:n,onAssignUser:u,onArchiveTask:j,projectMembers:O,onOpenTask:T},b.id))})}),d&&e.jsx(B.div,{layout:!0,initial:{opacity:0}
1,animate:{opacity:1},className:"p-3 border-t border-slate-100 bg-slate-50/70",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-4 h-4 rounded-sm border-2 border-gray-300 flex-shrink-0 bg-white"}),e.jsx("input",{ref:I,type:"text",value:A,onChange:b=>S(b.target.value),onKeyDown:U,onBlur:()=>{setTimeout(()=>{A.trim()===""&&m(!1)},100)},placeholder:"What needs to be done?",className:"w-full text-sm p-2 bg-white border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-transparent"}),e.jsx("div",{className:"text-xs text-gray-400 hidden sm:block",children:"Press Enter to add"})]})}),e.jsx(F,{children:!d&&e.jsxs(B.button,{layout:!0,onClick:()=>m(!0),className:"w-full flex items-center gap-2 p-3 text-sm font-medium text-gray-500 hover:text-brand-600 hover:bg-slate-50 border-t border-slate-100 transition-colors",children:[e.jsx(J,{className:"w-4 h-4"})," Add Task"]})})]})})})]})},Ie=(s,a)=>{const o=(a||"").trim().toLowerCase();if(!o)return!0;if(!s)return!1;const n=s.toLowerCase();return o.split(/\s+/).filter(Boolean).every(l=>n.includes(l))},me=(s,a,o)=>{if(a){const n=s.name||s.title||"",l=s.desc||s.description||"",u=`${n} ${l}`;if(!Ie(u,a))return!1}if(o?.status?.length>0){const n=s.complete||s.isCompleted||!1;if(!o.status.some(u=>u==="Complete"?n:u==="Incomplete"?!n:!1))return!1}if(o?.priority?.length>0){const n=(s.priority||"Medium").toLowerCase();if(!o.priority.some(u=>u.toLowerCase()===n))return!1}if(o?.assignedTo?.length>0){const n=s.assignedTo||[],l=n.some(j=>o.assignedTo.includes(j.userId||j.id)),u=o.assignedTo.includes("unassigned")&&n.length===0;if(!l&&!u)return!1}if(o?.deadline?.length>0){if(s.deadline){const n=new Date(s.deadline),l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()),j=new Date(n.getFullYear(),n.getMonth(),n.getDate()),O=s.complete||s.isCompleted||!1,T=j<u&&!O,w=u.getDate()-u.getDay(),C=new Date(u);C.setDate(w);const k=new Date(C);k.setDate(k.getDate()+6),k.setHours(23,59,59,999);const y=new Date(k);y.setDate(y.getDate()+1),y.setHours(0,0,0,0);const d=new Date(y);d.setDate(d.getDate()+6),d.setHours(23,59,59,999);const m=j.getTime()===u.getTime(),A=j>=u&&j<=k,S=j>=y&&j<=d;if(!o.deadline.some(D=>D==="overdue"?T:D==="today"?m:D==="week"?A:D==="next_week"?S:!1))return!1}else if(!o.deadline.includes("no_deadline"))return!1}return!0};function Pe(){const{projectid:s}=ge(),{project:a,tasks:o,setTasks:n,sections:l,setSections:u,updateProject:j,onOpenTask:O,searchQuery:T,filters:w}=fe(),{user:C}=be(),[k,y]=h.useState(!1),[d,m]=h.useState([]),[A,S]=h.useState([]),[R,D]=h.useState("position"),[I,U]=h.useState(!0),[N,L]=h.useState(null),_=h.useRef(!0),E=h.useRef(null),P=(r=[])=>{const x=[...r].filter(i=>i?.id).sort((i,f)=>(i.pos||0)-(f.pos||0)),g=new Set(x.map(i=>i.id));(!E.current||!g.has(E.current))&&(E.current=x[0]?.id||null)};h.useEffect(()=>{o&&m(o)},[o]),h.useEffect(()=>{l&&(P(l),S(l))},[l]),h.useEffect(()=>{if(!s)return;const r=async()=>{o.length>0&&l.length>0||y(!0);try{const i=await ve({projectId:s,options:{includeTasks:!0,includeSections:!0,includeDetails:!a}});i.tasks&&(n(i.tasks),m(i.tasks)),i.sections&&(P(i.sections),u(i.sections),S(i.sections)),i.projectDetails&&j&&j(i.projectDetails)}catch(g){console.error("List fetch error:",g)}finally{y(!1)}};(_.current||!k)&&(r(),_.current=!1)},[s]);const b=h.useMemo(()=>{const x=d.filter(c=>!c.parentId&&!c.archived).filter(c=>I||!(c.complete||c.isCompleted)).filter(c=>me(c,T,w)),g=[...A].sort((c,M)=>(c.pos||0)-(M.pos||0)),i=new Set(g.map(c=>c.id)),f=i.has(E.current)?E.current:g[0]?.id||null,p=x.reduce((c,M)=>{let v=M.sectionid;return(!v||!i.has(v))&&(v=f),v&&(c[v]||(c[v]=[]),c[v].push(M)),c},{});return g.map(c=>{const M=p[c.id]||[];return{...c,tasks:Me(M,R)}})},[d,A,T,w,I,R]),H=h.useMemo(()=>{const x=d.filter(p=>!p.parentId&&!p.archived).filter(p=>me(p,T,w)),g=x.filter(p=>p.complete||p.isCompleted).length,i=x.filter(p=>ae(p.deadline,p.complete||p.isCompleted).isOverdue).length,f=x.filter(p=>!Array.isArray(p.assignedTo)||p.assignedTo.length===0).length;return{total:x.length,open:Math.max(x.length-g,0),completed:g,overdue:i,unassigned:f}},[d,T,w]),z=async(r,x)=>{if(x){const f=d.filter(p=>p.parentId===r&&!(p.complete||p.isCompleted)).length;if(f>0){ne(`Complete all subtasks first (${f} open).`);return}}const g=d,i=d.map(f=>f.id===r?{...f,complete:x,isCompleted:x}:f);m(i),n(i);try{await Y({projectId:s,action:"toggleComplete",payload:{id:r,complete:x}})}catch(f){console.error("Failed to toggle complete",f),m(g),n(g)}},G=async(r,x)=>{const g=d,i=d.map(f=>f.id===r?{...f,name:x,title:x}:f);m(i),n(i);try{await Y({projectId:s,action:"updateTask",payload:{id:r,updates:{name:x}}})}catch(f){console.error("Failed to update task name",f),m(g),n(g)}},X=async(r,x)=>{const i=d.filter(c=>c.sectionid===r&&!c.parentId).length+1,f={id:`temp-task-${Date.now()}`,name:x,title:x,sectionid:r,complete:!1,priority:"Medium",assignedTo:[],pos:i,createdAt:new Date().toISOString()},p=d,W=[...d,f];m(W),n(W);try{const c=await Y({projectId:s,action:"addTask",payload:{name:x,sectionid:r,pos:i}});if(c&&c.success){const M=W.map(v=>v.id===f.id?{...v,id:c.id,...c}:v);m(M),n(M)}else m(p),n(p)}catch(c){console.error("Failed to add task",c),m(p),n(p)}},V=async(r,x)=>{const{id:g,userId:i,...f}=x,p=we(C),W={...f,userId:i??g},c=d,M=d.map(v=>{if(v.id===r){const Z=v.assignedTo||[];if(Z.some(pe=>
1pe.userId===W.userId))return v;const ue=[...Z,W];return{...v,assignedTo:ue,assignedBy:p,assignedAt:new Date().toISOString()}}return v});m(M),n(M);try{const v=M.find(Z=>Z.id===r);await Y({projectId:s,action:"updateTask",payload:{id:r,updates:{assignedTo:v.assignedTo}}})}catch(v){console.error("Failed to assign user",v),m(c),n(c)}},t=async r=>{const x=d,g=d.map(i=>i.id===r?{...i,archived:!0}:i);m(g),n(g);try{await Y({projectId:s,action:"updateTask",payload:{id:r,updates:{archived:!0}}}),he.success("Task archived")}catch(i){console.error("Failed to archive task",i),m(x),n(x),ne("Could not archive this task. Please try again.")}};if(k&&d.length===0&&A.length===0)return e.jsx(je,{text:"Loading Tasks..."});const $=(a?.members||[]).map(r=>({userId:r.userId||r.id,...r})),K=b.find(r=>r.id)?.id||null;return e.jsxs("div",{className:"bg-slate-50 h-full pb-10",children:[e.jsxs("div",{className:"mb-4 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-slate-900",children:"List view"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Scan, assign, complete, and archive tasks without opening each drawer."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:!K,onClick:()=>K&&L(K),className:"inline-flex items-center gap-1.5 rounded-xl bg-brand-700 px-3.5 py-2 text-sm font-semibold text-white shadow-sm transition-colors hover:bg-brand-800 disabled:cursor-not-allowed disabled:bg-slate-200 disabled:text-slate-500",children:[e.jsx(J,{className:"w-4 h-4"})," Add Task"]}),e.jsxs("label",{className:"inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-semibold text-slate-700",children:[e.jsx(Ne,{}),e.jsxs("select",{value:R,onChange:r=>D(r.target.value),className:"bg-transparent text-sm font-semibold text-slate-700 outline-none",children:[e.jsx("option",{value:"position",children:"Board order"}),e.jsx("option",{value:"deadline",children:"Deadline"}),e.jsx("option",{value:"priority",children:"Priority"})]})]}),e.jsxs("button",{type:"button",onClick:()=>U(r=>!r),className:`inline-flex items-center gap-1.5 rounded-xl border px-3 py-2 text-sm font-semibold transition-colors ${I?"border-slate-200 bg-white text-slate-700 hover:bg-slate-50":"border-slate-300 bg-slate-900 text-white hover:bg-slate-800"}`,children:[e.jsx(ee,{className:"h-3.5 w-3.5"})," ",I?"Hide completed":"Show completed"]})]})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white px-3 py-2 shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:"Open"}),e.jsx("div",{className:"mt-1 text-xl font-bold text-slate-900",children:H.open})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white px-3 py-2 shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})," Complete"]}),e.jsx("div",{className:"mt-1 text-xl font-bold text-slate-900",children:H.completed})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white px-3 py-2 shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-rose-500"})," Late"]}),e.jsx("div",{className:"mt-1 text-xl font-bold text-slate-900",children:H.overdue})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white px-3 py-2 shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-slate-500",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500"})," Unassigned"]}),e.jsx("div",{className:"mt-1 text-xl font-bold text-slate-900",children:H.unassigned})]})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs(F,{children:[b.map(r=>e.jsx(Se,{section:r,tasks:r.tasks,onToggleComplete:z,onUpdateTaskName:G,onAddTask:X,onAssignUser:V,onArchiveTask:t,projectMembers:$,onOpenTask:O,shouldStartAdd:N===r.id,onAddStarted:()=>L(null)},r.id)),b.length===0&&!k&&e.jsx("div",{className:"text-center py-10 text-gray-500 bg-white rounded-xl border border-dashed border-gray-300",children:e.jsx("p",{children:"No sections foun
1d. Switch to Board view to create sections."})})]})})]})}export{Pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.