@libxai/board 0.17.371 → 0.17.372

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
@@ -339,7 +339,7 @@
339
339
  </Calendars>
340
340
  <Tasks>${m}
341
341
  </Tasks>
342
- </Project>`,u=new Blob([i],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=fe.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let h of i.dependencies){let C=t.find(T=>T.id===h);if(C){o(C);let T=r.get(h)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,p=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){p(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let h=g-u;n.set(i.id,{ls:h,lf:g});};a.forEach(p);let m=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&m.push(i.id);}}return m},calculateSlack:(e,t)=>{let a=fe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(fe.calculateCriticalPath(e).includes(t))return 0;let o=fe.getDependentTasks(e,t);if(o.length===0){let p=fe.getLatestEndDate(e);if(!p)return null;let m=fe.calculateDuration(a.endDate,p);return Math.max(0,m)}let s=o.filter(p=>p.startDate).map(p=>p.startDate.getTime()).sort((p,m)=>p-m)[0];if(!s)return null;let n=fe.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>fe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=fe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=fe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let p=fe.calculateDuration(n.startDate,n.endDate),m;a!==void 0?(m=new Date(n.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let i=fe.calculateEndDate(m,p),u=d=>d.map(g=>g.id===n.id?{...g,startDate:m,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=fe.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,p)=>{if(a===0)return [];let m=[],i=o.getTime(),u=1e3*60*60*24,d=fe.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(h,C,T=new Set)=>{if(T.has(h))return;T.add(h);let c=fe.getDependentTasks(e,h);for(let b of c){if(!b.startDate||!b.endDate)continue;let y=r.findIndex(D=>D.id===b.id);if(y===-1)continue;let l=b.startDate.getTime(),v=(b.endDate.getTime()-l)/u,k=(l-i)/u*s,w=k+C*s,R=Math.max(v*s,s),M=p+y*n+12;m.push({taskId:b.id,taskName:b.name,originalX:k,previewX:w,width:R,y:M,rowIndex:y,daysDelta:C,color:b.color}),g(b.id,C,T);}};return g(t,a),m},splitTask:(e,t,a,r=3)=>{let o=fe.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 n=new Date(a);n.setDate(n.getDate()+r);let p=new Date(o.endDate);p.setDate(p.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:p}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:p,segments:m}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function In({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:p,dependencyLineStyle:m="curved",onTaskClick:i,onTaskDblClick:u,onTaskContextMenu:d,onTaskDateChange:g,onDependencyCreate:h,onDependencyDelete:C}){let[c,b]=react.useState([]),[y,l]=react.useState(null),x=react.useCallback($=>{l($);},[]),v=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),S=r==="day"?60:r==="week"?20:8,k=v*S*n,w=$=>{let J=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),U=J.getUTCDay()||7;J.setUTCDate(J.getUTCDate()+4-U);let G=new Date(Date.UTC(J.getUTCFullYear(),0,1));return Math.ceil(((J.getTime()-G.getTime())/864e5+1)/7)},R=$=>{let J=$.getDay();return J===0||J===6},M=react.useCallback($=>{let J=Math.round($/(S*n)),U=new Date(o);return U.setDate(U.getDate()+J),U},[o,S,n]),D=react.useCallback(($,J)=>{if(J.startDate&&J.endDate)return;let U=$.currentTarget.ownerSVGElement;if(!U)return;let G=U.createSVGPoint();G.x=$.clientX,G.y=$.clientY;let A=G.matrixTransform(U.getScreenCTM()?.inverse()),Q=M(A.x),X=new Date(Q);X.setDate(X.getDate()+1),g?.(J,Q,X);},[M,g]),I=react.useMemo(()=>{let $=A=>A.map(Q=>{if(Q.subtasks&&Q.subtasks.length>0){let X=$(Q.subtasks),H=X.filter(Ce=>Ce.startDate&&Ce.endDate);if(H.length>0){let Ce=H.map(Ke=>Ke.startDate.getTime()),Me=H.map(Ke=>Ke.endDate.getTime()),Oe=new Date(Math.min(...Ce)),ve=new Date(Math.max(...Me));return {...Q,subtasks:X,startDate:Oe,endDate:ve}}return {...Q,subtasks:X}}return Q}),J=(A,Q=[])=>{for(let X of A)Q.push(X),X.subtasks&&X.subtasks.length>0&&(X.isExpanded===void 0||X.isExpanded)&&J(X.subtasks,Q);return Q},U=$(e);return J(U)},[e]),B=react.useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let J=$.startDate.getTime(),U=$.endDate.getTime(),G=o.getTime(),A=(J-G)/(1e3*60*60*24),Q=(U-J)/(1e3*60*60*24),X=A*S*n,H=Math.max(S*n,40),Ce=Math.max(Q*S*n,H);return {x:X,width:Ce}},[o,S,n]),K=react.useMemo(()=>I.filter($=>$.startDate&&$.endDate).map($=>{let{x:J,width:U}=B($),A=I.findIndex(Q=>Q.id===$.id)*a+12;return {id:$.id,x:J,y:A,width:U,height:32}}),[I,B]),te=react.useCallback(($,J,U)=>{if(!U||J===0){b([]);return}let G=fe.calculateCascadePreview(e,$,J,I,o,S*n,a,48);b(G);},[e,I,o,S,n,a,48]),ie=react.useMemo(()=>{let $=[],J=new Date(o);for(;J<=s;){let A=(J.getTime()-o.getTime())/864e5*S*n;if(r==="day")$.push({date:new Date(J),label:J.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:A}),J.setDate(J.getDate()+1);else if(r==="week"){let Q=w(J);$.push({date:new Date(J),label:`Week ${Q}`,x:A}),J.setDate(J.getDate()+7);}else $.push({date:new Date(J),label:J.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:A}),J.setMonth(J.getMonth()+1);}return $},[o,s,r,S,n]),de=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*S*n,[o,S,n]),be=Math.max(I.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary,overflow:"visible"},children:[jsxRuntime.jsx("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:t.bgGrid,flexShrink:0,height:"48px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:jsxRuntime.jsxs("svg",{width:Math.max(k,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(k,1e3),height:48,fill:t.bgGrid}),ie.map(($,J)=>jsxRuntime.jsxs("g",{children:[J>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${J}`)),de>=0&&de<=k&&jsxRuntime.jsx("circle",{cx:de,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(k,1e3),height:be,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(k,1e3),height:be,fill:t.bgPrimary}),ie.map(($,J)=>{let U=ie[J+1]?.x||k,G=R($.date);return jsxRuntime.jsxs("g",{children:[G&&jsxRuntime.jsx("rect",{x:$.x,y:0,width:U-$.x,height:I.length*a,fill:t.bgWeekend,opacity:1}),J>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:I.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},J)}),I.map(($,J)=>{let U=$.startDate&&$.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:J*a,width:k,height:a,fill:J%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!U&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:J*a,width:k,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:G=>D(G,$),onMouseEnter:G=>{G.currentTarget.setAttribute("fill",t.accentLight),G.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:G=>{G.currentTarget.setAttribute("fill","transparent"),G.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsxRuntime.jsx("text",{x:de>0?de:100,y:J*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-${$.id}`)]})]},`row-group-${$.id}`)}),I.map(($,J)=>{if(!$.startDate||!$.endDate)return null;let{x:U,width:G}=B($),A=J*a+12,Q=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsxRuntime.jsx(Fn,{task:$,x:U+G/2,y:A+16,theme:t,onClick:i},$.id):Q?jsxRuntime.jsxs("g",{onClick:()=>i?.($),onContextMenu:X=>{X.preventDefault(),X.stopPropagation(),d?.($,X);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:U,y:A,width:G,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:U,y1:A,x2:U+G,y2:A,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:U,y1:A,x2:U,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:U+G,y1:A,x2:U+G,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:U,y1:A+32,x2:U+G,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),G>60&&jsxRuntime.jsx("text",{x:U+12,y:A+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsxRuntime.jsx(Sn,{task:$,x:U,y:A,width:G,theme:t,dayWidth:S*n,startDate:o,templates:p,onClick:i,onDoubleClick:u,onContextMenu:d,onDateChange:g,onDependencyCreate:h,allTaskPositions:K,onDragMove:te,onHoverChange:x},$.id)}),I.map(($,J)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(U=>{let G=I.find(ve=>ve.id===U);if(!G||!G.startDate||!G.endDate)return null;let A=I.findIndex(ve=>ve.id===U),Q=B(G),X=B($),H=Q.x+Q.width,Ce=A*a+28,Me=X.x,Oe=J*a+28;return jsxRuntime.jsx(Mn,{x1:H,y1:Ce,x2:Me,y2:Oe,theme:t,lineStyle:m,onDelete:()=>C?.($.id,U)},`dep-${U}-${$.id}`)})),c.map($=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsxRuntime.jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),de>=0&&de<=k&&jsxRuntime.jsx("line",{x1:de,y1:0,x2:de,y2:be,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),y&&jsxRuntime.jsx(pc,{tooltipData:y,theme:t})]})]})}var m0=['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"'],hc=()=>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"})]}),p0=()=>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"})}),u0=()=>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"})}),g0=()=>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"})}),f0=()=>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 Bn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:p,onDependencyDelete:m}){let[i,u]=react.useState(false),[d,g]=react.useState(false),[h,C]=react.useState([]),[T,c]=react.useState(""),[b,y]=react.useState(false),[l,x]=react.useState(true),v=react.useRef(null),S=react.useRef(null),k=react.useRef(null),{enabled:w=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:M="bottom-right",onCommand:D,suggestions:I=m0,maxHistory:B=50,persistHistory:K}=a,te=K?.storageKey||"gantt-ai-history",ie=K?.maxMessages??5;react.useEffect(()=>{if(K?.enabled)try{let G=localStorage.getItem(te);if(G){let Q=JSON.parse(G).map(X=>({...X,timestamp:new Date(X.timestamp)}));C(Q.slice(-ie));}}catch(G){console.warn("[GanttAIAssistant] Failed to load persisted history:",G);}},[K?.enabled,te,ie]),react.useEffect(()=>{if(K?.enabled&&h.length>0)try{let G=h.filter(A=>!A.isLoading).slice(-ie);localStorage.setItem(te,JSON.stringify(G));}catch(G){console.warn("[GanttAIAssistant] Failed to persist history:",G);}},[h,K?.enabled,te,ie]),react.useEffect(()=>{S.current&&S.current.scrollIntoView({behavior:"smooth"});},[h]),react.useEffect(()=>{i&&!d&&v.current&&setTimeout(()=>v.current?.focus(),100);},[i,d]);let de=react.useCallback(G=>{if(G.success)switch(G.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":G.taskId&&G.updates&&o?.(G.taskId,G.updates);break;case "create_task":G.newTask&&s?.(G.newTask);break;case "delete_task":G.taskId&&n?.(G.taskId);break;case "link_tasks":G.dependencyFrom&&G.dependencyTo&&p?.(G.dependencyFrom,G.dependencyTo);break;case "unlink_tasks":G.taskId&&G.dependencyFrom&&m?.(G.taskId,G.dependencyFrom);break}},[o,s,n,p,m]),be=react.useCallback(async G=>{if(!G.trim()||b)return;let A={id:`user-${Date.now()}`,role:"user",content:G,timestamp:new Date};C(X=>[...X.slice(-(B-1)),A]),c(""),x(false),y(true);let Q={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(X=>[...X,Q]);try{if(D){let X=await D(G,e);C(H=>{let Ce=H.filter(Oe=>!Oe.isLoading),Me={id:`assistant-${Date.now()}`,role:"assistant",content:X.message,timestamp:new Date,command:X};return [...Ce,Me]}),de(X);}else C(X=>[...X.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(X){C(H=>[...H.filter(Me=>!Me.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${X instanceof Error?X.message:"Unknown error"}`,timestamp:new Date}]);}finally{y(false);}},[b,B,D,e,de]),$=G=>{G.preventDefault(),be(T);},J=G=>{c(G),v.current?.focus();};if(react.useEffect(()=>{let G=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),u(Q=>!Q),i||g(false)),A.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[i]),react.useEffect(()=>{if(!i)return;let G=Q=>{let X=Q.target;k.current&&!k.current.contains(X)&&u(false);},A=setTimeout(()=>{document.addEventListener("mousedown",G);},100);return ()=>{clearTimeout(A),document.removeEventListener("mousedown",G);}},[i]),!w)return null;let U={"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(lt,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!i&&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 ${U[M]} 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:()=>u(true),children:[jsxRuntime.jsx(hc,{}),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:i&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:k,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${U[M]} 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(hc,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>g(G=>!G),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(g0,{})}),jsxRuntime.jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(u0,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&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:[h.length===0&&l&&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:I.slice(0,4).map((G,A)=>jsxRuntime.jsx("button",{onClick:()=>J(G),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:G.length>30?G.slice(0,30)+"...":G},A))})]}),h.map(G=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${G.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${G.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:G.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:G.role==="user"?"white":t.textPrimary},children:[G.isLoading?jsxRuntime.jsx(f0,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:G.content}),G.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:G.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:G.command.success?"#10B981":"#EF4444"},children:[G.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:G.command.type.replace(/_/g," ")})]})]})},G.id)),jsxRuntime.jsx("div",{ref:S})]}),jsxRuntime.jsxs("form",{onSubmit:$,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:v,type:"text",value:T,onChange:G=>c(G.target.value),placeholder:R,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!T.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:T.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:T.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(p0,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function bc(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((i,u=true)=>{r(d=>{let g=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:g};if(!u)return {...d,present:g};let h=[...d.past,d.present];return h.length>t&&h.shift(),{past:h,present:g,future:[]}});},[t]),n=react.useCallback(()=>{r(i=>{if(i.past.length===0)return i;let u=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[i.present,...i.future]}});},[]),p=react.useCallback(()=>{r(i=>{if(i.future.length===0)return i;let u=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:u,future:d}});},[]),m=react.useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:p,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function yc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=n=>{let p=navigator.platform.toUpperCase().indexOf("MAC")>=0,m=p?n.metaKey:n.ctrlKey;if(m&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!p&&m&&n.key==="y"){n.preventDefault(),t();return}if(p&&m&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var v0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${fe.formatDate(e.startDate)} - ${fe.formatDate(e.endDate)}`);let a=fe.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=>fe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function vc(e){return {...v0,...e}}var D0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},wc=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:p="comfortable",showThemeSelector:m=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:h,aiAssistant:C,locale:T="en",customTranslations:c,showCreateTaskButton:b=false,createTaskLabel:y,onCreateTask:l,taskFilter:x,onTaskFilterChange:v,onThemeChange:S,onTaskClick:k,onTaskDblClick:w,onTaskContextMenu:R,onTaskUpdate:M,onProgressChange:D,onTaskEdit:I,onTaskAddSubtask:B,onTaskMarkIncomplete:K,onTaskSetInProgress:te,onDependencyCreate:ie,onDependencyDelete:de,onBeforeTaskAdd:be,onAfterTaskAdd:$,onBeforeTaskUpdate:J,onAfterTaskUpdate:U,onBeforeTaskDelete:G,onAfterTaskDelete:A}=a,X=react.useContext(vn)?.theme,[H,Ce]=react.useState(X||s||"dark"),[Me,Oe]=react.useState(n),[ve,Ke]=react.useState(p),[We,et]=react.useState(1),[vt,Mt]=react.useState("all"),mt=x??vt,O=v??Mt,[le,xe]=react.useState(0),[Pe,ze]=react.useState(false),[at,Et]=react.useState(null),[Fe,Xt]=react.useState({isOpen:false,x:0,y:0,task:null}),[Ot,Nt]=react.useState(null),[ct,Jt]=react.useState(null);react.useEffect(()=>{X&&X!==H&&Ce(X);},[X]),react.useEffect(()=>{s&&s!==H&&Ce(s);},[s]);let Ea=react.useCallback(F=>{Ce(F),S?.(F);},[S]),{state:oe,setState:ue,undo:pa,redo:ya,canUndo:N,canRedo:ee,clearHistory:se}=bc(t,50),De=react.useCallback(()=>h?typeof h=="string"?h:"gantt-expanded-tasks":null,[h]),$e=react.useRef(new Map),tt=react.useRef(false);if(!tt.current&&h){tt.current=true;let F=typeof h=="string"?h:"gantt-expanded-tasks";try{let L=localStorage.getItem(F);if(L){let V=JSON.parse(L);Array.isArray(V)&&($e.current=new Map(V));}}catch(L){console.warn("[GanttBoard] Error loading expanded state from localStorage:",L);}}let Ge=react.useCallback(()=>{let F=De();if(F)try{let L=Array.from($e.current.entries());localStorage.setItem(F,JSON.stringify(L));}catch(L){console.warn("[GanttBoard] Error saving expanded state to localStorage:",L);}},[De]);react.useEffect(()=>{let F=L=>L.map(V=>{let re=$e.current.get(V.id),ge=re!==void 0?{...V,isExpanded:re}:V;return ge.subtasks?.length?{...ge,subtasks:F(ge.subtasks)}:ge});$e.current.size>0?ue(F(t)):ue(t);},[t,ue]);let Be=react.useRef(t),rt=react.useRef(true);react.useEffect(()=>{if(rt.current){rt.current=false,Be.current=oe;return}if(!r)return;let F=JSON.stringify(Be.current),L=JSON.stringify(oe);F!==L&&(Be.current=oe,r(oe));},[oe,r]);let _=react.useMemo(()=>ti(T,c),[T,c]),ae=react.useCallback(F=>[{id:"name",label:F.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:F.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:F.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:F.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:F.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:F.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:F.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:F.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ee,Ue]=react.useState(()=>ae(_));react.useEffect(()=>{Ue(F=>F.map(L=>({...L,label:_.columns[L.id==="name"?"taskName":L.id]||L.label})));},[_]);let He=react.useMemo(()=>Ee.filter(L=>L.visible).reduce((L,V)=>L+V.width,0),[Ee]),W=react.useRef(Ee.filter(F=>F.visible).map(F=>F.id).join(","));react.useEffect(()=>{let F=Ee.filter(re=>re.visible),L=F.map(re=>re.id).join(","),V=W.current;if(L!==V){let re=F.some(Ne=>Ne.id!=="name"),ge=V.includes(",");re?!ge&&re&&Et(null):Et(null),W.current=L;}},[Ee]);let ce=60,Ie=.6,Dt=react.useMemo(()=>{let L=He+ce,V=typeof window<"u"?window.innerWidth*Ie:800,re=Math.max(L,V);return at!==null?Math.max(200,Math.min(at,re)):Math.max(200,L)},[at,He]),Je=react.useRef(null),va=react.useRef(null),ua=react.useRef(null),E=react.useMemo(()=>Ud(H),[H]),ye=react.useMemo(()=>({theme:E,themeName:H}),[E,H]),q=react.useMemo(()=>vc(d),[d]),Ae=react.useMemo(()=>{if(!g)return oe;let F=fe.calculateCriticalPath(oe),L=V=>V.map(re=>({...re,isCriticalPath:F.includes(re.id),subtasks:re.subtasks?L(re.subtasks):void 0}));return L(oe)},[oe,g]),ot=react.useMemo(()=>{if(mt==="all")return Ae;let F=L=>{let V=[];for(let re of L){let ge=re.subtasks?.length?F(re.subtasks):void 0,Ne=false;switch(mt){case "incomplete":Ne=re.progress<100;break;case "in_progress":Ne=re.progress>0&&re.progress<100;break;case "completed":Ne=re.progress===100;break}(Ne||ge&&ge.length>0)&&V.push({...re,subtasks:ge});}return V};return F(Ae)},[Ae,mt]),ne=D0(ve);yc({undo:pa,redo:ya,canUndo:N,canRedo:ee,enabled:true}),react.useImperativeHandle(o,()=>({getTask:F=>fe.findTaskById(oe,F),addTask:(F,L)=>{ue(V=>{if(!L)return [...V,{...F,level:0}];let re=ge=>ge.map(Ne=>Ne.id===L?{...Ne,subtasks:[...Ne.subtasks||[],{...F,parentId:L,level:(Ne.level||0)+1}],isExpanded:true}:Ne.subtasks?{...Ne,subtasks:re(Ne.subtasks)}:Ne);return re(V)});},updateTask:(F,L)=>{ue(V=>{let re=ge=>ge.map(Ne=>Ne.id===F?{...Ne,...L}:Ne.subtasks?{...Ne,subtasks:re(Ne.subtasks)}:Ne);return re(V)});},deleteTask:F=>{ue(L=>{let V=re=>re.filter(ge=>ge.id===F?false:(ge.subtasks&&(ge.subtasks=V(ge.subtasks)),true));return V(L)});},deleteTasks:F=>{ue(L=>mi(L,F));},duplicateTask:F=>{ue(L=>pi(L,[F]));},splitTask:(F,L,V=3)=>{ue(re=>fe.splitTask(re,F,L,V));},calculateEndDate:fe.calculateEndDate,calculateDuration:fe.calculateDuration,validateDependency:(F,L)=>!fe.validateDependencies(oe,F,L),getAllTasks:()=>fe.flattenTasks(oe),getTasksByStatus:F=>fe.flattenTasks(oe).filter(L=>L.status===F),getTasksByParent:F=>F?fe.findTaskById(oe,F)?.subtasks||[]:oe.filter(V=>!V.parentId),getCriticalPath:()=>fe.flattenTasks(oe).filter(F=>F.isCriticalPath),indentTask:F=>{ue(L=>li(L,[F]));},outdentTask:F=>{ue(L=>di(L,[F]));},moveTask:(F,L)=>{ue(V=>ci(V,[F],L));},createSubtask:async F=>{let{tasks:L,newTask:V}=fi(oe,F);if(be){let re=be({...V,parentId:F});if((re instanceof Promise?await re:re)===false)return}ue(L),$&&$({...V,parentId:F});},scrollToTask:F=>{let V=fe.flattenTasks(oe).findIndex(re=>re.id===F);if(V!==-1&&Je.current){let re=V*ne;Je.current.scrollTo({top:re,behavior:"smooth"}),va.current&&va.current.scrollTo({top:re,behavior:"smooth"});}},highlightTask:(F,L=2e3)=>{},expandTask:F=>{ue(L=>{let V=re=>re.map(ge=>ge.id===F?{...ge,isExpanded:true}:ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge);return V(L)});},collapseTask:F=>{ue(L=>{let V=re=>re.map(ge=>ge.id===F?{...ge,isExpanded:false}:ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge);return V(L)});},expandAll:()=>{ue(F=>{let L=V=>V.map(re=>({...re,isExpanded:true,subtasks:re.subtasks?L(re.subtasks):void 0}));return L(F)});},collapseAll:()=>{ue(F=>{let L=V=>V.map(re=>({...re,isExpanded:false,subtasks:re.subtasks?L(re.subtasks):void 0}));return L(F)});},undo:pa,redo:ya,canUndo:()=>N,canRedo:()=>ee,clearHistory:se,exportToPNG:async()=>{if(!ua.current||!Je.current||!va.current)throw new Error("Gantt container not found");let F=ua.current,L=Je.current.querySelector(".gantt-grid-scroll"),V=va.current,re=L?.scrollTop||0,ge=V.scrollTop,Ne=F.style.overflow,ft=F.style.height;try{let Qt=L?.querySelector(".gantt-taskgrid-content"),xa=V.querySelector("svg"),ka=Qt?.scrollHeight||L?.scrollHeight||600,Fa=xa?.getBoundingClientRect().height||V.scrollHeight,Rr=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(ka,Fa)+20;L&&(L.scrollTop=0),V.scrollTop=0,F.style.overflow="visible",F.style.height=`${Rr}px`,await new Promise(wr=>setTimeout(wr,100));let kr=await kc__default.default(F,{backgroundColor:E.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:wr=>{let ro=window.getComputedStyle(wr),$r=parseInt(ro.zIndex,10);return !isNaN($r)&&$r>=50||ro.position==="fixed"}});return new Promise((wr,ro)=>{kr.toBlob($r=>{$r?wr($r):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Ne,F.style.height=ft,L&&(L.scrollTop=re),V.scrollTop=ge;}},exportToPDF:async F=>{await fe.exportToPDF(oe,F);},exportToExcel:async F=>{await fe.exportToExcel(oe,F);},exportToJSON:()=>fe.exportToJSON(oe),exportToCSV:()=>fe.exportToCSV(oe),importFromJSON:F=>{let L=fe.importFromJSON(F);ue(L);},getTasks:()=>oe,refresh:()=>{ue(F=>[...F]);},clearAll:()=>{ue([]);}}),[oe,pa,ya,N,ee,se,E,ne]);let Re=react.useCallback(F=>{Ue(L=>L.map(V=>V.id===F?{...V,visible:!V.visible}:V));},[]),xt=react.useCallback((F,L)=>{Ue(V=>V.map(re=>{if(re.id!==F)return re;let ge=re.minWidth??100,Ne=re.maxWidth??800,ft=Math.max(ge,Math.min(Ne,L));return {...re,width:ft}}));},[]),Le=react.useCallback(F=>{ue(L=>{let V=gi(L,F),re=ge=>{for(let Ne of ge){if(Ne.id===F){$e.current.set(F,Ne.isExpanded??true);return}Ne.subtasks?.length&&re(Ne.subtasks);}};return re(V),Ge(),V}),a.onTaskToggleExpand?.(F);},[a,Ge]),At=react.useCallback((F,L)=>{if(J&&J(F,L)===false)return;let re=fe.findTaskById(oe,F)?.progress,ge=ft=>ft.map(Qt=>Qt.id===F?{...Qt,...L}:Qt.subtasks?{...Qt,subtasks:ge(Qt.subtasks)}:Qt);ue(ge(oe));let Ne=fe.findTaskById(ge(oe),F);Ne&&(M?.(Ne),U?.(Ne),L.progress!==void 0&&re!==void 0&&L.progress!==re&&D?.(F,re,L.progress));},[oe,M,J,U,D]),st=react.useCallback(F=>{F.length!==0&&(ue(L=>li(L,F)),a.onTaskIndent?.(F[0]));},[a]),ga=react.useCallback(F=>{F.length!==0&&(ue(L=>di(L,F)),a.onTaskOutdent?.(F[0]));},[a]),zt=react.useCallback((F,L,V)=>{ue(re=>oc(re,F,L,V)),a.onTaskReparent?.(F,L,V);},[a]),je=react.useCallback((F,L)=>{F.length!==0&&(ue(V=>ci(V,F,L)),a.onTaskMove?.(F[0],L));},[a]),kt=react.useCallback(async F=>{let L=[];for(let V of F)G&&await Promise.resolve(G(V))===false||L.push(V);L.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(L):(ue(V=>mi(V,L)),L.forEach(V=>a.onTaskDelete?.(V))),A&&L.forEach(V=>A(V)));},[a,G,A]),ia=react.useCallback(F=>{ue(L=>pi(L,F)),F.forEach(L=>a.onTaskDuplicate?.(L));},[a]),vr=react.useCallback((F,L)=>{ue(V=>{let{tasks:re,newTask:ge}=rc(V,F,L);return be&&be(ge)===false?V:(a.onTaskCreate?.(ge.parentId,ge.position||0),$?.(ge),re)});},[a,be,$]),Hm=react.useCallback((F,L)=>{ue(V=>ui(V,F,L)),a.onTaskRename?.(F,L);},[a]),Zn=react.useCallback(F=>{ue(L=>{let{tasks:V}=fi(L,F);return a.onTaskCreate?.(F,0),V});},[a]),Wm=react.useCallback((F,L,V)=>{let re=F.startDate?Math.round((L.getTime()-F.startDate.getTime())/864e5):0,ge=Qt=>Qt.map(xa=>xa.id===F.id?{...xa,startDate:L,endDate:V,...F.segments&&{segments:F.segments}}:xa.subtasks?{...xa,subtasks:ge(xa.subtasks)}:xa),Ne=ge(oe);Ne=fe.autoScheduleDependents(Ne,F.id,re),ue(Ne);let ft={...F,startDate:L,endDate:V};M?.(ft);},[oe,M]),Gm=react.useCallback((F,L)=>{R?.(F,L),Xt({isOpen:true,x:L.clientX,y:L.clientY,task:F});},[R]),_m=react.useCallback((F,L)=>{let V=fe.splitTask(oe,F.id,L);ue(V),Xt({isOpen:false,x:0,y:0,task:null});},[oe]),hl=react.useCallback(F=>{let L=fe.findTaskById(oe,F.id)||F;w?.(L),I||Nt(L);},[oe,w,I]),bl=react.useCallback((F,L,V)=>{let re=new Map,ge=ka=>{ka.forEach(Fa=>{Fa.dependencies&&re.set(Fa.id,Fa.dependencies),Fa.subtasks&&ge(Fa.subtasks);});};ge(V);let Ne=re.get(L)||[];re.set(L,[...Ne,F]);let ft=new Set,Qt=new Set,xa=ka=>{if(!ft.has(ka)){ft.add(ka),Qt.add(ka);let Fa=re.get(ka)||[];for(let xr of Fa){if(!ft.has(xr)&&xa(xr))return true;if(Qt.has(xr))return true}}return Qt.delete(ka),false};return xa(L)},[]),yl=react.useCallback((F,L)=>{if(bl(F.id,L,oe)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
342
+ </Project>`,u=new Blob([i],{type:"application/xml;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(u),d.download=a,d.click(),URL.revokeObjectURL(d.href);},calculateCriticalPath:e=>{let t=fe.flattenTasks(e),a=t.filter(i=>i.startDate&&i.endDate);if(a.length===0)return [];let r=new Map,o=i=>{if(r.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=0;if(i.dependencies&&i.dependencies.length>0)for(let h of i.dependencies){let C=t.find(T=>T.id===h);if(C){o(C);let T=r.get(h)?.ef||0;d=Math.max(d,T);}}let g=d+u;r.set(i.id,{es:d,ef:g});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(i=>i.ef)),n=new Map,p=i=>{if(n.has(i.id))return;let u=i.startDate&&i.endDate?fe.calculateDuration(i.startDate,i.endDate):0,d=t.filter(C=>C.dependencies&&C.dependencies.includes(i.id)),g=s;if(d.length>0)for(let C of d){p(C);let T=n.get(C.id)?.ls||0;g=Math.min(g,T);}let h=g-u;n.set(i.id,{ls:h,lf:g});};a.forEach(p);let m=[];for(let i of a){let u=r.get(i.id),d=n.get(i.id);if(u&&d){let g=d.ls-u.es;Math.abs(g)<.01&&m.push(i.id);}}return m},calculateSlack:(e,t)=>{let a=fe.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(fe.calculateCriticalPath(e).includes(t))return 0;let o=fe.getDependentTasks(e,t);if(o.length===0){let p=fe.getLatestEndDate(e);if(!p)return null;let m=fe.calculateDuration(a.endDate,p);return Math.max(0,m)}let s=o.filter(p=>p.startDate).map(p=>p.startDate.getTime()).sort((p,m)=>p-m)[0];if(!s)return null;let n=fe.calculateDuration(a.endDate,new Date(s));return Math.max(0,n)},isOnCriticalPath:(e,t)=>fe.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=fe.findTaskById(e,t);if(!r||!r.endDate)return e;let o=fe.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let n of o){if(!n.startDate||!n.endDate)continue;let p=fe.calculateDuration(n.startDate,n.endDate),m;a!==void 0?(m=new Date(n.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let i=fe.calculateEndDate(m,p),u=d=>d.map(g=>g.id===n.id?{...g,startDate:m,endDate:i}:g.subtasks?{...g,subtasks:u(g.subtasks)}:g);s=u(s),s=fe.autoScheduleDependents(s,n.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,n,p)=>{if(a===0)return [];let m=[],i=o.getTime(),u=1e3*60*60*24,d=fe.findTaskById(e,t);if(!d||!d.endDate)return [];let g=(h,C,T=new Set)=>{if(T.has(h))return;T.add(h);let c=fe.getDependentTasks(e,h);for(let b of c){if(!b.startDate||!b.endDate)continue;let y=r.findIndex(D=>D.id===b.id);if(y===-1)continue;let l=b.startDate.getTime(),v=(b.endDate.getTime()-l)/u,k=(l-i)/u*s,w=k+C*s,R=Math.max(v*s,s),M=p+y*n+12;m.push({taskId:b.id,taskName:b.name,originalX:k,previewX:w,width:R,y:M,rowIndex:y,daysDelta:C,color:b.color}),g(b.id,C,T);}};return g(t,a),m},splitTask:(e,t,a,r=3)=>{let o=fe.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 n=new Date(a);n.setDate(n.getDate()+r);let p=new Date(o.endDate);p.setDate(p.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:n,endDate:p}],i=u=>u.map(d=>d.id===o.id?{...d,endDate:p,segments:m}:d.subtasks?{...d,subtasks:i(d.subtasks)}:d);return i(e)}};function In({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:n,templates:p,dependencyLineStyle:m="curved",onTaskClick:i,onTaskDblClick:u,onTaskContextMenu:d,onTaskDateChange:g,onDependencyCreate:h,onDependencyDelete:C}){let[c,b]=react.useState([]),[y,l]=react.useState(null),x=react.useCallback($=>{l($);},[]),v=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),S=r==="day"?60:r==="week"?20:8,k=v*S*n,w=$=>{let J=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate())),U=J.getUTCDay()||7;J.setUTCDate(J.getUTCDate()+4-U);let G=new Date(Date.UTC(J.getUTCFullYear(),0,1));return Math.ceil(((J.getTime()-G.getTime())/864e5+1)/7)},R=$=>{let J=$.getDay();return J===0||J===6},M=react.useCallback($=>{let J=Math.round($/(S*n)),U=new Date(o);return U.setDate(U.getDate()+J),U},[o,S,n]),D=react.useCallback(($,J)=>{if(J.startDate&&J.endDate)return;let U=$.currentTarget.ownerSVGElement;if(!U)return;let G=U.createSVGPoint();G.x=$.clientX,G.y=$.clientY;let A=G.matrixTransform(U.getScreenCTM()?.inverse()),Q=M(A.x),X=new Date(Q);X.setDate(X.getDate()+1),g?.(J,Q,X);},[M,g]),I=react.useMemo(()=>{let $=A=>A.map(Q=>{if(Q.subtasks&&Q.subtasks.length>0){let X=$(Q.subtasks),H=X.filter(Ce=>Ce.startDate&&Ce.endDate);if(H.length>0){let Ce=H.map(Ke=>Ke.startDate.getTime()),Me=H.map(Ke=>Ke.endDate.getTime()),Oe=new Date(Math.min(...Ce)),ve=new Date(Math.max(...Me));return {...Q,subtasks:X,startDate:Oe,endDate:ve}}return {...Q,subtasks:X}}return Q}),J=(A,Q=[])=>{for(let X of A)Q.push(X),X.subtasks&&X.subtasks.length>0&&(X.isExpanded===void 0||X.isExpanded)&&J(X.subtasks,Q);return Q},U=$(e);return J(U)},[e]),B=react.useCallback($=>{if(!$.startDate||!$.endDate)return {x:0,width:0};let J=$.startDate.getTime(),U=$.endDate.getTime(),G=o.getTime(),A=(J-G)/(1e3*60*60*24),Q=(U-J)/(1e3*60*60*24),X=A*S*n,H=Math.max(S*n,40),Ce=Math.max(Q*S*n,H);return {x:X,width:Ce}},[o,S,n]),K=react.useMemo(()=>I.filter($=>$.startDate&&$.endDate).map($=>{let{x:J,width:U}=B($),A=I.findIndex(Q=>Q.id===$.id)*a+12;return {id:$.id,x:J,y:A,width:U,height:32}}),[I,B]),te=react.useCallback(($,J,U)=>{if(!U||J===0){b([]);return}let G=fe.calculateCascadePreview(e,$,J,I,o,S*n,a,48);b(G);},[e,I,o,S,n,a,48]),ie=react.useMemo(()=>{let $=[],J=new Date(o);for(;J<=s;){let A=(J.getTime()-o.getTime())/864e5*S*n;if(r==="day")$.push({date:new Date(J),label:J.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:A}),J.setDate(J.getDate()+1);else if(r==="week"){let Q=w(J);$.push({date:new Date(J),label:`Week ${Q}`,x:A}),J.setDate(J.getDate()+7);}else $.push({date:new Date(J),label:J.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:A}),J.setMonth(J.getMonth()+1);}return $},[o,s,r,S,n]),de=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*S*n,[o,S,n]),be=Math.max(I.length*a,552);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col","data-gantt-chart":true,style:{backgroundColor:t.bgPrimary},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(k,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(k,1e3),height:48,fill:t.bgGrid}),ie.map(($,J)=>jsxRuntime.jsxs("g",{children:[J>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:$.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:$.label})]},`header-${J}`)),de>=0&&de<=k&&jsxRuntime.jsx("circle",{cx:de,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(k,1e3),height:be,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(k,1e3),height:be,fill:t.bgPrimary}),ie.map(($,J)=>{let U=ie[J+1]?.x||k,G=R($.date);return jsxRuntime.jsxs("g",{children:[G&&jsxRuntime.jsx("rect",{x:$.x,y:0,width:U-$.x,height:I.length*a,fill:t.bgWeekend,opacity:1}),J>0&&jsxRuntime.jsx("line",{x1:$.x,y1:0,x2:$.x,y2:I.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},J)}),I.map(($,J)=>{let U=$.startDate&&$.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:J*a,width:k,height:a,fill:J%2===0?t.bgPrimary:t.bgGrid,opacity:1,style:{pointerEvents:"none"}},`row-${$.id}`),!U&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:J*a,width:k,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:G=>D(G,$),onMouseEnter:G=>{G.currentTarget.setAttribute("fill",t.accentLight),G.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:G=>{G.currentTarget.setAttribute("fill","transparent"),G.currentTarget.setAttribute("opacity","1");}},`clickable-${$.id}`),jsxRuntime.jsx("text",{x:de>0?de:100,y:J*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-${$.id}`)]})]},`row-group-${$.id}`)}),I.map(($,J)=>{if(!$.startDate||!$.endDate)return null;let{x:U,width:G}=B($),A=J*a+12,Q=$.subtasks&&$.subtasks.length>0&&!$.isMilestone;return $.isMilestone?jsxRuntime.jsx(Fn,{task:$,x:U+G/2,y:A+16,theme:t,onClick:i},$.id):Q?jsxRuntime.jsxs("g",{onClick:()=>i?.($),onContextMenu:X=>{X.preventDefault(),X.stopPropagation(),d?.($,X);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:U,y:A,width:G,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:U,y1:A,x2:U+G,y2:A,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:U,y1:A,x2:U,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:U+G,y1:A,x2:U+G,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:U,y1:A+32,x2:U+G,y2:A+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),G>60&&jsxRuntime.jsx("text",{x:U+12,y:A+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:$.name})]},$.id):jsxRuntime.jsx(Sn,{task:$,x:U,y:A,width:G,theme:t,dayWidth:S*n,startDate:o,templates:p,onClick:i,onDoubleClick:u,onContextMenu:d,onDateChange:g,onDependencyCreate:h,allTaskPositions:K,onDragMove:te,onHoverChange:x},$.id)}),I.map(($,J)=>!$.dependencies||$.dependencies.length===0||!$.startDate||!$.endDate?null:$.dependencies.map(U=>{let G=I.find(ve=>ve.id===U);if(!G||!G.startDate||!G.endDate)return null;let A=I.findIndex(ve=>ve.id===U),Q=B(G),X=B($),H=Q.x+Q.width,Ce=A*a+28,Me=X.x,Oe=J*a+28;return jsxRuntime.jsx(Mn,{x1:H,y1:Ce,x2:Me,y2:Oe,theme:t,lineStyle:m,onDelete:()=>C?.($.id,U)},`dep-${U}-${$.id}`)})),c.map($=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:$.previewX,y:$.y-48,width:$.width,height:32,rx:8,fill:$.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs($.daysDelta)>0&&jsxRuntime.jsx("text",{x:$.previewX+$.width/2,y:$.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:$.daysDelta>0?`+${$.daysDelta}d`:`${$.daysDelta}d`})]},`cascade-preview-${$.taskId}`)),de>=0&&de<=k&&jsxRuntime.jsx("line",{x1:de,y1:0,x2:de,y2:be,stroke:t.today,strokeWidth:1,opacity:1,style:{pointerEvents:"none"}}),y&&jsxRuntime.jsx(pc,{tooltipData:y,theme:t})]})]})}var m0=['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"'],hc=()=>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"})]}),p0=()=>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"})}),u0=()=>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"})}),g0=()=>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"})}),f0=()=>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 Bn({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:n,onDependencyCreate:p,onDependencyDelete:m}){let[i,u]=react.useState(false),[d,g]=react.useState(false),[h,C]=react.useState([]),[T,c]=react.useState(""),[b,y]=react.useState(false),[l,x]=react.useState(true),v=react.useRef(null),S=react.useRef(null),k=react.useRef(null),{enabled:w=true,placeholder:R='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:M="bottom-right",onCommand:D,suggestions:I=m0,maxHistory:B=50,persistHistory:K}=a,te=K?.storageKey||"gantt-ai-history",ie=K?.maxMessages??5;react.useEffect(()=>{if(K?.enabled)try{let G=localStorage.getItem(te);if(G){let Q=JSON.parse(G).map(X=>({...X,timestamp:new Date(X.timestamp)}));C(Q.slice(-ie));}}catch(G){console.warn("[GanttAIAssistant] Failed to load persisted history:",G);}},[K?.enabled,te,ie]),react.useEffect(()=>{if(K?.enabled&&h.length>0)try{let G=h.filter(A=>!A.isLoading).slice(-ie);localStorage.setItem(te,JSON.stringify(G));}catch(G){console.warn("[GanttAIAssistant] Failed to persist history:",G);}},[h,K?.enabled,te,ie]),react.useEffect(()=>{S.current&&S.current.scrollIntoView({behavior:"smooth"});},[h]),react.useEffect(()=>{i&&!d&&v.current&&setTimeout(()=>v.current?.focus(),100);},[i,d]);let de=react.useCallback(G=>{if(G.success)switch(G.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":G.taskId&&G.updates&&o?.(G.taskId,G.updates);break;case "create_task":G.newTask&&s?.(G.newTask);break;case "delete_task":G.taskId&&n?.(G.taskId);break;case "link_tasks":G.dependencyFrom&&G.dependencyTo&&p?.(G.dependencyFrom,G.dependencyTo);break;case "unlink_tasks":G.taskId&&G.dependencyFrom&&m?.(G.taskId,G.dependencyFrom);break}},[o,s,n,p,m]),be=react.useCallback(async G=>{if(!G.trim()||b)return;let A={id:`user-${Date.now()}`,role:"user",content:G,timestamp:new Date};C(X=>[...X.slice(-(B-1)),A]),c(""),x(false),y(true);let Q={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};C(X=>[...X,Q]);try{if(D){let X=await D(G,e);C(H=>{let Ce=H.filter(Oe=>!Oe.isLoading),Me={id:`assistant-${Date.now()}`,role:"assistant",content:X.message,timestamp:new Date,command:X};return [...Ce,Me]}),de(X);}else C(X=>[...X.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(X){C(H=>[...H.filter(Me=>!Me.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${X instanceof Error?X.message:"Unknown error"}`,timestamp:new Date}]);}finally{y(false);}},[b,B,D,e,de]),$=G=>{G.preventDefault(),be(T);},J=G=>{c(G),v.current?.focus();};if(react.useEffect(()=>{let G=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),u(Q=>!Q),i||g(false)),A.key==="Escape"&&i&&u(false);};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[i]),react.useEffect(()=>{if(!i)return;let G=Q=>{let X=Q.target;k.current&&!k.current.contains(X)&&u(false);},A=setTimeout(()=>{document.addEventListener("mousedown",G);},100);return ()=>{clearTimeout(A),document.removeEventListener("mousedown",G);}},[i]),!w)return null;let U={"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(lt,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!i&&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 ${U[M]} 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:()=>u(true),children:[jsxRuntime.jsx(hc,{}),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:i&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:k,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:d?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${U[M]} 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(hc,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>g(G=>!G),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(g0,{})}),jsxRuntime.jsx("button",{onClick:()=>u(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(u0,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!d&&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:[h.length===0&&l&&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:I.slice(0,4).map((G,A)=>jsxRuntime.jsx("button",{onClick:()=>J(G),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:G.length>30?G.slice(0,30)+"...":G},A))})]}),h.map(G=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${G.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${G.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:G.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:G.role==="user"?"white":t.textPrimary},children:[G.isLoading?jsxRuntime.jsx(f0,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:G.content}),G.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:G.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:G.command.success?"#10B981":"#EF4444"},children:[G.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:G.command.type.replace(/_/g," ")})]})]})},G.id)),jsxRuntime.jsx("div",{ref:S})]}),jsxRuntime.jsxs("form",{onSubmit:$,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:v,type:"text",value:T,onChange:G=>c(G.target.value),placeholder:R,disabled:b,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!T.trim()||b,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:T.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:T.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(p0,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function bc(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((i,u=true)=>{r(d=>{let g=typeof i=="function"?i(d.present):i;if(o.current)return {...d,present:g};if(!u)return {...d,present:g};let h=[...d.past,d.present];return h.length>t&&h.shift(),{past:h,present:g,future:[]}});},[t]),n=react.useCallback(()=>{r(i=>{if(i.past.length===0)return i;let u=i.past[i.past.length-1],d=i.past.slice(0,i.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:d,present:u,future:[i.present,...i.future]}});},[]),p=react.useCallback(()=>{r(i=>{if(i.future.length===0)return i;let u=i.future[0],d=i.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...i.past,i.present],present:u,future:d}});},[]),m=react.useCallback(()=>{r(i=>({past:[],present:i.present,future:[]}));},[]);return {state:a.present,setState:s,undo:n,redo:p,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function yc({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=n=>{let p=navigator.platform.toUpperCase().indexOf("MAC")>=0,m=p?n.metaKey:n.ctrlKey;if(m&&n.key==="z"&&!n.shiftKey&&a){n.preventDefault(),e();return}if(r){if(!p&&m&&n.key==="y"){n.preventDefault(),t();return}if(p&&m&&n.shiftKey&&n.key==="z"){n.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var v0={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${fe.formatDate(e.startDate)} - ${fe.formatDate(e.endDate)}`);let a=fe.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=>fe.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function vc(e){return {...v0,...e}}var D0=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},wc=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:n="week",rowDensity:p="comfortable",showThemeSelector:m=true,showExportButton:i=true,availableUsers:u=[],templates:d,enableAutoCriticalPath:g=true,persistExpandedState:h,aiAssistant:C,locale:T="en",customTranslations:c,showCreateTaskButton:b=false,createTaskLabel:y,onCreateTask:l,taskFilter:x,onTaskFilterChange:v,onThemeChange:S,onTaskClick:k,onTaskDblClick:w,onTaskContextMenu:R,onTaskUpdate:M,onProgressChange:D,onTaskEdit:I,onTaskAddSubtask:B,onTaskMarkIncomplete:K,onTaskSetInProgress:te,onDependencyCreate:ie,onDependencyDelete:de,onBeforeTaskAdd:be,onAfterTaskAdd:$,onBeforeTaskUpdate:J,onAfterTaskUpdate:U,onBeforeTaskDelete:G,onAfterTaskDelete:A}=a,X=react.useContext(vn)?.theme,[H,Ce]=react.useState(X||s||"dark"),[Me,Oe]=react.useState(n),[ve,Ke]=react.useState(p),[We,et]=react.useState(1),[vt,Mt]=react.useState("all"),mt=x??vt,O=v??Mt,[le,xe]=react.useState(0),[Pe,ze]=react.useState(false),[at,Et]=react.useState(null),[Fe,Xt]=react.useState({isOpen:false,x:0,y:0,task:null}),[Ot,Nt]=react.useState(null),[ct,Jt]=react.useState(null);react.useEffect(()=>{X&&X!==H&&Ce(X);},[X]),react.useEffect(()=>{s&&s!==H&&Ce(s);},[s]);let Ea=react.useCallback(F=>{Ce(F),S?.(F);},[S]),{state:oe,setState:ue,undo:pa,redo:ya,canUndo:N,canRedo:ee,clearHistory:se}=bc(t,50),De=react.useCallback(()=>h?typeof h=="string"?h:"gantt-expanded-tasks":null,[h]),$e=react.useRef(new Map),tt=react.useRef(false);if(!tt.current&&h){tt.current=true;let F=typeof h=="string"?h:"gantt-expanded-tasks";try{let L=localStorage.getItem(F);if(L){let V=JSON.parse(L);Array.isArray(V)&&($e.current=new Map(V));}}catch(L){console.warn("[GanttBoard] Error loading expanded state from localStorage:",L);}}let Ge=react.useCallback(()=>{let F=De();if(F)try{let L=Array.from($e.current.entries());localStorage.setItem(F,JSON.stringify(L));}catch(L){console.warn("[GanttBoard] Error saving expanded state to localStorage:",L);}},[De]);react.useEffect(()=>{let F=L=>L.map(V=>{let re=$e.current.get(V.id),ge=re!==void 0?{...V,isExpanded:re}:V;return ge.subtasks?.length?{...ge,subtasks:F(ge.subtasks)}:ge});$e.current.size>0?ue(F(t)):ue(t);},[t,ue]);let Be=react.useRef(t),rt=react.useRef(true);react.useEffect(()=>{if(rt.current){rt.current=false,Be.current=oe;return}if(!r)return;let F=JSON.stringify(Be.current),L=JSON.stringify(oe);F!==L&&(Be.current=oe,r(oe));},[oe,r]);let _=react.useMemo(()=>ti(T,c),[T,c]),ae=react.useCallback(F=>[{id:"name",label:F.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:F.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:F.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:F.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:F.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:F.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:F.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:F.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ee,Ue]=react.useState(()=>ae(_));react.useEffect(()=>{Ue(F=>F.map(L=>({...L,label:_.columns[L.id==="name"?"taskName":L.id]||L.label})));},[_]);let He=react.useMemo(()=>Ee.filter(L=>L.visible).reduce((L,V)=>L+V.width,0),[Ee]),W=react.useRef(Ee.filter(F=>F.visible).map(F=>F.id).join(","));react.useEffect(()=>{let F=Ee.filter(re=>re.visible),L=F.map(re=>re.id).join(","),V=W.current;if(L!==V){let re=F.some(Ne=>Ne.id!=="name"),ge=V.includes(",");re?!ge&&re&&Et(null):Et(null),W.current=L;}},[Ee]);let ce=60,Ie=.6,Dt=react.useMemo(()=>{let L=He+ce,V=typeof window<"u"?window.innerWidth*Ie:800,re=Math.max(L,V);return at!==null?Math.max(200,Math.min(at,re)):Math.max(200,L)},[at,He]),Je=react.useRef(null),va=react.useRef(null),ua=react.useRef(null),E=react.useMemo(()=>Ud(H),[H]),ye=react.useMemo(()=>({theme:E,themeName:H}),[E,H]),q=react.useMemo(()=>vc(d),[d]),Ae=react.useMemo(()=>{if(!g)return oe;let F=fe.calculateCriticalPath(oe),L=V=>V.map(re=>({...re,isCriticalPath:F.includes(re.id),subtasks:re.subtasks?L(re.subtasks):void 0}));return L(oe)},[oe,g]),ot=react.useMemo(()=>{if(mt==="all")return Ae;let F=L=>{let V=[];for(let re of L){let ge=re.subtasks?.length?F(re.subtasks):void 0,Ne=false;switch(mt){case "incomplete":Ne=re.progress<100;break;case "in_progress":Ne=re.progress>0&&re.progress<100;break;case "completed":Ne=re.progress===100;break}(Ne||ge&&ge.length>0)&&V.push({...re,subtasks:ge});}return V};return F(Ae)},[Ae,mt]),ne=D0(ve);yc({undo:pa,redo:ya,canUndo:N,canRedo:ee,enabled:true}),react.useImperativeHandle(o,()=>({getTask:F=>fe.findTaskById(oe,F),addTask:(F,L)=>{ue(V=>{if(!L)return [...V,{...F,level:0}];let re=ge=>ge.map(Ne=>Ne.id===L?{...Ne,subtasks:[...Ne.subtasks||[],{...F,parentId:L,level:(Ne.level||0)+1}],isExpanded:true}:Ne.subtasks?{...Ne,subtasks:re(Ne.subtasks)}:Ne);return re(V)});},updateTask:(F,L)=>{ue(V=>{let re=ge=>ge.map(Ne=>Ne.id===F?{...Ne,...L}:Ne.subtasks?{...Ne,subtasks:re(Ne.subtasks)}:Ne);return re(V)});},deleteTask:F=>{ue(L=>{let V=re=>re.filter(ge=>ge.id===F?false:(ge.subtasks&&(ge.subtasks=V(ge.subtasks)),true));return V(L)});},deleteTasks:F=>{ue(L=>mi(L,F));},duplicateTask:F=>{ue(L=>pi(L,[F]));},splitTask:(F,L,V=3)=>{ue(re=>fe.splitTask(re,F,L,V));},calculateEndDate:fe.calculateEndDate,calculateDuration:fe.calculateDuration,validateDependency:(F,L)=>!fe.validateDependencies(oe,F,L),getAllTasks:()=>fe.flattenTasks(oe),getTasksByStatus:F=>fe.flattenTasks(oe).filter(L=>L.status===F),getTasksByParent:F=>F?fe.findTaskById(oe,F)?.subtasks||[]:oe.filter(V=>!V.parentId),getCriticalPath:()=>fe.flattenTasks(oe).filter(F=>F.isCriticalPath),indentTask:F=>{ue(L=>li(L,[F]));},outdentTask:F=>{ue(L=>di(L,[F]));},moveTask:(F,L)=>{ue(V=>ci(V,[F],L));},createSubtask:async F=>{let{tasks:L,newTask:V}=fi(oe,F);if(be){let re=be({...V,parentId:F});if((re instanceof Promise?await re:re)===false)return}ue(L),$&&$({...V,parentId:F});},scrollToTask:F=>{let V=fe.flattenTasks(oe).findIndex(re=>re.id===F);if(V!==-1&&Je.current){let re=V*ne;Je.current.scrollTo({top:re,behavior:"smooth"}),va.current&&va.current.scrollTo({top:re,behavior:"smooth"});}},highlightTask:(F,L=2e3)=>{},expandTask:F=>{ue(L=>{let V=re=>re.map(ge=>ge.id===F?{...ge,isExpanded:true}:ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge);return V(L)});},collapseTask:F=>{ue(L=>{let V=re=>re.map(ge=>ge.id===F?{...ge,isExpanded:false}:ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge);return V(L)});},expandAll:()=>{ue(F=>{let L=V=>V.map(re=>({...re,isExpanded:true,subtasks:re.subtasks?L(re.subtasks):void 0}));return L(F)});},collapseAll:()=>{ue(F=>{let L=V=>V.map(re=>({...re,isExpanded:false,subtasks:re.subtasks?L(re.subtasks):void 0}));return L(F)});},undo:pa,redo:ya,canUndo:()=>N,canRedo:()=>ee,clearHistory:se,exportToPNG:async()=>{if(!ua.current||!Je.current||!va.current)throw new Error("Gantt container not found");let F=ua.current,L=Je.current.querySelector(".gantt-grid-scroll"),V=va.current,re=L?.scrollTop||0,ge=V.scrollTop,Ne=F.style.overflow,ft=F.style.height;try{let Qt=L?.querySelector(".gantt-taskgrid-content"),xa=V.querySelector("svg"),ka=Qt?.scrollHeight||L?.scrollHeight||600,Fa=xa?.getBoundingClientRect().height||V.scrollHeight,Rr=(F.querySelector('[class*="h-12"]')?.offsetHeight||48)+Math.max(ka,Fa)+20;L&&(L.scrollTop=0),V.scrollTop=0,F.style.overflow="visible",F.style.height=`${Rr}px`,await new Promise(wr=>setTimeout(wr,100));let kr=await kc__default.default(F,{backgroundColor:E.bgPrimary,scale:2,logging:!1,useCORS:!0,ignoreElements:wr=>{let ro=window.getComputedStyle(wr),$r=parseInt(ro.zIndex,10);return !isNaN($r)&&$r>=50||ro.position==="fixed"}});return new Promise((wr,ro)=>{kr.toBlob($r=>{$r?wr($r):ro(new Error("Failed to create blob from canvas"));},"image/png");})}finally{F.style.overflow=Ne,F.style.height=ft,L&&(L.scrollTop=re),V.scrollTop=ge;}},exportToPDF:async F=>{await fe.exportToPDF(oe,F);},exportToExcel:async F=>{await fe.exportToExcel(oe,F);},exportToJSON:()=>fe.exportToJSON(oe),exportToCSV:()=>fe.exportToCSV(oe),importFromJSON:F=>{let L=fe.importFromJSON(F);ue(L);},getTasks:()=>oe,refresh:()=>{ue(F=>[...F]);},clearAll:()=>{ue([]);}}),[oe,pa,ya,N,ee,se,E,ne]);let Re=react.useCallback(F=>{Ue(L=>L.map(V=>V.id===F?{...V,visible:!V.visible}:V));},[]),xt=react.useCallback((F,L)=>{Ue(V=>V.map(re=>{if(re.id!==F)return re;let ge=re.minWidth??100,Ne=re.maxWidth??800,ft=Math.max(ge,Math.min(Ne,L));return {...re,width:ft}}));},[]),Le=react.useCallback(F=>{ue(L=>{let V=gi(L,F),re=ge=>{for(let Ne of ge){if(Ne.id===F){$e.current.set(F,Ne.isExpanded??true);return}Ne.subtasks?.length&&re(Ne.subtasks);}};return re(V),Ge(),V}),a.onTaskToggleExpand?.(F);},[a,Ge]),At=react.useCallback((F,L)=>{if(J&&J(F,L)===false)return;let re=fe.findTaskById(oe,F)?.progress,ge=ft=>ft.map(Qt=>Qt.id===F?{...Qt,...L}:Qt.subtasks?{...Qt,subtasks:ge(Qt.subtasks)}:Qt);ue(ge(oe));let Ne=fe.findTaskById(ge(oe),F);Ne&&(M?.(Ne),U?.(Ne),L.progress!==void 0&&re!==void 0&&L.progress!==re&&D?.(F,re,L.progress));},[oe,M,J,U,D]),st=react.useCallback(F=>{F.length!==0&&(ue(L=>li(L,F)),a.onTaskIndent?.(F[0]));},[a]),ga=react.useCallback(F=>{F.length!==0&&(ue(L=>di(L,F)),a.onTaskOutdent?.(F[0]));},[a]),zt=react.useCallback((F,L,V)=>{ue(re=>oc(re,F,L,V)),a.onTaskReparent?.(F,L,V);},[a]),je=react.useCallback((F,L)=>{F.length!==0&&(ue(V=>ci(V,F,L)),a.onTaskMove?.(F[0],L));},[a]),kt=react.useCallback(async F=>{let L=[];for(let V of F)G&&await Promise.resolve(G(V))===false||L.push(V);L.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(L):(ue(V=>mi(V,L)),L.forEach(V=>a.onTaskDelete?.(V))),A&&L.forEach(V=>A(V)));},[a,G,A]),ia=react.useCallback(F=>{ue(L=>pi(L,F)),F.forEach(L=>a.onTaskDuplicate?.(L));},[a]),vr=react.useCallback((F,L)=>{ue(V=>{let{tasks:re,newTask:ge}=rc(V,F,L);return be&&be(ge)===false?V:(a.onTaskCreate?.(ge.parentId,ge.position||0),$?.(ge),re)});},[a,be,$]),Hm=react.useCallback((F,L)=>{ue(V=>ui(V,F,L)),a.onTaskRename?.(F,L);},[a]),Zn=react.useCallback(F=>{ue(L=>{let{tasks:V}=fi(L,F);return a.onTaskCreate?.(F,0),V});},[a]),Wm=react.useCallback((F,L,V)=>{let re=F.startDate?Math.round((L.getTime()-F.startDate.getTime())/864e5):0,ge=Qt=>Qt.map(xa=>xa.id===F.id?{...xa,startDate:L,endDate:V,...F.segments&&{segments:F.segments}}:xa.subtasks?{...xa,subtasks:ge(xa.subtasks)}:xa),Ne=ge(oe);Ne=fe.autoScheduleDependents(Ne,F.id,re),ue(Ne);let ft={...F,startDate:L,endDate:V};M?.(ft);},[oe,M]),Gm=react.useCallback((F,L)=>{R?.(F,L),Xt({isOpen:true,x:L.clientX,y:L.clientY,task:F});},[R]),_m=react.useCallback((F,L)=>{let V=fe.splitTask(oe,F.id,L);ue(V),Xt({isOpen:false,x:0,y:0,task:null});},[oe]),hl=react.useCallback(F=>{let L=fe.findTaskById(oe,F.id)||F;w?.(L),I||Nt(L);},[oe,w,I]),bl=react.useCallback((F,L,V)=>{let re=new Map,ge=ka=>{ka.forEach(Fa=>{Fa.dependencies&&re.set(Fa.id,Fa.dependencies),Fa.subtasks&&ge(Fa.subtasks);});};ge(V);let Ne=re.get(L)||[];re.set(L,[...Ne,F]);let ft=new Set,Qt=new Set,xa=ka=>{if(!ft.has(ka)){ft.add(ka),Qt.add(ka);let Fa=re.get(ka)||[];for(let xr of Fa){if(!ft.has(xr)&&xa(xr))return true;if(Qt.has(xr))return true}}return Qt.delete(ka),false};return xa(L)},[]),yl=react.useCallback((F,L)=>{if(bl(F.id,L,oe)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
343
343
 
344
344
  Task dependencies must flow in one direction only.`);return}let V=re=>re.map(ge=>{if(ge.id===L){let Ne=ge.dependencies||[];if(!Ne.includes(F.id))return {...ge,dependencies:[...Ne,F.id]}}return ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge});ue(V(oe)),ie?.(F.id,L);},[oe,ie,bl]),vl=react.useCallback((F,L)=>{let V=re=>re.map(ge=>{if(ge.id===F&&ge.dependencies){let Ne=ge.dependencies.filter(ft=>ft!==L);return {...ge,dependencies:Ne}}return ge.subtasks?{...ge,subtasks:V(ge.subtasks)}:ge});ue(V(oe)),de?.(F,L);},[oe,de]),{startDate:Vm,endDate:jm}=react.useMemo(()=>{let F=oe.filter(Ne=>Ne.startDate&&Ne.endDate);if(F.length===0){let Ne=new Date,ft=new Date(Ne);ft.setDate(ft.getDate()-30);let Qt=new Date(Ne);return Qt.setDate(Qt.getDate()+60),{startDate:ft,endDate:Qt}}let L=F.flatMap(Ne=>[Ne.startDate,Ne.endDate]).filter(Ne=>Ne!==void 0),V=new Date(Math.min(...L.map(Ne=>Ne.getTime()))),re=new Date(Math.max(...L.map(Ne=>Ne.getTime()))),ge=Me==="day"?7:Me==="week"?14:30;return V.setDate(V.getDate()-ge),re.setDate(re.getDate()+ge),{startDate:V,endDate:re}},[oe,Me]),Km=react.useCallback(async()=>{if(!ua.current||!Je.current||!va.current)return;await new Promise(Rr=>setTimeout(Rr,200));let F=ua.current,L=Je.current.querySelector(".gantt-grid-scroll"),V=va.current,re=L?.scrollTop||0,ge=L?.scrollLeft||0,Ne=V.scrollTop,ft=V.scrollLeft,Qt=F.style.overflow,xa=F.style.height,ka=L?.style.overflow||"",Fa=V.style.overflow,xr=F.style.width,Qo=V.style.width;try{let Rr=L?.querySelector(".gantt-taskgrid-content"),kr=V.querySelector("svg"),wr=kr?.getAttribute("height")?parseInt(kr.getAttribute("height"),10):kr?.getBoundingClientRect().height||0,ro=Rr?.scrollHeight||L?.scrollHeight||600,$r=Math.max(wr,V.scrollHeight),xl=kr?.getAttribute("width")?parseInt(kr.getAttribute("width"),10):kr?.getBoundingClientRect().width||V.scrollWidth,ep=F.querySelector('[class*="h-12"]')?.offsetHeight||48,es=Math.max(ro,$r,wr),ts=ep+es+50,as=(L?.offsetWidth||300)+xl+10;L&&(L.scrollTop=0,L.scrollLeft=0),V.scrollTop=0,V.scrollLeft=0,F.style.overflow="visible",F.style.height=`${ts}px`,F.style.width=`${as}px`,L&&(L.style.overflow="visible",L.style.height=`${es+50}px`),V.style.overflow="visible",V.style.height=`${es+50}px`,V.style.width=`${xl+10}px`,await new Promise(os=>setTimeout(os,150));let tp=await kc__default.default(F,{backgroundColor:E.bgPrimary,scale:2,logging:!1,useCORS:!0,allowTaint:!0,width:as,height:ts,windowWidth:as+100,windowHeight:ts+100,scrollX:0,scrollY:0,ignoreElements:os=>{let kl=window.getComputedStyle(os),wl=parseInt(kl.zIndex,10);return !isNaN(wl)&&wl>=50||kl.position==="fixed"}}),rs=document.createElement("a");rs.download=`gantt-chart-${new Date().toISOString().slice(0,10)}.png`,rs.href=tp.toDataURL("image/png"),rs.click();}finally{F.style.overflow=Qt,F.style.height=xa,F.style.width=xr,L&&(L.style.overflow=ka,L.style.height="",L.scrollTop=re,L.scrollLeft=ge),V.style.overflow=Fa,V.style.height="",V.style.width=Qo,V.scrollTop=Ne,V.scrollLeft=ft;}},[E]),Ym=react.useCallback(async()=>{await fe.exportToPDF(oe);},[oe]),qm=react.useCallback(async()=>{await fe.exportToExcel(oe);},[oe]),Xm=react.useCallback(()=>{let F=fe.exportToCSV(oe),L=new Blob([F],{type:"text/csv;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(L),V.download="gantt-chart.csv",V.click(),URL.revokeObjectURL(V.href);},[oe]),Jm=react.useCallback(()=>{let F=fe.exportToJSON(oe),L=new Blob([F],{type:"application/json;charset=utf-8;"}),V=document.createElement("a");V.href=URL.createObjectURL(L),V.download="gantt-chart.json",V.click(),URL.revokeObjectURL(V.href);},[oe]),Qm=react.useCallback(()=>{fe.exportToMSProject(oe,"Gantt Project","project.xml");},[oe]),Zm=F=>{F.preventDefault(),ze(true);},ao=react.useRef(false);return react.useEffect(()=>{let F=va.current,L=Je.current?.querySelector(".gantt-grid-scroll");if(!F||!L)return;let V=()=>{if(ao.current)return;ao.current=true;let ft=F.scrollTop;xe(ft),L.scrollTop=ft,requestAnimationFrame(()=>{ao.current=false;});},re=()=>{if(ao.current)return;ao.current=true;let ft=L.scrollTop;xe(ft),F.scrollTop=ft,requestAnimationFrame(()=>{ao.current=false;});},ge=ft=>{if(Pe&&L){let xa=L.parentElement?.getBoundingClientRect()?.left||0,ka=ft.clientX-xa,Fa=200,xr=He+ce,Qo=window.innerWidth*Ie,Rr=Math.max(xr,Qo);ka>=Fa&&ka<=Rr&&Et(ka);}},Ne=()=>{ze(false);};return F.addEventListener("scroll",V),L.addEventListener("scroll",re),document.addEventListener("mousemove",ge),document.addEventListener("mouseup",Ne),()=>{F.removeEventListener("scroll",V),L.removeEventListener("scroll",re),document.removeEventListener("mousemove",ge),document.removeEventListener("mouseup",Ne);}},[Pe,He]),jsxRuntime.jsx(ho.Provider,{value:_,children:jsxRuntime.jsx(ds.Provider,{value:ye,children:jsxRuntime.jsxs("div",{ref:ua,className:"flex flex-col h-full w-full",style:{backgroundColor:E.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(wn,{theme:E,timeScale:Me,onTimeScaleChange:Oe,zoom:We,onZoomChange:et,currentTheme:H,onThemeChange:Ea,rowDensity:ve,onRowDensityChange:Ke,showThemeSelector:m,showCreateTaskButton:b,createTaskLabel:y,onCreateTask:l,taskFilter:mt,onTaskFilterChange:O,onExportPNG:i?Km:void 0,onExportPDF:i?Ym:void 0,onExportExcel:i?qm:void 0,onExportCSV:i?Xm:void 0,onExportJSON:i?Jm:void 0,onExportMSProject:i?Qm:void 0}),jsxRuntime.jsxs("div",{ref:Je,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:Dt,overflowX:"auto",overflowY:"scroll",scrollbarWidth:"none",msOverflowStyle:"none"},children:jsxRuntime.jsx(Dn,{tasks:ot,theme:E,rowHeight:ne,availableUsers:u,templates:q,onTaskClick:k,onTaskDblClick:hl,onTaskContextMenu:R,onTaskToggle:Le,scrollTop:le,columns:Ee,onToggleColumn:Re,onColumnResize:xt,onTaskUpdate:At,onTaskIndent:st,onTaskOutdent:ga,onTaskMove:je,onMultiTaskDelete:kt,onTaskDuplicate:ia,onTaskCreate:vr,onTaskRename:Hm,onCreateSubtask:Zn,onOpenTaskModal:k?F=>k(F):void 0,onDeleteRequest:(F,L)=>Jt({taskId:F,taskName:L}),onTaskReparent:zt})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize hover:bg-blue-500/50 transition-colors h-full",style:{width:1,backgroundColor:E.border,zIndex:15},onMouseDown:Zm}),jsxRuntime.jsx("div",{ref:va,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(In,{tasks:ot,theme:E,rowHeight:ne,timeScale:Me,startDate:Vm,endDate:jm,zoom:We,templates:q,dependencyLineStyle:a?.dependencyLineStyle,onTaskClick:k,onTaskDblClick:hl,onTaskContextMenu:Gm,onTaskDateChange:Wm,onDependencyCreate:yl,onDependencyDelete:vl})})]}),Fe.task&&jsxRuntime.jsx(yo,{isOpen:Fe.isOpen,x:Fe.x,y:Fe.y,theme:E,onClose:()=>Xt({isOpen:false,x:0,y:0,task:null}),items:(()=>{let F=Fe.task;if(!F)return [];let L=fe.findTaskById(oe,F.id)||F;return L.subtasks&&L.subtasks.length>0?[{id:"addSubtask",label:_.contextMenu?.addSubtask||"Add Subtask",icon:Rt.Add,onClick:()=>{B?B(L):Zn(L.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:_.contextMenu?.deleteTask||"Delete Task",icon:Rt.Delete,onClick:()=>{Jt({taskId:L.id,taskName:L.name});}}]:[{id:"edit",label:_.contextMenu?.editTask||"Edit Task",icon:Rt.Pencil,onClick:()=>{I?I(L):Nt(L);}},{id:"addSubtask",label:_.contextMenu?.addSubtask||"Add Subtask",icon:Rt.Add,onClick:()=>{B?B(L):Zn(L.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:_.contextMenu?.markIncomplete||"Mark Incomplete",icon:Rt.MarkIncomplete,onClick:()=>{K?K(L):At(L.id,{status:"todo",progress:0});},disabled:L.status==="todo"},{id:"setInProgress",label:_.contextMenu?.setInProgress||"Set In Progress",icon:Rt.SetInProgress,onClick:()=>{te?te(L):At(L.id,{status:"in-progress"});},disabled:L.status==="in-progress"},{id:"markComplete",label:_.contextMenu?.markComplete||"Mark Complete",icon:Rt.MarkComplete,onClick:()=>{At(L.id,{status:"completed",progress:100});},disabled:L.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:_.contextMenu?.splitTask||"Split Task",icon:Rt.Split,onClick:()=>{if(!L.startDate||!L.endDate){console.warn("Cannot split task without dates");return}let re=L.startDate.getTime(),ge=L.endDate.getTime(),Ne=re+(ge-re)/2,ft=new Date(Ne);_m(L,ft);},disabled:!L.startDate||!L.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:_.contextMenu?.deleteTask||"Delete Task",icon:Rt.Delete,onClick:()=>{Jt({taskId:L.id,taskName:L.name});}}]})()}),jsxRuntime.jsx(_r,{task:Ot,isOpen:!!Ot,onClose:()=>Nt(null),onTaskUpdate:F=>{Ot&&(At(Ot.id,F),Nt(null));},theme:H==="light"?"light":"dark",locale:T==="es"?"es":"en",availableUsers:u,availableTasks:t}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:ct&&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:()=>Jt(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:F=>F.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:E.bgSecondary,border:`1px solid ${E.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${E.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:E.textPrimary,fontFamily:"Inter, sans-serif"},children:[_.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:E.textSecondary,fontFamily:"Inter, sans-serif"},children:T==="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:E.textSecondary,fontFamily:"Inter, sans-serif"},children:[T==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:E.textPrimary},children:['"',ct.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:E.bgPrimary,borderTop:`1px solid ${E.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>Jt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:E.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:F=>{F.currentTarget.style.backgroundColor=E.hoverBg;},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="transparent";},children:T==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{kt([ct.taskId]),Jt(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:F=>{F.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:F=>{F.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),T==="es"?"Eliminar":"Delete"]})]})]})})}),C?.enabled&&jsxRuntime.jsx(Bn,{tasks:oe,theme:E,config:C,onTasksUpdate:ue,onTaskUpdate:At,onTaskCreate:F=>{ue(L=>[...L,F]);},onTaskDelete:F=>{kt([F]);},onDependencyCreate:(F,L)=>{let V=fe.findTaskById(oe,F);V&&yl(V,L);},onDependencyDelete:vl})]})})})});var ki=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],wi=[{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 Nc({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:n=false,mode:p=a?"edit":"create",theme:m="dark",customStatuses:i=[],availableTags:u=[],onCreateTag:d,attachments:g=[],onUploadAttachments:h,onDeleteAttachment:C}){let T=[...ki,...i.filter(O=>!ki.some(le=>le.id===O.id))],c=Ye[m]||Ye.dark,[b,y]=react.useState(false),[l,x]=react.useState(false),[v,S]=react.useState(false),[k,w]=react.useState(false),[R,M]=react.useState({top:0,left:0}),[D,I]=react.useState(null),[B,K]=react.useState(new Date),[te,ie]=react.useState({top:0,left:0}),[de,be]=react.useState(false),[$,J]=react.useState([]),U=react.useRef(null),G=react.useRef(null),A=react.useRef(null),Q=react.useRef(null),X=react.useRef(null),[H,Ce]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],tags:[]}),[Me,Oe]=react.useState({});react.useEffect(()=>{a?(Ce({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[],tags:a.tags||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&be(true)):(Ce({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[],pendingFiles:[],tags:[]}),be(false),J([]));},[a,e]),react.useEffect(()=>{let O=le=>{U.current&&!U.current.contains(le.target)&&y(false),G.current&&!G.current.contains(le.target)&&x(false),A.current&&!A.current.contains(le.target)&&S(false),Q.current&&!Q.current.contains(le.target)&&w(false);};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);let ve=()=>{let O={};return H.name.trim()||(O.name="El nombre es requerido"),H.startDate&&H.endDate&&H.startDate>H.endDate&&(O.endDate="La fecha de fin debe ser posterior a la de inicio"),Oe(O),Object.keys(O).length===0},Ke=async O=>{if(O.preventDefault(),!!ve())try{let le=p==="create"&&$.length>0?{...H,pendingFiles:$}:H;await s(le),J([]),t();}catch(le){console.error("Error submitting task:",le);}},We=(O,le)=>{Ce(xe=>{let Pe={...xe,[O]:le};if(O==="status"){let ze=le;ze==="todo"?Pe.progress=0:ze==="in-progress"?(xe.progress===0||xe.progress===100)&&(Pe.progress=50):ze==="completed"||ze==="closed"?Pe.progress=100:(ze==="in-review"||ze==="review")&&(Pe.progress=75);}if(O==="progress"){let ze=typeof le=="number"?le:parseInt(le,10);ze===100&&xe.status!=="completed"?Pe.status="completed":ze>0&&ze<100&&xe.status==="todo"?Pe.status="in-progress":ze===0&&xe.status!=="todo"&&(Pe.status="todo");}return Pe}),Me[O]&&Oe(xe=>{let Pe={...xe};return delete Pe[O],Pe});},et=T.find(O=>O.id===H.status)??ki[0],vt=wi.find(O=>O.id===H.priority)??wi[1],Mt=sr.find(O=>O.value===H.color)??sr[0],mt={backgroundColor:c.bgSecondary,border:`1px solid ${c.borderLight}`,color:c.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","data-theme":m,style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:O=>O.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${c.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:et.color||c.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:c.textSecondary},children:p==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:c.textTertiary},onMouseEnter:O=>{O.currentTarget.style.backgroundColor=c.hoverBg,O.currentTarget.style.color=c.textPrimary;},onMouseLeave:O=>{O.currentTarget.style.backgroundColor="transparent",O.currentTarget.style.color=c.textTertiary;},disabled:n,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:Ke,className:"max-h-[calc(100vh-200px)] overflow-y-auto",children:[jsxRuntime.jsxs("div",{className:"p-5 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{type:"text",value:H.name,onChange:O=>We("name",O.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:c.textPrimary},placeholder:"Nombre de la tarea",disabled:n,autoFocus:true}),Me.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"}),Me.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:H.description||"",onChange:O=>We("description",O.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:c.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:n})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${c.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:U,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&y(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...mt,borderColor:et.color,backgroundColor:`${et.color}15`},disabled:n,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:et.color}}),jsxRuntime.jsx("span",{style:{color:et.color},children:et.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:et.color}})]}),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},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},children:T.map(O=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:le=>le.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{We("status",O.id),y(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:O.color}}),O.title,H.status===O.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},O.id))})})]}),jsxRuntime.jsxs("div",{ref:G,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&x(!l),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:mt,disabled:n,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:vt.color}}),jsxRuntime.jsx("span",{children:vt.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:l&&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:c.bgPrimary,border:`1px solid ${c.border}`},children:wi.map(O=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:c.textPrimary},onMouseEnter:le=>le.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{We("priority",O.id),x(false);},children:[jsxRuntime.jsx("span",{children:O.icon}),O.label,H.priority===O.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:c.accent}})]},O.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:A,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!n&&S(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:mt,disabled:n,children:[H.assignees&&H.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:H.assignees.slice(0,3).map((O,le)=>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:O.color||c.accent,borderColor:c.bgSecondary},children:O.initials},le))}),H.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:c.textTertiary},children:["+",H.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:c.textTertiary}}),jsxRuntime.jsx("span",{style:{color:c.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:c.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-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},children:o.map(O=>{let le=H.assignees?.some(xe=>xe.name===O.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:c.textPrimary},onMouseEnter:xe=>xe.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:xe=>xe.currentTarget.style.backgroundColor="transparent",onClick:()=>{let xe=le?(H.assignees||[]).filter(Pe=>Pe.name!==O.name):[...H.assignees||[],{name:O.name,avatar:O.avatar,initials:O.name.split(" ").map(Pe=>Pe[0]).join("").toUpperCase().slice(0,2),color:c.accent}];We("assignees",xe);},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:c.accent},children:O.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1 text-left",children:O.name}),jsxRuntime.jsx("div",{className:"w-4 flex-shrink-0 flex justify-end",children:le&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:c.accent}})})]},O.id)})})})]}),jsxRuntime.jsxs("div",{ref:Q,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{if(!n)if(k)w(false);else {if(Q.current){let O=Q.current.getBoundingClientRect(),le=window.innerHeight,xe=120,ze=le-O.bottom<xe?O.top-xe-8:O.bottom+8;M({top:ze,left:O.left});}w(true);}},className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:mt,disabled:n,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:H.color}}),jsxRuntime.jsx("span",{children:Mt.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:c.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:k&&jsxRuntime.jsxs(lt,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>w(false)}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"rounded-lg",style:{position:"fixed",top:`${R.top}px`,left:`${R.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},onClick:O=>O.stopPropagation(),children:jsxRuntime.jsx("div",{style:{padding:"6px 8px"},children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 28px)",gap:"2px"},children:sr.slice(0,18).map(O=>{let le=H.color===O.value;return jsxRuntime.jsx("button",{type:"button",onClick:xe=>{xe.preventDefault(),xe.stopPropagation(),We("color",O.value),w(false);},style:{width:"28px",height:"28px",borderRadius:"6px",backgroundColor:"transparent",cursor:"pointer",border:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0},title:O.name,children:jsxRuntime.jsx("span",{style:{width:"16px",height:"16px",borderRadius:"50%",backgroundColor:O.value,outline:le?`2px solid ${O.value}`:"none",outlineOffset:"2px",pointerEvents:"none",display:"block"}})},O.value)})})})})]})})]}),u.length>0||d?jsxRuntime.jsx(nr,{selectedTags:H.tags||[],availableTags:u,onChange:O=>We("tags",O),onCreateTag:d,theme:c,disabled:n}):null]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxRuntime.jsxs("div",{ref:X,className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!H.isMilestone)if(D==="start")I(null);else {if(X.current){let O=X.current.getBoundingClientRect(),le=window.innerHeight,xe=320,ze=le-O.bottom<xe?O.top-xe-8:O.bottom+8;ie({top:ze,left:O.left});}I("start"),K(H.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...mt,opacity:H.isMilestone?.5:1,cursor:H.isMilestone?"not-allowed":"pointer"},disabled:n||H.isMilestone,children:H.startDate?H.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:c.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{if(!n&&!H.isMilestone)if(D==="end")I(null);else {if(X.current){let O=X.current.getBoundingClientRect(),le=window.innerHeight,xe=320,ze=le-O.bottom<xe?O.top-xe-8:O.bottom+8;ie({top:ze,left:O.left});}I("end"),K(H.endDate||H.startDate||new Date);}},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...mt,opacity:H.isMilestone?.5:1,cursor:H.isMilestone?"not-allowed":"pointer"},disabled:n||H.isMilestone,children:H.endDate?H.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:D&&jsxRuntime.jsxs(lt,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0",style:{zIndex:99998},onClick:()=>I(null)}),jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"rounded-xl shadow-2xl overflow-hidden flex",style:{position:"fixed",top:`${te.top}px`,left:`${te.left}px`,zIndex:99999,backgroundColor:c.bgPrimary,border:`1px solid ${c.border}`},onClick:O=>O.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${c.border}`},children:[(()=>{let O=new Date,le=new Date(O);le.setDate(O.getDate()+1);let xe=new Date(O);xe.setDate(O.getDate()+7);let Pe=new Date(O);return Pe.setDate(O.getDate()+14),[{label:"Hoy",date:O},{label:"Ma\xF1ana",date:le},{label:"Pr\xF3xima semana",date:xe},{label:"2 semanas",date:Pe}].map((at,Et)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:c.textPrimary},onMouseEnter:Fe=>Fe.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:Fe=>Fe.currentTarget.style.backgroundColor="transparent",onClick:()=>{D==="start"?(We("startDate",at.date),(!H.endDate||at.date>H.endDate)&&We("endDate",at.date),I("end")):(We("endDate",at.date),(!H.startDate||at.date<H.startDate)&&We("startDate",at.date),I(null));},children:at.label},Et))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${c.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:O=>O.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",onClick:()=>{We("startDate",void 0),We("endDate",void 0),I(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:()=>K(new Date(B.getFullYear(),B.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:c.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:c.textPrimary},children:B.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>K(new Date(B.getFullYear(),B.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:c.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((O,le)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:c.textTertiary},children:O},le))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let O=B.getFullYear(),le=B.getMonth(),xe=new Date(O,le,1).getDay(),Pe=new Date(O,le+1,0).getDate(),ze=new Date,at=[];for(let Fe=xe-1;Fe>=0;Fe--)at.push({day:new Date(O,le,-Fe).getDate(),date:new Date(O,le-1,new Date(O,le,-Fe).getDate()),isCurrentMonth:false});for(let Fe=1;Fe<=Pe;Fe++)at.push({day:Fe,date:new Date(O,le,Fe),isCurrentMonth:true});let Et=42-at.length;for(let Fe=1;Fe<=Et;Fe++)at.push({day:Fe,date:new Date(O,le+1,Fe),isCurrentMonth:false});return at.map((Fe,Xt)=>{let Ot=Fe.date.toDateString()===ze.toDateString(),Nt=H.startDate?.toDateString()===Fe.date.toDateString(),ct=H.endDate?.toDateString()===Fe.date.toDateString(),Jt=H.startDate&&H.endDate&&Fe.date>=H.startDate&&Fe.date<=H.endDate;return jsxRuntime.jsx("button",{type:"button",className:"w-7 h-7 rounded-full flex items-center justify-center text-xs transition-colors",style:{color:Fe.isCurrentMonth?Nt||ct?"#FFF":c.textPrimary:c.textTertiary,backgroundColor:Nt?"#3B82F6":ct?"#7C3AED":Jt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Ot&&!Nt&&!ct?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{D==="start"?(We("startDate",Fe.date),H.endDate&&Fe.date>H.endDate&&We("endDate",Fe.date),I("end")):(We("endDate",Fe.date),H.startDate&&Fe.date<H.startDate&&We("startDate",Fe.date),I(null));},children:Fe.day},Xt)})})()})]})]})]})})]}),Me.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:Me.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:c.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:H.progress,onChange:O=>We("progress",parseInt(O.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:c.bgSecondary,accentColor:H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"},disabled:n}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"}20`,color:H.progress<30?"#EF4444":H.progress<70?"#F59E0B":"#10B981"},children:[H.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>be(!de),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:c.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${de?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:de&&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:[(h||g.length>0||p==="create")&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:c.textTertiary},children:jsxRuntime.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),jsxRuntime.jsxs("span",{className:"text-xs",style:{color:c.textTertiary},children:["Adjuntos ",p==="create"?$.length>0&&`(${$.length})`:g.length>0&&`(${g.length})`]})]}),p==="create"?jsxRuntime.jsx(dr,{cardId:"pending",attachments:$.map((O,le)=>({id:`pending-${le}`,cardId:"pending",name:O.name,size:O.size,type:O.type,url:URL.createObjectURL(O),uploadedAt:new Date().toISOString(),uploadedBy:"current-user"})),onUpload:O=>J(le=>[...le,...O]),onDelete:O=>{let le=parseInt(O.replace("pending-",""),10);J(xe=>xe.filter((Pe,ze)=>ze!==le));},maxSizeMB:10,maxFiles:20}):jsxRuntime.jsx(dr,{cardId:a?.id||"new",attachments:g,onUpload:h&&a?.id?O=>h(a.id,O):void 0,onDelete:C,maxSizeMB:10,maxFiles:20}),p==="create"&&$.length>0&&jsxRuntime.jsxs("p",{className:"text-xs mt-1",style:{color:c.textTertiary},children:[$.length," archivo(s) se subir\xE1n al crear la tarea"]})]}),jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:H.isMilestone,onChange:O=>We("isMilestone",O.target.checked),className:"w-4 h-4 rounded",style:{accentColor:c.accent},disabled:n}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:c.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:c.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:c.bgSecondary},children:r.filter(O=>O.id!==a?.id).map(O=>{let le=H.dependencies?.includes(O.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let xe=le?(H.dependencies||[]).filter(Pe=>Pe!==O.id):[...H.dependencies||[],O.id];We("dependencies",xe);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:le?`${c.accent}30`:c.bgPrimary,color:le?c.accent:c.textSecondary,border:`1px solid ${le?c.accent:c.borderLight}`},disabled:n,children:O.name},O.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${c.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:c.textSecondary},onMouseEnter:O=>O.currentTarget.style.backgroundColor=c.hoverBg,onMouseLeave:O=>O.currentTarget.style.backgroundColor="transparent",disabled:n,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:n,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:c.accent,color:"#FFF"},onMouseEnter:O=>!n&&(O.currentTarget.style.opacity="0.9"),onMouseLeave:O=>!n&&(O.currentTarget.style.opacity="1"),children:n?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:p==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var Dc=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
345
345