@libxai/board 0.17.143 → 0.17.144

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 CHANGED
@@ -273,7 +273,7 @@
273
273
  </Calendars>
274
274
  <Tasks>${m}
275
275
  </Tasks>
276
- </Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),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 p=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+p;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 p=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-p;d.set(n.id,{ls:u,lf:i});};a.forEach(c);let m=[];for(let n of a){let p=r.get(n.id),l=d.get(n.id);if(p&&l){let i=l.ls-p.es;Math.abs(i)<.01&&m.push(n.id);}}return m},calculateSlack:(e,t)=>{let a=se.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(se.calculateCriticalPath(e).includes(t))return 0;let o=se.getDependentTasks(e,t);if(o.length===0){let c=se.getLatestEndDate(e);if(!c)return null;let m=se.calculateDuration(a.endDate,c);return Math.max(0,m)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,m)=>c-m)[0];if(!s)return null;let 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),m;a!==void 0?(m=new Date(d.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let n=se.calculateEndDate(m,c),p=l=>l.map(i=>i.id===d.id?{...i,startDate:m,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=se.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,c)=>{if(a===0)return [];let m=[],n=o.getTime(),p=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(z=>z.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/p,S=(g-n)/p*s,C=S+v*s,O=Math.max(D*s,s),T=c+b*d+12;m.push({taskId:x.id,taskName:x.name,originalX:S,previewX:C,width:O,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),m},splitTask:(e,t,a,r=3)=>{let o=se.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let d=new Date(a);d.setDate(d.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:c}],n=p=>p.map(l=>l.id===o.id?{...l,endDate:c,segments:m}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function Ko({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:c,onTaskClick:m,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=react.useState([]),[x,b]=react.useState(null),[g,k]=react.useState(null),D=react.useCallback(A=>{b(A);},[]),h=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),S=r==="day"?60:r==="week"?20:8,C=h*S*d,O=A=>{let L=new Date(Date.UTC(A.getFullYear(),A.getMonth(),A.getDate())),$=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-$);let E=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-E.getTime())/864e5+1)/7)},T=A=>{let L=A.getDay();return L===0||L===6},z=react.useCallback(A=>{let L=Math.round(A/(S*d)),$=new Date(o);return $.setDate($.getDate()+L),$},[o,S,d]),H=react.useCallback((A,L)=>{if(L.startDate&&L.endDate)return;let $=A.currentTarget.ownerSVGElement;if(!$)return;let E=$.createSVGPoint();E.x=A.clientX,E.y=A.clientY;let Y=E.matrixTransform($.getScreenCTM()?.inverse()),P=z(Y.x),G=new Date(P);G.setDate(G.getDate()+1),l?.(L,P,G);},[z,l]),F=react.useMemo(()=>{let A=Y=>Y.map(P=>{if(P.subtasks&&P.subtasks.length>0){let G=A(P.subtasks),ce=G.filter(re=>re.startDate&&re.endDate);if(ce.length>0){let re=ce.map(ge=>ge.startDate.getTime()),Ee=ce.map(ge=>ge.endDate.getTime()),ae=new Date(Math.min(...re)),_e=new Date(Math.max(...Ee));return {...P,subtasks:G,startDate:ae,endDate:_e}}return {...P,subtasks:G}}return P}),L=(Y,P=[])=>{for(let G of Y)P.push(G),G.subtasks&&G.subtasks.length>0&&(G.isExpanded===void 0||G.isExpanded)&&L(G.subtasks,P);return P},$=A(e);return L($)},[e]),M=react.useCallback(A=>{if(!A.startDate||!A.endDate)return {x:0,width:0};let L=A.startDate.getTime(),$=A.endDate.getTime(),E=o.getTime(),Y=(L-E)/(1e3*60*60*24),P=($-L)/(1e3*60*60*24),G=Y*S*d,ce=Math.max(S*d,40),re=Math.max(P*S*d,ce);return {x:G,width:re}},[o,S,d]),ee=react.useMemo(()=>F.filter(A=>A.startDate&&A.endDate).map(A=>{let{x:L,width:$}=M(A),Y=F.findIndex(P=>P.id===A.id)*a+12;return {id:A.id,x:L,y:Y,width:$,height:32}}),[F,M]),be=react.useCallback((A,L,$)=>{if(!$||L===0){y([]);return}let E=se.calculateCascadePreview(e,A,L,F,o,S*d,a,48);y(E);},[e,F,o,S,d,a,48]),we=react.useMemo(()=>{let A=[],L=new Date(o);for(;L<=s;){let Y=(L.getTime()-o.getTime())/864e5*S*d;if(r==="day")A.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:Y}),L.setDate(L.getDate()+1);else if(r==="week"){let P=O(L);A.push({date:new Date(L),label:`Week ${P}`,x:Y}),L.setDate(L.getDate()+7);}else A.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:Y}),L.setMonth(L.getMonth()+1);}return A},[o,s,r,S,d]),Pe=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*S*d,[o,S,d]),Fe=Math.max(F.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}),we.map((A,L)=>jsxRuntime.jsxs("g",{children:[L>0&&jsxRuntime.jsx("line",{x1:A.x,y1:0,x2:A.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:A.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:A.label})]},`header-${L}`)),Pe>=0&&Pe<=C&&jsxRuntime.jsx("circle",{cx:Pe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(C,1e3),height:Fe,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:Fe,fill:t.bgPrimary}),we.map((A,L)=>{let $=we[L+1]?.x||C,E=T(A.date);return jsxRuntime.jsxs("g",{children:[E&&jsxRuntime.jsx("rect",{x:A.x,y:0,width:$-A.x,height:F.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsxRuntime.jsx("line",{x1:A.x,y1:0,x2:A.x,y2:F.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),Pe>=0&&Pe<=C&&jsxRuntime.jsx("line",{x1:Pe,y1:0,x2:Pe,y2:F.length*a,stroke:t.today,strokeWidth:2,opacity:1}),F.map((A,L)=>{let $=A.startDate&&A.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-${A.id}`),!$&&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=>H(E,A),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-${A.id}`),jsxRuntime.jsx("text",{x:Pe>0?Pe: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-${A.id}`)]})]},`row-group-${A.id}`)}),F.map((A,L)=>!A.dependencies||A.dependencies.length===0||!A.startDate||!A.endDate?null:A.dependencies.map($=>{let E=F.find(ce=>ce.id===$);if(!E||!E.startDate||!E.endDate)return null;let Y=F.findIndex(ce=>ce.id===$),P=M(E),G=M(A);return jsxRuntime.jsx(Ho,{x1:P.x+P.width,y1:Y*a+a/2,x2:G.x,y2:L*a+a/2,theme:t},`dep-${$}-${A.id}`)})),F.map((A,L)=>{if(!A.startDate||!A.endDate)return null;let{x:$,width:E}=M(A),Y=L*a+12,P=A.subtasks&&A.subtasks.length>0&&!A.isMilestone;return A.isMilestone?jsxRuntime.jsx(Vo,{task:A,x:$+E/2,y:Y+16,theme:t,onClick:m},A.id):P?jsxRuntime.jsxs("g",{onClick:()=>m?.(A),onContextMenu:G=>{G.preventDefault(),G.stopPropagation(),p?.(A,G);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:$,y:Y,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:$,y1:Y,x2:$+E,y2:Y,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:$,y1:Y,x2:$,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:$+E,y1:Y,x2:$+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:$,y1:Y+32,x2:$+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsxRuntime.jsx("text",{x:$+12,y:Y+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:A.name})]},A.id):jsxRuntime.jsx(zo,{task:A,x:$,y:Y,width:E,theme:t,dayWidth:S*d,startDate:o,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:ee,onDragMove:be,onHoverChange:D},A.id)}),F.map((A,L)=>!A.dependencies||A.dependencies.length===0||!A.startDate||!A.endDate?null:A.dependencies.map($=>{let E=F.find(at=>at.id===$);if(!E||!E.startDate||!E.endDate)return null;let Y=F.findIndex(at=>at.id===$),P=M(E),G=M(A),ce=P.x+P.width,re=Y*a+a/2,Ee=G.x,ae=L*a+a/2,_e=Ee-ce,ge=ce+_e/2,ct=`M ${ce} ${re} C ${ge} ${re}, ${ge} ${ae}, ${Ee} ${ae}`;return g&&g.x1===ce&&g.y1===re&&g.x2===Ee&&g.y2===ae?null:jsxRuntime.jsx("path",{d:ct,fill:"none",stroke:"transparent",strokeWidth:24,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{k({x1:ce,y1:re,x2:Ee,y2:ae,onDelete:()=>u?.(A.id,$)});}},`dep-hover-${$}-${A.id}`)})),f.map(A=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:A.previewX,y:A.y-48,width:A.width,height:32,rx:8,fill:A.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(A.daysDelta)>0&&jsxRuntime.jsx("text",{x:A.previewX+A.width/2,y:A.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:A.daysDelta>0?`+${A.daysDelta}d`:`${A.daysDelta}d`})]},`cascade-preview-${A.taskId}`)),g&&(()=>{let{x1:A,y1:L,x2:$,y2:E,onDelete:Y}=g,P=$-A,G=E-L,ce=A+P/2,re=(L+E)/2,Ee=`M ${A} ${L} C ${ce} ${L}, ${ce} ${E}, ${$} ${E}`,ae=6,_e=Math.atan2(G,P),ge=$-ae*Math.cos(_e-Math.PI/6),ct=E-ae*Math.sin(_e-Math.PI/6),Nt=$-ae*Math.cos(_e+Math.PI/6),at=E-ae*Math.sin(_e+Math.PI/6),rt=t.dependency,ot="#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:ce,cy:re,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:Ee,fill:"none",stroke:rt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:Ee,fill:"none",stroke:rt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${$} ${E} L ${ge} ${ct} M ${$} ${E} L ${Nt} ${at}`,fill:"none",stroke:rt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:$,cy:E,r:4,fill:rt,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:Zt=>{Zt.stopPropagation(),Y();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:ce,cy:re,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:ot,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsxRuntime.jsx("line",{x1:ce-3,y1:re-3,x2:ce+3,y2:re+3,stroke:ot,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:ce+3,y1:re-3,x2:ce-3,y2:re+3,stroke:ot,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),x&&jsxRuntime.jsx(sd,{tooltipData:x,theme:t})]})]})}var Yo=[{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 Es=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Ps=[{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 Xo({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:d=false,mode:c=a?"edit":"create",theme:m="dark",customStatuses:n=[]}){let p=[...Es,...n.filter(P=>!Es.some(G=>G.id===P.id))],l=Oe[m]||Oe.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,S]=react.useState(new Date),[C,O]=react.useState(false),T=react.useRef(null),z=react.useRef(null),H=react.useRef(null),F=react.useRef(null),[M,ee]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[be,we]=react.useState({});react.useEffect(()=>{a?(ee({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)&&O(true)):(ee({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),O(false));},[a,e]),react.useEffect(()=>{let P=G=>{T.current&&!T.current.contains(G.target)&&u(false),z.current&&!z.current.contains(G.target)&&f(false),H.current&&!H.current.contains(G.target)&&x(false),F.current&&!F.current.contains(G.target)&&g(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let Pe=()=>{let P={};return M.name.trim()||(P.name="El nombre es requerido"),M.startDate&&M.endDate&&M.startDate>M.endDate&&(P.endDate="La fecha de fin debe ser posterior a la de inicio"),we(P),Object.keys(P).length===0},Fe=async P=>{if(P.preventDefault(),!!Pe())try{await s(M),t();}catch(G){console.error("Error submitting task:",G);}},A=(P,G)=>{ee(ce=>{let re={...ce,[P]:G};if(P==="status"){let Ee=G;Ee==="todo"?re.progress=0:Ee==="in-progress"?(ce.progress===0||ce.progress===100)&&(re.progress=50):Ee==="completed"||Ee==="closed"?re.progress=100:(Ee==="in-review"||Ee==="review")&&(re.progress=75);}if(P==="progress"){let Ee=typeof G=="number"?G:parseInt(G,10);Ee===100&&ce.status!=="completed"?re.status="completed":Ee>0&&Ee<100&&ce.status==="todo"?re.status="in-progress":Ee===0&&ce.status!=="todo"&&(re.status="todo");}return re}),be[P]&&we(ce=>{let re={...ce};return delete re[P],re});},L=p.find(P=>P.id===M.status)??Es[0],$=Ps.find(P=>P.id===M.priority)??Ps[1],E=Yo.find(P=>P.value===M.color)??Yo[0],Y={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:P=>P.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:L.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:P=>{P.currentTarget.style.backgroundColor=l.hoverBg,P.currentTarget.style.color=l.textPrimary;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:Fe,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:M.name,onChange:P=>A("name",P.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}),be.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"}),be.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:M.description||"",onChange:P=>A("description",P.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:T,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:{...Y,borderColor:L.color,backgroundColor:`${L.color}15`},disabled:d,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:L.color}}),jsxRuntime.jsx("span",{style:{color:L.color},children:L.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:L.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:p.map(P=>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:G=>G.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:G=>G.currentTarget.style.backgroundColor="transparent",onClick:()=>{A("status",P.id),u(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:P.color}}),P.title,M.status===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),jsxRuntime.jsxs("div",{ref:z,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:Y,disabled:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:$.color}}),jsxRuntime.jsx("span",{children:$.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:Ps.map(P=>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:G=>G.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:G=>G.currentTarget.style.backgroundColor="transparent",onClick:()=>{A("priority",P.id),f(false);},children:[jsxRuntime.jsx("span",{children:P.icon}),P.label,M.priority===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:H,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:Y,disabled:d,children:[M.assignees&&M.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:M.assignees.slice(0,3).map((P,G)=>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:P.color||l.accent,borderColor:l.bgSecondary},children:P.initials},G))}),M.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:l.textTertiary},children:["+",M.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(P=>{let G=M.assignees?.some(ce=>ce.name===P.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:ce=>ce.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ce=>ce.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ce=G?(M.assignees||[]).filter(re=>re.name!==P.name):[...M.assignees||[],{name:P.name,avatar:P.avatar,initials:P.name.split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),color:l.accent}];A("assignees",ce);},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:P.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:P.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:G&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})})]},P.id)})})})]}),jsxRuntime.jsxs("div",{ref:F,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:Y,disabled:d,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:M.color}}),jsxRuntime.jsx("span",{children:E.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:Yo.slice(0,16).map(P=>{let G=M.color===P.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>{A("color",P.value),g(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:P.value,outline:G?`2px solid ${P.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:P.name},P.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",{className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!M.isMilestone&&(D(k==="start"?null:"start"),S(M.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...Y,opacity:M.isMilestone?.5:1,cursor:M.isMilestone?"not-allowed":"pointer"},disabled:d||M.isMilestone,children:M.startDate?M.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!M.isMilestone&&(D(k==="end"?null:"end"),S(M.endDate||M.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...Y,opacity:M.isMilestone?.5:1,cursor:M.isMilestone?"not-allowed":"pointer"},disabled:d||M.isMilestone,children:M.endDate?M.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>D(null)}),jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let P=new Date,G=new Date(P);G.setDate(P.getDate()+1);let ce=new Date(P);ce.setDate(P.getDate()+7);let re=new Date(P);return re.setDate(P.getDate()+14),[{label:"Hoy",date:P},{label:"Ma\xF1ana",date:G},{label:"Pr\xF3xima semana",date:ce},{label:"2 semanas",date:re}].map((ae,_e)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:ge=>ge.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ge=>ge.currentTarget.style.backgroundColor="transparent",onClick:()=>{k==="start"?(A("startDate",ae.date),(!M.endDate||ae.date>M.endDate)&&A("endDate",ae.date),D("end")):(A("endDate",ae.date),(!M.startDate||ae.date<M.startDate)&&A("startDate",ae.date),D(null));},children:ae.label},_e))})(),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:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",onClick:()=>{A("startDate",void 0),A("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:()=>S(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:()=>S(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((P,G)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:P},G))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=h.getFullYear(),G=h.getMonth(),ce=new Date(P,G,1).getDay(),re=new Date(P,G+1,0).getDate(),Ee=new Date,ae=[];for(let ge=ce-1;ge>=0;ge--)ae.push({day:new Date(P,G,-ge).getDate(),date:new Date(P,G-1,new Date(P,G,-ge).getDate()),isCurrentMonth:false});for(let ge=1;ge<=re;ge++)ae.push({day:ge,date:new Date(P,G,ge),isCurrentMonth:true});let _e=42-ae.length;for(let ge=1;ge<=_e;ge++)ae.push({day:ge,date:new Date(P,G+1,ge),isCurrentMonth:false});return ae.map((ge,ct)=>{let Nt=ge.date.toDateString()===Ee.toDateString(),at=M.startDate?.toDateString()===ge.date.toDateString(),rt=M.endDate?.toDateString()===ge.date.toDateString(),ot=M.startDate&&M.endDate&&ge.date>=M.startDate&&ge.date<=M.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:ge.isCurrentMonth?at||rt?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:at?"#3B82F6":rt?"#7C3AED":ot?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Nt&&!at&&!rt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{k==="start"?(A("startDate",ge.date),M.endDate&&ge.date>M.endDate&&A("endDate",ge.date),D("end")):(A("endDate",ge.date),M.startDate&&ge.date<M.startDate&&A("startDate",ge.date),D(null));},children:ge.day},ct)})})()})]})]})]})})]}),be.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:be.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:M.progress,onChange:P=>A("progress",parseInt(P.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:M.progress<30?"#EF4444":M.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:`${M.progress<30?"#EF4444":M.progress<70?"#F59E0B":"#10B981"}20`,color:M.progress<30?"#EF4444":M.progress<70?"#F59E0B":"#10B981"},children:[M.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>O(!C),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 ${C?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:C&&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:M.isMilestone,onChange:P=>A("isMilestone",P.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(P=>P.id!==a?.id).map(P=>{let G=M.dependencies?.includes(P.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let ce=G?(M.dependencies||[]).filter(re=>re!==P.id):[...M.dependencies||[],P.id];A("dependencies",ce);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:G?`${l.accent}30`:l.bgPrimary,color:G?l.accent:l.textSecondary,border:`1px solid ${G?l.accent:l.borderLight}`},disabled:d,children:P.name},P.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:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.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:P=>!d&&(P.currentTarget.style.opacity="0.9"),onMouseLeave:P=>!d&&(P.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"'],md=()=>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"})]}),Ug=()=>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"})}),zg=()=>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 Jo({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:d,onDependencyCreate:c,onDependencyDelete:m}){let[n,p]=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),S=react.useRef(null),{enabled:C=true,placeholder:O='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:z,suggestions:H=$g,maxHistory:F=50,persistHistory:M}=a,ee=M?.storageKey||"gantt-ai-history",be=M?.maxMessages??5;react.useEffect(()=>{if(M?.enabled)try{let $=localStorage.getItem(ee);if($){let Y=JSON.parse($).map(P=>({...P,timestamp:new Date(P.timestamp)}));v(Y.slice(-be));}}catch($){console.warn("[GanttAIAssistant] Failed to load persisted history:",$);}},[M?.enabled,ee,be]),react.useEffect(()=>{if(M?.enabled&&u.length>0)try{let $=u.filter(E=>!E.isLoading).slice(-be);localStorage.setItem(ee,JSON.stringify($));}catch($){console.warn("[GanttAIAssistant] Failed to persist history:",$);}},[u,M?.enabled,ee,be]),react.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let we=react.useCallback($=>{if($.success)switch($.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":$.taskId&&$.updates&&o?.($.taskId,$.updates);break;case "create_task":$.newTask&&s?.($.newTask);break;case "delete_task":$.taskId&&d?.($.taskId);break;case "link_tasks":$.dependencyFrom&&$.dependencyTo&&c?.($.dependencyFrom,$.dependencyTo);break;case "unlink_tasks":$.taskId&&$.dependencyFrom&&m?.($.taskId,$.dependencyFrom);break}},[o,s,d,c,m]),Pe=react.useCallback(async $=>{if(!$.trim()||x)return;let E={id:`user-${Date.now()}`,role:"user",content:$,timestamp:new Date};v(P=>[...P.slice(-(F-1)),E]),y(""),k(false),b(true);let Y={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(P=>[...P,Y]);try{if(z){let P=await z($,e);v(G=>{let ce=G.filter(Ee=>!Ee.isLoading),re={id:`assistant-${Date.now()}`,role:"assistant",content:P.message,timestamp:new Date,command:P};return [...ce,re]}),we(P);}else v(P=>[...P.filter(ce=>!ce.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(P){v(G=>[...G.filter(re=>!re.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${P instanceof Error?P.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,F,z,e,we]),Fe=$=>{$.preventDefault(),Pe(f);},A=$=>{y($),D.current?.focus();};if(react.useEffect(()=>{let $=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),p(Y=>!Y),n||i(false)),E.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[n]),react.useEffect(()=>{if(!n)return;let $=Y=>{let P=Y.target;S.current&&!S.current.contains(P)&&p(false);},E=setTimeout(()=>{document.addEventListener("mousedown",$);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",$);}},[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(Ye,{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:()=>p(true),children:[jsxRuntime.jsx(md,{}),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:S,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(md,{}),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($=>!$),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:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(zg,{})})]})]}),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:H.slice(0,4).map(($,E)=>jsxRuntime.jsx("button",{onClick:()=>A($),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:$.length>30?$.slice(0,30)+"...":$},E))})]}),u.map($=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${$.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${$.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:$.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:$.role==="user"?"white":t.textPrimary},children:[$.isLoading?jsxRuntime.jsx(Gg,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:$.content}),$.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:$.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:$.command.success?"#10B981":"#EF4444"},children:[$.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:$.command.type.replace(/_/g," ")})]})]})},$.id)),jsxRuntime.jsx("div",{ref:h})]}),jsxRuntime.jsxs("form",{onSubmit:Fe,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:$=>y($.target.value),placeholder:O,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(Ug,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function pd(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,p=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!p)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 p=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:p,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:l}});},[]),m=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:m}}function ud({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,m=c?d.metaKey:d.ctrlKey;if(m&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!c&&m&&d.key==="y"){d.preventDefault(),t();return}if(c&&m&&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 gd(e){return {...jg,...e}}var Qg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hd=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:c="comfortable",showThemeSelector:m=true,showExportButton:n=true,availableUsers:p=[],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:S,onProgressChange:C,onTaskEdit:O,onTaskAddSubtask:T,onTaskMarkIncomplete:z,onTaskSetInProgress:H,onDependencyCreate:F,onDependencyDelete:M,onBeforeTaskAdd:ee,onAfterTaskAdd:be,onBeforeTaskUpdate:we,onAfterTaskUpdate:Pe,onBeforeTaskDelete:Fe,onAfterTaskDelete:A}=a,$=react.useContext(Lo)?.theme,[E,Y]=react.useState($||s||"dark"),[P,G]=react.useState(d),[ce,re]=react.useState(c),[Ee,ae]=react.useState(1),[_e,ge]=react.useState(0),[ct,Nt]=react.useState(false),[at,rt]=react.useState(null),[ot,mt]=react.useState({isOpen:false,x:0,y:0,task:null}),[Zt,wt]=react.useState(null),[pt,Lt]=react.useState(null);react.useEffect(()=>{$&&$!==E&&Y($);},[$]),react.useEffect(()=>{s&&s!==E&&Y(s);},[s]);let jt=react.useCallback(N=>{Y(N),g?.(N);},[g]),{state:Ce,setState:U,undo:De,redo:ze,canUndo:Ue,canRedo:bt,clearHistory:J}=pd(t,50);react.useEffect(()=>{U(t);},[t,U]);let Q=react.useRef(t),xe=react.useRef(true);react.useEffect(()=>{if(xe.current){xe.current=false,Q.current=Ce;return}if(!r)return;let N=JSON.stringify(Q.current),W=JSON.stringify(Ce);N!==W&&(Q.current=Ce,r(Ce));},[Ce,r]);let fe=react.useMemo(()=>ps(v,f),[v,f]),te=react.useCallback(N=>[{id:"name",label:N.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:N.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:N.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:N.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:N.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:N.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:N.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:N.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Te,he]=react.useState(()=>te(fe));react.useEffect(()=>{he(N=>N.map(W=>({...W,label:fe.columns[W.id==="name"?"taskName":W.id]||W.label})));},[fe]);let ke=react.useMemo(()=>{let N=Te.filter(ne=>ne.visible),W=N.some(ne=>ne.id!=="name");return N.reduce((ne,ye)=>ne+ye.width,0)+(W?20:0)},[Te]);react.useEffect(()=>{at!==null&&at>ke&&(Te.filter(q=>q.visible).some(q=>q.id!=="name")||rt(null));},[Te,ke,at]);let R=react.useMemo(()=>at!==null?Math.max(280,at,ke):Math.max(280,ke),[at,ke]),_=react.useRef(null),X=react.useRef(null),le=react.useRef(null),de=react.useMemo(()=>Ll(E),[E]),B=react.useMemo(()=>({theme:de,themeName:E}),[de,E]),K=react.useMemo(()=>gd(l),[l]),Ne=react.useMemo(()=>{if(!i)return Ce;let N=se.calculateCriticalPath(Ce),W=q=>q.map(ne=>({...ne,isCriticalPath:N.includes(ne.id),subtasks:ne.subtasks?W(ne.subtasks):void 0}));return W(Ce)},[Ce,i]),je=Qg(ce);ud({undo:De,redo:ze,canUndo:Ue,canRedo:bt,enabled:true}),react.useImperativeHandle(o,()=>({getTask:N=>se.findTaskById(Ce,N),addTask:(N,W)=>{U(q=>{if(!W)return [...q,{...N,level:0}];let ne=ye=>ye.map(Se=>Se.id===W?{...Se,subtasks:[...Se.subtasks||[],{...N,parentId:W,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:ne(Se.subtasks)}:Se);return ne(q)});},updateTask:(N,W)=>{U(q=>{let ne=ye=>ye.map(Se=>Se.id===N?{...Se,...W}:Se.subtasks?{...Se,subtasks:ne(Se.subtasks)}:Se);return ne(q)});},deleteTask:N=>{U(W=>{let q=ne=>ne.filter(ye=>ye.id===N?false:(ye.subtasks&&(ye.subtasks=q(ye.subtasks)),true));return q(W)});},deleteTasks:N=>{U(W=>vs(W,N));},duplicateTask:N=>{U(W=>xs(W,[N]));},splitTask:(N,W,q=3)=>{U(ne=>se.splitTask(ne,N,W,q));},calculateEndDate:se.calculateEndDate,calculateDuration:se.calculateDuration,validateDependency:(N,W)=>!se.validateDependencies(Ce,N,W),getAllTasks:()=>se.flattenTasks(Ce),getTasksByStatus:N=>se.flattenTasks(Ce).filter(W=>W.status===N),getTasksByParent:N=>N?se.findTaskById(Ce,N)?.subtasks||[]:Ce.filter(q=>!q.parentId),getCriticalPath:()=>se.flattenTasks(Ce).filter(N=>N.isCriticalPath),indentTask:N=>{U(W=>bs(W,[N]));},outdentTask:N=>{U(W=>hs(W,[N]));},moveTask:(N,W)=>{U(q=>ys(q,[N],W));},createSubtask:async N=>{let{tasks:W,newTask:q}=Cs(Ce,N);if(ee){let ne=ee({...q,parentId:N});if((ne instanceof Promise?await ne:ne)===false)return}U(W),be&&be({...q,parentId:N});},scrollToTask:N=>{let q=se.flattenTasks(Ce).findIndex(ne=>ne.id===N);if(q!==-1&&_.current){let ne=q*je;_.current.scrollTo({top:ne,behavior:"smooth"}),X.current&&X.current.scrollTo({top:ne,behavior:"smooth"});}},highlightTask:(N,W=2e3)=>{},expandTask:N=>{U(W=>{let q=ne=>ne.map(ye=>ye.id===N?{...ye,isExpanded:true}:ye.subtasks?{...ye,subtasks:q(ye.subtasks)}:ye);return q(W)});},collapseTask:N=>{U(W=>{let q=ne=>ne.map(ye=>ye.id===N?{...ye,isExpanded:false}:ye.subtasks?{...ye,subtasks:q(ye.subtasks)}:ye);return q(W)});},expandAll:()=>{U(N=>{let W=q=>q.map(ne=>({...ne,isExpanded:true,subtasks:ne.subtasks?W(ne.subtasks):void 0}));return W(N)});},collapseAll:()=>{U(N=>{let W=q=>q.map(ne=>({...ne,isExpanded:false,subtasks:ne.subtasks?W(ne.subtasks):void 0}));return W(N)});},undo:De,redo:ze,canUndo:()=>Ue,canRedo:()=>bt,clearHistory:J,exportToPNG:async()=>{if(!le.current)throw new Error("Gantt container not found");let N=await bd__default.default(le.current,{backgroundColor:de.bgPrimary,scale:2});return new Promise((W,q)=>{N.toBlob(ne=>{ne?W(ne):q(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await se.exportToPDF(Ce,N);},exportToExcel:async N=>{await se.exportToExcel(Ce,N);},exportToJSON:()=>se.exportToJSON(Ce),exportToCSV:()=>se.exportToCSV(Ce),importFromJSON:N=>{let W=se.importFromJSON(N);U(W);},getTasks:()=>Ce,refresh:()=>{U(N=>[...N]);},clearAll:()=>{U([]);}}),[Ce,De,ze,Ue,bt,J,de,je]);let Pt=react.useCallback(N=>{he(W=>W.map(q=>q.id===N?{...q,visible:!q.visible}:q));},[]),zr=react.useCallback((N,W)=>{he(q=>q.map(ne=>{if(ne.id!==N)return ne;let ye=ne.minWidth??100,Se=ne.maxWidth??800,Ft=Math.max(ye,Math.min(Se,W));return {...ne,width:Ft}}));},[]),Wr=react.useCallback(N=>{U(W=>ws(W,N)),a.onTaskToggleExpand?.(N);},[a]),Wa=react.useCallback((N,W)=>{if(we&&we(N,W)===false)return;let ne=se.findTaskById(Ce,N)?.progress,ye=Ft=>Ft.map(Bt=>Bt.id===N?{...Bt,...W}:Bt.subtasks?{...Bt,subtasks:ye(Bt.subtasks)}:Bt);U(ye(Ce));let Se=se.findTaskById(ye(Ce),N);Se&&(S?.(Se),Pe?.(Se),W.progress!==void 0&&ne!==void 0&&W.progress!==ne&&C?.(N,ne,W.progress));},[Ce,S,we,Pe,C]),yn=react.useCallback(N=>{N.length!==0&&(U(W=>bs(W,N)),a.onTaskIndent?.(N[0]));},[a]),me=react.useCallback(N=>{N.length!==0&&(U(W=>hs(W,N)),a.onTaskOutdent?.(N[0]));},[a]),ut=react.useCallback((N,W,q)=>{U(ne=>Ql(ne,N,W,q)),a.onTaskReparent?.(N,W,q);},[a]),Ht=react.useCallback((N,W)=>{N.length!==0&&(U(q=>ys(q,N,W)),a.onTaskMove?.(N[0],W));},[a]),Ga=react.useCallback(async N=>{let W=[];for(let q of N)Fe&&await Promise.resolve(Fe(q))===false||W.push(q);W.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(W):(U(q=>vs(q,W)),W.forEach(q=>a.onTaskDelete?.(q))),A&&W.forEach(q=>A(q)));},[a,Fe,A]),bo=react.useCallback(N=>{U(W=>xs(W,N)),N.forEach(W=>a.onTaskDuplicate?.(W));},[a]),vr=react.useCallback((N,W)=>{U(q=>{let{tasks:ne,newTask:ye}=Zl(q,N,W);return ee&&ee(ye)===false?q:(a.onTaskCreate?.(ye.parentId,ye.position||0),be?.(ye),ne)});},[a,ee,be]),Ma=react.useCallback((N,W)=>{U(q=>ks(q,N,W)),a.onTaskRename?.(N,W);},[a]),Aa=react.useCallback(N=>{U(W=>{let{tasks:q}=Cs(W,N);return a.onTaskCreate?.(N,0),q});},[a]),Ct=react.useCallback((N,W,q)=>{let ne=N.startDate?Math.round((W.getTime()-N.startDate.getTime())/864e5):0,ye=Bt=>Bt.map(_t=>_t.id===N.id?{..._t,startDate:W,endDate:q,...N.segments&&{segments:N.segments}}:_t.subtasks?{..._t,subtasks:ye(_t.subtasks)}:_t),Se=ye(Ce);Se=se.autoScheduleDependents(Se,N.id,ne),U(Se);let Ft={...N,startDate:W,endDate:q};S?.(Ft);},[Ce,S]),vn=react.useCallback((N,W)=>{h?.(N,W),mt({isOpen:true,x:W.clientX,y:W.clientY,task:N});},[h]),xn=react.useCallback((N,W)=>{let q=se.splitTask(Ce,N.id,W);U(q),mt({isOpen:false,x:0,y:0,task:null});},[Ce]),kn=react.useCallback(N=>{D?.(N),O||wt(N);},[D,O]),xr=react.useCallback((N,W,q)=>{let ne=new Map,ye=fa=>{fa.forEach(Ia=>{Ia.dependencies&&ne.set(Ia.id,Ia.dependencies),Ia.subtasks&&ye(Ia.subtasks);});};ye(q);let Se=ne.get(W)||[];ne.set(W,[...Se,N]);let Ft=new Set,Bt=new Set,_t=fa=>{if(!Ft.has(fa)){Ft.add(fa),Bt.add(fa);let Ia=ne.get(fa)||[];for(let er of Ia){if(!Ft.has(er)&&_t(er))return true;if(Bt.has(er))return true}}return Bt.delete(fa),false};return _t(W)},[]),Ti=react.useCallback((N,W)=>{if(xr(N.id,W,Ce)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
276
+ </Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),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 p=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+p;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 p=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-p;d.set(n.id,{ls:u,lf:i});};a.forEach(c);let m=[];for(let n of a){let p=r.get(n.id),l=d.get(n.id);if(p&&l){let i=l.ls-p.es;Math.abs(i)<.01&&m.push(n.id);}}return m},calculateSlack:(e,t)=>{let a=se.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(se.calculateCriticalPath(e).includes(t))return 0;let o=se.getDependentTasks(e,t);if(o.length===0){let c=se.getLatestEndDate(e);if(!c)return null;let m=se.calculateDuration(a.endDate,c);return Math.max(0,m)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,m)=>c-m)[0];if(!s)return null;let 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),m;a!==void 0?(m=new Date(d.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let n=se.calculateEndDate(m,c),p=l=>l.map(i=>i.id===d.id?{...i,startDate:m,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=se.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,c)=>{if(a===0)return [];let m=[],n=o.getTime(),p=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(z=>z.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/p,S=(g-n)/p*s,C=S+v*s,O=Math.max(D*s,s),T=c+b*d+12;m.push({taskId:x.id,taskName:x.name,originalX:S,previewX:C,width:O,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),m},splitTask:(e,t,a,r=3)=>{let o=se.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let d=new Date(a);d.setDate(d.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:c}],n=p=>p.map(l=>l.id===o.id?{...l,endDate:c,segments:m}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function Ko({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:c,onTaskClick:m,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=react.useState([]),[x,b]=react.useState(null),[g,k]=react.useState(null),D=react.useCallback(A=>{b(A);},[]),h=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),S=r==="day"?60:r==="week"?20:8,C=h*S*d,O=A=>{let L=new Date(Date.UTC(A.getFullYear(),A.getMonth(),A.getDate())),$=L.getUTCDay()||7;L.setUTCDate(L.getUTCDate()+4-$);let E=new Date(Date.UTC(L.getUTCFullYear(),0,1));return Math.ceil(((L.getTime()-E.getTime())/864e5+1)/7)},T=A=>{let L=A.getDay();return L===0||L===6},z=react.useCallback(A=>{let L=Math.round(A/(S*d)),$=new Date(o);return $.setDate($.getDate()+L),$},[o,S,d]),H=react.useCallback((A,L)=>{if(L.startDate&&L.endDate)return;let $=A.currentTarget.ownerSVGElement;if(!$)return;let E=$.createSVGPoint();E.x=A.clientX,E.y=A.clientY;let Y=E.matrixTransform($.getScreenCTM()?.inverse()),P=z(Y.x),G=new Date(P);G.setDate(G.getDate()+1),l?.(L,P,G);},[z,l]),F=react.useMemo(()=>{let A=Y=>Y.map(P=>{if(P.subtasks&&P.subtasks.length>0){let G=A(P.subtasks),ce=G.filter(re=>re.startDate&&re.endDate);if(ce.length>0){let re=ce.map(ge=>ge.startDate.getTime()),Ee=ce.map(ge=>ge.endDate.getTime()),ae=new Date(Math.min(...re)),_e=new Date(Math.max(...Ee));return {...P,subtasks:G,startDate:ae,endDate:_e}}return {...P,subtasks:G}}return P}),L=(Y,P=[])=>{for(let G of Y)P.push(G),G.subtasks&&G.subtasks.length>0&&(G.isExpanded===void 0||G.isExpanded)&&L(G.subtasks,P);return P},$=A(e);return L($)},[e]),M=react.useCallback(A=>{if(!A.startDate||!A.endDate)return {x:0,width:0};let L=A.startDate.getTime(),$=A.endDate.getTime(),E=o.getTime(),Y=(L-E)/(1e3*60*60*24),P=($-L)/(1e3*60*60*24),G=Y*S*d,ce=Math.max(S*d,40),re=Math.max(P*S*d,ce);return {x:G,width:re}},[o,S,d]),ee=react.useMemo(()=>F.filter(A=>A.startDate&&A.endDate).map(A=>{let{x:L,width:$}=M(A),Y=F.findIndex(P=>P.id===A.id)*a+12;return {id:A.id,x:L,y:Y,width:$,height:32}}),[F,M]),be=react.useCallback((A,L,$)=>{if(!$||L===0){y([]);return}let E=se.calculateCascadePreview(e,A,L,F,o,S*d,a,48);y(E);},[e,F,o,S,d,a,48]),we=react.useMemo(()=>{let A=[],L=new Date(o);for(;L<=s;){let Y=(L.getTime()-o.getTime())/864e5*S*d;if(r==="day")A.push({date:new Date(L),label:L.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:Y}),L.setDate(L.getDate()+1);else if(r==="week"){let P=O(L);A.push({date:new Date(L),label:`Week ${P}`,x:Y}),L.setDate(L.getDate()+7);}else A.push({date:new Date(L),label:L.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:Y}),L.setMonth(L.getMonth()+1);}return A},[o,s,r,S,d]),Pe=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*S*d,[o,S,d]),Fe=Math.max(F.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}),we.map((A,L)=>jsxRuntime.jsxs("g",{children:[L>0&&jsxRuntime.jsx("line",{x1:A.x,y1:0,x2:A.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:A.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:A.label})]},`header-${L}`)),Pe>=0&&Pe<=C&&jsxRuntime.jsx("circle",{cx:Pe,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(C,1e3),height:Fe,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:Fe,fill:t.bgPrimary}),we.map((A,L)=>{let $=we[L+1]?.x||C,E=T(A.date);return jsxRuntime.jsxs("g",{children:[E&&jsxRuntime.jsx("rect",{x:A.x,y:0,width:$-A.x,height:F.length*a,fill:t.bgWeekend,opacity:1}),L>0&&jsxRuntime.jsx("line",{x1:A.x,y1:0,x2:A.x,y2:F.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},L)}),Pe>=0&&Pe<=C&&jsxRuntime.jsx("line",{x1:Pe,y1:0,x2:Pe,y2:F.length*a,stroke:t.today,strokeWidth:2,opacity:1}),F.map((A,L)=>{let $=A.startDate&&A.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-${A.id}`),!$&&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=>H(E,A),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-${A.id}`),jsxRuntime.jsx("text",{x:Pe>0?Pe: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-${A.id}`)]})]},`row-group-${A.id}`)}),F.map((A,L)=>!A.dependencies||A.dependencies.length===0||!A.startDate||!A.endDate?null:A.dependencies.map($=>{let E=F.find(ce=>ce.id===$);if(!E||!E.startDate||!E.endDate)return null;let Y=F.findIndex(ce=>ce.id===$),P=M(E),G=M(A);return jsxRuntime.jsx(Ho,{x1:P.x+P.width,y1:Y*a+a/2,x2:G.x,y2:L*a+a/2,theme:t},`dep-${$}-${A.id}`)})),F.map((A,L)=>{if(!A.startDate||!A.endDate)return null;let{x:$,width:E}=M(A),Y=L*a+12,P=A.subtasks&&A.subtasks.length>0&&!A.isMilestone;return A.isMilestone?jsxRuntime.jsx(Vo,{task:A,x:$+E/2,y:Y+16,theme:t,onClick:m},A.id):P?jsxRuntime.jsxs("g",{onClick:()=>m?.(A),onContextMenu:G=>{G.preventDefault(),G.stopPropagation(),p?.(A,G);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:$,y:Y,width:E,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:$,y1:Y,x2:$+E,y2:Y,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:$,y1:Y,x2:$,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:$+E,y1:Y,x2:$+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:$,y1:Y+32,x2:$+E,y2:Y+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),E>60&&jsxRuntime.jsx("text",{x:$+12,y:Y+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:A.name})]},A.id):jsxRuntime.jsx(zo,{task:A,x:$,y:Y,width:E,theme:t,dayWidth:S*d,startDate:o,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:ee,onDragMove:be,onHoverChange:D},A.id)}),F.map((A,L)=>!A.dependencies||A.dependencies.length===0||!A.startDate||!A.endDate?null:A.dependencies.map($=>{let E=F.find(at=>at.id===$);if(!E||!E.startDate||!E.endDate)return null;let Y=F.findIndex(at=>at.id===$),P=M(E),G=M(A),ce=P.x+P.width,re=Y*a+a/2,Ee=G.x,ae=L*a+a/2,_e=Ee-ce,ge=ce+_e/2,ct=`M ${ce} ${re} C ${ge} ${re}, ${ge} ${ae}, ${Ee} ${ae}`;return g&&g.x1===ce&&g.y1===re&&g.x2===Ee&&g.y2===ae?null:jsxRuntime.jsx("path",{d:ct,fill:"none",stroke:"transparent",strokeWidth:24,strokeLinecap:"round",style:{cursor:"pointer"},onMouseEnter:()=>{k({x1:ce,y1:re,x2:Ee,y2:ae,onDelete:()=>u?.(A.id,$)});}},`dep-hover-${$}-${A.id}`)})),f.map(A=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:A.previewX,y:A.y-48,width:A.width,height:32,rx:8,fill:A.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(A.daysDelta)>0&&jsxRuntime.jsx("text",{x:A.previewX+A.width/2,y:A.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:A.daysDelta>0?`+${A.daysDelta}d`:`${A.daysDelta}d`})]},`cascade-preview-${A.taskId}`)),g&&(()=>{let{x1:A,y1:L,x2:$,y2:E,onDelete:Y}=g,P=$-A,G=E-L,ce=A+P/2,re=(L+E)/2,Ee=`M ${A} ${L} C ${ce} ${L}, ${ce} ${E}, ${$} ${E}`,ae=6,_e=Math.atan2(G,P),ge=$-ae*Math.cos(_e-Math.PI/6),ct=E-ae*Math.sin(_e-Math.PI/6),Nt=$-ae*Math.cos(_e+Math.PI/6),at=E-ae*Math.sin(_e+Math.PI/6),rt=t.dependency,ot="#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:ce,cy:re,r:25,fill:"transparent",style:{cursor:"pointer"}}),jsxRuntime.jsx("path",{d:Ee,fill:"none",stroke:rt,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsxRuntime.jsx("path",{d:Ee,fill:"none",stroke:rt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("path",{d:`M ${$} ${E} L ${ge} ${ct} M ${$} ${E} L ${Nt} ${at}`,fill:"none",stroke:rt,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsxRuntime.jsx("circle",{cx:$,cy:E,r:4,fill:rt,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:Zt=>{Zt.stopPropagation(),k(null),Y();},style:{cursor:"pointer"},children:[jsxRuntime.jsx("circle",{cx:ce,cy:re,r:9,fill:"rgba(248, 113, 113, 0.15)",stroke:ot,strokeWidth:1.5,style:{transition:"all 0.15s ease"}}),jsxRuntime.jsx("line",{x1:ce-3,y1:re-3,x2:ce+3,y2:re+3,stroke:ot,strokeWidth:1.5,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:ce+3,y1:re-3,x2:ce-3,y2:re+3,stroke:ot,strokeWidth:1.5,strokeLinecap:"round"})]})]})})(),x&&jsxRuntime.jsx(sd,{tooltipData:x,theme:t})]})]})}var Yo=[{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 Es=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],Ps=[{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 Xo({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:d=false,mode:c=a?"edit":"create",theme:m="dark",customStatuses:n=[]}){let p=[...Es,...n.filter(P=>!Es.some(G=>G.id===P.id))],l=Oe[m]||Oe.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,S]=react.useState(new Date),[C,O]=react.useState(false),T=react.useRef(null),z=react.useRef(null),H=react.useRef(null),F=react.useRef(null),[M,ee]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[be,we]=react.useState({});react.useEffect(()=>{a?(ee({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)&&O(true)):(ee({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),O(false));},[a,e]),react.useEffect(()=>{let P=G=>{T.current&&!T.current.contains(G.target)&&u(false),z.current&&!z.current.contains(G.target)&&f(false),H.current&&!H.current.contains(G.target)&&x(false),F.current&&!F.current.contains(G.target)&&g(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let Pe=()=>{let P={};return M.name.trim()||(P.name="El nombre es requerido"),M.startDate&&M.endDate&&M.startDate>M.endDate&&(P.endDate="La fecha de fin debe ser posterior a la de inicio"),we(P),Object.keys(P).length===0},Fe=async P=>{if(P.preventDefault(),!!Pe())try{await s(M),t();}catch(G){console.error("Error submitting task:",G);}},A=(P,G)=>{ee(ce=>{let re={...ce,[P]:G};if(P==="status"){let Ee=G;Ee==="todo"?re.progress=0:Ee==="in-progress"?(ce.progress===0||ce.progress===100)&&(re.progress=50):Ee==="completed"||Ee==="closed"?re.progress=100:(Ee==="in-review"||Ee==="review")&&(re.progress=75);}if(P==="progress"){let Ee=typeof G=="number"?G:parseInt(G,10);Ee===100&&ce.status!=="completed"?re.status="completed":Ee>0&&Ee<100&&ce.status==="todo"?re.status="in-progress":Ee===0&&ce.status!=="todo"&&(re.status="todo");}return re}),be[P]&&we(ce=>{let re={...ce};return delete re[P],re});},L=p.find(P=>P.id===M.status)??Es[0],$=Ps.find(P=>P.id===M.priority)??Ps[1],E=Yo.find(P=>P.value===M.color)??Yo[0],Y={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:P=>P.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:L.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:P=>{P.currentTarget.style.backgroundColor=l.hoverBg,P.currentTarget.style.color=l.textPrimary;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:Fe,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:M.name,onChange:P=>A("name",P.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}),be.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"}),be.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:M.description||"",onChange:P=>A("description",P.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:T,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:{...Y,borderColor:L.color,backgroundColor:`${L.color}15`},disabled:d,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:L.color}}),jsxRuntime.jsx("span",{style:{color:L.color},children:L.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:L.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:p.map(P=>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:G=>G.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:G=>G.currentTarget.style.backgroundColor="transparent",onClick:()=>{A("status",P.id),u(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:P.color}}),P.title,M.status===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),jsxRuntime.jsxs("div",{ref:z,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:Y,disabled:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:$.color}}),jsxRuntime.jsx("span",{children:$.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:Ps.map(P=>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:G=>G.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:G=>G.currentTarget.style.backgroundColor="transparent",onClick:()=>{A("priority",P.id),f(false);},children:[jsxRuntime.jsx("span",{children:P.icon}),P.label,M.priority===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:H,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:Y,disabled:d,children:[M.assignees&&M.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:M.assignees.slice(0,3).map((P,G)=>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:P.color||l.accent,borderColor:l.bgSecondary},children:P.initials},G))}),M.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:l.textTertiary},children:["+",M.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(P=>{let G=M.assignees?.some(ce=>ce.name===P.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:ce=>ce.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ce=>ce.currentTarget.style.backgroundColor="transparent",onClick:()=>{let ce=G?(M.assignees||[]).filter(re=>re.name!==P.name):[...M.assignees||[],{name:P.name,avatar:P.avatar,initials:P.name.split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),color:l.accent}];A("assignees",ce);},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:P.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:P.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:G&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})})]},P.id)})})})]}),jsxRuntime.jsxs("div",{ref:F,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:Y,disabled:d,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:M.color}}),jsxRuntime.jsx("span",{children:E.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:Yo.slice(0,16).map(P=>{let G=M.color===P.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>{A("color",P.value),g(false);},style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:P.value,outline:G?`2px solid ${P.value}`:"none",outlineOffset:"3px",cursor:"pointer",border:"none"},whileHover:{scale:1.2},whileTap:{scale:.95},title:P.name},P.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",{className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!M.isMilestone&&(D(k==="start"?null:"start"),S(M.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...Y,opacity:M.isMilestone?.5:1,cursor:M.isMilestone?"not-allowed":"pointer"},disabled:d||M.isMilestone,children:M.startDate?M.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!M.isMilestone&&(D(k==="end"?null:"end"),S(M.endDate||M.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...Y,opacity:M.isMilestone?.5:1,cursor:M.isMilestone?"not-allowed":"pointer"},disabled:d||M.isMilestone,children:M.endDate?M.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>D(null)}),jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let P=new Date,G=new Date(P);G.setDate(P.getDate()+1);let ce=new Date(P);ce.setDate(P.getDate()+7);let re=new Date(P);return re.setDate(P.getDate()+14),[{label:"Hoy",date:P},{label:"Ma\xF1ana",date:G},{label:"Pr\xF3xima semana",date:ce},{label:"2 semanas",date:re}].map((ae,_e)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:ge=>ge.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:ge=>ge.currentTarget.style.backgroundColor="transparent",onClick:()=>{k==="start"?(A("startDate",ae.date),(!M.endDate||ae.date>M.endDate)&&A("endDate",ae.date),D("end")):(A("endDate",ae.date),(!M.startDate||ae.date<M.startDate)&&A("startDate",ae.date),D(null));},children:ae.label},_e))})(),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:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",onClick:()=>{A("startDate",void 0),A("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:()=>S(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:()=>S(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((P,G)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:P},G))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=h.getFullYear(),G=h.getMonth(),ce=new Date(P,G,1).getDay(),re=new Date(P,G+1,0).getDate(),Ee=new Date,ae=[];for(let ge=ce-1;ge>=0;ge--)ae.push({day:new Date(P,G,-ge).getDate(),date:new Date(P,G-1,new Date(P,G,-ge).getDate()),isCurrentMonth:false});for(let ge=1;ge<=re;ge++)ae.push({day:ge,date:new Date(P,G,ge),isCurrentMonth:true});let _e=42-ae.length;for(let ge=1;ge<=_e;ge++)ae.push({day:ge,date:new Date(P,G+1,ge),isCurrentMonth:false});return ae.map((ge,ct)=>{let Nt=ge.date.toDateString()===Ee.toDateString(),at=M.startDate?.toDateString()===ge.date.toDateString(),rt=M.endDate?.toDateString()===ge.date.toDateString(),ot=M.startDate&&M.endDate&&ge.date>=M.startDate&&ge.date<=M.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:ge.isCurrentMonth?at||rt?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:at?"#3B82F6":rt?"#7C3AED":ot?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Nt&&!at&&!rt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{k==="start"?(A("startDate",ge.date),M.endDate&&ge.date>M.endDate&&A("endDate",ge.date),D("end")):(A("endDate",ge.date),M.startDate&&ge.date<M.startDate&&A("startDate",ge.date),D(null));},children:ge.day},ct)})})()})]})]})]})})]}),be.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:be.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:M.progress,onChange:P=>A("progress",parseInt(P.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:M.progress<30?"#EF4444":M.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:`${M.progress<30?"#EF4444":M.progress<70?"#F59E0B":"#10B981"}20`,color:M.progress<30?"#EF4444":M.progress<70?"#F59E0B":"#10B981"},children:[M.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>O(!C),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 ${C?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:C&&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:M.isMilestone,onChange:P=>A("isMilestone",P.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(P=>P.id!==a?.id).map(P=>{let G=M.dependencies?.includes(P.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let ce=G?(M.dependencies||[]).filter(re=>re!==P.id):[...M.dependencies||[],P.id];A("dependencies",ce);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:G?`${l.accent}30`:l.bgPrimary,color:G?l.accent:l.textSecondary,border:`1px solid ${G?l.accent:l.borderLight}`},disabled:d,children:P.name},P.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:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.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:P=>!d&&(P.currentTarget.style.opacity="0.9"),onMouseLeave:P=>!d&&(P.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"'],md=()=>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"})]}),Ug=()=>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"})}),zg=()=>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 Jo({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:d,onDependencyCreate:c,onDependencyDelete:m}){let[n,p]=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),S=react.useRef(null),{enabled:C=true,placeholder:O='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:z,suggestions:H=$g,maxHistory:F=50,persistHistory:M}=a,ee=M?.storageKey||"gantt-ai-history",be=M?.maxMessages??5;react.useEffect(()=>{if(M?.enabled)try{let $=localStorage.getItem(ee);if($){let Y=JSON.parse($).map(P=>({...P,timestamp:new Date(P.timestamp)}));v(Y.slice(-be));}}catch($){console.warn("[GanttAIAssistant] Failed to load persisted history:",$);}},[M?.enabled,ee,be]),react.useEffect(()=>{if(M?.enabled&&u.length>0)try{let $=u.filter(E=>!E.isLoading).slice(-be);localStorage.setItem(ee,JSON.stringify($));}catch($){console.warn("[GanttAIAssistant] Failed to persist history:",$);}},[u,M?.enabled,ee,be]),react.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let we=react.useCallback($=>{if($.success)switch($.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":$.taskId&&$.updates&&o?.($.taskId,$.updates);break;case "create_task":$.newTask&&s?.($.newTask);break;case "delete_task":$.taskId&&d?.($.taskId);break;case "link_tasks":$.dependencyFrom&&$.dependencyTo&&c?.($.dependencyFrom,$.dependencyTo);break;case "unlink_tasks":$.taskId&&$.dependencyFrom&&m?.($.taskId,$.dependencyFrom);break}},[o,s,d,c,m]),Pe=react.useCallback(async $=>{if(!$.trim()||x)return;let E={id:`user-${Date.now()}`,role:"user",content:$,timestamp:new Date};v(P=>[...P.slice(-(F-1)),E]),y(""),k(false),b(true);let Y={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(P=>[...P,Y]);try{if(z){let P=await z($,e);v(G=>{let ce=G.filter(Ee=>!Ee.isLoading),re={id:`assistant-${Date.now()}`,role:"assistant",content:P.message,timestamp:new Date,command:P};return [...ce,re]}),we(P);}else v(P=>[...P.filter(ce=>!ce.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(P){v(G=>[...G.filter(re=>!re.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${P instanceof Error?P.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,F,z,e,we]),Fe=$=>{$.preventDefault(),Pe(f);},A=$=>{y($),D.current?.focus();};if(react.useEffect(()=>{let $=E=>{(E.metaKey||E.ctrlKey)&&E.key==="k"&&(E.preventDefault(),p(Y=>!Y),n||i(false)),E.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[n]),react.useEffect(()=>{if(!n)return;let $=Y=>{let P=Y.target;S.current&&!S.current.contains(P)&&p(false);},E=setTimeout(()=>{document.addEventListener("mousedown",$);},100);return ()=>{clearTimeout(E),document.removeEventListener("mousedown",$);}},[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(Ye,{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:()=>p(true),children:[jsxRuntime.jsx(md,{}),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:S,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(md,{}),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($=>!$),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:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(zg,{})})]})]}),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:H.slice(0,4).map(($,E)=>jsxRuntime.jsx("button",{onClick:()=>A($),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:$.length>30?$.slice(0,30)+"...":$},E))})]}),u.map($=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${$.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${$.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:$.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:$.role==="user"?"white":t.textPrimary},children:[$.isLoading?jsxRuntime.jsx(Gg,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:$.content}),$.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:$.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:$.command.success?"#10B981":"#EF4444"},children:[$.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:$.command.type.replace(/_/g," ")})]})]})},$.id)),jsxRuntime.jsx("div",{ref:h})]}),jsxRuntime.jsxs("form",{onSubmit:Fe,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:$=>y($.target.value),placeholder:O,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(Ug,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function pd(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,p=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!p)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 p=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:p,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:l}});},[]),m=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:m}}function ud({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,m=c?d.metaKey:d.ctrlKey;if(m&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!c&&m&&d.key==="y"){d.preventDefault(),t();return}if(c&&m&&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 gd(e){return {...jg,...e}}var Qg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},hd=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:c="comfortable",showThemeSelector:m=true,showExportButton:n=true,availableUsers:p=[],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:S,onProgressChange:C,onTaskEdit:O,onTaskAddSubtask:T,onTaskMarkIncomplete:z,onTaskSetInProgress:H,onDependencyCreate:F,onDependencyDelete:M,onBeforeTaskAdd:ee,onAfterTaskAdd:be,onBeforeTaskUpdate:we,onAfterTaskUpdate:Pe,onBeforeTaskDelete:Fe,onAfterTaskDelete:A}=a,$=react.useContext(Lo)?.theme,[E,Y]=react.useState($||s||"dark"),[P,G]=react.useState(d),[ce,re]=react.useState(c),[Ee,ae]=react.useState(1),[_e,ge]=react.useState(0),[ct,Nt]=react.useState(false),[at,rt]=react.useState(null),[ot,mt]=react.useState({isOpen:false,x:0,y:0,task:null}),[Zt,wt]=react.useState(null),[pt,Lt]=react.useState(null);react.useEffect(()=>{$&&$!==E&&Y($);},[$]),react.useEffect(()=>{s&&s!==E&&Y(s);},[s]);let jt=react.useCallback(N=>{Y(N),g?.(N);},[g]),{state:Ce,setState:U,undo:De,redo:ze,canUndo:Ue,canRedo:bt,clearHistory:J}=pd(t,50);react.useEffect(()=>{U(t);},[t,U]);let Q=react.useRef(t),xe=react.useRef(true);react.useEffect(()=>{if(xe.current){xe.current=false,Q.current=Ce;return}if(!r)return;let N=JSON.stringify(Q.current),W=JSON.stringify(Ce);N!==W&&(Q.current=Ce,r(Ce));},[Ce,r]);let fe=react.useMemo(()=>ps(v,f),[v,f]),te=react.useCallback(N=>[{id:"name",label:N.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:N.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:N.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:N.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:N.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:N.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:N.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:N.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Te,he]=react.useState(()=>te(fe));react.useEffect(()=>{he(N=>N.map(W=>({...W,label:fe.columns[W.id==="name"?"taskName":W.id]||W.label})));},[fe]);let ke=react.useMemo(()=>{let N=Te.filter(ne=>ne.visible),W=N.some(ne=>ne.id!=="name");return N.reduce((ne,ye)=>ne+ye.width,0)+(W?20:0)},[Te]);react.useEffect(()=>{at!==null&&at>ke&&(Te.filter(q=>q.visible).some(q=>q.id!=="name")||rt(null));},[Te,ke,at]);let R=react.useMemo(()=>at!==null?Math.max(280,at,ke):Math.max(280,ke),[at,ke]),_=react.useRef(null),X=react.useRef(null),le=react.useRef(null),de=react.useMemo(()=>Ll(E),[E]),B=react.useMemo(()=>({theme:de,themeName:E}),[de,E]),K=react.useMemo(()=>gd(l),[l]),Ne=react.useMemo(()=>{if(!i)return Ce;let N=se.calculateCriticalPath(Ce),W=q=>q.map(ne=>({...ne,isCriticalPath:N.includes(ne.id),subtasks:ne.subtasks?W(ne.subtasks):void 0}));return W(Ce)},[Ce,i]),je=Qg(ce);ud({undo:De,redo:ze,canUndo:Ue,canRedo:bt,enabled:true}),react.useImperativeHandle(o,()=>({getTask:N=>se.findTaskById(Ce,N),addTask:(N,W)=>{U(q=>{if(!W)return [...q,{...N,level:0}];let ne=ye=>ye.map(Se=>Se.id===W?{...Se,subtasks:[...Se.subtasks||[],{...N,parentId:W,level:(Se.level||0)+1}],isExpanded:true}:Se.subtasks?{...Se,subtasks:ne(Se.subtasks)}:Se);return ne(q)});},updateTask:(N,W)=>{U(q=>{let ne=ye=>ye.map(Se=>Se.id===N?{...Se,...W}:Se.subtasks?{...Se,subtasks:ne(Se.subtasks)}:Se);return ne(q)});},deleteTask:N=>{U(W=>{let q=ne=>ne.filter(ye=>ye.id===N?false:(ye.subtasks&&(ye.subtasks=q(ye.subtasks)),true));return q(W)});},deleteTasks:N=>{U(W=>vs(W,N));},duplicateTask:N=>{U(W=>xs(W,[N]));},splitTask:(N,W,q=3)=>{U(ne=>se.splitTask(ne,N,W,q));},calculateEndDate:se.calculateEndDate,calculateDuration:se.calculateDuration,validateDependency:(N,W)=>!se.validateDependencies(Ce,N,W),getAllTasks:()=>se.flattenTasks(Ce),getTasksByStatus:N=>se.flattenTasks(Ce).filter(W=>W.status===N),getTasksByParent:N=>N?se.findTaskById(Ce,N)?.subtasks||[]:Ce.filter(q=>!q.parentId),getCriticalPath:()=>se.flattenTasks(Ce).filter(N=>N.isCriticalPath),indentTask:N=>{U(W=>bs(W,[N]));},outdentTask:N=>{U(W=>hs(W,[N]));},moveTask:(N,W)=>{U(q=>ys(q,[N],W));},createSubtask:async N=>{let{tasks:W,newTask:q}=Cs(Ce,N);if(ee){let ne=ee({...q,parentId:N});if((ne instanceof Promise?await ne:ne)===false)return}U(W),be&&be({...q,parentId:N});},scrollToTask:N=>{let q=se.flattenTasks(Ce).findIndex(ne=>ne.id===N);if(q!==-1&&_.current){let ne=q*je;_.current.scrollTo({top:ne,behavior:"smooth"}),X.current&&X.current.scrollTo({top:ne,behavior:"smooth"});}},highlightTask:(N,W=2e3)=>{},expandTask:N=>{U(W=>{let q=ne=>ne.map(ye=>ye.id===N?{...ye,isExpanded:true}:ye.subtasks?{...ye,subtasks:q(ye.subtasks)}:ye);return q(W)});},collapseTask:N=>{U(W=>{let q=ne=>ne.map(ye=>ye.id===N?{...ye,isExpanded:false}:ye.subtasks?{...ye,subtasks:q(ye.subtasks)}:ye);return q(W)});},expandAll:()=>{U(N=>{let W=q=>q.map(ne=>({...ne,isExpanded:true,subtasks:ne.subtasks?W(ne.subtasks):void 0}));return W(N)});},collapseAll:()=>{U(N=>{let W=q=>q.map(ne=>({...ne,isExpanded:false,subtasks:ne.subtasks?W(ne.subtasks):void 0}));return W(N)});},undo:De,redo:ze,canUndo:()=>Ue,canRedo:()=>bt,clearHistory:J,exportToPNG:async()=>{if(!le.current)throw new Error("Gantt container not found");let N=await bd__default.default(le.current,{backgroundColor:de.bgPrimary,scale:2});return new Promise((W,q)=>{N.toBlob(ne=>{ne?W(ne):q(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await se.exportToPDF(Ce,N);},exportToExcel:async N=>{await se.exportToExcel(Ce,N);},exportToJSON:()=>se.exportToJSON(Ce),exportToCSV:()=>se.exportToCSV(Ce),importFromJSON:N=>{let W=se.importFromJSON(N);U(W);},getTasks:()=>Ce,refresh:()=>{U(N=>[...N]);},clearAll:()=>{U([]);}}),[Ce,De,ze,Ue,bt,J,de,je]);let Pt=react.useCallback(N=>{he(W=>W.map(q=>q.id===N?{...q,visible:!q.visible}:q));},[]),zr=react.useCallback((N,W)=>{he(q=>q.map(ne=>{if(ne.id!==N)return ne;let ye=ne.minWidth??100,Se=ne.maxWidth??800,Ft=Math.max(ye,Math.min(Se,W));return {...ne,width:Ft}}));},[]),Wr=react.useCallback(N=>{U(W=>ws(W,N)),a.onTaskToggleExpand?.(N);},[a]),Wa=react.useCallback((N,W)=>{if(we&&we(N,W)===false)return;let ne=se.findTaskById(Ce,N)?.progress,ye=Ft=>Ft.map(Bt=>Bt.id===N?{...Bt,...W}:Bt.subtasks?{...Bt,subtasks:ye(Bt.subtasks)}:Bt);U(ye(Ce));let Se=se.findTaskById(ye(Ce),N);Se&&(S?.(Se),Pe?.(Se),W.progress!==void 0&&ne!==void 0&&W.progress!==ne&&C?.(N,ne,W.progress));},[Ce,S,we,Pe,C]),yn=react.useCallback(N=>{N.length!==0&&(U(W=>bs(W,N)),a.onTaskIndent?.(N[0]));},[a]),me=react.useCallback(N=>{N.length!==0&&(U(W=>hs(W,N)),a.onTaskOutdent?.(N[0]));},[a]),ut=react.useCallback((N,W,q)=>{U(ne=>Ql(ne,N,W,q)),a.onTaskReparent?.(N,W,q);},[a]),Ht=react.useCallback((N,W)=>{N.length!==0&&(U(q=>ys(q,N,W)),a.onTaskMove?.(N[0],W));},[a]),Ga=react.useCallback(async N=>{let W=[];for(let q of N)Fe&&await Promise.resolve(Fe(q))===false||W.push(q);W.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(W):(U(q=>vs(q,W)),W.forEach(q=>a.onTaskDelete?.(q))),A&&W.forEach(q=>A(q)));},[a,Fe,A]),bo=react.useCallback(N=>{U(W=>xs(W,N)),N.forEach(W=>a.onTaskDuplicate?.(W));},[a]),vr=react.useCallback((N,W)=>{U(q=>{let{tasks:ne,newTask:ye}=Zl(q,N,W);return ee&&ee(ye)===false?q:(a.onTaskCreate?.(ye.parentId,ye.position||0),be?.(ye),ne)});},[a,ee,be]),Ma=react.useCallback((N,W)=>{U(q=>ks(q,N,W)),a.onTaskRename?.(N,W);},[a]),Aa=react.useCallback(N=>{U(W=>{let{tasks:q}=Cs(W,N);return a.onTaskCreate?.(N,0),q});},[a]),Ct=react.useCallback((N,W,q)=>{let ne=N.startDate?Math.round((W.getTime()-N.startDate.getTime())/864e5):0,ye=Bt=>Bt.map(_t=>_t.id===N.id?{..._t,startDate:W,endDate:q,...N.segments&&{segments:N.segments}}:_t.subtasks?{..._t,subtasks:ye(_t.subtasks)}:_t),Se=ye(Ce);Se=se.autoScheduleDependents(Se,N.id,ne),U(Se);let Ft={...N,startDate:W,endDate:q};S?.(Ft);},[Ce,S]),vn=react.useCallback((N,W)=>{h?.(N,W),mt({isOpen:true,x:W.clientX,y:W.clientY,task:N});},[h]),xn=react.useCallback((N,W)=>{let q=se.splitTask(Ce,N.id,W);U(q),mt({isOpen:false,x:0,y:0,task:null});},[Ce]),kn=react.useCallback(N=>{D?.(N),O||wt(N);},[D,O]),xr=react.useCallback((N,W,q)=>{let ne=new Map,ye=fa=>{fa.forEach(Ia=>{Ia.dependencies&&ne.set(Ia.id,Ia.dependencies),Ia.subtasks&&ye(Ia.subtasks);});};ye(q);let Se=ne.get(W)||[];ne.set(W,[...Se,N]);let Ft=new Set,Bt=new Set,_t=fa=>{if(!Ft.has(fa)){Ft.add(fa),Bt.add(fa);let Ia=ne.get(fa)||[];for(let er of Ia){if(!Ft.has(er)&&_t(er))return true;if(Bt.has(er))return true}}return Bt.delete(fa),false};return _t(W)},[]),Ti=react.useCallback((N,W)=>{if(xr(N.id,W,Ce)){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 q=ne=>ne.map(ye=>{if(ye.id===W){let Se=ye.dependencies||[];if(!Se.includes(N.id))return {...ye,dependencies:[...Se,N.id]}}return ye.subtasks?{...ye,subtasks:q(ye.subtasks)}:ye});U(q(Ce)),F?.(N.id,W);},[Ce,F,xr]),Di=react.useCallback((N,W)=>{let q=ne=>ne.map(ye=>{if(ye.id===N&&ye.dependencies){let Se=ye.dependencies.filter(Ft=>Ft!==W);return {...ye,dependencies:Se}}return ye.subtasks?{...ye,subtasks:q(ye.subtasks)}:ye});U(q(Ce)),M?.(N,W);},[Ce,M]),{startDate:Ac,endDate:Ic}=react.useMemo(()=>{let N=Ce.filter(Se=>Se.startDate&&Se.endDate);if(N.length===0){let Se=new Date,Ft=new Date(Se);Ft.setDate(Ft.getDate()-30);let Bt=new Date(Se);return Bt.setDate(Bt.getDate()+60),{startDate:Ft,endDate:Bt}}let W=N.flatMap(Se=>[Se.startDate,Se.endDate]).filter(Se=>Se!==void 0),q=new Date(Math.min(...W.map(Se=>Se.getTime()))),ne=new Date(Math.max(...W.map(Se=>Se.getTime()))),ye=P==="day"?7:P==="week"?14:30;return q.setDate(q.getDate()-ye),ne.setDate(ne.getDate()+ye),{startDate:q,endDate:ne}},[Ce,P]),Lc=react.useCallback(async()=>{if(!le.current)return;let N=await bd__default.default(le.current,{backgroundColor:de.bgPrimary,scale:2}),W=document.createElement("a");W.download="gantt-chart.png",W.href=N.toDataURL("image/png"),W.click();},[de]),Fc=react.useCallback(async()=>{await se.exportToPDF(Ce);},[Ce]),Bc=react.useCallback(async()=>{await se.exportToExcel(Ce);},[Ce]),Rc=react.useCallback(()=>{let N=se.exportToCSV(Ce),W=new Blob([N],{type:"text/csv;charset=utf-8;"}),q=document.createElement("a");q.href=URL.createObjectURL(W),q.download="gantt-chart.csv",q.click(),URL.revokeObjectURL(q.href);},[Ce]),Oc=react.useCallback(()=>{let N=se.exportToJSON(Ce),W=new Blob([N],{type:"application/json;charset=utf-8;"}),q=document.createElement("a");q.href=URL.createObjectURL(W),q.download="gantt-chart.json",q.click(),URL.revokeObjectURL(q.href);},[Ce]),$c=react.useCallback(()=>{se.exportToMSProject(Ce,"Gantt Project","project.xml");},[Ce]),Uc=N=>{N.preventDefault(),Nt(true);};return react.useEffect(()=>{let N=X.current,W=_.current;if(!N||!W)return;let q=W.querySelector(".gantt-taskgrid-content"),ne=()=>{let _t=N.scrollTop;ge(_t),q&&(q.style.transform=`translateY(-${_t}px)`);},ye=_t=>{if(ct&&W){let Ia=W.parentElement?.getBoundingClientRect()?.left||0,er=_t.clientX-Ia,zc=280,Wc=Math.min(window.innerWidth-300,800);er>=zc&&er<=Wc&&rt(er);}},Se=()=>{Nt(false);},Ft=W.querySelector(".gantt-grid-scroll")||W,Bt=_t=>{let fa=_t;fa.deltaY!==0&&(N.scrollTop+=fa.deltaY,_t.preventDefault());};return N.addEventListener("scroll",ne),Ft.addEventListener("wheel",Bt,{passive:false}),document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Se),()=>{N.removeEventListener("scroll",ne),Ft.removeEventListener("wheel",Bt),document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Se);}},[ct]),jsxRuntime.jsx(Ar.Provider,{value:fe,children:jsxRuntime.jsx(Nn.Provider,{value:B,children:jsxRuntime.jsxs("div",{ref:le,className:"flex flex-col h-full w-full",style:{backgroundColor:de.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(Bo,{theme:de,timeScale:P,onTimeScaleChange:G,zoom:Ee,onZoomChange:ae,currentTheme:E,onThemeChange:jt,rowDensity:ce,onRowDensityChange:re,showThemeSelector:m,showCreateTaskButton:y,createTaskLabel:x,onCreateTask:b,onExportPNG:n?Lc:void 0,onExportPDF:n?Fc:void 0,onExportExcel:n?Bc:void 0,onExportCSV:n?Rc:void 0,onExportJSON:n?Oc:void 0,onExportMSProject:n?$c:void 0}),jsxRuntime.jsxs("div",{ref:_,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:R,overflow:"hidden"},children:jsxRuntime.jsx(Uo,{tasks:Ne,theme:de,rowHeight:je,availableUsers:p,templates:K,onTaskClick:k,onTaskDblClick:kn,onTaskContextMenu:h,onTaskToggle:Wr,scrollTop:_e,columns:Te,onToggleColumn:Pt,onColumnResize:zr,onTaskUpdate:Wa,onTaskIndent:yn,onTaskOutdent:me,onTaskMove:Ht,onMultiTaskDelete:Ga,onTaskDuplicate:bo,onTaskCreate:vr,onTaskRename:Ma,onCreateSubtask:Aa,onOpenTaskModal:k?N=>k(N):void 0,onDeleteRequest:(N,W)=>Lt({taskId:N,taskName:W}),onTaskReparent:ut})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:Uc}),jsxRuntime.jsx("div",{ref:X,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(Ko,{tasks:Ne,theme:de,rowHeight:je,timeScale:P,startDate:Ac,endDate:Ic,zoom:Ee,templates:K,onTaskClick:k,onTaskDblClick:kn,onTaskContextMenu:vn,onTaskDateChange:Ct,onDependencyCreate:Ti,onDependencyDelete:Di})})]}),ot.task&&jsxRuntime.jsx(Ir,{isOpen:ot.isOpen,x:ot.x,y:ot.y,theme:de,onClose:()=>mt({isOpen:false,x:0,y:0,task:null}),items:(()=>{let N=ot.task;return N?N.subtasks&&N.subtasks.length>0?[{id:"addSubtask",label:fe.contextMenu?.addSubtask||"Add Subtask",icon:lt.Add,onClick:()=>{T?T(N):Aa(N.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:fe.contextMenu?.deleteTask||"Delete Task",icon:lt.Delete,onClick:()=>{Lt({taskId:N.id,taskName:N.name});}}]:[{id:"edit",label:fe.contextMenu?.editTask||"Edit Task",icon:lt.Pencil,onClick:()=>{O?O(N):wt(N);}},{id:"addSubtask",label:fe.contextMenu?.addSubtask||"Add Subtask",icon:lt.Add,onClick:()=>{T?T(N):Aa(N.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:fe.contextMenu?.markIncomplete||"Mark Incomplete",icon:lt.MarkIncomplete,onClick:()=>{z?z(N):Wa(N.id,{status:"todo",progress:0});},disabled:N.status==="todo"},{id:"setInProgress",label:fe.contextMenu?.setInProgress||"Set In Progress",icon:lt.SetInProgress,onClick:()=>{H?H(N):Wa(N.id,{status:"in-progress"});},disabled:N.status==="in-progress"},{id:"markComplete",label:fe.contextMenu?.markComplete||"Mark Complete",icon:lt.MarkComplete,onClick:()=>{Wa(N.id,{status:"completed",progress:100});},disabled:N.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:fe.contextMenu?.splitTask||"Split Task",icon:lt.Split,onClick:()=>{if(!N.startDate||!N.endDate){console.warn("Cannot split task without dates");return}let q=N.startDate.getTime(),ne=N.endDate.getTime(),ye=q+(ne-q)/2,Se=new Date(ye);xn(N,Se);},disabled:!N.startDate||!N.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:fe.contextMenu?.deleteTask||"Delete Task",icon:lt.Delete,onClick:()=>{Lt({taskId:N.id,taskName:N.name});}}]:[]})()}),Zt&&jsxRuntime.jsx(Xo,{isOpen:true,onClose:()=>wt(null),task:Zt,onSubmit:N=>{Wa(Zt.id,N),wt(null);},mode:"edit",theme:E}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:pt&&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:()=>Lt(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:N=>N.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:de.bgSecondary,border:`1px solid ${de.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${de.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:de.textPrimary,fontFamily:"Inter, sans-serif"},children:[fe.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:de.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:de.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:de.textPrimary},children:['"',pt.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:de.bgPrimary,borderTop:`1px solid ${de.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>Lt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:de.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor=de.hoverBg;},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:v==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{Ga([pt.taskId]),Lt(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:N=>{N.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),v==="es"?"Eliminar":"Delete"]})]})]})})}),u?.enabled&&jsxRuntime.jsx(Jo,{tasks:Ce,theme:de,config:u,onTasksUpdate:U,onTaskUpdate:Wa,onTaskCreate:N=>{U(W=>[...W,N]);},onTaskDelete:N=>{Ga([N]);},onDependencyCreate:(N,W)=>{let q=se.findTaskById(Ce,N);q&&Ti(q,W);},onDependencyDelete:Di})]})})})});var yd=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
279
279