@libxai/board 0.17.152 → 0.17.153
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
</Calendars>
|
|
274
274
|
<Tasks>${p}
|
|
275
275
|
</Tasks>
|
|
276
|
-
</Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(m),l.download=a,l.click(),URL.revokeObjectURL(l.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 m=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,l=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;l=Math.max(l,f);}}let i=l+m;r.set(n.id,{es:l,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),d=new Map,c=n=>{if(d.has(n.id))return;let m=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,l=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(l.length>0)for(let v of l){c(v);let f=d.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-m;d.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),l=d.get(n.id);if(m&&l){let i=l.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},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 p=se.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let d=se.calculateDuration(a.endDate,new Date(s));return Math.max(0,d)},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 d of o){if(!d.startDate||!d.endDate)continue;let c=se.calculateDuration(d.startDate,d.endDate),p;a!==void 0?(p=new Date(d.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=se.calculateEndDate(p,c),m=l=>l.map(i=>i.id===d.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=se.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,l=se.findTaskById(e,t);if(!l||!l.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let y=se.getDependentTasks(e,u);for(let x of y){if(!x.startDate||!x.endDate)continue;let b=r.findIndex($=>$.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/m,P=(g-n)/m*s,C=P+v*s,B=Math.max(D*s,s),T=c+b*d+12;p.push({taskId:x.id,taskName:x.name,originalX:P,previewX:C,width:B,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),p},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 d=new Date(a);d.setDate(d.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:c}],n=m=>m.map(l=>l.id===o.id?{...l,endDate:c,segments:p}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function tn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=react.useState([]),[x,b]=react.useState(null),[g,k]=react.useState(null),D=react.useCallback(F=>{b(F);},[]),h=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),P=r==="day"?60:r==="week"?20:8,C=h*P*d,B=F=>{let L=new Date(Date.UTC(F.getFullYear(),F.getMonth(),F.getDate())),R=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-R);let E=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-E.getTime())/864e5+1)/7)},T=F=>{let L=F.getDay();return L===0||L===6},$=react.useCallback(F=>{let L=Math.round(F/(P*d)),R=new Date(o);return R.setDate(R.getDate()+L),R},[o,P,d]),W=react.useCallback((F,L)=>{if(L.startDate&&L.endDate)return;let R=F.currentTarget.ownerSVGElement;if(!R)return;let E=R.createSVGPoint();E.x=F.clientX,E.y=F.clientY;let j=E.matrixTransform(R.getScreenCTM()?.inverse()),oe=$(j.x),q=new Date(oe);q.setDate(q.getDate()+1),l?.(L,oe,q);},[$,l]),I=react.useMemo(()=>{let F=j=>j.map(oe=>{if(oe.subtasks&&oe.subtasks.length>0){let q=F(oe.subtasks),De=q.filter(M=>M.startDate&&M.endDate);if(De.length>0){let M=De.map(Ee=>Ee.startDate.getTime()),ee=De.map(Ee=>Ee.endDate.getTime()),Y=new Date(Math.min(...M)),Ne=new Date(Math.max(...ee));return {...oe,subtasks:q,startDate:Y,endDate:Ne}}return {...oe,subtasks:q}}return oe}),L=(j,oe=[])=>{for(let q of j)oe.push(q),q.subtasks&&q.subtasks.length>0&&(q.isExpanded===void 0||q.isExpanded)&&L(q.subtasks,oe);return oe},R=F(e);return L(R)},[e]),G=react.useCallback(F=>{if(!F.startDate||!F.endDate)return {x:0,width:0};let L=F.startDate.getTime(),R=F.endDate.getTime(),E=o.getTime(),j=(L-E)/(1e3*60*60*24),oe=(R-L)/(1e3*60*60*24),q=j*P*d,De=Math.max(P*d,40),M=Math.max(oe*P*d,De);return {x:q,width:M}},[o,P,d]),te=react.useMemo(()=>I.filter(F=>F.startDate&&F.endDate).map(F=>{let{x:L,width:R}=G(F),j=I.findIndex(oe=>oe.id===F.id)*a+12;return {id:F.id,x:L,y:j,width:R,height:32}}),[I,G]),fe=react.useCallback((F,L,R)=>{if(!R||L===0){y([]);return}let E=se.calculateCascadePreview(e,F,L,I,o,P*d,a,48);y(E);},[e,I,o,P,d,a,48]),H=react.useMemo(()=>{let F=[],L=new Date(o);for(;L<=s;){let j=(L.getTime()-o.getTime())/864e5*P*d;if(r==="day")F.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:j}),L.setDate(L.getDate()+1);else if(r==="week"){let oe=B(L);F.push({date:new Date(L),label:`Week ${oe}`,x:j}),L.setDate(L.getDate()+7);}else F.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:j}),L.setMonth(L.getMonth()+1);}return F},[o,s,r,P,d]),Me=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*P*d,[o,P,d]),Re=Math.max(I.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.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:jsxRuntime.jsxs("svg",{width:Math.max(C,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(C,1e3),height:48,fill:t.bgGrid}),H.map((F,L)=>jsxRuntime.jsxs("g",{children:[L>0&&jsxRuntime.jsx("line",{x1:F.x,y1:0,x2:F.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:F.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:F.label})]},`header-${L}`)),Me>=0&&Me<=C&&jsxRuntime.jsx("circle",{cx:Me,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(C,1e3),height:Re,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:"shadow",children:jsxRuntime.jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsxRuntime.jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsxRuntime.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(C,1e3),height:Re,fill:t.bgPrimary}),H.map((F,L)=>{let R=H[L+1]?.x||C,E=T(F.date);return jsxRuntime.jsxs("g",{children:[E&&jsxRuntime.jsx("rect",{x:F.x,y:0,width:R-F.x,height:I.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsxRuntime.jsx("line",{x1:F.x,y1:0,x2:F.x,y2:I.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),Me>=0&&Me<=C&&jsxRuntime.jsx("line",{x1:Me,y1:0,x2:Me,y2:I.length*a,stroke:t.today,strokeWidth:2,opacity:1}),I.map((F,L)=>{let R=F.startDate&&F.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:L*a,width:C,height:a,fill:L%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${F.id}`),!R&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:L*a,width:C,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>W(E,F),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-${F.id}`),jsxRuntime.jsx("text",{x:Me>0?Me: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-${F.id}`)]})]},`row-group-${F.id}`)}),I.map((F,L)=>!F.dependencies||F.dependencies.length===0||!F.startDate||!F.endDate?null:F.dependencies.map(R=>{let E=I.find(De=>De.id===R);if(!E||!E.startDate||!E.endDate)return null;let j=I.findIndex(De=>De.id===R),oe=G(E),q=G(F);return jsxRuntime.jsx(Jo,{x1:oe.x+oe.width,y1:j*a+a/2,x2:q.x,y2:L*a+a/2,theme:t},`dep-${R}-${F.id}`)})),I.map((F,L)=>{if(!F.startDate||!F.endDate)return null;let{x:R,width:E}=G(F),j=L*a+12,oe=F.subtasks&&F.subtasks.length>0&&!F.isMilestone;return F.isMilestone?jsxRuntime.jsx(Qo,{task:F,x:R+E/2,y:j+16,theme:t,onClick:p},F.id):oe?jsxRuntime.jsxs("g",{onClick:()=>p?.(F),onContextMenu:q=>{q.preventDefault(),q.stopPropagation(),m?.(F,q);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:R,y:j,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:R,y1:j,x2:R+E,y2:j,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:R,y1:j,x2:R,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:R+E,y1:j,x2:R+E,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:R,y1:j+32,x2:R+E,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsxRuntime.jsx("text",{x:R+12,y:j+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:F.name})]},F.id):jsxRuntime.jsx(Yo,{task:F,x:R,y:j,width:E,theme:t,dayWidth:P*d,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:l,onDependencyCreate:i,allTaskPositions:te,onDragMove:fe,onHoverChange:D},F.id)}),I.map((F,L)=>!F.dependencies||F.dependencies.length===0||!F.startDate||!F.endDate?null:F.dependencies.map(R=>{let E=I.find(Fe=>Fe.id===R);if(!E||!E.startDate||!E.endDate)return null;let j=I.findIndex(Fe=>Fe.id===R),oe=G(E),q=G(F),De=oe.x+oe.width,M=j*a+a/2,ee=q.x,Y=L*a+a/2,Ne=ee-De,Ee=De+Ne/2,_e=Fe=>{let it=(1-Fe)*(1-Fe)*(1-Fe)*De+3*(1-Fe)*(1-Fe)*Fe*Ee+3*(1-Fe)*Fe*Fe*Ee+Fe*Fe*Fe*ee,Ze=(1-Fe)*(1-Fe)*(1-Fe)*M+3*(1-Fe)*(1-Fe)*Fe*M+3*(1-Fe)*Fe*Fe*Y+Fe*Fe*Fe*Y;return {x:it,y:Ze}},lt=_e(.15),Se=_e(.5),ot=_e(.85),gt=`M ${lt.x} ${lt.y} Q ${Se.x} ${Se.y} ${ot.x} ${ot.y}`;return g&&g.x1===De&&g.y1===M&&g.x2===ee&&g.y2===Y?null:jsxRuntime.jsx("path",{d:gt,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{k({x1:De,y1:M,x2:ee,y2:Y,onDelete:()=>u?.(F.id,R)});}},`dep-hover-${R}-${F.id}`)})),f.map(F=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:F.previewX,y:F.y-48,width:F.width,height:32,rx:8,fill:F.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(F.daysDelta)>0&&jsxRuntime.jsx("text",{x:F.previewX+F.width/2,y:F.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:F.daysDelta>0?`+${F.daysDelta}d`:`${F.daysDelta}d`})]},`cascade-preview-${F.taskId}`)),g&&(()=>{let{x1:F,y1:L,x2:R,y2:E,onDelete:j}=g,oe=R-F,q=E-L,De=F+oe/2,M=(L+E)/2,ee=`M ${F} ${L} C ${De} ${L}, ${De} ${E}, ${R} ${E}`,Y=6,Ne=Math.atan2(q,oe),Ee=R-Y*Math.cos(Ne-Math.PI/6),_e=E-Y*Math.sin(Ne-Math.PI/6),lt=R-Y*Math.cos(Ne+Math.PI/6),Se=E-Y*Math.sin(Ne+Math.PI/6),ot=t.dependency,gt="#f87171";return jsxRuntime.jsxs("g",{onMouseLeave:()=>k(null),children:[jsxRuntime.jsx("path",{d:ee,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsxRuntime.jsx("circle",{cx:De,cy:M,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:ee,fill:"none",stroke:ot,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:ee,fill:"none",stroke:ot,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${R} ${E} L ${Ee} ${_e} M ${R} ${E} L ${lt} ${Se}`,fill:"none",stroke:ot,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:R,cy:E,r:4,fill:ot,opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:Fe=>{Fe.stopPropagation(),k(null),j();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:De,cy:M,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:gt,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsxRuntime.jsx("line",{x1:De-3,y1:M-3,x2:De+3,y2:M+3,stroke:gt,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:De+3,y1:M-3,x2:De-3,y2:M+3,stroke:gt,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),x&&jsxRuntime.jsx(dd,{tooltipData:x,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 As=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Is=[{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:d=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[]}){let m=[...As,...n.filter(M=>!As.some(ee=>ee.id===M.id))],l=He[p]||He.dark,[i,u]=react.useState(false),[v,f]=react.useState(false),[y,x]=react.useState(false),[b,g]=react.useState(false),[k,D]=react.useState(null),[h,P]=react.useState(new Date),[C,B]=react.useState({top:0,left:0}),[T,$]=react.useState(false),W=react.useRef(null),I=react.useRef(null),G=react.useRef(null),te=react.useRef(null),fe=react.useRef(null),[H,Me]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[Re,F]=react.useState({});react.useEffect(()=>{a?(Me({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||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&$(true)):(Me({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),$(false));},[a,e]),react.useEffect(()=>{let M=ee=>{W.current&&!W.current.contains(ee.target)&&u(false),I.current&&!I.current.contains(ee.target)&&f(false),G.current&&!G.current.contains(ee.target)&&x(false),te.current&&!te.current.contains(ee.target)&&g(false);};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);let L=()=>{let M={};return H.name.trim()||(M.name="El nombre es requerido"),H.startDate&&H.endDate&&H.startDate>H.endDate&&(M.endDate="La fecha de fin debe ser posterior a la de inicio"),F(M),Object.keys(M).length===0},R=async M=>{if(M.preventDefault(),!!L())try{await s(H),t();}catch(ee){console.error("Error submitting task:",ee);}},E=(M,ee)=>{Me(Y=>{let Ne={...Y,[M]:ee};if(M==="status"){let Ee=ee;Ee==="todo"?Ne.progress=0:Ee==="in-progress"?(Y.progress===0||Y.progress===100)&&(Ne.progress=50):Ee==="completed"||Ee==="closed"?Ne.progress=100:(Ee==="in-review"||Ee==="review")&&(Ne.progress=75);}if(M==="progress"){let Ee=typeof ee=="number"?ee:parseInt(ee,10);Ee===100&&Y.status!=="completed"?Ne.status="completed":Ee>0&&Ee<100&&Y.status==="todo"?Ne.status="in-progress":Ee===0&&Y.status!=="todo"&&(Ne.status="todo");}return Ne}),Re[M]&&F(Y=>{let Ne={...Y};return delete Ne[M],Ne});},j=m.find(M=>M.id===H.status)??As[0],oe=Is.find(M=>M.id===H.priority)??Is[1],q=an.find(M=>M.value===H.color)??an[0],De={backgroundColor:l.bgSecondary,border:`1px solid ${l.borderLight}`,color:l.textPrimary};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.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:jsxRuntime.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:M=>M.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${l.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:j.color||l.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:l.textTertiary},onMouseEnter:M=>{M.currentTarget.style.backgroundColor=l.hoverBg,M.currentTarget.style.color=l.textPrimary;},onMouseLeave:M=>{M.currentTarget.style.backgroundColor="transparent",M.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:R,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxRuntime.jsxs("div",{className:"p-5 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{type:"text",value:H.name,onChange:M=>E("name",M.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:l.textPrimary},placeholder:"Nombre de la tarea",disabled:d,autoFocus:true}),Re.name&&jsxRuntime.jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-3 h-3"}),Re.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:H.description||"",onChange:M=>E("description",M.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:l.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:d})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:W,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&u(!i),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...De,borderColor:j.color,backgroundColor:`${j.color}15`},disabled:d,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:j.color}}),jsxRuntime.jsx("span",{style:{color:j.color},children:j.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:j.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsx(framerMotion.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:l.bgPrimary,border:`1px solid ${l.border}`},children:m.map(M=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:ee=>ee.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ee=>ee.currentTarget.style.backgroundColor="transparent",onClick:()=>{E("status",M.id),u(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:M.color}}),M.title,H.status===M.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},M.id))})})]}),jsxRuntime.jsxs("div",{ref:I,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&f(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:De,disabled:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:oe.color}}),jsxRuntime.jsx("span",{children:oe.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:v&&jsxRuntime.jsx(framerMotion.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:l.bgPrimary,border:`1px solid ${l.border}`},children:Is.map(M=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:ee=>ee.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ee=>ee.currentTarget.style.backgroundColor="transparent",onClick:()=>{E("priority",M.id),f(false);},children:[jsxRuntime.jsx("span",{children:M.icon}),M.label,H.priority===M.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},M.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:G,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&x(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:De,disabled:d,children:[H.assignees&&H.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:H.assignees.slice(0,3).map((M,ee)=>jsxRuntime.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:M.color||l.accent,borderColor:l.bgSecondary},children:M.initials},ee))}),H.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:l.textTertiary},children:["+",H.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:l.textTertiary}}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:y&&jsxRuntime.jsx(framerMotion.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:l.bgPrimary,border:`1px solid ${l.border}`},children:o.map(M=>{let ee=H.assignees?.some(Y=>Y.name===M.name);return jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:Y=>Y.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:Y=>Y.currentTarget.style.backgroundColor="transparent",onClick:()=>{let Y=ee?(H.assignees||[]).filter(Ne=>Ne.name!==M.name):[...H.assignees||[],{name:M.name,avatar:M.avatar,initials:M.name.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),color:l.accent}];E("assignees",Y);},children:[jsxRuntime.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:l.accent},children:M.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:M.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:ee&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})})]},M.id)})})})]}),jsxRuntime.jsxs("div",{ref:te,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&g(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:De,disabled:d,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:H.color}}),jsxRuntime.jsx("span",{children:q.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"absolute left-0 top-full mt-1.5 z-50 rounded-lg",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:jsxRuntime.jsx("div",{style:{padding:"14px 18px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 16px)",gap:"14px"},children:an.slice(0,16).map(M=>{let ee=H.color===M.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>{E("color",M.value),g(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:M.value,outline:ee?`2px solid ${M.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:M.name},M.value)})})})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{ref:fe,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!d&&!H.isMilestone)if(k==="start")D(null);else {if(fe.current){let M=fe.current.getBoundingClientRect(),ee=window.innerHeight,Y=320,Ee=ee-M.bottom<Y?M.top-Y-8:M.bottom+8;B({top:Ee,left:M.left});}D("start"),P(H.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...De,opacity:H.isMilestone?.5:1,cursor:H.isMilestone?"not-allowed":"pointer"},disabled:d||H.isMilestone,children:H.startDate?H.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!d&&!H.isMilestone)if(k==="end")D(null);else {if(fe.current){let M=fe.current.getBoundingClientRect(),ee=window.innerHeight,Y=320,Ee=ee-M.bottom<Y?M.top-Y-8:M.bottom+8;B({top:Ee,left:M.left});}D("end"),P(H.endDate||H.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...De,opacity:H.isMilestone?.5:1,cursor:H.isMilestone?"not-allowed":"pointer"},disabled:d||H.isMilestone,children:H.endDate?H.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&jsxRuntime.jsxs(Xe,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>D(null)}),jsxRuntime.jsxs(framerMotion.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:`${C.top}px`,left:`${C.left}px`,zIndex:99999,backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:M=>M.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let M=new Date,ee=new Date(M);ee.setDate(M.getDate()+1);let Y=new Date(M);Y.setDate(M.getDate()+7);let Ne=new Date(M);return Ne.setDate(M.getDate()+14),[{label:"Hoy",date:M},{label:"Ma\xF1ana",date:ee},{label:"Pr\xF3xima semana",date:Y},{label:"2 semanas",date:Ne}].map((_e,lt)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:Se=>Se.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:Se=>Se.currentTarget.style.backgroundColor="transparent",onClick:()=>{k==="start"?(E("startDate",_e.date),(!H.endDate||_e.date>H.endDate)&&E("endDate",_e.date),D("end")):(E("endDate",_e.date),(!H.startDate||_e.date<H.startDate)&&E("startDate",_e.date),D(null));},children:_e.label},lt))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.border}`,margin:"0.5rem 0"}}),jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:M=>M.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:M=>M.currentTarget.style.backgroundColor="transparent",onClick:()=>{E("startDate",void 0),E("endDate",void 0),D(null);},children:"Borrar fechas"})]}),jsxRuntime.jsxs("div",{className:"p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>P(new Date(h.getFullYear(),h.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:l.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textPrimary},children:h.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>P(new Date(h.getFullYear(),h.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:l.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((M,ee)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:M},ee))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let M=h.getFullYear(),ee=h.getMonth(),Y=new Date(M,ee,1).getDay(),Ne=new Date(M,ee+1,0).getDate(),Ee=new Date,_e=[];for(let Se=Y-1;Se>=0;Se--)_e.push({day:new Date(M,ee,-Se).getDate(),date:new Date(M,ee-1,new Date(M,ee,-Se).getDate()),isCurrentMonth:false});for(let Se=1;Se<=Ne;Se++)_e.push({day:Se,date:new Date(M,ee,Se),isCurrentMonth:true});let lt=42-_e.length;for(let Se=1;Se<=lt;Se++)_e.push({day:Se,date:new Date(M,ee+1,Se),isCurrentMonth:false});return _e.map((Se,ot)=>{let gt=Se.date.toDateString()===Ee.toDateString(),ft=H.startDate?.toDateString()===Se.date.toDateString(),Fe=H.endDate?.toDateString()===Se.date.toDateString(),it=H.startDate&&H.endDate&&Se.date>=H.startDate&&Se.date<=H.endDate;return jsxRuntime.jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Se.isCurrentMonth?ft||Fe?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:ft?"#3B82F6":Fe?"#7C3AED":it?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:gt&&!ft&&!Fe?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{k==="start"?(E("startDate",Se.date),H.endDate&&Se.date>H.endDate&&E("endDate",Se.date),D("end")):(E("endDate",Se.date),H.startDate&&Se.date<H.startDate&&E("startDate",Se.date),D(null));},children:Se.day},ot)})})()})]})]})]})})]}),Re.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:Re.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:H.progress,onChange:M=>E("progress",parseInt(M.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"},disabled:d}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"}20`,color:H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"},children:[H.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>$(!T),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${T?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:T&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxRuntime.jsxs("div",{className:"pt-3 space-y-3",children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:H.isMilestone,onChange:M=>E("isMilestone",M.target.checked),className:"w-4 h-4 rounded",style:{accentColor:l.accent},disabled:d}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:l.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:l.bgSecondary},children:r.filter(M=>M.id!==a?.id).map(M=>{let ee=H.dependencies?.includes(M.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let Y=ee?(H.dependencies||[]).filter(Ne=>Ne!==M.id):[...H.dependencies||[],M.id];E("dependencies",Y);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ee?`${l.accent}30`:l.bgPrimary,color:ee?l.accent:l.textSecondary,border:`1px solid ${ee?l.accent:l.borderLight}`},disabled:d,children:M.name},M.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${l.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:l.textSecondary},onMouseEnter:M=>M.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:M=>M.currentTarget.style.backgroundColor="transparent",disabled:d,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:l.accent,color:"#FFF"},onMouseEnter:M=>!d&&(M.currentTarget.style.opacity="0.9"),onMouseLeave:M=>!d&&(M.currentTarget.style.opacity="1"),children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var $g=['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"'],gd=()=>jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.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"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),zg=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),Ug=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),Wg=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M5 12h14"})}),Gg=()=>jsxRuntime.jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsxRuntime.jsx(framerMotion.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:d,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=react.useState(false),[l,i]=react.useState(false),[u,v]=react.useState([]),[f,y]=react.useState(""),[x,b]=react.useState(false),[g,k]=react.useState(true),D=react.useRef(null),h=react.useRef(null),P=react.useRef(null),{enabled:C=true,placeholder:B='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:$,suggestions:W=$g,maxHistory:I=50,persistHistory:G}=a,te=G?.storageKey||"gantt-ai-history",fe=G?.maxMessages??5;react.useEffect(()=>{if(G?.enabled)try{let R=localStorage.getItem(te);if(R){let j=JSON.parse(R).map(oe=>({...oe,timestamp:new Date(oe.timestamp)}));v(j.slice(-fe));}}catch(R){console.warn("[GanttAIAssistant] Failed to load persisted history:",R);}},[G?.enabled,te,fe]),react.useEffect(()=>{if(G?.enabled&&u.length>0)try{let R=u.filter(E=>!E.isLoading).slice(-fe);localStorage.setItem(te,JSON.stringify(R));}catch(R){console.warn("[GanttAIAssistant] Failed to persist history:",R);}},[u,G?.enabled,te,fe]),react.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let H=react.useCallback(R=>{if(R.success)switch(R.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":R.taskId&&R.updates&&o?.(R.taskId,R.updates);break;case "create_task":R.newTask&&s?.(R.newTask);break;case "delete_task":R.taskId&&d?.(R.taskId);break;case "link_tasks":R.dependencyFrom&&R.dependencyTo&&c?.(R.dependencyFrom,R.dependencyTo);break;case "unlink_tasks":R.taskId&&R.dependencyFrom&&p?.(R.taskId,R.dependencyFrom);break}},[o,s,d,c,p]),Me=react.useCallback(async R=>{if(!R.trim()||x)return;let E={id:`user-${Date.now()}`,role:"user",content:R,timestamp:new Date};v(oe=>[...oe.slice(-(I-1)),E]),y(""),k(false),b(true);let j={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(oe=>[...oe,j]);try{if($){let oe=await $(R,e);v(q=>{let De=q.filter(ee=>!ee.isLoading),M={id:`assistant-${Date.now()}`,role:"assistant",content:oe.message,timestamp:new Date,command:oe};return [...De,M]}),H(oe);}else v(oe=>[...oe.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(oe){v(q=>[...q.filter(M=>!M.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${oe instanceof Error?oe.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,I,$,e,H]),Re=R=>{R.preventDefault(),Me(f);},F=R=>{y(R),D.current?.focus();};if(react.useEffect(()=>{let R=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(j=>!j),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[n]),react.useEffect(()=>{if(!n)return;let R=j=>{let oe=j.target;P.current&&!P.current.contains(oe)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",R);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",R);}},[n]),!C)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 jsxRuntime.jsxs(Xe,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&jsxRuntime.jsxs(framerMotion.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:()=>m(true),children:[jsxRuntime.jsx(gd,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.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"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:P,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(gd,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(R=>!R),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Wg,{})}),jsxRuntime.jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Ug,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!l&&jsxRuntime.jsxs(framerMotion.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:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&g&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:W.slice(0,4).map((R,E)=>jsxRuntime.jsx("button",{onClick:()=>F(R),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:R.length>30?R.slice(0,30)+"...":R},E))})]}),u.map(R=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${R.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${R.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:R.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:R.role==="user"?"white":t.textPrimary},children:[R.isLoading?jsxRuntime.jsx(Gg,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:R.content}),R.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:R.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:R.command.success?"#10B981":"#EF4444"},children:[R.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:R.command.type.replace(/_/g," ")})]})]})},R.id)),jsxRuntime.jsx("div",{ref:h})]}),jsxRuntime.jsxs("form",{onSubmit:Re,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:D,type:"text",value:f,onChange:R=>y(R.target.value),placeholder:B,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!f.trim()||x,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:jsxRuntime.jsx(zg,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function fd(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,m=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!m)return {...l,present:i};let u=[...l.past,l.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),d=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],l=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:m,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:l}});},[]),p=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:d,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function bd({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=d=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?d.metaKey:d.ctrlKey;if(p&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!c&&p&&d.key==="y"){d.preventDefault(),t();return}if(c&&p&&d.shiftKey&&d.key==="z"){d.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var jg={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 hd(e){return {...jg,...e}}var Qg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},xd=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:l,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:f,showCreateTaskButton:y=false,createTaskLabel:x,onCreateTask:b,onThemeChange:g,onTaskClick:k,onTaskDblClick:D,onTaskContextMenu:h,onTaskUpdate:P,onProgressChange:C,onTaskEdit:B,onTaskAddSubtask:T,onTaskMarkIncomplete:$,onTaskSetInProgress:W,onDependencyCreate:I,onDependencyDelete:G,onBeforeTaskAdd:te,onAfterTaskAdd:fe,onBeforeTaskUpdate:H,onAfterTaskUpdate:Me,onBeforeTaskDelete:Re,onAfterTaskDelete:F}=a,R=react.useContext(Wo)?.theme,[E,j]=react.useState(R||s||"dark"),[oe,q]=react.useState(d),[De,M]=react.useState(c),[ee,Y]=react.useState(1),[Ne,Ee]=react.useState(0),[_e,lt]=react.useState(false),[Se,ot]=react.useState(null),[gt,ft]=react.useState({isOpen:false,x:0,y:0,task:null}),[Fe,it]=react.useState(null),[Ze,bt]=react.useState(null);react.useEffect(()=>{R&&R!==E&&j(R);},[R]),react.useEffect(()=>{s&&s!==E&&j(s);},[s]);let Qt=react.useCallback(S=>{j(S),g?.(S);},[g]),{state:xe,setState:O,undo:we,redo:Ve,canUndo:Ge,canRedo:kt,clearHistory:J}=fd(t,50);react.useEffect(()=>{O(t);},[t,O]);let Q=react.useRef(t),ve=react.useRef(true);react.useEffect(()=>{if(ve.current){ve.current=false,Q.current=xe;return}if(!r)return;let S=JSON.stringify(Q.current),z=JSON.stringify(xe);S!==z&&(Q.current=xe,r(xe));},[xe,r]);let be=react.useMemo(()=>fs(v,f),[v,f]),ae=react.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}],[]),[Ce,ue]=react.useState(()=>ae(be));react.useEffect(()=>{ue(S=>S.map(z=>({...z,label:be.columns[z.id==="name"?"taskName":z.id]||z.label})));},[be]);let ke=react.useMemo(()=>{let S=Ce.filter(ne=>ne.visible),z=S.some(ne=>ne.id!=="name");return S.reduce((ne,he)=>ne+he.width,0)+(z?20:0)},[Ce]);react.useEffect(()=>{Se!==null&&Se>ke&&(Ce.filter(K=>K.visible).some(K=>K.id!=="name")||ot(null));},[Ce,ke,Se]);let ge=react.useMemo(()=>Se!==null?Math.max(280,Se,ke):Math.max(280,ke),[Se,ke]),Ae=react.useRef(null),pe=react.useRef(null),Ie=react.useRef(null),U=react.useMemo(()=>Bl(E),[E]),N=react.useMemo(()=>({theme:U,themeName:E}),[U,E]),X=react.useMemo(()=>hd(l),[l]),me=react.useMemo(()=>{if(!i)return xe;let S=se.calculateCriticalPath(xe),z=K=>K.map(ne=>({...ne,isCriticalPath:S.includes(ne.id),subtasks:ne.subtasks?z(ne.subtasks):void 0}));return z(xe)},[xe,i]),Te=Qg(De);bd({undo:we,redo:Ve,canUndo:Ge,canRedo:kt,enabled:true}),react.useImperativeHandle(o,()=>({getTask:S=>se.findTaskById(xe,S),addTask:(S,z)=>{O(K=>{if(!z)return [...K,{...S,level:0}];let ne=he=>he.map(Pe=>Pe.id===z?{...Pe,subtasks:[...Pe.subtasks||[],{...S,parentId:z,level:(Pe.level||0)+1}],isExpanded:true}:Pe.subtasks?{...Pe,subtasks:ne(Pe.subtasks)}:Pe);return ne(K)});},updateTask:(S,z)=>{O(K=>{let ne=he=>he.map(Pe=>Pe.id===S?{...Pe,...z}:Pe.subtasks?{...Pe,subtasks:ne(Pe.subtasks)}:Pe);return ne(K)});},deleteTask:S=>{O(z=>{let K=ne=>ne.filter(he=>he.id===S?false:(he.subtasks&&(he.subtasks=K(he.subtasks)),true));return K(z)});},deleteTasks:S=>{O(z=>ws(z,S));},duplicateTask:S=>{O(z=>Cs(z,[S]));},splitTask:(S,z,K=3)=>{O(ne=>se.splitTask(ne,S,z,K));},calculateEndDate:se.calculateEndDate,calculateDuration:se.calculateDuration,validateDependency:(S,z)=>!se.validateDependencies(xe,S,z),getAllTasks:()=>se.flattenTasks(xe),getTasksByStatus:S=>se.flattenTasks(xe).filter(z=>z.status===S),getTasksByParent:S=>S?se.findTaskById(xe,S)?.subtasks||[]:xe.filter(K=>!K.parentId),getCriticalPath:()=>se.flattenTasks(xe).filter(S=>S.isCriticalPath),indentTask:S=>{O(z=>vs(z,[S]));},outdentTask:S=>{O(z=>xs(z,[S]));},moveTask:(S,z)=>{O(K=>ks(K,[S],z));},createSubtask:async S=>{let{tasks:z,newTask:K}=Ns(xe,S);if(te){let ne=te({...K,parentId:S});if((ne instanceof Promise?await ne:ne)===false)return}O(z),fe&&fe({...K,parentId:S});},scrollToTask:S=>{let K=se.flattenTasks(xe).findIndex(ne=>ne.id===S);if(K!==-1&&Ae.current){let ne=K*Te;Ae.current.scrollTo({top:ne,behavior:"smooth"}),pe.current&&pe.current.scrollTo({top:ne,behavior:"smooth"});}},highlightTask:(S,z=2e3)=>{},expandTask:S=>{O(z=>{let K=ne=>ne.map(he=>he.id===S?{...he,isExpanded:true}:he.subtasks?{...he,subtasks:K(he.subtasks)}:he);return K(z)});},collapseTask:S=>{O(z=>{let K=ne=>ne.map(he=>he.id===S?{...he,isExpanded:false}:he.subtasks?{...he,subtasks:K(he.subtasks)}:he);return K(z)});},expandAll:()=>{O(S=>{let z=K=>K.map(ne=>({...ne,isExpanded:true,subtasks:ne.subtasks?z(ne.subtasks):void 0}));return z(S)});},collapseAll:()=>{O(S=>{let z=K=>K.map(ne=>({...ne,isExpanded:false,subtasks:ne.subtasks?z(ne.subtasks):void 0}));return z(S)});},undo:we,redo:Ve,canUndo:()=>Ge,canRedo:()=>kt,clearHistory:J,exportToPNG:async()=>{if(!Ie.current)throw new Error("Gantt container not found");let S=await vd__default.default(Ie.current,{backgroundColor:U.bgPrimary,scale:2});return new Promise((z,K)=>{S.toBlob(ne=>{ne?z(ne):K(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await se.exportToPDF(xe,S);},exportToExcel:async S=>{await se.exportToExcel(xe,S);},exportToJSON:()=>se.exportToJSON(xe),exportToCSV:()=>se.exportToCSV(xe),importFromJSON:S=>{let z=se.importFromJSON(S);O(z);},getTasks:()=>xe,refresh:()=>{O(S=>[...S]);},clearAll:()=>{O([]);}}),[xe,we,Ve,Ge,kt,J,U,Te]);let At=react.useCallback(S=>{ue(z=>z.map(K=>K.id===S?{...K,visible:!K.visible}:K));},[]),Et=react.useCallback((S,z)=>{ue(K=>K.map(ne=>{if(ne.id!==S)return ne;let he=ne.minWidth??100,Pe=ne.maxWidth??800,$t=Math.max(he,Math.min(Pe,z));return {...ne,width:$t}}));},[]),It=react.useCallback(S=>{O(z=>Ds(z,S)),a.onTaskToggleExpand?.(S);},[a]),Xt=react.useCallback((S,z)=>{if(H&&H(S,z)===false)return;let ne=se.findTaskById(xe,S)?.progress,he=$t=>$t.map(zt=>zt.id===S?{...zt,...z}:zt.subtasks?{...zt,subtasks:he(zt.subtasks)}:zt);O(he(xe));let Pe=se.findTaskById(he(xe),S);Pe&&(P?.(Pe),Me?.(Pe),z.progress!==void 0&&ne!==void 0&&z.progress!==ne&&C?.(S,ne,z.progress));},[xe,P,H,Me,C]),ht=react.useCallback(S=>{S.length!==0&&(O(z=>vs(z,S)),a.onTaskIndent?.(S[0]));},[a]),Dr=react.useCallback(S=>{S.length!==0&&(O(z=>xs(z,S)),a.onTaskOutdent?.(S[0]));},[a]),or=react.useCallback((S,z,K)=>{O(ne=>td(ne,S,z,K)),a.onTaskReparent?.(S,z,K);},[a]),_a=react.useCallback((S,z)=>{S.length!==0&&(O(K=>ks(K,S,z)),a.onTaskMove?.(S[0],z));},[a]),nr=react.useCallback(async S=>{let z=[];for(let K of S)Re&&await Promise.resolve(Re(K))===false||z.push(K);z.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(z):(O(K=>ws(K,z)),z.forEach(K=>a.onTaskDelete?.(K))),F&&z.forEach(K=>F(K)));},[a,Re,F]),le=react.useCallback(S=>{O(z=>Cs(z,S)),S.forEach(z=>a.onTaskDuplicate?.(z));},[a]),yt=react.useCallback((S,z)=>{O(K=>{let{tasks:ne,newTask:he}=ed(K,S,z);return te&&te(he)===false?K:(a.onTaskCreate?.(he.parentId,he.position||0),fe?.(he),ne)});},[a,te,fe]),Kt=react.useCallback((S,z)=>{O(K=>Ts(K,S,z)),a.onTaskRename?.(S,z);},[a]),Va=react.useCallback(S=>{O(z=>{let{tasks:K}=Ns(z,S);return a.onTaskCreate?.(S,0),K});},[a]),wo=react.useCallback((S,z,K)=>{let ne=S.startDate?Math.round((z.getTime()-S.startDate.getTime())/864e5):0,he=zt=>zt.map(Yt=>Yt.id===S.id?{...Yt,startDate:z,endDate:K,...S.segments&&{segments:S.segments}}:Yt.subtasks?{...Yt,subtasks:he(Yt.subtasks)}:Yt),Pe=he(xe);Pe=se.autoScheduleDependents(Pe,S.id,ne),O(Pe);let $t={...S,startDate:z,endDate:K};P?.($t);},[xe,P]),Nr=react.useCallback((S,z)=>{h?.(S,z),ft({isOpen:true,x:z.clientX,y:z.clientY,task:S});},[h]),Ba=react.useCallback((S,z)=>{let K=se.splitTask(xe,S.id,z);O(K),ft({isOpen:false,x:0,y:0,task:null});},[xe]),ja=react.useCallback(S=>{D?.(S),B||it(S);},[D,B]),wt=react.useCallback((S,z,K)=>{let ne=new Map,he=va=>{va.forEach(Ra=>{Ra.dependencies&&ne.set(Ra.id,Ra.dependencies),Ra.subtasks&&he(Ra.subtasks);});};he(K);let Pe=ne.get(z)||[];ne.set(z,[...Pe,S]);let $t=new Set,zt=new Set,Yt=va=>{if(!$t.has(va)){$t.add(va),zt.add(va);let Ra=ne.get(va)||[];for(let sr of Ra){if(!$t.has(sr)&&Yt(sr))return true;if(zt.has(sr))return true}}return zt.delete(va),false};return Yt(z)},[]),Co=react.useCallback((S,z)=>{if(wt(S.id,z,xe)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
276
|
+
</Project>`,m=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(m),l.download=a,l.click(),URL.revokeObjectURL(l.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 m=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,l=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;l=Math.max(l,f);}}let i=l+m;r.set(n.id,{es:l,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),d=new Map,c=n=>{if(d.has(n.id))return;let m=n.startDate&&n.endDate?se.calculateDuration(n.startDate,n.endDate):0,l=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(l.length>0)for(let v of l){c(v);let f=d.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-m;d.set(n.id,{ls:u,lf:i});};a.forEach(c);let p=[];for(let n of a){let m=r.get(n.id),l=d.get(n.id);if(m&&l){let i=l.ls-m.es;Math.abs(i)<.01&&p.push(n.id);}}return p},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 p=se.calculateDuration(a.endDate,c);return Math.max(0,p)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,p)=>c-p)[0];if(!s)return null;let d=se.calculateDuration(a.endDate,new Date(s));return Math.max(0,d)},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 d of o){if(!d.startDate||!d.endDate)continue;let c=se.calculateDuration(d.startDate,d.endDate),p;a!==void 0?(p=new Date(d.startDate),p.setDate(p.getDate()+a)):(p=new Date(r.endDate),p.setDate(p.getDate()+1));let n=se.calculateEndDate(p,c),m=l=>l.map(i=>i.id===d.id?{...i,startDate:p,endDate:n}:i.subtasks?{...i,subtasks:m(i.subtasks)}:i);s=m(s),s=se.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,c)=>{if(a===0)return [];let p=[],n=o.getTime(),m=1e3*60*60*24,l=se.findTaskById(e,t);if(!l||!l.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let y=se.getDependentTasks(e,u);for(let x of y){if(!x.startDate||!x.endDate)continue;let b=r.findIndex($=>$.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/m,P=(g-n)/m*s,C=P+v*s,B=Math.max(D*s,s),T=c+b*d+12;p.push({taskId:x.id,taskName:x.name,originalX:P,previewX:C,width:B,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),p},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 d=new Date(a);d.setDate(d.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let p=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:c}],n=m=>m.map(l=>l.id===o.id?{...l,endDate:c,segments:p}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function tn({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:c,onTaskClick:p,onTaskDblClick:n,onTaskContextMenu:m,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=react.useState([]),[x,b]=react.useState(null),[g,k]=react.useState(null),D=react.useCallback(F=>{b(F);},[]),h=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),P=r==="day"?60:r==="week"?20:8,C=h*P*d,B=F=>{let L=new Date(Date.UTC(F.getFullYear(),F.getMonth(),F.getDate())),R=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-R);let E=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-E.getTime())/864e5+1)/7)},T=F=>{let L=F.getDay();return L===0||L===6},$=react.useCallback(F=>{let L=Math.round(F/(P*d)),R=new Date(o);return R.setDate(R.getDate()+L),R},[o,P,d]),W=react.useCallback((F,L)=>{if(L.startDate&&L.endDate)return;let R=F.currentTarget.ownerSVGElement;if(!R)return;let E=R.createSVGPoint();E.x=F.clientX,E.y=F.clientY;let j=E.matrixTransform(R.getScreenCTM()?.inverse()),oe=$(j.x),q=new Date(oe);q.setDate(q.getDate()+1),l?.(L,oe,q);},[$,l]),I=react.useMemo(()=>{let F=j=>j.map(oe=>{if(oe.subtasks&&oe.subtasks.length>0){let q=F(oe.subtasks),De=q.filter(M=>M.startDate&&M.endDate);if(De.length>0){let M=De.map(Ee=>Ee.startDate.getTime()),ee=De.map(Ee=>Ee.endDate.getTime()),Y=new Date(Math.min(...M)),Ne=new Date(Math.max(...ee));return {...oe,subtasks:q,startDate:Y,endDate:Ne}}return {...oe,subtasks:q}}return oe}),L=(j,oe=[])=>{for(let q of j)oe.push(q),q.subtasks&&q.subtasks.length>0&&(q.isExpanded===void 0||q.isExpanded)&&L(q.subtasks,oe);return oe},R=F(e);return L(R)},[e]),G=react.useCallback(F=>{if(!F.startDate||!F.endDate)return {x:0,width:0};let L=F.startDate.getTime(),R=F.endDate.getTime(),E=o.getTime(),j=(L-E)/(1e3*60*60*24),oe=(R-L)/(1e3*60*60*24),q=j*P*d,De=Math.max(P*d,40),M=Math.max(oe*P*d,De);return {x:q,width:M}},[o,P,d]),te=react.useMemo(()=>I.filter(F=>F.startDate&&F.endDate).map(F=>{let{x:L,width:R}=G(F),j=I.findIndex(oe=>oe.id===F.id)*a+12;return {id:F.id,x:L,y:j,width:R,height:32}}),[I,G]),fe=react.useCallback((F,L,R)=>{if(!R||L===0){y([]);return}let E=se.calculateCascadePreview(e,F,L,I,o,P*d,a,48);y(E);},[e,I,o,P,d,a,48]),H=react.useMemo(()=>{let F=[],L=new Date(o);for(;L<=s;){let j=(L.getTime()-o.getTime())/864e5*P*d;if(r==="day")F.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:j}),L.setDate(L.getDate()+1);else if(r==="week"){let oe=B(L);F.push({date:new Date(L),label:`Week ${oe}`,x:j}),L.setDate(L.getDate()+7);}else F.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:j}),L.setMonth(L.getMonth()+1);}return F},[o,s,r,P,d]),Me=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*P*d,[o,P,d]),Re=Math.max(I.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.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:jsxRuntime.jsxs("svg",{width:Math.max(C,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(C,1e3),height:48,fill:t.bgGrid}),H.map((F,L)=>jsxRuntime.jsxs("g",{children:[L>0&&jsxRuntime.jsx("line",{x1:F.x,y1:0,x2:F.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:F.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:F.label})]},`header-${L}`)),Me>=0&&Me<=C&&jsxRuntime.jsx("circle",{cx:Me,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(C,1e3),height:Re,style:{display:"block",flexShrink:0,overflow:"visible"},children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:"shadow",children:jsxRuntime.jsx("feDropShadow",{dx:"0",dy:"1",stdDeviation:"2",floodOpacity:"0.1"})}),jsxRuntime.jsx("pattern",{id:"diagonal-stripes",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:jsxRuntime.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:t.border,strokeWidth:"2"})})]}),jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(C,1e3),height:Re,fill:t.bgPrimary}),H.map((F,L)=>{let R=H[L+1]?.x||C,E=T(F.date);return jsxRuntime.jsxs("g",{children:[E&&jsxRuntime.jsx("rect",{x:F.x,y:0,width:R-F.x,height:I.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsxRuntime.jsx("line",{x1:F.x,y1:0,x2:F.x,y2:I.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),Me>=0&&Me<=C&&jsxRuntime.jsx("line",{x1:Me,y1:0,x2:Me,y2:I.length*a,stroke:t.today,strokeWidth:2,opacity:1}),I.map((F,L)=>{let R=F.startDate&&F.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:L*a,width:C,height:a,fill:L%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${F.id}`),!R&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:L*a,width:C,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:E=>W(E,F),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-${F.id}`),jsxRuntime.jsx("text",{x:Me>0?Me: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-${F.id}`)]})]},`row-group-${F.id}`)}),I.map((F,L)=>!F.dependencies||F.dependencies.length===0||!F.startDate||!F.endDate?null:F.dependencies.map(R=>{let E=I.find(De=>De.id===R);if(!E||!E.startDate||!E.endDate)return null;let j=I.findIndex(De=>De.id===R),oe=G(E),q=G(F);return jsxRuntime.jsx(Jo,{x1:oe.x+oe.width,y1:j*a+a/2,x2:q.x,y2:L*a+a/2,theme:t},`dep-${R}-${F.id}`)})),I.map((F,L)=>{if(!F.startDate||!F.endDate)return null;let{x:R,width:E}=G(F),j=L*a+12,oe=F.subtasks&&F.subtasks.length>0&&!F.isMilestone;return F.isMilestone?jsxRuntime.jsx(Qo,{task:F,x:R+E/2,y:j+16,theme:t,onClick:p},F.id):oe?jsxRuntime.jsxs("g",{onClick:()=>p?.(F),onContextMenu:q=>{q.preventDefault(),q.stopPropagation(),m?.(F,q);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:R,y:j,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:R,y1:j,x2:R+E,y2:j,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:R,y1:j,x2:R,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:R+E,y1:j,x2:R+E,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:R,y1:j+32,x2:R+E,y2:j+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsxRuntime.jsx("text",{x:R+12,y:j+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:F.name})]},F.id):jsxRuntime.jsx(Yo,{task:F,x:R,y:j,width:E,theme:t,dayWidth:P*d,startDate:o,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:l,onDependencyCreate:i,allTaskPositions:te,onDragMove:fe,onHoverChange:D},F.id)}),I.map((F,L)=>!F.dependencies||F.dependencies.length===0||!F.startDate||!F.endDate?null:F.dependencies.map(R=>{let E=I.find(Fe=>Fe.id===R);if(!E||!E.startDate||!E.endDate)return null;let j=I.findIndex(Fe=>Fe.id===R),oe=G(E),q=G(F),De=oe.x+oe.width,M=j*a+a/2,ee=q.x,Y=L*a+a/2,Ne=ee-De,Ee=De+Ne/2,_e=Fe=>{let it=(1-Fe)*(1-Fe)*(1-Fe)*De+3*(1-Fe)*(1-Fe)*Fe*Ee+3*(1-Fe)*Fe*Fe*Ee+Fe*Fe*Fe*ee,Ze=(1-Fe)*(1-Fe)*(1-Fe)*M+3*(1-Fe)*(1-Fe)*Fe*M+3*(1-Fe)*Fe*Fe*Y+Fe*Fe*Fe*Y;return {x:it,y:Ze}},lt=_e(.1),Se=_e(.5),ot=_e(.9),gt=`M ${lt.x} ${lt.y} Q ${Se.x} ${Se.y} ${ot.x} ${ot.y}`;return g&&g.x1===De&&g.y1===M&&g.x2===ee&&g.y2===Y?null:jsxRuntime.jsx("path",{d:gt,fill:"none",stroke:"transparent",strokeWidth:12,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{k({x1:De,y1:M,x2:ee,y2:Y,onDelete:()=>u?.(F.id,R)});}},`dep-hover-${R}-${F.id}`)})),f.map(F=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:F.previewX,y:F.y-48,width:F.width,height:32,rx:8,fill:F.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(F.daysDelta)>0&&jsxRuntime.jsx("text",{x:F.previewX+F.width/2,y:F.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:F.daysDelta>0?`+${F.daysDelta}d`:`${F.daysDelta}d`})]},`cascade-preview-${F.taskId}`)),g&&(()=>{let{x1:F,y1:L,x2:R,y2:E,onDelete:j}=g,oe=R-F,q=E-L,De=F+oe/2,M=(L+E)/2,ee=`M ${F} ${L} C ${De} ${L}, ${De} ${E}, ${R} ${E}`,Y=6,Ne=Math.atan2(q,oe),Ee=R-Y*Math.cos(Ne-Math.PI/6),_e=E-Y*Math.sin(Ne-Math.PI/6),lt=R-Y*Math.cos(Ne+Math.PI/6),Se=E-Y*Math.sin(Ne+Math.PI/6),ot=t.dependency,gt="#f87171";return jsxRuntime.jsxs("g",{onMouseLeave:()=>k(null),children:[jsxRuntime.jsx("path",{d:ee,fill:"none",stroke:"transparent",strokeWidth:50,strokeLinecap:"round",style:{cursor:"pointer"}}),jsxRuntime.jsx("circle",{cx:De,cy:M,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:ee,fill:"none",stroke:ot,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:ee,fill:"none",stroke:ot,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${R} ${E} L ${Ee} ${_e} M ${R} ${E} L ${lt} ${Se}`,fill:"none",stroke:ot,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:R,cy:E,r:4,fill:ot,opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:Fe=>{Fe.stopPropagation(),k(null),j();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:De,cy:M,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:gt,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsxRuntime.jsx("line",{x1:De-3,y1:M-3,x2:De+3,y2:M+3,stroke:gt,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:De+3,y1:M-3,x2:De-3,y2:M+3,stroke:gt,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),x&&jsxRuntime.jsx(dd,{tooltipData:x,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 As=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Is=[{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:d=false,mode:c=a?"edit":"create",theme:p="dark",customStatuses:n=[]}){let m=[...As,...n.filter(M=>!As.some(ee=>ee.id===M.id))],l=He[p]||He.dark,[i,u]=react.useState(false),[v,f]=react.useState(false),[y,x]=react.useState(false),[b,g]=react.useState(false),[k,D]=react.useState(null),[h,P]=react.useState(new Date),[C,B]=react.useState({top:0,left:0}),[T,$]=react.useState(false),W=react.useRef(null),I=react.useRef(null),G=react.useRef(null),te=react.useRef(null),fe=react.useRef(null),[H,Me]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[Re,F]=react.useState({});react.useEffect(()=>{a?(Me({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||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&$(true)):(Me({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),$(false));},[a,e]),react.useEffect(()=>{let M=ee=>{W.current&&!W.current.contains(ee.target)&&u(false),I.current&&!I.current.contains(ee.target)&&f(false),G.current&&!G.current.contains(ee.target)&&x(false),te.current&&!te.current.contains(ee.target)&&g(false);};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);let L=()=>{let M={};return H.name.trim()||(M.name="El nombre es requerido"),H.startDate&&H.endDate&&H.startDate>H.endDate&&(M.endDate="La fecha de fin debe ser posterior a la de inicio"),F(M),Object.keys(M).length===0},R=async M=>{if(M.preventDefault(),!!L())try{await s(H),t();}catch(ee){console.error("Error submitting task:",ee);}},E=(M,ee)=>{Me(Y=>{let Ne={...Y,[M]:ee};if(M==="status"){let Ee=ee;Ee==="todo"?Ne.progress=0:Ee==="in-progress"?(Y.progress===0||Y.progress===100)&&(Ne.progress=50):Ee==="completed"||Ee==="closed"?Ne.progress=100:(Ee==="in-review"||Ee==="review")&&(Ne.progress=75);}if(M==="progress"){let Ee=typeof ee=="number"?ee:parseInt(ee,10);Ee===100&&Y.status!=="completed"?Ne.status="completed":Ee>0&&Ee<100&&Y.status==="todo"?Ne.status="in-progress":Ee===0&&Y.status!=="todo"&&(Ne.status="todo");}return Ne}),Re[M]&&F(Y=>{let Ne={...Y};return delete Ne[M],Ne});},j=m.find(M=>M.id===H.status)??As[0],oe=Is.find(M=>M.id===H.priority)??Is[1],q=an.find(M=>M.value===H.color)??an[0],De={backgroundColor:l.bgSecondary,border:`1px solid ${l.borderLight}`,color:l.textPrimary};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.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:jsxRuntime.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:M=>M.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${l.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:j.color||l.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:l.textTertiary},onMouseEnter:M=>{M.currentTarget.style.backgroundColor=l.hoverBg,M.currentTarget.style.color=l.textPrimary;},onMouseLeave:M=>{M.currentTarget.style.backgroundColor="transparent",M.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:R,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxRuntime.jsxs("div",{className:"p-5 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{type:"text",value:H.name,onChange:M=>E("name",M.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:l.textPrimary},placeholder:"Nombre de la tarea",disabled:d,autoFocus:true}),Re.name&&jsxRuntime.jsxs("p",{className:"mt-1 text-xs text-red-400 flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-3 h-3"}),Re.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:H.description||"",onChange:M=>E("description",M.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:l.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:d})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:W,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&u(!i),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...De,borderColor:j.color,backgroundColor:`${j.color}15`},disabled:d,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:j.color}}),jsxRuntime.jsx("span",{style:{color:j.color},children:j.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:j.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsx(framerMotion.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:l.bgPrimary,border:`1px solid ${l.border}`},children:m.map(M=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:ee=>ee.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ee=>ee.currentTarget.style.backgroundColor="transparent",onClick:()=>{E("status",M.id),u(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:M.color}}),M.title,H.status===M.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},M.id))})})]}),jsxRuntime.jsxs("div",{ref:I,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&f(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:De,disabled:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:oe.color}}),jsxRuntime.jsx("span",{children:oe.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:v&&jsxRuntime.jsx(framerMotion.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:l.bgPrimary,border:`1px solid ${l.border}`},children:Is.map(M=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:ee=>ee.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ee=>ee.currentTarget.style.backgroundColor="transparent",onClick:()=>{E("priority",M.id),f(false);},children:[jsxRuntime.jsx("span",{children:M.icon}),M.label,H.priority===M.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},M.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:G,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&x(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:De,disabled:d,children:[H.assignees&&H.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:H.assignees.slice(0,3).map((M,ee)=>jsxRuntime.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:M.color||l.accent,borderColor:l.bgSecondary},children:M.initials},ee))}),H.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:l.textTertiary},children:["+",H.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:l.textTertiary}}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:y&&jsxRuntime.jsx(framerMotion.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:l.bgPrimary,border:`1px solid ${l.border}`},children:o.map(M=>{let ee=H.assignees?.some(Y=>Y.name===M.name);return jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:Y=>Y.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:Y=>Y.currentTarget.style.backgroundColor="transparent",onClick:()=>{let Y=ee?(H.assignees||[]).filter(Ne=>Ne.name!==M.name):[...H.assignees||[],{name:M.name,avatar:M.avatar,initials:M.name.split(" ").map(Ne=>Ne[0]).join("").toUpperCase().slice(0,2),color:l.accent}];E("assignees",Y);},children:[jsxRuntime.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:l.accent},children:M.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:M.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:ee&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})})]},M.id)})})})]}),jsxRuntime.jsxs("div",{ref:te,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&g(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:De,disabled:d,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:H.color}}),jsxRuntime.jsx("span",{children:q.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"absolute left-0 top-full mt-1.5 z-50 rounded-lg",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:jsxRuntime.jsx("div",{style:{padding:"14px 18px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 16px)",gap:"14px"},children:an.slice(0,16).map(M=>{let ee=H.color===M.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>{E("color",M.value),g(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:M.value,outline:ee?`2px solid ${M.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:M.name},M.value)})})})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{ref:fe,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!d&&!H.isMilestone)if(k==="start")D(null);else {if(fe.current){let M=fe.current.getBoundingClientRect(),ee=window.innerHeight,Y=320,Ee=ee-M.bottom<Y?M.top-Y-8:M.bottom+8;B({top:Ee,left:M.left});}D("start"),P(H.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...De,opacity:H.isMilestone?.5:1,cursor:H.isMilestone?"not-allowed":"pointer"},disabled:d||H.isMilestone,children:H.startDate?H.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!d&&!H.isMilestone)if(k==="end")D(null);else {if(fe.current){let M=fe.current.getBoundingClientRect(),ee=window.innerHeight,Y=320,Ee=ee-M.bottom<Y?M.top-Y-8:M.bottom+8;B({top:Ee,left:M.left});}D("end"),P(H.endDate||H.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...De,opacity:H.isMilestone?.5:1,cursor:H.isMilestone?"not-allowed":"pointer"},disabled:d||H.isMilestone,children:H.endDate?H.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&jsxRuntime.jsxs(Xe,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>D(null)}),jsxRuntime.jsxs(framerMotion.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:`${C.top}px`,left:`${C.left}px`,zIndex:99999,backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:M=>M.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let M=new Date,ee=new Date(M);ee.setDate(M.getDate()+1);let Y=new Date(M);Y.setDate(M.getDate()+7);let Ne=new Date(M);return Ne.setDate(M.getDate()+14),[{label:"Hoy",date:M},{label:"Ma\xF1ana",date:ee},{label:"Pr\xF3xima semana",date:Y},{label:"2 semanas",date:Ne}].map((_e,lt)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:Se=>Se.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:Se=>Se.currentTarget.style.backgroundColor="transparent",onClick:()=>{k==="start"?(E("startDate",_e.date),(!H.endDate||_e.date>H.endDate)&&E("endDate",_e.date),D("end")):(E("endDate",_e.date),(!H.startDate||_e.date<H.startDate)&&E("startDate",_e.date),D(null));},children:_e.label},lt))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.border}`,margin:"0.5rem 0"}}),jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:M=>M.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:M=>M.currentTarget.style.backgroundColor="transparent",onClick:()=>{E("startDate",void 0),E("endDate",void 0),D(null);},children:"Borrar fechas"})]}),jsxRuntime.jsxs("div",{className:"p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>P(new Date(h.getFullYear(),h.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:l.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textPrimary},children:h.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>P(new Date(h.getFullYear(),h.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:l.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((M,ee)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:M},ee))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let M=h.getFullYear(),ee=h.getMonth(),Y=new Date(M,ee,1).getDay(),Ne=new Date(M,ee+1,0).getDate(),Ee=new Date,_e=[];for(let Se=Y-1;Se>=0;Se--)_e.push({day:new Date(M,ee,-Se).getDate(),date:new Date(M,ee-1,new Date(M,ee,-Se).getDate()),isCurrentMonth:false});for(let Se=1;Se<=Ne;Se++)_e.push({day:Se,date:new Date(M,ee,Se),isCurrentMonth:true});let lt=42-_e.length;for(let Se=1;Se<=lt;Se++)_e.push({day:Se,date:new Date(M,ee+1,Se),isCurrentMonth:false});return _e.map((Se,ot)=>{let gt=Se.date.toDateString()===Ee.toDateString(),ft=H.startDate?.toDateString()===Se.date.toDateString(),Fe=H.endDate?.toDateString()===Se.date.toDateString(),it=H.startDate&&H.endDate&&Se.date>=H.startDate&&Se.date<=H.endDate;return jsxRuntime.jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Se.isCurrentMonth?ft||Fe?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:ft?"#3B82F6":Fe?"#7C3AED":it?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:gt&&!ft&&!Fe?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{k==="start"?(E("startDate",Se.date),H.endDate&&Se.date>H.endDate&&E("endDate",Se.date),D("end")):(E("endDate",Se.date),H.startDate&&Se.date<H.startDate&&E("startDate",Se.date),D(null));},children:Se.day},ot)})})()})]})]})]})})]}),Re.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:Re.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:H.progress,onChange:M=>E("progress",parseInt(M.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"},disabled:d}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"}20`,color:H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"},children:[H.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>$(!T),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${T?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:T&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxRuntime.jsxs("div",{className:"pt-3 space-y-3",children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:H.isMilestone,onChange:M=>E("isMilestone",M.target.checked),className:"w-4 h-4 rounded",style:{accentColor:l.accent},disabled:d}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:l.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:l.bgSecondary},children:r.filter(M=>M.id!==a?.id).map(M=>{let ee=H.dependencies?.includes(M.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let Y=ee?(H.dependencies||[]).filter(Ne=>Ne!==M.id):[...H.dependencies||[],M.id];E("dependencies",Y);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:ee?`${l.accent}30`:l.bgPrimary,color:ee?l.accent:l.textSecondary,border:`1px solid ${ee?l.accent:l.borderLight}`},disabled:d,children:M.name},M.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${l.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:l.textSecondary},onMouseEnter:M=>M.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:M=>M.currentTarget.style.backgroundColor="transparent",disabled:d,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:l.accent,color:"#FFF"},onMouseEnter:M=>!d&&(M.currentTarget.style.opacity="0.9"),onMouseLeave:M=>!d&&(M.currentTarget.style.opacity="1"),children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var $g=['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"'],gd=()=>jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.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"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),zg=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"})}),Ug=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M18 6L6 18M6 6L18 18"})}),Wg=()=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M5 12h14"})}),Gg=()=>jsxRuntime.jsx("div",{className:"flex gap-1 items-center",children:[0,1,2].map(e=>jsxRuntime.jsx(framerMotion.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:d,onDependencyCreate:c,onDependencyDelete:p}){let[n,m]=react.useState(false),[l,i]=react.useState(false),[u,v]=react.useState([]),[f,y]=react.useState(""),[x,b]=react.useState(false),[g,k]=react.useState(true),D=react.useRef(null),h=react.useRef(null),P=react.useRef(null),{enabled:C=true,placeholder:B='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:$,suggestions:W=$g,maxHistory:I=50,persistHistory:G}=a,te=G?.storageKey||"gantt-ai-history",fe=G?.maxMessages??5;react.useEffect(()=>{if(G?.enabled)try{let R=localStorage.getItem(te);if(R){let j=JSON.parse(R).map(oe=>({...oe,timestamp:new Date(oe.timestamp)}));v(j.slice(-fe));}}catch(R){console.warn("[GanttAIAssistant] Failed to load persisted history:",R);}},[G?.enabled,te,fe]),react.useEffect(()=>{if(G?.enabled&&u.length>0)try{let R=u.filter(E=>!E.isLoading).slice(-fe);localStorage.setItem(te,JSON.stringify(R));}catch(R){console.warn("[GanttAIAssistant] Failed to persist history:",R);}},[u,G?.enabled,te,fe]),react.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let H=react.useCallback(R=>{if(R.success)switch(R.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":R.taskId&&R.updates&&o?.(R.taskId,R.updates);break;case "create_task":R.newTask&&s?.(R.newTask);break;case "delete_task":R.taskId&&d?.(R.taskId);break;case "link_tasks":R.dependencyFrom&&R.dependencyTo&&c?.(R.dependencyFrom,R.dependencyTo);break;case "unlink_tasks":R.taskId&&R.dependencyFrom&&p?.(R.taskId,R.dependencyFrom);break}},[o,s,d,c,p]),Me=react.useCallback(async R=>{if(!R.trim()||x)return;let E={id:`user-${Date.now()}`,role:"user",content:R,timestamp:new Date};v(oe=>[...oe.slice(-(I-1)),E]),y(""),k(false),b(true);let j={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(oe=>[...oe,j]);try{if($){let oe=await $(R,e);v(q=>{let De=q.filter(ee=>!ee.isLoading),M={id:`assistant-${Date.now()}`,role:"assistant",content:oe.message,timestamp:new Date,command:oe};return [...De,M]}),H(oe);}else v(oe=>[...oe.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(oe){v(q=>[...q.filter(M=>!M.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${oe instanceof Error?oe.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,I,$,e,H]),Re=R=>{R.preventDefault(),Me(f);},F=R=>{y(R),D.current?.focus();};if(react.useEffect(()=>{let R=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),m(j=>!j),n||i(false)),E.key==="Escape"&&n&&m(false);};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[n]),react.useEffect(()=>{if(!n)return;let R=j=>{let oe=j.target;P.current&&!P.current.contains(oe)&&m(false);},E=setTimeout(()=>{document.addEventListener("mousedown",R);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",R);}},[n]),!C)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 jsxRuntime.jsxs(Xe,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&jsxRuntime.jsxs(framerMotion.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:()=>m(true),children:[jsxRuntime.jsx(gd,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.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"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:P,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(gd,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(R=>!R),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Wg,{})}),jsxRuntime.jsx("button",{onClick:()=>m(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Ug,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!l&&jsxRuntime.jsxs(framerMotion.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:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&g&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:W.slice(0,4).map((R,E)=>jsxRuntime.jsx("button",{onClick:()=>F(R),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:R.length>30?R.slice(0,30)+"...":R},E))})]}),u.map(R=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${R.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${R.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:R.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:R.role==="user"?"white":t.textPrimary},children:[R.isLoading?jsxRuntime.jsx(Gg,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:R.content}),R.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:R.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:R.command.success?"#10B981":"#EF4444"},children:[R.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:R.command.type.replace(/_/g," ")})]})]})},R.id)),jsxRuntime.jsx("div",{ref:h})]}),jsxRuntime.jsxs("form",{onSubmit:Re,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:D,type:"text",value:f,onChange:R=>y(R.target.value),placeholder:B,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!f.trim()||x,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:jsxRuntime.jsx(zg,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function fd(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,m=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!m)return {...l,present:i};let u=[...l.past,l.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),d=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let m=n.past[n.past.length-1],l=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:m,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let m=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:m,future:l}});},[]),p=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:d,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:p}}function bd({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=d=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,p=c?d.metaKey:d.ctrlKey;if(p&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!c&&p&&d.key==="y"){d.preventDefault(),t();return}if(c&&p&&d.shiftKey&&d.key==="z"){d.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var jg={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 hd(e){return {...jg,...e}}var Qg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},xd=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:c="comfortable",showThemeSelector:p=true,showExportButton:n=true,availableUsers:m=[],templates:l,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:f,showCreateTaskButton:y=false,createTaskLabel:x,onCreateTask:b,onThemeChange:g,onTaskClick:k,onTaskDblClick:D,onTaskContextMenu:h,onTaskUpdate:P,onProgressChange:C,onTaskEdit:B,onTaskAddSubtask:T,onTaskMarkIncomplete:$,onTaskSetInProgress:W,onDependencyCreate:I,onDependencyDelete:G,onBeforeTaskAdd:te,onAfterTaskAdd:fe,onBeforeTaskUpdate:H,onAfterTaskUpdate:Me,onBeforeTaskDelete:Re,onAfterTaskDelete:F}=a,R=react.useContext(Wo)?.theme,[E,j]=react.useState(R||s||"dark"),[oe,q]=react.useState(d),[De,M]=react.useState(c),[ee,Y]=react.useState(1),[Ne,Ee]=react.useState(0),[_e,lt]=react.useState(false),[Se,ot]=react.useState(null),[gt,ft]=react.useState({isOpen:false,x:0,y:0,task:null}),[Fe,it]=react.useState(null),[Ze,bt]=react.useState(null);react.useEffect(()=>{R&&R!==E&&j(R);},[R]),react.useEffect(()=>{s&&s!==E&&j(s);},[s]);let Qt=react.useCallback(S=>{j(S),g?.(S);},[g]),{state:xe,setState:O,undo:we,redo:Ve,canUndo:Ge,canRedo:kt,clearHistory:J}=fd(t,50);react.useEffect(()=>{O(t);},[t,O]);let Q=react.useRef(t),ve=react.useRef(true);react.useEffect(()=>{if(ve.current){ve.current=false,Q.current=xe;return}if(!r)return;let S=JSON.stringify(Q.current),z=JSON.stringify(xe);S!==z&&(Q.current=xe,r(xe));},[xe,r]);let be=react.useMemo(()=>fs(v,f),[v,f]),ae=react.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}],[]),[Ce,ue]=react.useState(()=>ae(be));react.useEffect(()=>{ue(S=>S.map(z=>({...z,label:be.columns[z.id==="name"?"taskName":z.id]||z.label})));},[be]);let ke=react.useMemo(()=>{let S=Ce.filter(ne=>ne.visible),z=S.some(ne=>ne.id!=="name");return S.reduce((ne,he)=>ne+he.width,0)+(z?20:0)},[Ce]);react.useEffect(()=>{Se!==null&&Se>ke&&(Ce.filter(K=>K.visible).some(K=>K.id!=="name")||ot(null));},[Ce,ke,Se]);let ge=react.useMemo(()=>Se!==null?Math.max(280,Se,ke):Math.max(280,ke),[Se,ke]),Ae=react.useRef(null),pe=react.useRef(null),Ie=react.useRef(null),U=react.useMemo(()=>Bl(E),[E]),N=react.useMemo(()=>({theme:U,themeName:E}),[U,E]),X=react.useMemo(()=>hd(l),[l]),me=react.useMemo(()=>{if(!i)return xe;let S=se.calculateCriticalPath(xe),z=K=>K.map(ne=>({...ne,isCriticalPath:S.includes(ne.id),subtasks:ne.subtasks?z(ne.subtasks):void 0}));return z(xe)},[xe,i]),Te=Qg(De);bd({undo:we,redo:Ve,canUndo:Ge,canRedo:kt,enabled:true}),react.useImperativeHandle(o,()=>({getTask:S=>se.findTaskById(xe,S),addTask:(S,z)=>{O(K=>{if(!z)return [...K,{...S,level:0}];let ne=he=>he.map(Pe=>Pe.id===z?{...Pe,subtasks:[...Pe.subtasks||[],{...S,parentId:z,level:(Pe.level||0)+1}],isExpanded:true}:Pe.subtasks?{...Pe,subtasks:ne(Pe.subtasks)}:Pe);return ne(K)});},updateTask:(S,z)=>{O(K=>{let ne=he=>he.map(Pe=>Pe.id===S?{...Pe,...z}:Pe.subtasks?{...Pe,subtasks:ne(Pe.subtasks)}:Pe);return ne(K)});},deleteTask:S=>{O(z=>{let K=ne=>ne.filter(he=>he.id===S?false:(he.subtasks&&(he.subtasks=K(he.subtasks)),true));return K(z)});},deleteTasks:S=>{O(z=>ws(z,S));},duplicateTask:S=>{O(z=>Cs(z,[S]));},splitTask:(S,z,K=3)=>{O(ne=>se.splitTask(ne,S,z,K));},calculateEndDate:se.calculateEndDate,calculateDuration:se.calculateDuration,validateDependency:(S,z)=>!se.validateDependencies(xe,S,z),getAllTasks:()=>se.flattenTasks(xe),getTasksByStatus:S=>se.flattenTasks(xe).filter(z=>z.status===S),getTasksByParent:S=>S?se.findTaskById(xe,S)?.subtasks||[]:xe.filter(K=>!K.parentId),getCriticalPath:()=>se.flattenTasks(xe).filter(S=>S.isCriticalPath),indentTask:S=>{O(z=>vs(z,[S]));},outdentTask:S=>{O(z=>xs(z,[S]));},moveTask:(S,z)=>{O(K=>ks(K,[S],z));},createSubtask:async S=>{let{tasks:z,newTask:K}=Ns(xe,S);if(te){let ne=te({...K,parentId:S});if((ne instanceof Promise?await ne:ne)===false)return}O(z),fe&&fe({...K,parentId:S});},scrollToTask:S=>{let K=se.flattenTasks(xe).findIndex(ne=>ne.id===S);if(K!==-1&&Ae.current){let ne=K*Te;Ae.current.scrollTo({top:ne,behavior:"smooth"}),pe.current&&pe.current.scrollTo({top:ne,behavior:"smooth"});}},highlightTask:(S,z=2e3)=>{},expandTask:S=>{O(z=>{let K=ne=>ne.map(he=>he.id===S?{...he,isExpanded:true}:he.subtasks?{...he,subtasks:K(he.subtasks)}:he);return K(z)});},collapseTask:S=>{O(z=>{let K=ne=>ne.map(he=>he.id===S?{...he,isExpanded:false}:he.subtasks?{...he,subtasks:K(he.subtasks)}:he);return K(z)});},expandAll:()=>{O(S=>{let z=K=>K.map(ne=>({...ne,isExpanded:true,subtasks:ne.subtasks?z(ne.subtasks):void 0}));return z(S)});},collapseAll:()=>{O(S=>{let z=K=>K.map(ne=>({...ne,isExpanded:false,subtasks:ne.subtasks?z(ne.subtasks):void 0}));return z(S)});},undo:we,redo:Ve,canUndo:()=>Ge,canRedo:()=>kt,clearHistory:J,exportToPNG:async()=>{if(!Ie.current)throw new Error("Gantt container not found");let S=await vd__default.default(Ie.current,{backgroundColor:U.bgPrimary,scale:2});return new Promise((z,K)=>{S.toBlob(ne=>{ne?z(ne):K(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async S=>{await se.exportToPDF(xe,S);},exportToExcel:async S=>{await se.exportToExcel(xe,S);},exportToJSON:()=>se.exportToJSON(xe),exportToCSV:()=>se.exportToCSV(xe),importFromJSON:S=>{let z=se.importFromJSON(S);O(z);},getTasks:()=>xe,refresh:()=>{O(S=>[...S]);},clearAll:()=>{O([]);}}),[xe,we,Ve,Ge,kt,J,U,Te]);let At=react.useCallback(S=>{ue(z=>z.map(K=>K.id===S?{...K,visible:!K.visible}:K));},[]),Et=react.useCallback((S,z)=>{ue(K=>K.map(ne=>{if(ne.id!==S)return ne;let he=ne.minWidth??100,Pe=ne.maxWidth??800,$t=Math.max(he,Math.min(Pe,z));return {...ne,width:$t}}));},[]),It=react.useCallback(S=>{O(z=>Ds(z,S)),a.onTaskToggleExpand?.(S);},[a]),Xt=react.useCallback((S,z)=>{if(H&&H(S,z)===false)return;let ne=se.findTaskById(xe,S)?.progress,he=$t=>$t.map(zt=>zt.id===S?{...zt,...z}:zt.subtasks?{...zt,subtasks:he(zt.subtasks)}:zt);O(he(xe));let Pe=se.findTaskById(he(xe),S);Pe&&(P?.(Pe),Me?.(Pe),z.progress!==void 0&&ne!==void 0&&z.progress!==ne&&C?.(S,ne,z.progress));},[xe,P,H,Me,C]),ht=react.useCallback(S=>{S.length!==0&&(O(z=>vs(z,S)),a.onTaskIndent?.(S[0]));},[a]),Dr=react.useCallback(S=>{S.length!==0&&(O(z=>xs(z,S)),a.onTaskOutdent?.(S[0]));},[a]),or=react.useCallback((S,z,K)=>{O(ne=>td(ne,S,z,K)),a.onTaskReparent?.(S,z,K);},[a]),_a=react.useCallback((S,z)=>{S.length!==0&&(O(K=>ks(K,S,z)),a.onTaskMove?.(S[0],z));},[a]),nr=react.useCallback(async S=>{let z=[];for(let K of S)Re&&await Promise.resolve(Re(K))===false||z.push(K);z.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(z):(O(K=>ws(K,z)),z.forEach(K=>a.onTaskDelete?.(K))),F&&z.forEach(K=>F(K)));},[a,Re,F]),le=react.useCallback(S=>{O(z=>Cs(z,S)),S.forEach(z=>a.onTaskDuplicate?.(z));},[a]),yt=react.useCallback((S,z)=>{O(K=>{let{tasks:ne,newTask:he}=ed(K,S,z);return te&&te(he)===false?K:(a.onTaskCreate?.(he.parentId,he.position||0),fe?.(he),ne)});},[a,te,fe]),Kt=react.useCallback((S,z)=>{O(K=>Ts(K,S,z)),a.onTaskRename?.(S,z);},[a]),Va=react.useCallback(S=>{O(z=>{let{tasks:K}=Ns(z,S);return a.onTaskCreate?.(S,0),K});},[a]),wo=react.useCallback((S,z,K)=>{let ne=S.startDate?Math.round((z.getTime()-S.startDate.getTime())/864e5):0,he=zt=>zt.map(Yt=>Yt.id===S.id?{...Yt,startDate:z,endDate:K,...S.segments&&{segments:S.segments}}:Yt.subtasks?{...Yt,subtasks:he(Yt.subtasks)}:Yt),Pe=he(xe);Pe=se.autoScheduleDependents(Pe,S.id,ne),O(Pe);let $t={...S,startDate:z,endDate:K};P?.($t);},[xe,P]),Nr=react.useCallback((S,z)=>{h?.(S,z),ft({isOpen:true,x:z.clientX,y:z.clientY,task:S});},[h]),Ba=react.useCallback((S,z)=>{let K=se.splitTask(xe,S.id,z);O(K),ft({isOpen:false,x:0,y:0,task:null});},[xe]),ja=react.useCallback(S=>{D?.(S),B||it(S);},[D,B]),wt=react.useCallback((S,z,K)=>{let ne=new Map,he=va=>{va.forEach(Ra=>{Ra.dependencies&&ne.set(Ra.id,Ra.dependencies),Ra.subtasks&&he(Ra.subtasks);});};he(K);let Pe=ne.get(z)||[];ne.set(z,[...Pe,S]);let $t=new Set,zt=new Set,Yt=va=>{if(!$t.has(va)){$t.add(va),zt.add(va);let Ra=ne.get(va)||[];for(let sr of Ra){if(!$t.has(sr)&&Yt(sr))return true;if(zt.has(sr))return true}}return zt.delete(va),false};return Yt(z)},[]),Co=react.useCallback((S,z)=>{if(wt(S.id,z,xe)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
277
277
|
|
|
278
278
|
Task dependencies must flow in one direction only.`);return}let K=ne=>ne.map(he=>{if(he.id===z){let Pe=he.dependencies||[];if(!Pe.includes(S.id))return {...he,dependencies:[...Pe,S.id]}}return he.subtasks?{...he,subtasks:K(he.subtasks)}:he});O(K(xe)),I?.(S.id,z);},[xe,I,wt]),To=react.useCallback((S,z)=>{let K=ne=>ne.map(he=>{if(he.id===S&&he.dependencies){let Pe=he.dependencies.filter($t=>$t!==z);return {...he,dependencies:Pe}}return he.subtasks?{...he,subtasks:K(he.subtasks)}:he});O(K(xe)),G?.(S,z);},[xe,G]),{startDate:Si,endDate:Vr}=react.useMemo(()=>{let S=xe.filter(Pe=>Pe.startDate&&Pe.endDate);if(S.length===0){let Pe=new Date,$t=new Date(Pe);$t.setDate($t.getDate()-30);let zt=new Date(Pe);return zt.setDate(zt.getDate()+60),{startDate:$t,endDate:zt}}let z=S.flatMap(Pe=>[Pe.startDate,Pe.endDate]).filter(Pe=>Pe!==void 0),K=new Date(Math.min(...z.map(Pe=>Pe.getTime()))),ne=new Date(Math.max(...z.map(Pe=>Pe.getTime()))),he=oe==="day"?7:oe==="week"?14:30;return K.setDate(K.getDate()-he),ne.setDate(ne.getDate()+he),{startDate:K,endDate:ne}},[xe,oe]),Fc=react.useCallback(async()=>{if(!Ie.current)return;let S=await vd__default.default(Ie.current,{backgroundColor:U.bgPrimary,scale:2}),z=document.createElement("a");z.download="gantt-chart.png",z.href=S.toDataURL("image/png"),z.click();},[U]),Bc=react.useCallback(async()=>{await se.exportToPDF(xe);},[xe]),Rc=react.useCallback(async()=>{await se.exportToExcel(xe);},[xe]),Oc=react.useCallback(()=>{let S=se.exportToCSV(xe),z=new Blob([S],{type:"text/csv;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(z),K.download="gantt-chart.csv",K.click(),URL.revokeObjectURL(K.href);},[xe]),$c=react.useCallback(()=>{let S=se.exportToJSON(xe),z=new Blob([S],{type:"application/json;charset=utf-8;"}),K=document.createElement("a");K.href=URL.createObjectURL(z),K.download="gantt-chart.json",K.click(),URL.revokeObjectURL(K.href);},[xe]),zc=react.useCallback(()=>{se.exportToMSProject(xe,"Gantt Project","project.xml");},[xe]),Uc=S=>{S.preventDefault(),lt(true);};return react.useEffect(()=>{let S=pe.current,z=Ae.current;if(!S||!z)return;let K=z.querySelector(".gantt-taskgrid-content"),ne=()=>{let Yt=S.scrollTop;Ee(Yt),K&&(K.style.transform=`translateY(-${Yt}px)`);},he=Yt=>{if(_e&&z){let Ra=z.parentElement?.getBoundingClientRect()?.left||0,sr=Yt.clientX-Ra,Wc=280,Gc=Math.min(window.innerWidth-300,800);sr>=Wc&&sr<=Gc&&ot(sr);}},Pe=()=>{lt(false);},$t=z.querySelector(".gantt-grid-scroll")||z,zt=Yt=>{let va=Yt;va.deltaY!==0&&(S.scrollTop+=va.deltaY,Yt.preventDefault());};return S.addEventListener("scroll",ne),$t.addEventListener("wheel",zt,{passive:false}),document.addEventListener("mousemove",he),document.addEventListener("mouseup",Pe),()=>{S.removeEventListener("scroll",ne),$t.removeEventListener("wheel",zt),document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Pe);}},[_e]),jsxRuntime.jsx(Or.Provider,{value:be,children:jsxRuntime.jsx(Pn.Provider,{value:N,children:jsxRuntime.jsxs("div",{ref:Ie,className:"flex flex-col h-full w-full",style:{backgroundColor:U.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(Ho,{theme:U,timeScale:oe,onTimeScaleChange:q,zoom:ee,onZoomChange:Y,currentTheme:E,onThemeChange:Qt,rowDensity:De,onRowDensityChange:M,showThemeSelector:p,showCreateTaskButton:y,createTaskLabel:x,onCreateTask:b,onExportPNG:n?Fc:void 0,onExportPDF:n?Bc:void 0,onExportExcel:n?Rc:void 0,onExportCSV:n?Oc:void 0,onExportJSON:n?$c:void 0,onExportMSProject:n?zc:void 0}),jsxRuntime.jsxs("div",{ref:Ae,className:"flex-1 flex min-h-0",style:{overflow:"clip",overflowClipMargin:"100px"},children:[jsxRuntime.jsx("div",{className:"gantt-grid-scroll flex-shrink-0",style:{width:ge,overflow:"hidden"},children:jsxRuntime.jsx(Ko,{tasks:me,theme:U,rowHeight:Te,availableUsers:m,templates:X,onTaskClick:k,onTaskDblClick:ja,onTaskContextMenu:h,onTaskToggle:It,scrollTop:Ne,columns:Ce,onToggleColumn:At,onColumnResize:Et,onTaskUpdate:Xt,onTaskIndent:ht,onTaskOutdent:Dr,onTaskMove:_a,onMultiTaskDelete:nr,onTaskDuplicate:le,onTaskCreate:yt,onTaskRename:Kt,onCreateSubtask:Va,onOpenTaskModal:k?S=>k(S):void 0,onDeleteRequest:(S,z)=>bt({taskId:S,taskName:z}),onTaskReparent:or})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:Uc}),jsxRuntime.jsx("div",{ref:pe,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(tn,{tasks:me,theme:U,rowHeight:Te,timeScale:oe,startDate:Si,endDate:Vr,zoom:ee,templates:X,onTaskClick:k,onTaskDblClick:ja,onTaskContextMenu:Nr,onTaskDateChange:wo,onDependencyCreate:Co,onDependencyDelete:To})})]}),gt.task&&jsxRuntime.jsx($r,{isOpen:gt.isOpen,x:gt.x,y:gt.y,theme:U,onClose:()=>ft({isOpen:false,x:0,y:0,task:null}),items:(()=>{let S=gt.task;return S?S.subtasks&&S.subtasks.length>0?[{id:"addSubtask",label:be.contextMenu?.addSubtask||"Add Subtask",icon:mt.Add,onClick:()=>{T?T(S):Va(S.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:be.contextMenu?.deleteTask||"Delete Task",icon:mt.Delete,onClick:()=>{bt({taskId:S.id,taskName:S.name});}}]:[{id:"edit",label:be.contextMenu?.editTask||"Edit Task",icon:mt.Pencil,onClick:()=>{B?B(S):it(S);}},{id:"addSubtask",label:be.contextMenu?.addSubtask||"Add Subtask",icon:mt.Add,onClick:()=>{T?T(S):Va(S.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:be.contextMenu?.markIncomplete||"Mark Incomplete",icon:mt.MarkIncomplete,onClick:()=>{$?$(S):Xt(S.id,{status:"todo",progress:0});},disabled:S.status==="todo"},{id:"setInProgress",label:be.contextMenu?.setInProgress||"Set In Progress",icon:mt.SetInProgress,onClick:()=>{W?W(S):Xt(S.id,{status:"in-progress"});},disabled:S.status==="in-progress"},{id:"markComplete",label:be.contextMenu?.markComplete||"Mark Complete",icon:mt.MarkComplete,onClick:()=>{Xt(S.id,{status:"completed",progress:100});},disabled:S.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:be.contextMenu?.splitTask||"Split Task",icon:mt.Split,onClick:()=>{if(!S.startDate||!S.endDate){console.warn("Cannot split task without dates");return}let K=S.startDate.getTime(),ne=S.endDate.getTime(),he=K+(ne-K)/2,Pe=new Date(he);Ba(S,Pe);},disabled:!S.startDate||!S.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:be.contextMenu?.deleteTask||"Delete Task",icon:mt.Delete,onClick:()=>{bt({taskId:S.id,taskName:S.name});}}]:[]})()}),Fe&&jsxRuntime.jsx(rn,{isOpen:true,onClose:()=>it(null),task:Fe,onSubmit:S=>{Xt(Fe.id,S),it(null);},mode:"edit",theme:E}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:Ze&&jsxRuntime.jsx(framerMotion.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:()=>bt(null),children:jsxRuntime.jsxs(framerMotion.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:U.bgSecondary,border:`1px solid ${U.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${U.border}`},children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.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:jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5",style:{color:"#EF4444"}})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("h3",{className:"text-lg font-semibold",style:{color:U.textPrimary,fontFamily:"Inter, sans-serif"},children:[be.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:U.textSecondary,fontFamily:"Inter, sans-serif"},children:v==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsxs("p",{className:"text-sm leading-relaxed",style:{color:U.textSecondary,fontFamily:"Inter, sans-serif"},children:[v==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:U.textPrimary},children:['"',Ze.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:U.bgPrimary,borderTop:`1px solid ${U.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>bt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:U.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=U.hoverBg;},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:v==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{nr([Ze.taskId]),bt(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:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),v==="es"?"Eliminar":"Delete"]})]})]})})}),u?.enabled&&jsxRuntime.jsx(on,{tasks:xe,theme:U,config:u,onTasksUpdate:O,onTaskUpdate:Xt,onTaskCreate:S=>{O(z=>[...z,S]);},onTaskDelete:S=>{nr([S]);},onDependencyCreate:(S,z)=>{let K=se.findTaskById(xe,S);K&&Co(K,z);},onDependencyDelete:To})]})})})});var kd=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
279
279
|
|