@libxai/board 0.17.197 → 0.17.198

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -341,7 +341,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
341
341
  </Tasks>
342
342
  </Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(p),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=se.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let p=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,d=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let x=t.find(f=>f.id===u);if(x){o(x);let f=r.get(u)?.ef||0;d=Math.max(d,f);}}let i=d+p;r.set(n.id,{es:d,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),l=new Map,c=n=>{if(l.has(n.id))return;let p=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,d=t.filter(x=>x.dependencies&&x.dependencies.includes(n.id)),i=s;if(d.length>0)for(let x of d){c(x);let f=l.get(x.id)?.ls||0;i=Math.min(i,f);}let u=i-p;l.set(n.id,{ls:u,lf:i});};a.forEach(c);let m=[];for(let n of a){let p=r.get(n.id),d=l.get(n.id);if(p&&d){let i=d.ls-p.es;Math.abs(i)<.01&&m.push(n.id);}}return m},calculateSlack:(e,t)=>{let a=se.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(se.calculateCriticalPath(e).includes(t))return 0;let o=se.getDependentTasks(e,t);if(o.length===0){let c=se.getLatestEndDate(e);if(!c)return null;let m=se.calculateDuration(a.endDate,c);return Math.max(0,m)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,m)=>c-m)[0];if(!s)return null;let l=se.calculateDuration(a.endDate,new Date(s));return Math.max(0,l)},isOnCriticalPath:(e,t)=>se.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=se.findTaskById(e,t);if(!r||!r.endDate)return e;let o=se.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let l of o){if(!l.startDate||!l.endDate)continue;let c=se.calculateDuration(l.startDate,l.endDate),m;a!==void 0?(m=new Date(l.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let n=se.calculateEndDate(m,c),p=d=>d.map(i=>i.id===l.id?{...i,startDate:m,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=se.autoScheduleDependents(s,l.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,l,c)=>{if(a===0)return [];let m=[],n=o.getTime(),p=1e3*60*60*24,d=se.findTaskById(e,t);if(!d||!d.endDate)return [];let i=(u,x,f=new Set)=>{if(f.has(u))return;f.add(u);let g=se.getDependentTasks(e,u);for(let k of g){if(!k.startDate||!k.endDate)continue;let h=r.findIndex(w=>w.id===k.id);if(h===-1)continue;let b=k.startDate.getTime(),D=(k.endDate.getTime()-b)/p,A=(b-n)/p*s,v=A+x*s,F=Math.max(D*s,s),T=c+h*l+12;m.push({taskId:k.id,taskName:k.name,originalX:A,previewX:v,width:F,y:T,rowIndex:h,daysDelta:x,color:k.color}),i(k.id,x,f);}};return i(t,a),m},splitTask:(e,t,a,r=3)=>{let o=se.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let l=new Date(a);l.setDate(l.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:l,endDate:c}],n=p=>p.map(d=>d.id===o.id?{...d,endDate:c,segments:m}:d.subtasks?{...d,subtasks:n(d.subtasks)}:d);return n(e)}};function tn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:l,templates:c,onTaskClick:m,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:d,onDependencyCreate:i,onDependencyDelete:u}){let[f,g]=useState([]),[k,h]=useState(null),[b,y]=useState(null),D=useCallback(z=>{h(z);},[]),N=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),A=r==="day"?60:r==="week"?20:8,v=N*A*l,F=z=>{let L=new Date(Date.UTC(z.getFullYear(),z.getMonth(),z.getDate())),W=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-W);let E=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-E.getTime())/864e5+1)/7)},T=z=>{let L=z.getDay();return L===0||L===6},w=useCallback(z=>{let L=Math.round(z/(A*l)),W=new Date(o);return W.setDate(W.getDate()+L),W},[o,A,l]),B=useCallback((z,L)=>{if(L.startDate&&L.endDate)return;let W=z.currentTarget.ownerSVGElement;if(!W)return;let E=W.createSVGPoint();E.x=z.clientX,E.y=z.clientY;let q=E.matrixTransform(W.getScreenCTM()?.inverse()),J=w(q.x),$=new Date(J);$.setDate($.getDate()+1),d?.(L,J,$);},[w,d]),P=useMemo(()=>{let z=q=>q.map(J=>{if(J.subtasks&&J.subtasks.length>0){let $=z(J.subtasks),De=$.filter(ke=>ke.startDate&&ke.endDate);if(De.length>0){let ke=De.map(Le=>Le.startDate.getTime()),_e=De.map(Le=>Le.endDate.getTime()),be=new Date(Math.min(...ke)),et=new Date(Math.max(..._e));return {...J,subtasks:$,startDate:be,endDate:et}}return {...J,subtasks:$}}return J}),L=(q,J=[])=>{for(let $ of q)J.push($),$.subtasks&&$.subtasks.length>0&&($.isExpanded===void 0||$.isExpanded)&&L($.subtasks,J);return J},W=z(e);return L(W)},[e]),H=useCallback(z=>{if(!z.startDate||!z.endDate)return {x:0,width:0};let L=z.startDate.getTime(),W=z.endDate.getTime(),E=o.getTime(),q=(L-E)/(1e3*60*60*24),J=(W-L)/(1e3*60*60*24),$=q*A*l,De=Math.max(A*l,40),ke=Math.max(J*A*l,De);return {x:$,width:ke}},[o,A,l]),X=useMemo(()=>P.filter(z=>z.startDate&&z.endDate).map(z=>{let{x:L,width:W}=H(z),q=P.findIndex(J=>J.id===z.id)*a+12;return {id:z.id,x:L,y:q,width:W,height:32}}),[P,H]),he=useCallback((z,L,W)=>{if(!W||L===0){g([]);return}let E=se.calculateCascadePreview(e,z,L,P,o,A*l,a,48);g(E);},[e,P,o,A,l,a,48]),xe=useMemo(()=>{let z=[],L=new Date(o);for(;L<=s;){let q=(L.getTime()-o.getTime())/864e5*A*l;if(r==="day")z.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:q}),L.setDate(L.getDate()+1);else if(r==="week"){let J=F(L);z.push({date:new Date(L),label:`Week ${J}`,x:q}),L.setDate(L.getDate()+7);}else z.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:q}),L.setMonth(L.getMonth()+1);}return z},[o,s,r,A,l]),Re=useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*A*l,[o,A,l]),We=Math.max(P.length*a,552);return jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxs("svg",{width:Math.max(v,1e3),height:47,style:{display:"block"},children:[jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:48,fill:t.bgGrid}),xe.map((z,L)=>jsxs("g",{children:[L>0&&jsx("line",{x1:z.x,y1:0,x2:z.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsx("text",{x:z.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:z.label})]},`header-${L}`)),Re>=0&&Re<=v&&jsx("circle",{cx:Re,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxs("svg",{width:Math.max(v,1e3),height:We,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxs("defs",{children:[jsx("filter",{id:"shadow",children:jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsx("rect",{x:0,y:0,width:Math.max(v,1e3),height:We,fill:t.bgPrimary}),xe.map((z,L)=>{let W=xe[L+1]?.x||v,E=T(z.date);return jsxs("g",{children:[E&&jsx("rect",{x:z.x,y:0,width:W-z.x,height:P.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsx("line",{x1:z.x,y1:0,x2:z.x,y2:P.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),P.map((z,L)=>{let W=z.startDate&&z.endDate;return jsxs("g",{children:[jsx("rect",{x:0,y:L*a,width:v,height:a,fill:L%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${z.id}`),!W&&jsxs(Fragment,{children:[jsx("rect",{x:0,y:L*a,width:v,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>B(E,z),onMouseEnter:E=>{E.currentTarget.setAttribute("fill",t.accentLight),E.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:E=>{E.currentTarget.setAttribute("fill","transparent"),E.currentTarget.setAttribute("opacity","1");}},`clickable-${z.id}`),jsx("text",{x:Re>0?Re:100,y:L*a+a/2,fill:t.textTertiary,fontSize:"12",fontFamily:"Inter, sans-serif",fontStyle:"italic",dominantBaseline:"middle",opacity:.4,style:{pointerEvents:"none",userSelect:"none"},children:"Click to set dates..."},`placeholder-${z.id}`)]})]},`row-group-${z.id}`)}),P.map((z,L)=>!z.dependencies||z.dependencies.length===0||!z.startDate||!z.endDate?null:z.dependencies.map(W=>{let E=P.find(De=>De.id===W);if(!E||!E.startDate||!E.endDate)return null;let q=P.findIndex(De=>De.id===W),J=H(E),$=H(z);return jsx(Jo,{x1:J.x+J.width,y1:q*a+a/2,x2:$.x,y2:L*a+a/2,theme:t},`dep-${W}-${z.id}`)})),P.map((z,L)=>{if(!z.startDate||!z.endDate)return null;let{x:W,width:E}=H(z),q=L*a+12,J=z.subtasks&&z.subtasks.length>0&&!z.isMilestone;return z.isMilestone?jsx(Qo,{task:z,x:W+E/2,y:q+16,theme:t,onClick:m},z.id):J?jsxs("g",{onClick:()=>m?.(z),onContextMenu:$=>{$.preventDefault(),$.stopPropagation(),p?.(z,$);},style:{cursor:"default"},children:[jsx("rect",{x:W,y:q,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsx("line",{x1:W,y1:q,x2:W+E,y2:q,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:q,x2:W,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W+E,y1:q,x2:W+E,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsx("line",{x1:W,y1:q+32,x2:W+E,y2:q+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsx("text",{x:W+12,y:q+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:z.name})]},z.id):jsx(Yo,{task:z,x:W,y:q,width:E,theme:t,dayWidth:A*l,startDate:o,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:d,onDependencyCreate:i,allTaskPositions:X,onDragMove:he,onHoverChange:D},z.id)}),P.map((z,L)=>!z.dependencies||z.dependencies.length===0||!z.startDate||!z.endDate?null:z.dependencies.map(W=>{let E=P.find(le=>le.id===W);if(!E||!E.startDate||!E.endDate)return null;let q=P.findIndex(le=>le.id===W),J=H(E),$=H(z),De=J.x+J.width,ke=q*a+a/2,_e=$.x,be=L*a+a/2,et=_e-De,Le=De+et/2,Qe=le=>{let Pe=1-le,Ae=Pe*Pe,rt=Ae*Pe,nt=le*le,Ie=nt*le,_=rt*De+3*Ae*le*Le+3*Pe*nt*Le+Ie*_e,we=rt*ke+3*Ae*le*ke+3*Pe*nt*be+Ie*be;return {x:_,y:we}},gt=20,Dt=[];for(let le=0;le<=gt;le++){let Pe=.1+le/gt*.8;Dt.push(Qe(Pe));}let lt=Dt[0],O=`M ${lt.x} ${lt.y} `+Dt.slice(1).map(le=>`L ${le.x} ${le.y}`).join(" ");return b&&b.x1===De&&b.y1===ke&&b.x2===_e&&b.y2===be?null:jsx("path",{d:O,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{y({x1:De,y1:ke,x2:_e,y2:be,onDelete:()=>u?.(z.id,W)});}},`dep-hover-${W}-${z.id}`)})),f.map(z=>jsxs("g",{style:{pointerEvents:"none"},children:[jsx("rect",{x:z.previewX,y:z.y-48,width:z.width,height:32,rx:8,fill:z.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(z.daysDelta)>0&&jsx("text",{x:z.previewX+z.width/2,y:z.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:z.daysDelta>0?`+${z.daysDelta}d`:`${z.daysDelta}d`})]},`cascade-preview-${z.taskId}`)),b&&(()=>{let{x1:z,y1:L,x2:W,y2:E,onDelete:q}=b,J=W-z,$=E-L,De=z+J/2,ke=(L+E)/2,_e=`M ${z} ${L} C ${De} ${L}, ${De} ${E}, ${W} ${E}`,be=6,et=Math.atan2($,J),Le=W-be*Math.cos(et-Math.PI/6),Qe=E-be*Math.sin(et-Math.PI/6),gt=W-be*Math.cos(et+Math.PI/6),Dt=E-be*Math.sin(et+Math.PI/6),lt=t.dependency,O="#f87171";return jsxs("g",{onMouseLeave:()=>y(null),children:[jsx("path",{d:_e,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("circle",{cx:De,cy:ke,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsx("path",{d:_e,fill:"none",stroke:lt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:_e,fill:"none",stroke:lt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:`M ${W} ${E} L ${Le} ${Qe} M ${W} ${E} L ${gt} ${Dt}`,fill:"none",stroke:lt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:W,cy:E,r:4,fill:lt,opacity:.9,style:{pointerEvents:"none"}}),jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:le=>{le.stopPropagation(),y(null),q();},style:{cursor:"pointer"},children:[jsx("circle",{cx:De,cy:ke,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:O,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsx("line",{x1:De-3,y1:ke-3,x2:De+3,y2:ke+3,stroke:O,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:De+3,y1:ke-3,x2:De-3,y2:ke+3,stroke:O,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),Re>=0&&Re<=v&&jsx("line",{x1:Re,y1:0,x2:Re,y2:We,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),k&&jsx(wd,{tooltipData:k,theme:t})]})]})}var an=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var zs=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],$s=[{id:"low",label:"Baja",color:"#10B981",icon:"\u{1F7E2}"},{id:"medium",label:"Media",color:"#F59E0B",icon:"\u{1F7E1}"},{id:"high",label:"Alta",color:"#F97316",icon:"\u{1F7E0}"},{id:"urgent",label:"Urgente",color:"#EF4444",icon:"\u{1F534}"}];function rn({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:l=false,mode:c=a?"edit":"create",theme:m="dark",customStatuses:n=[],availableTags:p=[],onCreateTag:d,attachments:i=[],onUploadAttachments:u,onDeleteAttachment:x}){let f=[...zs,...n.filter(O=>!zs.some(ne=>ne.id===O.id))],g=Ve[m]||Ve.dark,[k,h]=useState(false),[b,y]=useState(false),[D,N]=useState(false),[A,v]=useState(false),[F,T]=useState({top:0,left:0}),[w,B]=useState(null),[P,H]=useState(new Date),[X$1,he]=useState({top:0,left:0}),[xe,Re]=useState(false),[We,z]=useState([]),L=useRef(null),W=useRef(null),E=useRef(null),q=useRef(null),J=useRef(null),[$,De]=useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[ke,_e]=useState({});useEffect(()=>{a?(De({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&Re(true)):(De({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),Re(false),z([]));},[a,e]),useEffect(()=>{let O=ne=>{L.current&&!L.current.contains(ne.target)&&h(false),W.current&&!W.current.contains(ne.target)&&y(false),E.current&&!E.current.contains(ne.target)&&N(false),q.current&&!q.current.contains(ne.target)&&v(false);};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);let be=()=>{let O={};return $.name.trim()||(O.name="El nombre es requerido"),$.startDate&&$.endDate&&$.startDate>$.endDate&&(O.endDate="La fecha de fin debe ser posterior a la de inicio"),_e(O),Object.keys(O).length===0},et=async O=>{if(O.preventDefault(),!!be())try{let ne=c==="create"&&We.length>0?{...$,pendingFiles:We}:$;await s(ne),z([]),t();}catch(ne){console.error("Error submitting task:",ne);}},Le=(O,ne)=>{De(le=>{let Pe={...le,[O]:ne};if(O==="status"){let Ae=ne;Ae==="todo"?Pe.progress=0:Ae==="in-progress"?(le.progress===0||le.progress===100)&&(Pe.progress=50):Ae==="completed"||Ae==="closed"?Pe.progress=100:(Ae==="in-review"||Ae==="review")&&(Pe.progress=75);}if(O==="progress"){let Ae=typeof ne=="number"?ne:parseInt(ne,10);Ae===100&&le.status!=="completed"?Pe.status="completed":Ae>0&&Ae<100&&le.status==="todo"?Pe.status="in-progress":Ae===0&&le.status!=="todo"&&(Pe.status="todo");}return Pe}),ke[O]&&_e(le=>{let Pe={...le};return delete Pe[O],Pe});},Qe=f.find(O=>O.id===$.status)??zs[0],gt=$s.find(O=>O.id===$.priority)??$s[1],Dt=an.find(O=>O.value===$.color)??an[0],lt={backgroundColor:g.bgSecondary,border:`1px solid ${g.borderLight}`,color:g.textPrimary};return jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsx(motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden","data-theme":m,style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${g.border}`},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Qe.color||g.accent}}),jsx("span",{className:"text-sm font-medium",style:{color:g.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:g.textTertiary},onMouseEnter:O=>{O.currentTarget.style.backgroundColor=g.hoverBg,O.currentTarget.style.color=g.textPrimary;},onMouseLeave:O=>{O.currentTarget.style.backgroundColor="transparent",O.currentTarget.style.color=g.textTertiary;},disabled:l,children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:et,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxs("div",{className:"p-5 space-y-4",children:[jsxs("div",{children:[jsx("input",{type:"text",value:$.name,onChange:O=>Le("name",O.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:g.textPrimary},placeholder:"Nombre de la tarea",disabled:l,autoFocus:true}),ke.name&&jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsx(AlertCircle,{className:"w-3 h-3"}),ke.name]})]}),jsx("div",{children:jsx("textarea",{value:$.description||"",onChange:O=>Le("description",O.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:g.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:l})}),jsx("div",{style:{borderTop:`1px solid ${g.borderLight}`}}),jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxs("div",{ref:L,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&h(!k),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...lt,borderColor:Qe.color,backgroundColor:`${Qe.color}15`},disabled:l,children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:Qe.color}}),jsx("span",{style:{color:Qe.color},children:Qe.title}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:Qe.color}})]}),jsx(AnimatePresence,{children:k&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:f.map(O=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Le("status",O.id),h(false);},children:[jsx(CircleDot,{className:"w-3.5 h-3.5",style:{color:O.color}}),O.title,$.status===O.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},O.id))})})]}),jsxs("div",{ref:W,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[jsx(Flag,{className:"w-3.5 h-3.5",style:{color:gt.color}}),jsx("span",{children:gt.label}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:b&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:$s.map(O=>jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:ne=>ne.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:ne=>ne.currentTarget.style.backgroundColor="transparent",onClick:()=>{Le("priority",O.id),y(false);},children:[jsx("span",{children:O.icon}),O.label,$.priority===O.id&&jsx(Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:g.accent}})]},O.id))})})]}),o.length>0&&jsxs("div",{ref:E,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>!l&&N(!D),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[$.assignees&&$.assignees.length>0?jsxs(Fragment,{children:[jsx("div",{className:"flex -space-x-1",children:$.assignees.slice(0,3).map((O,ne)=>jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:O.color||g.accent,borderColor:g.bgSecondary},children:O.initials},ne))}),$.assignees.length>3&&jsxs("span",{style:{color:g.textTertiary},children:["+",$.assignees.length-3]})]}):jsxs(Fragment,{children:[jsx(Users,{className:"w-3.5 h-3.5",style:{color:g.textTertiary}}),jsx("span",{style:{color:g.textTertiary},children:"Asignar"})]}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:D&&jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},children:o.map(O=>{let ne=$.assignees?.some(le=>le.name===O.name);return jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:g.textPrimary},onMouseEnter:le=>le.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{let le=ne?($.assignees||[]).filter(Pe=>Pe.name!==O.name):[...$.assignees||[],{name:O.name,avatar:O.avatar,initials:O.name.split(" ").map(Pe=>Pe[0]).join("").toUpperCase().slice(0,2),color:g.accent}];Le("assignees",le);},children:[jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium flex-shrink-0",style:{backgroundColor:g.accent},children:O.name.charAt(0).toUpperCase()}),jsx("span",{className:"truncate flex-1 text-left",children:O.name}),jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:ne&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:g.accent}})})]},O.id)})})})]}),jsxs("div",{ref:q,className:"relative",children:[jsxs("button",{type:"button",onClick:()=>{if(!l)if(A)v(false);else {if(q.current){let O=q.current.getBoundingClientRect(),ne=window.innerHeight,le=120,Ae=ne-O.bottom<le?O.top-le-8:O.bottom+8;T({top:Ae,left:O.left});}v(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:lt,disabled:l,children:[jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:$.color}}),jsx("span",{children:Dt.name}),jsx(ChevronDown,{className:"w-3 h-3",style:{color:g.textTertiary}})]}),jsx(AnimatePresence,{children:A&&jsxs(tt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>v(false)}),jsx(motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg",style:{position:"fixed",top:`${F.top}px`,left:`${F.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:O=>O.stopPropagation(),children:jsx("div",{style:{padding:"6px 8px"},children:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:an.slice(0,18).map(O=>{let ne=$.color===O.value;return jsx("button",{type:"button",onClick:le=>{le.preventDefault(),le.stopPropagation(),Le("color",O.value),v(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:O.name,children:jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:O.value,outline:ne?`2px solid ${O.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},O.value)})})})})]})})]}),p.length>0||d?jsx(Rr,{selectedTags:$.tags||[],availableTags:p,onChange:O=>Le("tags",O),onCreateTag:d,theme:g,disabled:l}):null]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Calendar,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{ref:J,className:"flex items-center gap-2 flex-1 relative",children:[jsx("button",{type:"button",onClick:()=>{if(!l&&!$.isMilestone)if(w==="start")B(null);else {if(J.current){let O=J.current.getBoundingClientRect(),ne=window.innerHeight,le=320,Ae=ne-O.bottom<le?O.top-le-8:O.bottom+8;he({top:Ae,left:O.left});}B("start"),H($.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...lt,opacity:$.isMilestone?.5:1,cursor:$.isMilestone?"not-allowed":"pointer"},disabled:l||$.isMilestone,children:$.startDate?$.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsx("span",{style:{color:g.textTertiary},children:"\u2192"}),jsx("button",{type:"button",onClick:()=>{if(!l&&!$.isMilestone)if(w==="end")B(null);else {if(J.current){let O=J.current.getBoundingClientRect(),ne=window.innerHeight,le=320,Ae=ne-O.bottom<le?O.top-le-8:O.bottom+8;he({top:Ae,left:O.left});}B("end"),H($.endDate||$.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...lt,opacity:$.isMilestone?.5:1,cursor:$.isMilestone?"not-allowed":"pointer"},disabled:l||$.isMilestone,children:$.endDate?$.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsx(AnimatePresence,{children:w&&jsxs(tt,{children:[jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>B(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"rounded-xl shadow-2xl overflow-hidden flex",style:{position:"fixed",top:`${X$1.top}px`,left:`${X$1.left}px`,zIndex:99999,backgroundColor:g.bgPrimary,border:`1px solid ${g.border}`},onClick:O=>O.stopPropagation(),children:[jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${g.border}`},children:[(()=>{let O=new Date,ne=new Date(O);ne.setDate(O.getDate()+1);let le=new Date(O);le.setDate(O.getDate()+7);let Pe=new Date(O);return Pe.setDate(O.getDate()+14),[{label:"Hoy",date:O},{label:"Ma\xF1ana",date:ne},{label:"Pr\xF3xima semana",date:le},{label:"2 semanas",date:Pe}].map((rt,nt)=>jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:g.textPrimary},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="transparent",onClick:()=>{w==="start"?(Le("startDate",rt.date),(!$.endDate||rt.date>$.endDate)&&Le("endDate",rt.date),B("end")):(Le("endDate",rt.date),(!$.startDate||rt.date<$.startDate)&&Le("startDate",rt.date),B(null));},children:rt.label},nt))})(),jsx("div",{style:{borderTop:`1px solid ${g.border}`,margin:"0.5rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:O=>O.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",onClick:()=>{Le("startDate",void 0),Le("endDate",void 0),B(null);},children:"Borrar fechas"})]}),jsxs("div",{className:"p-3",children:[jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsx("button",{type:"button",onClick:()=>H(new Date(P.getFullYear(),P.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-4 h-4",style:{color:g.textSecondary}})}),jsx("span",{className:"text-sm font-medium",style:{color:g.textPrimary},children:P.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>H(new Date(P.getFullYear(),P.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-4 h-4",style:{color:g.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((O,ne)=>jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:g.textTertiary},children:O},ne))}),jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let O=P.getFullYear(),ne=P.getMonth(),le=new Date(O,ne,1).getDay(),Pe=new Date(O,ne+1,0).getDate(),Ae=new Date,rt=[];for(let Ie=le-1;Ie>=0;Ie--)rt.push({day:new Date(O,ne,-Ie).getDate(),date:new Date(O,ne-1,new Date(O,ne,-Ie).getDate()),isCurrentMonth:false});for(let Ie=1;Ie<=Pe;Ie++)rt.push({day:Ie,date:new Date(O,ne,Ie),isCurrentMonth:true});let nt=42-rt.length;for(let Ie=1;Ie<=nt;Ie++)rt.push({day:Ie,date:new Date(O,ne+1,Ie),isCurrentMonth:false});return rt.map((Ie,_)=>{let we=Ie.date.toDateString()===Ae.toDateString(),Z=$.startDate?.toDateString()===Ie.date.toDateString(),ie=$.endDate?.toDateString()===Ie.date.toDateString(),yt=$.startDate&&$.endDate&&Ie.date>=$.startDate&&Ie.date<=$.endDate;return jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Ie.isCurrentMonth?Z||ie?"#FFF":g.textPrimary:g.textTertiary,backgroundColor:Z?"#3B82F6":ie?"#7C3AED":yt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:we&&!Z&&!ie?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{w==="start"?(Le("startDate",Ie.date),$.endDate&&Ie.date>$.endDate&&Le("endDate",Ie.date),B("end")):(Le("endDate",Ie.date),$.startDate&&Ie.date<$.startDate&&Le("startDate",Ie.date),B(null));},children:Ie.day},_)})})()})]})]})]})})]}),ke.endDate&&jsx("span",{className:"text-xs text-red-400",children:ke.endDate})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(Clock,{className:"w-4 h-4",style:{color:g.textTertiary}}),jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsx("input",{type:"range",min:"0",max:"100",step:"5",value:$.progress,onChange:O=>Le("progress",parseInt(O.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:g.bgSecondary,accentColor:$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"},disabled:l}),jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"}20`,color:$.progress<30?"#EF4444":$.progress<70?"#F59E0B":"#10B981"},children:[$.progress,"%"]})]})]}),(u||i.length>0||c==="create")&&jsxs("div",{className:"pt-2",children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:g.textTertiary},children:jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsxs("span",{className:"text-xs",style:{color:g.textTertiary},children:["Adjuntos ",c==="create"?We.length>0&&`(${We.length})`:i.length>0&&`(${i.length})`]})]}),c==="create"?jsx(Ua,{cardId:"pending",attachments:We.map((O,ne)=>({id:`pending-${ne}`,cardId:"pending",name:O.name,size:O.size,type:O.type,url:URL.createObjectURL(O),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:O=>z(ne=>[...ne,...O]),onDelete:O=>{let ne=parseInt(O.replace("pending-",""),10);z(le=>le.filter((Pe,Ae)=>Ae!==ne));},maxSizeMB:10,maxFiles:20}):jsx(Ua,{cardId:a?.id||"new",attachments:i,onUpload:u&&a?.id?O=>u(a.id,O):void 0,onDelete:x,maxSizeMB:10,maxFiles:20}),c==="create"&&We.length>0&&jsxs("p",{className:"text-xs mt-1",style:{color:g.textTertiary},children:[We.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxs("div",{children:[jsxs("button",{type:"button",onClick:()=>Re(!xe),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:g.textTertiary},children:[jsx(ChevronDown,{className:`w-3 h-3 transition-transform ${xe?"rotate-180":""}`}),"Opciones avanzadas"]}),jsx(AnimatePresence,{children:xe&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxs("div",{className:"pt-3 space-y-3",children:[jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsx("input",{type:"checkbox",checked:$.isMilestone,onChange:O=>Le("isMilestone",O.target.checked),className:"w-4 h-4 rounded",style:{accentColor:g.accent},disabled:l}),jsx(Milestone,{className:"w-4 h-4 text-yellow-500"}),jsx("span",{className:"text-sm",style:{color:g.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxs("div",{children:[jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:g.textTertiary},children:[jsx(Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:g.bgSecondary},children:r.filter(O=>O.id!==a?.id).map(O=>{let ne=$.dependencies?.includes(O.id);return jsx("button",{type:"button",onClick:()=>{let le=ne?($.dependencies||[]).filter(Pe=>Pe!==O.id):[...$.dependencies||[],O.id];Le("dependencies",le);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ne?`${g.accent}30`:g.bgPrimary,color:ne?g.accent:g.textSecondary,border:`1px solid ${ne?g.accent:g.borderLight}`},disabled:l,children:O.name},O.id)})})]})]})})})]})]}),jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${g.border}`},children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:g.textSecondary},onMouseEnter:O=>O.currentTarget.style.backgroundColor=g.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",disabled:l,children:"Cancelar"}),jsx("button",{type:"submit",disabled:l,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:g.accent,color:"#FFF"},onMouseEnter:O=>!l&&(O.currentTarget.style.opacity="0.9"),onMouseLeave:O=>!l&&(O.currentTarget.style.opacity="1"),children:l?jsxs(Fragment,{children:[jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsx(Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var nf=['Move "Task Name" to next Monday','Extend "Task Name" by 3 days','Rename "Old Name" to "New Name"','Set "Task Name" progress to 50%','Link "Task A" to "Task B"','Create a new task called "New Task"','Delete "Task Name"','Assign John to "Task Name"'],Sd=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707"}),jsx("circle",{cx:"12",cy:"12",r:"4"})]}),sf=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),lf=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),df=()=>jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M5 12h14"})}),cf=()=>jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsx(motion.div,{className:"w-2 h-2 rounded-full bg-current",animate:{scale:[1,1.2,1],opacity:[.5,1,.5]},transition:{duration:.8,repeat:1/0,delay:e*.15}},e))});function on({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:l,onDependencyCreate:c,onDependencyDelete:m}){let[n,p]=useState(false),[d,i]=useState(false),[u,x]=useState([]),[f,g]=useState(""),[k,h]=useState(false),[b,y]=useState(true),D=useRef(null),N=useRef(null),A=useRef(null),{enabled:v=true,placeholder:F='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:w,suggestions:B=nf,maxHistory:P=50,persistHistory:H}=a,X=H?.storageKey||"gantt-ai-history",he=H?.maxMessages??5;useEffect(()=>{if(H?.enabled)try{let W=localStorage.getItem(X);if(W){let q=JSON.parse(W).map(J=>({...J,timestamp:new Date(J.timestamp)}));x(q.slice(-he));}}catch(W){console.warn("[GanttAIAssistant] Failed to load persisted history:",W);}},[H?.enabled,X,he]),useEffect(()=>{if(H?.enabled&&u.length>0)try{let W=u.filter(E=>!E.isLoading).slice(-he);localStorage.setItem(X,JSON.stringify(W));}catch(W){console.warn("[GanttAIAssistant] Failed to persist history:",W);}},[u,H?.enabled,X,he]),useEffect(()=>{N.current&&N.current.scrollIntoView({behavior:"smooth"});},[u]),useEffect(()=>{n&&!d&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,d]);let xe=useCallback(W=>{if(W.success)switch(W.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":W.taskId&&W.updates&&o?.(W.taskId,W.updates);break;case "create_task":W.newTask&&s?.(W.newTask);break;case "delete_task":W.taskId&&l?.(W.taskId);break;case "link_tasks":W.dependencyFrom&&W.dependencyTo&&c?.(W.dependencyFrom,W.dependencyTo);break;case "unlink_tasks":W.taskId&&W.dependencyFrom&&m?.(W.taskId,W.dependencyFrom);break}},[o,s,l,c,m]),Re=useCallback(async W=>{if(!W.trim()||k)return;let E={id:`user-${Date.now()}`,role:"user",content:W,timestamp:new Date};x(J=>[...J.slice(-(P-1)),E]),g(""),y(false),h(true);let q={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};x(J=>[...J,q]);try{if(w){let J=await w(W,e);x($=>{let De=$.filter(_e=>!_e.isLoading),ke={id:`assistant-${Date.now()}`,role:"assistant",content:J.message,timestamp:new Date,command:J};return [...De,ke]}),xe(J);}else x(J=>[...J.filter(De=>!De.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(J){x($=>[...$.filter(ke=>!ke.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${J instanceof Error?J.message:"Unknown error"}`,timestamp:new Date}]);}finally{h(false);}},[k,P,w,e,xe]),We=W=>{W.preventDefault(),Re(f);},z=W=>{g(W),D.current?.focus();};if(useEffect(()=>{let W=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),p(q=>!q),n||i(false)),E.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n]),useEffect(()=>{if(!n)return;let W=q=>{let J=q.target;A.current&&!A.current.contains(J)&&p(false);},E=setTimeout(()=>{document.addEventListener("mousedown",W);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",W);}},[n]),!v)return null;let L={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"};return jsxs(tt,{children:[jsx(AnimatePresence,{children:!n&&jsxs(motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${L[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>p(true),children:[jsx(Sd,{}),jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsx(AnimatePresence,{children:n&&jsxs(motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${L[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsx(Sd,{}),jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{onClick:()=>i(W=>!W),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(df,{})}),jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsx(lf,{})})]})]}),jsx(AnimatePresence,{children:!d&&jsxs(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&b&&jsxs("div",{className:"space-y-3",children:[jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsx("div",{className:"flex flex-wrap gap-2",children:B.slice(0,4).map((W,E)=>jsx("button",{onClick:()=>z(W),className:"text-xs px-3 py-1.5 rounded-full transition-colors",style:{background:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.border}`},children:W.length>30?W.slice(0,30)+"...":W},E))})]}),u.map(W=>jsx(motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${W.role==="user"?"justify-end":"justify-start"}`,children:jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${W.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:W.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:W.role==="user"?"white":t.textPrimary},children:[W.isLoading?jsx(cf,{}):jsx("p",{className:"text-sm whitespace-pre-wrap",children:W.content}),W.command&&jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:W.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:W.command.success?"#10B981":"#EF4444"},children:[W.command.success?"\u2713":"\u2717",jsx("span",{className:"capitalize",children:W.command.type.replace(/_/g," ")})]})]})},W.id)),jsx("div",{ref:N})]}),jsxs("form",{onSubmit:We,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsx("input",{ref:D,type:"text",value:f,onChange:W=>g(W.target.value),placeholder:F,disabled:k,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsx("button",{type:"submit",disabled:!f.trim()||k,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsx(sf,{})})]}),jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function nn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let p=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]);let n=e.filter(p=>p.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:m,onClick:()=>{if(!r&&m.current){let p=m.current.getBoundingClientRect();l({x:p.left,y:p.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(tt,{children:jsx(motion.div,{ref:c,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),n.map(p=>jsxs("button",{onClick:()=>{t(p.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:p.label}),p.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},p.id))]})})})})]})}function Ad(e,t=50){let[a,r]=useState({past:[],present:e,future:[]}),o=useRef(false),s=useCallback((n,p=true)=>{r(d=>{let i=typeof n=="function"?n(d.present):n;if(o.current)return {...d,present:i};if(!p)return {...d,present:i};let u=[...d.past,d.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),l=useCallback(()=>{r(n=>{if(n.past.length===0)return n;let p=n.past[n.past.length-1],d=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:p,future:[n.present,...n.future]}});},[]),c=useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],d=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:d}});},[]),m=useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:l,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function Id({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){useEffect(()=>{if(!o)return;let s=l=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,m=c?l.metaKey:l.ctrlKey;if(m&&l.key==="z"&&!l.shiftKey&&a){l.preventDefault(),e();return}if(r){if(!c&&m&&l.key==="y"){l.preventDefault(),t();return}if(c&&m&&l.shiftKey&&l.key==="z"){l.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var vf={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${se.formatDate(e.startDate)} - ${se.formatDate(e.endDate)}`);let a=se.calculateDuration(e.startDate,e.endDate);t.push(`Duration: ${a} days`);}if(e.progress!==void 0&&t.push(`Progress: ${e.progress}%`),e.status&&t.push(`Status: ${e.status}`),e.assignees&&e.assignees.length>0){let a=e.assignees.map(r=>r.name).join(", ");t.push(`Assigned: ${a}`);}return e.dependencies&&e.dependencies.length>0&&t.push(`Dependencies: ${e.dependencies.length}`),t.join("<br/>")},taskLabel:e=>e.name,gridCell:(e,t,a)=>a,taskClass:e=>{let t=[];return e.isCriticalPath&&t.push("critical-path"),e.status==="completed"?t.push("completed"):e.status==="in-progress"?t.push("in-progress"):e.status==="todo"&&t.push("todo"),e.isMilestone&&t.push("milestone"),t.join(" ")},milestoneContent:e=>`\u25C6 ${e.name}`,dateFormat:e=>se.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function Ld(e){return {...vf,...e}}var Sf=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},Rd=forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:l="week",rowDensity:c="comfortable",showThemeSelector:m=true,showExportButton:n=true,availableUsers:p=[],templates:d,enableAutoCriticalPath:i=true,persistExpandedState:u,aiAssistant:x,locale:f="en",customTranslations:g,showCreateTaskButton:k=false,createTaskLabel:h,onCreateTask:b,onThemeChange:y,onTaskClick:D,onTaskDblClick:N,onTaskContextMenu:A,onTaskUpdate:v,onProgressChange:F,onTaskEdit:T,onTaskAddSubtask:w,onTaskMarkIncomplete:B,onTaskSetInProgress:P,onDependencyCreate:H,onDependencyDelete:X,onBeforeTaskAdd:he,onAfterTaskAdd:xe,onBeforeTaskUpdate:Re,onAfterTaskUpdate:We,onBeforeTaskDelete:z,onAfterTaskDelete:L}=a,E=useContext(_o)?.theme,[q,J]=useState(E||s||"dark"),[$,De]=useState(l),[ke,_e]=useState(c),[be,et]=useState(1),[Le,Qe]=useState(0),[gt,Dt]=useState(false),[lt,O]=useState(null),[ne,le]=useState({isOpen:false,x:0,y:0,task:null}),[Pe,Ae]=useState(null),[rt,nt]=useState(null),[Ie,_]=useState(false);useEffect(()=>{function S(M){ge.current&&!ge.current.contains(M.target)&&_(false);}if(Ie)return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[Ie]),useEffect(()=>{E&&E!==q&&J(E);},[E]),useEffect(()=>{s&&s!==q&&J(s);},[s]);let we=useCallback(S=>{J(S),y?.(S);},[y]),{state:Z,setState:ie,undo:yt,redo:ee,canUndo:ae,canRedo:ve,clearHistory:Ne}=Ad(t,50),re=useCallback(()=>u?typeof u=="string"?u:"gantt-expanded-tasks":null,[u]),Te=useRef(new Map),ye=useRef(false);if(!ye.current&&u){ye.current=true;let S=typeof u=="string"?u:"gantt-expanded-tasks";try{let M=localStorage.getItem(S);if(M){let Y=JSON.parse(M);Array.isArray(Y)&&(Te.current=new Map(Y));}}catch(M){console.warn("[GanttBoard] Error loading expanded state from localStorage:",M);}}let Se=useCallback(()=>{let S=re();if(S)try{let M=Array.from(Te.current.entries());localStorage.setItem(S,JSON.stringify(M));}catch(M){console.warn("[GanttBoard] Error saving expanded state to localStorage:",M);}},[re]);useEffect(()=>{let S=M=>M.map(Y=>{let Q=Te.current.get(Y.id),ce=Q!==void 0?{...Y,isExpanded:Q}:Y;return ce.subtasks?.length?{...ce,subtasks:S(ce.subtasks)}:ce});Te.current.size>0?ie(S(t)):ie(t);},[t,ie]);let me=useRef(t),Oe=useRef(true);useEffect(()=>{if(Oe.current){Oe.current=false,me.current=Z;return}if(!r)return;let S=JSON.stringify(me.current),M=JSON.stringify(Z);S!==M&&(me.current=Z,r(Z));},[Z,r]);let U=useMemo(()=>ks(f,g),[f,g]),j=useCallback(S=>[{id:"name",label:S.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:S.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:S.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:S.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:S.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:S.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:S.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:S.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[ze,Fe]=useState(()=>j(U));useEffect(()=>{Fe(S=>S.map(M=>({...M,label:U.columns[M.id==="name"?"taskName":M.id]||M.label})));},[U]);let Ue=useMemo(()=>{let S=ze.filter(Q=>Q.visible),M=S.some(Q=>Q.id!=="name");return S.reduce((Q,ce)=>Q+ce.width,0)+(M?20:0)},[ze]),Ut=useRef(ze.filter(S=>S.visible).map(S=>S.id).join(","));useEffect(()=>{let S=ze.filter(Q=>Q.visible),M=S.map(Q=>Q.id).join(","),Y=Ut.current;if(M!==Y){let Q=S.some(Ce=>Ce.id!=="name"),ce=Y.includes(",");Q?!ce&&Q&&O(null):O(null),Ut.current=M;}},[ze]);let Me=useMemo(()=>lt!==null?Math.max(280,lt):Math.max(280,Ue),[lt,Ue]),ft=useRef(null),Qt=useRef(null),R=useRef(null),ge=useRef(null),K=useMemo(()=>Jl(q),[q]),Ft=useMemo(()=>({theme:K,themeName:q}),[K,q]),aa=useMemo(()=>Ld(d),[d]),de=useMemo(()=>{if(!i)return Z;let S=se.calculateCriticalPath(Z),M=Y=>Y.map(Q=>({...Q,isCriticalPath:S.includes(Q.id),subtasks:Q.subtasks?M(Q.subtasks):void 0}));return M(Z)},[Z,i]),ht=Sf(ke);Id({undo:yt,redo:ee,canUndo:ae,canRedo:ve,enabled:true}),useImperativeHandle(o,()=>({getTask:S=>se.findTaskById(Z,S),addTask:(S,M)=>{ie(Y=>{if(!M)return [...Y,{...S,level:0}];let Q=ce=>ce.map(Ce=>Ce.id===M?{...Ce,subtasks:[...Ce.subtasks||[],{...S,parentId:M,level:(Ce.level||0)+1}],isExpanded:true}:Ce.subtasks?{...Ce,subtasks:Q(Ce.subtasks)}:Ce);return Q(Y)});},updateTask:(S,M)=>{ie(Y=>{let Q=ce=>ce.map(Ce=>Ce.id===S?{...Ce,...M}:Ce.subtasks?{...Ce,subtasks:Q(Ce.subtasks)}:Ce);return Q(Y)});},deleteTask:S=>{ie(M=>{let Y=Q=>Q.filter(ce=>ce.id===S?false:(ce.subtasks&&(ce.subtasks=Y(ce.subtasks)),true));return Y(M)});},deleteTasks:S=>{ie(M=>Ss(M,S));},duplicateTask:S=>{ie(M=>Es(M,[S]));},splitTask:(S,M,Y=3)=>{ie(Q=>se.splitTask(Q,S,M,Y));},calculateEndDate:se.calculateEndDate,calculateDuration:se.calculateDuration,validateDependency:(S,M)=>!se.validateDependencies(Z,S,M),getAllTasks:()=>se.flattenTasks(Z),getTasksByStatus:S=>se.flattenTasks(Z).filter(M=>M.status===S),getTasksByParent:S=>S?se.findTaskById(Z,S)?.subtasks||[]:Z.filter(Y=>!Y.parentId),getCriticalPath:()=>se.flattenTasks(Z).filter(S=>S.isCriticalPath),indentTask:S=>{ie(M=>Ts(M,[S]));},outdentTask:S=>{ie(M=>Ds(M,[S]));},moveTask:(S,M)=>{ie(Y=>Ns(Y,[S],M));},createSubtask:async S=>{let{tasks:M,newTask:Y}=As(Z,S);if(he){let Q=he({...Y,parentId:S});if((Q instanceof Promise?await Q:Q)===false)return}ie(M),xe&&xe({...Y,parentId:S});},scrollToTask:S=>{let Y=se.flattenTasks(Z).findIndex(Q=>Q.id===S);if(Y!==-1&&ft.current){let Q=Y*ht;ft.current.scrollTo({top:Q,behavior:"smooth"}),Qt.current&&Qt.current.scrollTo({top:Q,behavior:"smooth"});}},highlightTask:(S,M=2e3)=>{},expandTask:S=>{ie(M=>{let Y=Q=>Q.map(ce=>ce.id===S?{...ce,isExpanded:true}:ce.subtasks?{...ce,subtasks:Y(ce.subtasks)}:ce);return Y(M)});},collapseTask:S=>{ie(M=>{let Y=Q=>Q.map(ce=>ce.id===S?{...ce,isExpanded:false}:ce.subtasks?{...ce,subtasks:Y(ce.subtasks)}:ce);return Y(M)});},expandAll:()=>{ie(S=>{let M=Y=>Y.map(Q=>({...Q,isExpanded:true,subtasks:Q.subtasks?M(Q.subtasks):void 0}));return M(S)});},collapseAll:()=>{ie(S=>{let M=Y=>Y.map(Q=>({...Q,isExpanded:false,subtasks:Q.subtasks?M(Q.subtasks):void 0}));return M(S)});},undo:yt,redo:ee,canUndo:()=>ae,canRedo:()=>ve,clearHistory:Ne,exportToPNG:async()=>{if(!R.current)throw new Error("Gantt container not found");let S=await Bd(R.current,{backgroundColor:K.bgPrimary,scale:2});return new Promise((M,Y)=>{S.toBlob(Q=>{Q?M(Q):Y(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await se.exportToPDF(Z,S);},exportToExcel:async S=>{await se.exportToExcel(Z,S);},exportToJSON:()=>se.exportToJSON(Z),exportToCSV:()=>se.exportToCSV(Z),importFromJSON:S=>{let M=se.importFromJSON(S);ie(M);},getTasks:()=>Z,refresh:()=>{ie(S=>[...S]);},clearAll:()=>{ie([]);}}),[Z,yt,ee,ae,ve,Ne,K,ht]);let jt=useCallback(S=>{Fe(M=>M.map(Y=>Y.id===S?{...Y,visible:!Y.visible}:Y));},[]),Pr=useCallback((S,M)=>{Fe(Y=>Y.map(Q=>{if(Q.id!==S)return Q;let ce=Q.minWidth??100,Ce=Q.maxWidth??800,Ot=Math.max(ce,Math.min(Ce,M));return {...Q,width:Ot}}));},[]),Do=useCallback(S=>{ie(M=>{let Y=Ms(M,S),Q=ce=>{for(let Ce of ce){if(Ce.id===S){Te.current.set(S,Ce.isExpanded??true);return}Ce.subtasks?.length&&Q(Ce.subtasks);}};return Q(Y),Se(),Y}),a.onTaskToggleExpand?.(S);},[a,Se]),Sa=useCallback((S,M)=>{if(Re&&Re(S,M)===false)return;let Q=se.findTaskById(Z,S)?.progress,ce=Ot=>Ot.map(Gt=>Gt.id===S?{...Gt,...M}:Gt.subtasks?{...Gt,subtasks:ce(Gt.subtasks)}:Gt);ie(ce(Z));let Ce=se.findTaskById(ce(Z),S);Ce&&(v?.(Ce),We?.(Ce),M.progress!==void 0&&Q!==void 0&&M.progress!==Q&&F?.(S,Q,M.progress));},[Z,v,Re,We,F]),Ha=useCallback(S=>{S.length!==0&&(ie(M=>Ts(M,S)),a.onTaskIndent?.(S[0]));},[a]),dr=useCallback(S=>{S.length!==0&&(ie(M=>Ds(M,S)),a.onTaskOutdent?.(S[0]));},[a]),Bt=useCallback((S,M,Y)=>{ie(Q=>gd(Q,S,M,Y)),a.onTaskReparent?.(S,M,Y);},[a]),Nn=useCallback((S,M)=>{S.length!==0&&(ie(Y=>Ns(Y,S,M)),a.onTaskMove?.(S[0],M));},[a]),qr=useCallback(async S=>{let M=[];for(let Y of S)z&&await Promise.resolve(z(Y))===false||M.push(Y);M.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(M):(ie(Y=>Ss(Y,M)),M.forEach(Y=>a.onTaskDelete?.(Y))),L&&M.forEach(Y=>L(Y)));},[a,z,L]),Bi=useCallback(S=>{ie(M=>Es(M,S)),S.forEach(M=>a.onTaskDuplicate?.(M));},[a]),Xr=useCallback((S,M)=>{ie(Y=>{let{tasks:Q,newTask:ce}=ud(Y,S,M);return he&&he(ce)===false?Y:(a.onTaskCreate?.(ce.parentId,ce.position||0),xe?.(ce),Q)});},[a,he,xe]),Xc=useCallback((S,M)=>{ie(Y=>Ps(Y,S,M)),a.onTaskRename?.(S,M);},[a]),Sn=useCallback(S=>{ie(M=>{let{tasks:Y}=As(M,S);return a.onTaskCreate?.(S,0),Y});},[a]),Jc=useCallback((S,M,Y)=>{let Q=S.startDate?Math.round((M.getTime()-S.startDate.getTime())/864e5):0,ce=Gt=>Gt.map(Jt=>Jt.id===S.id?{...Jt,startDate:M,endDate:Y,...S.segments&&{segments:S.segments}}:Jt.subtasks?{...Jt,subtasks:ce(Jt.subtasks)}:Jt),Ce=ce(Z);Ce=se.autoScheduleDependents(Ce,S.id,Q),ie(Ce);let Ot={...S,startDate:M,endDate:Y};v?.(Ot);},[Z,v]),Zc=useCallback((S,M)=>{A?.(S,M),le({isOpen:true,x:M.clientX,y:M.clientY,task:S});},[A]),Qc=useCallback((S,M)=>{let Y=se.splitTask(Z,S.id,M);ie(Y),le({isOpen:false,x:0,y:0,task:null});},[Z]),Ri=useCallback(S=>{let M=se.findTaskById(Z,S.id)||S;N?.(M),T||Ae(M);},[Z,N,T]),Oi=useCallback((S,M,Y)=>{let Q=new Map,ce=Ea=>{Ea.forEach(Ga=>{Ga.dependencies&&Q.set(Ga.id,Ga.dependencies),Ga.subtasks&&ce(Ga.subtasks);});};ce(Y);let Ce=Q.get(M)||[];Q.set(M,[...Ce,S]);let Ot=new Set,Gt=new Set,Jt=Ea=>{if(!Ot.has(Ea)){Ot.add(Ea),Gt.add(Ea);let Ga=Q.get(Ea)||[];for(let cr of Ga){if(!Ot.has(cr)&&Jt(cr))return true;if(Gt.has(cr))return true}}return Gt.delete(Ea),false};return Jt(M)},[]),zi=useCallback((S,M)=>{if(Oi(S.id,M,Z)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
343
343
 
344
- Task dependencies must flow in one direction only.`);return}let Y=Q=>Q.map(ce=>{if(ce.id===M){let Ce=ce.dependencies||[];if(!Ce.includes(S.id))return {...ce,dependencies:[...Ce,S.id]}}return ce.subtasks?{...ce,subtasks:Y(ce.subtasks)}:ce});ie(Y(Z)),H?.(S.id,M);},[Z,H,Oi]),$i=useCallback((S,M)=>{let Y=Q=>Q.map(ce=>{if(ce.id===S&&ce.dependencies){let Ce=ce.dependencies.filter(Ot=>Ot!==M);return {...ce,dependencies:Ce}}return ce.subtasks?{...ce,subtasks:Y(ce.subtasks)}:ce});ie(Y(Z)),X?.(S,M);},[Z,X]),{startDate:em,endDate:tm}=useMemo(()=>{let S=Z.filter(Ce=>Ce.startDate&&Ce.endDate);if(S.length===0){let Ce=new Date,Ot=new Date(Ce);Ot.setDate(Ot.getDate()-30);let Gt=new Date(Ce);return Gt.setDate(Gt.getDate()+60),{startDate:Ot,endDate:Gt}}let M=S.flatMap(Ce=>[Ce.startDate,Ce.endDate]).filter(Ce=>Ce!==void 0),Y=new Date(Math.min(...M.map(Ce=>Ce.getTime()))),Q=new Date(Math.max(...M.map(Ce=>Ce.getTime()))),ce=$==="day"?7:$==="week"?14:30;return Y.setDate(Y.getDate()-ce),Q.setDate(Q.getDate()+ce),{startDate:Y,endDate:Q}},[Z,$]),am=useCallback(async()=>{if(!R.current)return;let S=await Bd(R.current,{backgroundColor:K.bgPrimary,scale:2}),M=document.createElement("a");M.download="gantt-chart.png",M.href=S.toDataURL("image/png"),M.click();},[K]),rm=useCallback(async()=>{await se.exportToPDF(Z);},[Z]),om=useCallback(async()=>{await se.exportToExcel(Z);},[Z]),nm=useCallback(()=>{let S=se.exportToCSV(Z),M=new Blob([S],{type:"text/csv;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(M),Y.download="gantt-chart.csv",Y.click(),URL.revokeObjectURL(Y.href);},[Z]),sm=useCallback(()=>{let S=se.exportToJSON(Z),M=new Blob([S],{type:"application/json;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(M),Y.download="gantt-chart.json",Y.click(),URL.revokeObjectURL(Y.href);},[Z]),im=useCallback(()=>{se.exportToMSProject(Z,"Gantt Project","project.xml");},[Z]),lm=S=>{S.preventDefault(),Dt(true);};return useEffect(()=>{let S=Qt.current,M=ft.current;if(!S||!M)return;let Y=M.querySelector(".gantt-taskgrid-content"),Q=()=>{let Jt=S.scrollTop;Qe(Jt),Y&&(Y.style.transform=`translateY(-${Jt}px)`);},ce=Jt=>{if(gt&&M){let Ga=M.parentElement?.getBoundingClientRect()?.left||0,cr=Jt.clientX-Ga,dm=280,cm=window.innerWidth-100;cr>=dm&&cr<=cm&&O(cr);}},Ce=()=>{Dt(false);},Ot=M.querySelector(".gantt-grid-scroll")||M,Gt=Jt=>{let Ea=Jt;Ea.deltaY!==0&&(S.scrollTop+=Ea.deltaY,Jt.preventDefault());};return S.addEventListener("scroll",Q),Ot.addEventListener("wheel",Gt,{passive:false}),document.addEventListener("mousemove",ce),document.addEventListener("mouseup",Ce),()=>{S.removeEventListener("scroll",Q),Ot.removeEventListener("wheel",Gt),document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",Ce);}},[gt]),jsx(Wr.Provider,{value:U,children:jsx(In.Provider,{value:Ft,children:jsxs("div",{ref:R,className:"flex flex-col h-full w-full",style:{backgroundColor:K.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(jo,{theme:K,timeScale:$,onTimeScaleChange:De,zoom:be,onZoomChange:et,currentTheme:q,onThemeChange:we,rowDensity:ke,onRowDensityChange:_e,showThemeSelector:m,showCreateTaskButton:k,createTaskLabel:h,onCreateTask:b,onExportPNG:n?am:void 0,onExportPDF:n?rm:void 0,onExportExcel:n?om:void 0,onExportCSV:n?nm:void 0,onExportJSON:n?sm:void 0,onExportMSProject:n?im:void 0}),jsxs("div",{ref:ft,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Me,overflowX:"auto",overflowY:"hidden"},children:jsx(Ko,{tasks:de,theme:K,rowHeight:ht,availableUsers:p,templates:aa,onTaskClick:D,onTaskDblClick:Ri,onTaskContextMenu:A,onTaskToggle:Do,scrollTop:Le,columns:ze,onToggleColumn:jt,onColumnResize:Pr,onTaskUpdate:Sa,onTaskIndent:Ha,onTaskOutdent:dr,onTaskMove:Nn,onMultiTaskDelete:qr,onTaskDuplicate:Bi,onTaskCreate:Xr,onTaskRename:Xc,onCreateSubtask:Sn,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,M)=>nt({taskId:S,taskName:M}),onTaskReparent:Bt})}),jsxs("div",{className:"flex-shrink-0 flex h-full",style:{zIndex:15},children:[jsx("div",{className:"cursor-col-resize hover:bg-blue-500/20 transition-colors flex flex-col",style:{width:5,backgroundColor:K.bgPrimary,borderLeft:`1px solid ${K.border}`},onMouseDown:lm,children:jsx("div",{style:{height:"48px",backgroundColor:K.bgGrid}})}),jsxs("div",{className:"flex flex-col",style:{backgroundColor:K.bgPrimary},children:[jsxs("div",{className:"flex items-center gap-1 px-1",style:{position:"relative",height:"48px",backgroundColor:K.bgGrid,borderBottom:`1px solid ${K.border}`},children:[jsx(nn,{columns:ze,onToggleColumn:jt,theme:K}),jsx("button",{onClick:()=>_(!Ie),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:K.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Ie&&jsxs("div",{ref:ge,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:K.bgPrimary,border:`1px solid ${K.border}`,color:K.textPrimary},onClick:S=>S.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:K.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:K.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>_(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:K.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]}),jsx("div",{className:"flex-1"})]})]}),jsx("div",{ref:Qt,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(tn,{tasks:de,theme:K,rowHeight:ht,timeScale:$,startDate:em,endDate:tm,zoom:be,templates:aa,onTaskClick:D,onTaskDblClick:Ri,onTaskContextMenu:Zc,onTaskDateChange:Jc,onDependencyCreate:zi,onDependencyDelete:$i})})]}),ne.task&&jsx(Hr,{isOpen:ne.isOpen,x:ne.x,y:ne.y,theme:K,onClose:()=>le({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=ne.task;if(!S)return [];let M=se.findTaskById(Z,S.id)||S;return M.subtasks&&M.subtasks.length>0?[{id:"addSubtask",label:U.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(M):Sn(M.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:U.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{nt({taskId:M.id,taskName:M.name});}}]:[{id:"edit",label:U.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{T?T(M):Ae(M);}},{id:"addSubtask",label:U.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(M):Sn(M.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:U.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{B?B(M):Sa(M.id,{status:"todo",progress:0});},disabled:M.status==="todo"},{id:"setInProgress",label:U.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{P?P(M):Sa(M.id,{status:"in-progress"});},disabled:M.status==="in-progress"},{id:"markComplete",label:U.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{Sa(M.id,{status:"completed",progress:100});},disabled:M.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:U.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{if(!M.startDate||!M.endDate){console.warn("Cannot split task without dates");return}let Q=M.startDate.getTime(),ce=M.endDate.getTime(),Ce=Q+(ce-Q)/2,Ot=new Date(Ce);Qc(M,Ot);},disabled:!M.startDate||!M.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:U.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{nt({taskId:M.id,taskName:M.name});}}]})()}),Pe&&jsx(rn,{isOpen:true,onClose:()=>Ae(null),task:Pe,onSubmit:S=>{Sa(Pe.id,S),Ae(null);},mode:"edit",theme:q}),jsx(AnimatePresence,{children:rt&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>nt(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:K.bgSecondary,border:`1px solid ${K.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${K.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:K.textPrimary,fontFamily:"Inter, sans-serif"},children:[U.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:K.textPrimary},children:['"',rt.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:K.bgPrimary,borderTop:`1px solid ${K.border}`},children:[jsx("button",{onClick:()=>nt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=K.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{qr([rt.taskId]),nt(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),x?.enabled&&jsx(on,{tasks:Z,theme:K,config:x,onTasksUpdate:ie,onTaskUpdate:Sa,onTaskCreate:S=>{ie(M=>[...M,S]);},onTaskDelete:S=>{qr([S]);},onDependencyCreate:(S,M)=>{let Y=se.findTaskById(Z,S);Y&&zi(Y,M);},onDependencyDelete:$i})]})})})});var Od=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
344
+ Task dependencies must flow in one direction only.`);return}let Y=Q=>Q.map(ce=>{if(ce.id===M){let Ce=ce.dependencies||[];if(!Ce.includes(S.id))return {...ce,dependencies:[...Ce,S.id]}}return ce.subtasks?{...ce,subtasks:Y(ce.subtasks)}:ce});ie(Y(Z)),H?.(S.id,M);},[Z,H,Oi]),$i=useCallback((S,M)=>{let Y=Q=>Q.map(ce=>{if(ce.id===S&&ce.dependencies){let Ce=ce.dependencies.filter(Ot=>Ot!==M);return {...ce,dependencies:Ce}}return ce.subtasks?{...ce,subtasks:Y(ce.subtasks)}:ce});ie(Y(Z)),X?.(S,M);},[Z,X]),{startDate:em,endDate:tm}=useMemo(()=>{let S=Z.filter(Ce=>Ce.startDate&&Ce.endDate);if(S.length===0){let Ce=new Date,Ot=new Date(Ce);Ot.setDate(Ot.getDate()-30);let Gt=new Date(Ce);return Gt.setDate(Gt.getDate()+60),{startDate:Ot,endDate:Gt}}let M=S.flatMap(Ce=>[Ce.startDate,Ce.endDate]).filter(Ce=>Ce!==void 0),Y=new Date(Math.min(...M.map(Ce=>Ce.getTime()))),Q=new Date(Math.max(...M.map(Ce=>Ce.getTime()))),ce=$==="day"?7:$==="week"?14:30;return Y.setDate(Y.getDate()-ce),Q.setDate(Q.getDate()+ce),{startDate:Y,endDate:Q}},[Z,$]),am=useCallback(async()=>{if(!R.current)return;let S=await Bd(R.current,{backgroundColor:K.bgPrimary,scale:2}),M=document.createElement("a");M.download="gantt-chart.png",M.href=S.toDataURL("image/png"),M.click();},[K]),rm=useCallback(async()=>{await se.exportToPDF(Z);},[Z]),om=useCallback(async()=>{await se.exportToExcel(Z);},[Z]),nm=useCallback(()=>{let S=se.exportToCSV(Z),M=new Blob([S],{type:"text/csv;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(M),Y.download="gantt-chart.csv",Y.click(),URL.revokeObjectURL(Y.href);},[Z]),sm=useCallback(()=>{let S=se.exportToJSON(Z),M=new Blob([S],{type:"application/json;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(M),Y.download="gantt-chart.json",Y.click(),URL.revokeObjectURL(Y.href);},[Z]),im=useCallback(()=>{se.exportToMSProject(Z,"Gantt Project","project.xml");},[Z]),lm=S=>{S.preventDefault(),Dt(true);};return useEffect(()=>{let S=Qt.current,M=ft.current;if(!S||!M)return;let Y=M.querySelector(".gantt-taskgrid-content"),Q=()=>{let Jt=S.scrollTop;Qe(Jt),Y&&(Y.style.transform=`translateY(-${Jt}px)`);},ce=Jt=>{if(gt&&M){let Ga=M.parentElement?.getBoundingClientRect()?.left||0,cr=Jt.clientX-Ga,dm=280,cm=window.innerWidth-100;cr>=dm&&cr<=cm&&O(cr);}},Ce=()=>{Dt(false);},Ot=M.querySelector(".gantt-grid-scroll")||M,Gt=Jt=>{let Ea=Jt;Ea.deltaY!==0&&(S.scrollTop+=Ea.deltaY,Jt.preventDefault());};return S.addEventListener("scroll",Q),Ot.addEventListener("wheel",Gt,{passive:false}),document.addEventListener("mousemove",ce),document.addEventListener("mouseup",Ce),()=>{S.removeEventListener("scroll",Q),Ot.removeEventListener("wheel",Gt),document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",Ce);}},[gt]),jsx(Wr.Provider,{value:U,children:jsx(In.Provider,{value:Ft,children:jsxs("div",{ref:R,className:"flex flex-col h-full w-full",style:{backgroundColor:K.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsx(jo,{theme:K,timeScale:$,onTimeScaleChange:De,zoom:be,onZoomChange:et,currentTheme:q,onThemeChange:we,rowDensity:ke,onRowDensityChange:_e,showThemeSelector:m,showCreateTaskButton:k,createTaskLabel:h,onCreateTask:b,onExportPNG:n?am:void 0,onExportPDF:n?rm:void 0,onExportExcel:n?om:void 0,onExportCSV:n?nm:void 0,onExportJSON:n?sm:void 0,onExportMSProject:n?im:void 0}),jsxs("div",{ref:ft,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:Me,overflowX:"auto",overflowY:"hidden"},children:jsx(Ko,{tasks:de,theme:K,rowHeight:ht,availableUsers:p,templates:aa,onTaskClick:D,onTaskDblClick:Ri,onTaskContextMenu:A,onTaskToggle:Do,scrollTop:Le,columns:ze,onToggleColumn:jt,onColumnResize:Pr,onTaskUpdate:Sa,onTaskIndent:Ha,onTaskOutdent:dr,onTaskMove:Nn,onMultiTaskDelete:qr,onTaskDuplicate:Bi,onTaskCreate:Xr,onTaskRename:Xc,onCreateSubtask:Sn,onOpenTaskModal:D?S=>D(S):void 0,onDeleteRequest:(S,M)=>nt({taskId:S,taskName:M}),onTaskReparent:Bt})}),jsxs("div",{className:"flex-shrink-0 flex h-full",style:{zIndex:15},children:[jsxs("div",{className:"flex flex-col",style:{backgroundColor:K.bgPrimary},children:[jsxs("div",{className:"flex items-center gap-1 px-1",style:{position:"relative",height:"48px",backgroundColor:K.bgGrid,borderBottom:`1px solid ${K.border}`},children:[jsx(nn,{columns:ze,onToggleColumn:jt,theme:K}),jsx("button",{onClick:()=>_(!Ie),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:K.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Ie&&jsxs("div",{ref:ge,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:K.bgPrimary,border:`1px solid ${K.border}`,color:K.textPrimary},onClick:S=>S.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:K.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:K.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>_(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:K.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:K.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:K.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:K.bgGrid,color:K.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]}),jsx("div",{className:"flex-1"})]}),jsx("div",{className:"cursor-col-resize hover:bg-blue-500/20 transition-colors flex flex-col",style:{width:5,backgroundColor:K.bgPrimary,borderRight:`1px solid ${K.border}`},onMouseDown:lm,children:jsx("div",{style:{height:"48px",backgroundColor:K.bgGrid}})})]}),jsx("div",{ref:Qt,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsx(tn,{tasks:de,theme:K,rowHeight:ht,timeScale:$,startDate:em,endDate:tm,zoom:be,templates:aa,onTaskClick:D,onTaskDblClick:Ri,onTaskContextMenu:Zc,onTaskDateChange:Jc,onDependencyCreate:zi,onDependencyDelete:$i})})]}),ne.task&&jsx(Hr,{isOpen:ne.isOpen,x:ne.x,y:ne.y,theme:K,onClose:()=>le({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=ne.task;if(!S)return [];let M=se.findTaskById(Z,S.id)||S;return M.subtasks&&M.subtasks.length>0?[{id:"addSubtask",label:U.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(M):Sn(M.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:U.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{nt({taskId:M.id,taskName:M.name});}}]:[{id:"edit",label:U.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{T?T(M):Ae(M);}},{id:"addSubtask",label:U.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{w?w(M):Sn(M.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:U.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{B?B(M):Sa(M.id,{status:"todo",progress:0});},disabled:M.status==="todo"},{id:"setInProgress",label:U.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{P?P(M):Sa(M.id,{status:"in-progress"});},disabled:M.status==="in-progress"},{id:"markComplete",label:U.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{Sa(M.id,{status:"completed",progress:100});},disabled:M.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:U.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{if(!M.startDate||!M.endDate){console.warn("Cannot split task without dates");return}let Q=M.startDate.getTime(),ce=M.endDate.getTime(),Ce=Q+(ce-Q)/2,Ot=new Date(Ce);Qc(M,Ot);},disabled:!M.startDate||!M.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:U.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{nt({taskId:M.id,taskName:M.name});}}]})()}),Pe&&jsx(rn,{isOpen:true,onClose:()=>Ae(null),task:Pe,onSubmit:S=>{Sa(Pe.id,S),Ae(null);},mode:"edit",theme:q}),jsx(AnimatePresence,{children:rt&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>nt(null),children:jsxs(motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:S=>S.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:K.bgSecondary,border:`1px solid ${K.border}`},children:[jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${K.border}`},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:"rgba(239, 68, 68, 0.2)"},children:jsx(AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxs("div",{className:"flex-1",children:[jsxs("h3",{className:"text-lg font-semibold",style:{color:K.textPrimary,fontFamily:"Inter, sans-serif"},children:[U.contextMenu?.deleteTask||"Delete Task","?"]}),jsx("p",{className:"text-sm mt-1",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:f==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsx("div",{className:"px-6 py-4",children:jsxs("p",{className:"text-sm leading-relaxed",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},children:[f==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxs("span",{className:"font-semibold",style:{color:K.textPrimary},children:['"',rt.taskName,'"']}),"."]})}),jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:K.bgPrimary,borderTop:`1px solid ${K.border}`},children:[jsx("button",{onClick:()=>nt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:K.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=K.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:f==="es"?"Cancelar":"Cancel"}),jsxs("button",{onClick:()=>{qr([rt.taskId]),nt(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="#EF4444";},children:[jsx(Trash2,{className:"w-4 h-4"}),f==="es"?"Eliminar":"Delete"]})]})]})})}),x?.enabled&&jsx(on,{tasks:Z,theme:K,config:x,onTasksUpdate:ie,onTaskUpdate:Sa,onTaskCreate:S=>{ie(M=>[...M,S]);},onTaskDelete:S=>{qr([S]);},onDependencyCreate:(S,M)=>{let Y=se.findTaskById(Z,S);Y&&zi(Y,M);},onDependencyDelete:$i})]})})})});var Od=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
345
345
 
346
346
  AVAILABLE COMMANDS:
347
347
  1. move_task - Move a task to a different date