@libxai/board 0.17.328 → 0.17.329

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