@libxai/board 0.17.120 → 0.17.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
</Calendars>
|
|
274
274
|
<Tasks>${m}
|
|
275
275
|
</Tasks>
|
|
276
|
-
</Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),l.download=a,l.click(),URL.revokeObjectURL(l.href);},calculateCriticalPath:e=>{let t=ae.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let p=n.startDate&&n.endDate?ae.calculateDuration(n.startDate,n.endDate):0,l=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;l=Math.max(l,f);}}let i=l+p;r.set(n.id,{es:l,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),d=new Map,c=n=>{if(d.has(n.id))return;let p=n.startDate&&n.endDate?ae.calculateDuration(n.startDate,n.endDate):0,l=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(l.length>0)for(let v of l){c(v);let f=d.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-p;d.set(n.id,{ls:u,lf:i});};a.forEach(c);let m=[];for(let n of a){let p=r.get(n.id),l=d.get(n.id);if(p&&l){let i=l.ls-p.es;Math.abs(i)<.01&&m.push(n.id);}}return m},calculateSlack:(e,t)=>{let a=ae.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(ae.calculateCriticalPath(e).includes(t))return 0;let o=ae.getDependentTasks(e,t);if(o.length===0){let c=ae.getLatestEndDate(e);if(!c)return null;let m=ae.calculateDuration(a.endDate,c);return Math.max(0,m)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,m)=>c-m)[0];if(!s)return null;let d=ae.calculateDuration(a.endDate,new Date(s));return Math.max(0,d)},isOnCriticalPath:(e,t)=>ae.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=ae.findTaskById(e,t);if(!r||!r.endDate)return e;let o=ae.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let d of o){if(!d.startDate||!d.endDate)continue;let c=ae.calculateDuration(d.startDate,d.endDate),m;a!==void 0?(m=new Date(d.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let n=ae.calculateEndDate(m,c),p=l=>l.map(i=>i.id===d.id?{...i,startDate:m,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=ae.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,c)=>{if(a===0)return [];let m=[],n=o.getTime(),p=1e3*60*60*24,l=ae.findTaskById(e,t);if(!l||!l.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let y=ae.getDependentTasks(e,u);for(let x of y){if(!x.startDate||!x.endDate)continue;let b=r.findIndex(U=>U.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/p,A=(g-n)/p*s,w=A+v*s,L=Math.max(D*s,s),T=c+b*d+12;m.push({taskId:x.id,taskName:x.name,originalX:A,previewX:w,width:L,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),m},splitTask:(e,t,a,r=3)=>{let o=ae.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let d=new Date(a);d.setDate(d.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:c}],n=p=>p.map(l=>l.id===o.id?{...l,endDate:c,segments:m}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function Oo({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:c,onTaskClick:m,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=react.useState([]),[x,b]=react.useState(null),[g,C]=react.useState(null),D=react.useCallback(S=>{b(S);},[]),h=react.useCallback(S=>{C(S);},[]),A=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),w=r==="day"?60:r==="week"?20:8,L=A*w*d,T=S=>{let F=new Date(Date.UTC(S.getFullYear(),S.getMonth(),S.getDate())),M=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-M);let V=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-V.getTime())/864e5+1)/7)},U=S=>{let F=S.getDay();return F===0||F===6},H=react.useCallback(S=>{let F=Math.round(S/(w*d)),M=new Date(o);return M.setDate(M.getDate()+F),M},[o,w,d]),$=react.useCallback((S,F)=>{if(F.startDate&&F.endDate)return;let M=S.currentTarget.ownerSVGElement;if(!M)return;let V=M.createSVGPoint();V.x=S.clientX,V.y=S.clientY;let P=V.matrixTransform(M.getScreenCTM()?.inverse()),W=H(P.x),le=new Date(W);le.setDate(le.getDate()+1),l?.(F,W,le);},[H,l]),E=react.useMemo(()=>{let S=P=>P.map(W=>{if(W.subtasks&&W.subtasks.length>0){let le=S(W.subtasks),te=le.filter(Se=>Se.startDate&&Se.endDate);if(te.length>0){let Se=te.map(tt=>tt.startDate.getTime()),ne=te.map(tt=>tt.endDate.getTime()),Ve=new Date(Math.min(...Se)),be=new Date(Math.max(...ne));return {...W,subtasks:le,startDate:Ve,endDate:be}}return {...W,subtasks:le}}return W}),F=(P,W=[])=>{for(let le of P)W.push(le),le.subtasks&&le.subtasks.length>0&&(le.isExpanded===void 0||le.isExpanded)&&F(le.subtasks,W);return W},M=S(e);return F(M)},[e]),J=react.useCallback(S=>{if(!S.startDate||!S.endDate)return {x:0,width:0};let F=S.startDate.getTime(),M=S.endDate.getTime(),V=o.getTime(),P=(F-V)/(1e3*60*60*24),W=(M-F)/(1e3*60*60*24),le=P*w*d,te=Math.max(w*d,40),Se=Math.max(W*w*d,te);return {x:le,width:Se}},[o,w,d]),ge=react.useMemo(()=>E.filter(S=>S.startDate&&S.endDate).map(S=>{let{x:F,width:M}=J(S),P=E.findIndex(W=>W.id===S.id)*a+12;return {id:S.id,x:F,y:P,width:M,height:32}}),[E,J]),ke=react.useCallback((S,F,M)=>{if(!M||F===0){y([]);return}let V=ae.calculateCascadePreview(e,S,F,E,o,w*d,a,48);y(V);},[e,E,o,w,d,a,48]),Le=react.useMemo(()=>{let S=[],F=new Date(o);for(;F<=s;){let P=(F.getTime()-o.getTime())/864e5*w*d;if(r==="day")S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:P}),F.setDate(F.getDate()+1);else if(r==="week"){let W=T(F);S.push({date:new Date(F),label:`Week ${W}`,x:P}),F.setDate(F.getDate()+7);}else S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:P}),F.setMonth(F.getMonth()+1);}return S},[o,s,r,w,d]),Ee=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*w*d,[o,w,d]),de=Math.max(E.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(L,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(L,1e3),height:48,fill:t.bgGrid}),Le.map((S,F)=>jsxRuntime.jsxs("g",{children:[F>0&&jsxRuntime.jsx("line",{x1:S.x,y1:0,x2:S.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:S.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:S.label})]},`header-${F}`)),Ee>=0&&Ee<=L&&jsxRuntime.jsx("circle",{cx:Ee,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(L,1e3),height:de,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(L,1e3),height:de,fill:t.bgPrimary}),Le.map((S,F)=>{let M=Le[F+1]?.x||L,V=U(S.date);return jsxRuntime.jsxs("g",{children:[V&&jsxRuntime.jsx("rect",{x:S.x,y:0,width:M-S.x,height:E.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsxRuntime.jsx("line",{x1:S.x,y1:0,x2:S.x,y2:E.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),Ee>=0&&Ee<=L&&jsxRuntime.jsx("line",{x1:Ee,y1:0,x2:Ee,y2:E.length*a,stroke:t.today,strokeWidth:2,opacity:1}),E.map((S,F)=>{let M=S.startDate&&S.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:L,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${S.id}`),!M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:L,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:V=>$(V,S),onMouseEnter:V=>{V.currentTarget.setAttribute("fill",t.accentLight),V.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:V=>{V.currentTarget.setAttribute("fill","transparent"),V.currentTarget.setAttribute("opacity","1");}},`clickable-${S.id}`),jsxRuntime.jsx("text",{x:Ee>0?Ee:100,y:F*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-${S.id}`)]})]},`row-group-${S.id}`)}),E.map((S,F)=>!S.dependencies||S.dependencies.length===0||!S.startDate||!S.endDate?null:S.dependencies.map(M=>{let V=E.find(te=>te.id===M);if(!V||!V.startDate||!V.endDate)return null;let P=E.findIndex(te=>te.id===M),W=J(V),le=J(S);return jsxRuntime.jsx(Lo,{x1:W.x+W.width,y1:P*a+a/2,x2:le.x,y2:F*a+a/2,theme:t,onDelete:()=>u?.(S.id,M),onHoverChange:h},`dep-${M}-${S.id}`)})),E.map((S,F)=>{if(!S.startDate||!S.endDate)return null;let{x:M,width:V}=J(S),P=F*a+12,W=S.subtasks&&S.subtasks.length>0&&!S.isMilestone;return S.isMilestone?jsxRuntime.jsx(Bo,{task:S,x:M+V/2,y:P+16,theme:t,onClick:m},S.id):W?jsxRuntime.jsxs("g",{onClick:()=>m?.(S),onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),p?.(S,le);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:M,y:P,width:V,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:M,y1:P,x2:M+V,y2:P,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:M,y1:P,x2:M,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:M+V,y1:P,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:M,y1:P+32,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),V>60&&jsxRuntime.jsx("text",{x:M+12,y:P+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:S.name})]},S.id):jsxRuntime.jsx(Mo,{task:S,x:M,y:P,width:V,theme:t,dayWidth:w*d,startDate:o,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:ge,onDragMove:ke,onHoverChange:D},S.id)}),f.map(S=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:S.previewX,y:S.y-48,width:S.width,height:32,rx:8,fill:S.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(S.daysDelta)>0&&jsxRuntime.jsx("text",{x:S.previewX+S.width/2,y:S.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:S.daysDelta>0?`+${S.daysDelta}d`:`${S.daysDelta}d`})]},`cascade-preview-${S.taskId}`)),g&&(()=>{let{x1:S,y1:F,x2:M,y2:V,onDelete:P}=g,W=M-S,le=V-F,te=S+W/2,Se=(F+V)/2,ne=`M ${S} ${F} C ${te} ${F}, ${te} ${V}, ${M} ${V}`,Ve=6,be=Math.atan2(le,W),tt=M-Ve*Math.cos(be-Math.PI/6),Tt=V-Ve*Math.sin(be-Math.PI/6),Dt=M-Ve*Math.cos(be+Math.PI/6),yt=V-Ve*Math.sin(be+Math.PI/6),Nt=t.dependency;return jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("path",{d:ne,fill:"none",stroke:Nt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsxRuntime.jsx("path",{d:`M ${M} ${V} L ${tt} ${Tt} M ${M} ${V} L ${Dt} ${yt}`,fill:"none",stroke:Nt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsxRuntime.jsx("circle",{cx:M,cy:V,r:5,fill:Nt}),jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:Mt=>{Mt.stopPropagation(),P();},style:{cursor:"pointer",pointerEvents:"auto"},children:[jsxRuntime.jsx("circle",{cx:te,cy:Se,r:10,fill:t.bgSecondary,stroke:t.error||"#ef4444",strokeWidth:2}),jsxRuntime.jsx("line",{x1:te-4,y1:Se-4,x2:te+4,y2:Se+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:te+4,y1:Se-4,x2:te-4,y2:Se+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})})(),x&&jsxRuntime.jsx(Kl,{tooltipData:x,theme:t})]})]})}var $o=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var bs=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],hs=[{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 zo({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:d=false,mode:c=a?"edit":"create",theme:m="dark",customStatuses:n=[]}){let p=[...bs,...n.filter(P=>!bs.some(W=>W.id===P.id))],l=Oe[m]||Oe.dark,[i,u]=react.useState(false),[v,f]=react.useState(false),[y,x]=react.useState(false),[b,g]=react.useState(false),[C,D]=react.useState(null),[h,A]=react.useState(new Date),[w,L]=react.useState(false),T=react.useRef(null),U=react.useRef(null),H=react.useRef(null),$=react.useRef(null),[E,J]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[ge,ke]=react.useState({});react.useEffect(()=>{a?(J({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&L(true)):(J({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),L(false));},[a,e]),react.useEffect(()=>{let P=W=>{T.current&&!T.current.contains(W.target)&&u(false),U.current&&!U.current.contains(W.target)&&f(false),H.current&&!H.current.contains(W.target)&&x(false),$.current&&!$.current.contains(W.target)&&g(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let Le=()=>{let P={};return E.name.trim()||(P.name="El nombre es requerido"),E.startDate&&E.endDate&&E.startDate>E.endDate&&(P.endDate="La fecha de fin debe ser posterior a la de inicio"),ke(P),Object.keys(P).length===0},Ee=async P=>{if(P.preventDefault(),!!Le())try{await s(E),t();}catch(W){console.error("Error submitting task:",W);}},de=(P,W)=>{J(le=>{let te={...le,[P]:W};if(P==="status"){let Se=W;Se==="todo"?te.progress=0:Se==="in-progress"?(le.progress===0||le.progress===100)&&(te.progress=50):Se==="completed"||Se==="closed"?te.progress=100:(Se==="in-review"||Se==="review")&&(te.progress=75);}if(P==="progress"){let Se=typeof W=="number"?W:parseInt(W,10);Se===100&&le.status!=="completed"?te.status="completed":Se>0&&Se<100&&le.status==="todo"?te.status="in-progress":Se===0&&le.status!=="todo"&&(te.status="todo");}return te}),ge[P]&&ke(le=>{let te={...le};return delete te[P],te});},S=p.find(P=>P.id===E.status)??bs[0],F=hs.find(P=>P.id===E.priority)??hs[1],M=$o.find(P=>P.value===E.color)??$o[0],V={backgroundColor:l.bgSecondary,border:`1px solid ${l.borderLight}`,color:l.textPrimary};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${l.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:S.color||l.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:l.textTertiary},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=l.hoverBg,P.currentTarget.style.color=l.textPrimary;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:Ee,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:E.name,onChange:P=>de("name",P.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:l.textPrimary},placeholder:"Nombre de la tarea",disabled:d,autoFocus:true}),ge.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"}),ge.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:E.description||"",onChange:P=>de("description",P.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:l.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:d})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:T,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&u(!i),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...V,borderColor:S.color,backgroundColor:`${S.color}15`},disabled:d,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:S.color}}),jsxRuntime.jsx("span",{style:{color:S.color},children:S.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:S.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:p.map(P=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("status",P.id),u(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:P.color}}),P.title,E.status===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),jsxRuntime.jsxs("div",{ref:U,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&f(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:F.color}}),jsxRuntime.jsx("span",{children:F.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:v&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:hs.map(P=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("priority",P.id),f(false);},children:[jsxRuntime.jsx("span",{children:P.icon}),P.label,E.priority===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:H,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&x(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[E.assignees&&E.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:E.assignees.slice(0,3).map((P,W)=>jsxRuntime.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:P.color||l.accent,borderColor:l.bgSecondary},children:P.initials},W))}),E.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:l.textTertiary},children:["+",E.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:l.textTertiary}}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:y&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:o.map(P=>{let W=E.assignees?.some(le=>le.name===P.name);return jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:le=>le.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{let le=W?(E.assignees||[]).filter(te=>te.name!==P.name):[...E.assignees||[],{name:P.name,avatar:P.avatar,initials:P.name.split(" ").map(te=>te[0]).join("").toUpperCase().slice(0,2),color:l.accent}];de("assignees",le);},children:[jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium",style:{backgroundColor:l.accent},children:P.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1",children:P.name}),W&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})]},P.id)})})})]}),jsxRuntime.jsxs("div",{ref:$,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&g(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:E.color}}),jsxRuntime.jsx("span",{children:M.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"absolute left-0 top-full mt-1.5 z-50 rounded-lg",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:jsxRuntime.jsx("div",{className:"p-4",children:jsxRuntime.jsx("div",{className:"grid grid-cols-8 gap-4",children:$o.slice(0,16).map(P=>{let W=E.color===P.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>{de("color",P.value),g(false);},className:"w-7 h-7 rounded-full",style:{backgroundColor:P.value,boxShadow:W?`0 0 0 2px ${l.bgPrimary}, 0 0 0 4px ${P.value}`:"none"},whileHover:{scale:1.15},whileTap:{scale:.9},title:P.name},P.value)})})})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(C==="start"?null:"start"),A(E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.startDate?E.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(C==="end"?null:"end"),A(E.endDate||E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.endDate?E.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:C&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>D(null)}),jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let P=new Date,W=new Date(P);W.setDate(P.getDate()+1);let le=new Date(P);le.setDate(P.getDate()+7);let te=new Date(P);return te.setDate(P.getDate()+14),[{label:"Hoy",date:P},{label:"Ma\xF1ana",date:W},{label:"Pr\xF3xima semana",date:le},{label:"2 semanas",date:te}].map((ne,Ve)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:be=>be.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:be=>be.currentTarget.style.backgroundColor="transparent",onClick:()=>{C==="start"?(de("startDate",ne.date),(!E.endDate||ne.date>E.endDate)&&de("endDate",ne.date),D("end")):(de("endDate",ne.date),(!E.startDate||ne.date<E.startDate)&&de("startDate",ne.date),D(null));},children:ne.label},Ve))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.border}`,margin:"0.5rem 0"}}),jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("startDate",void 0),de("endDate",void 0),D(null);},children:"Borrar fechas"})]}),jsxRuntime.jsxs("div",{className:"p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:l.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textPrimary},children:h.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:l.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((P,W)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:P},W))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=h.getFullYear(),W=h.getMonth(),le=new Date(P,W,1).getDay(),te=new Date(P,W+1,0).getDate(),Se=new Date,ne=[];for(let be=le-1;be>=0;be--)ne.push({day:new Date(P,W,-be).getDate(),date:new Date(P,W-1,new Date(P,W,-be).getDate()),isCurrentMonth:false});for(let be=1;be<=te;be++)ne.push({day:be,date:new Date(P,W,be),isCurrentMonth:true});let Ve=42-ne.length;for(let be=1;be<=Ve;be++)ne.push({day:be,date:new Date(P,W+1,be),isCurrentMonth:false});return ne.map((be,tt)=>{let Tt=be.date.toDateString()===Se.toDateString(),Dt=E.startDate?.toDateString()===be.date.toDateString(),yt=E.endDate?.toDateString()===be.date.toDateString(),Nt=E.startDate&&E.endDate&&be.date>=E.startDate&&be.date<=E.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:be.isCurrentMonth?Dt||yt?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:Dt?"#3B82F6":yt?"#7C3AED":Nt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Tt&&!Dt&&!yt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{C==="start"?(de("startDate",be.date),E.endDate&&be.date>E.endDate&&de("endDate",be.date),D("end")):(de("endDate",be.date),E.startDate&&be.date<E.startDate&&de("startDate",be.date),D(null));},children:be.day},tt)})})()})]})]})]})})]}),ge.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:ge.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:E.progress,onChange:P=>de("progress",parseInt(P.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},disabled:d}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"}20`,color:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},children:[E.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>L(!w),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${w?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:w&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxRuntime.jsxs("div",{className:"pt-3 space-y-3",children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:E.isMilestone,onChange:P=>de("isMilestone",P.target.checked),className:"w-4 h-4 rounded",style:{accentColor:l.accent},disabled:d}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:l.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:l.bgSecondary},children:r.filter(P=>P.id!==a?.id).map(P=>{let W=E.dependencies?.includes(P.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let le=W?(E.dependencies||[]).filter(te=>te!==P.id):[...E.dependencies||[],P.id];de("dependencies",le);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:W?`${l.accent}30`:l.bgPrimary,color:W?l.accent:l.textSecondary,border:`1px solid ${W?l.accent:l.borderLight}`},disabled:d,children:P.name},P.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${l.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:l.textSecondary},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",disabled:d,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:l.accent,color:"#FFF"},onMouseEnter:P=>!d&&(P.currentTarget.style.opacity="0.9"),onMouseLeave:P=>!d&&(P.currentTarget.style.opacity="1"),children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var Lg=['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"'],Zl=()=>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"})]}),Fg=()=>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"})}),Bg=()=>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"})}),Rg=()=>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"})}),Og=()=>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 Wo({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:d,onDependencyCreate:c,onDependencyDelete:m}){let[n,p]=react.useState(false),[l,i]=react.useState(false),[u,v]=react.useState([]),[f,y]=react.useState(""),[x,b]=react.useState(false),[g,C]=react.useState(true),D=react.useRef(null),h=react.useRef(null),A=react.useRef(null),{enabled:w=true,placeholder:L='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:U,suggestions:H=Lg,maxHistory:$=50,persistHistory:E}=a,J=E?.storageKey||"gantt-ai-history",ge=E?.maxMessages??5;react.useEffect(()=>{if(E?.enabled)try{let F=localStorage.getItem(J);if(F){let V=JSON.parse(F).map(P=>({...P,timestamp:new Date(P.timestamp)}));v(V.slice(-ge));}}catch(F){console.warn("[GanttAIAssistant] Failed to load persisted history:",F);}},[E?.enabled,J,ge]),react.useEffect(()=>{if(E?.enabled&&u.length>0)try{let F=u.filter(M=>!M.isLoading).slice(-ge);localStorage.setItem(J,JSON.stringify(F));}catch(F){console.warn("[GanttAIAssistant] Failed to persist history:",F);}},[u,E?.enabled,J,ge]),react.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let ke=react.useCallback(F=>{if(F.success)switch(F.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":F.taskId&&F.updates&&o?.(F.taskId,F.updates);break;case "create_task":F.newTask&&s?.(F.newTask);break;case "delete_task":F.taskId&&d?.(F.taskId);break;case "link_tasks":F.dependencyFrom&&F.dependencyTo&&c?.(F.dependencyFrom,F.dependencyTo);break;case "unlink_tasks":F.taskId&&F.dependencyFrom&&m?.(F.taskId,F.dependencyFrom);break}},[o,s,d,c,m]),Le=react.useCallback(async F=>{if(!F.trim()||x)return;let M={id:`user-${Date.now()}`,role:"user",content:F,timestamp:new Date};v(P=>[...P.slice(-($-1)),M]),y(""),C(false),b(true);let V={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(P=>[...P,V]);try{if(U){let P=await U(F,e);v(W=>{let le=W.filter(Se=>!Se.isLoading),te={id:`assistant-${Date.now()}`,role:"assistant",content:P.message,timestamp:new Date,command:P};return [...le,te]}),ke(P);}else v(P=>[...P.filter(le=>!le.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(P){v(W=>[...W.filter(te=>!te.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${P instanceof Error?P.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,$,U,e,ke]),Ee=F=>{F.preventDefault(),Le(f);},de=F=>{y(F),D.current?.focus();};if(react.useEffect(()=>{let F=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),p(V=>!V),n||i(false)),M.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n]),react.useEffect(()=>{if(!n)return;let F=V=>{let P=V.target;A.current&&!A.current.contains(P)&&p(false);},M=setTimeout(()=>{document.addEventListener("mousedown",F);},100);return ()=>{clearTimeout(M),document.removeEventListener("mousedown",F);}},[n]),!w)return null;let S={"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(Ke,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${S[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>p(true),children:[jsxRuntime.jsx(Zl,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${S[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(Zl,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(F=>!F),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Rg,{})}),jsxRuntime.jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Bg,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!l&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&g&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:H.slice(0,4).map((F,M)=>jsxRuntime.jsx("button",{onClick:()=>de(F),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:F.length>30?F.slice(0,30)+"...":F},M))})]}),u.map(F=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${F.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${F.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:F.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:F.role==="user"?"white":t.textPrimary},children:[F.isLoading?jsxRuntime.jsx(Og,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:F.content}),F.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:F.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:F.command.success?"#10B981":"#EF4444"},children:[F.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:F.command.type.replace(/_/g," ")})]})]})},F.id)),jsxRuntime.jsx("div",{ref:h})]}),jsxRuntime.jsxs("form",{onSubmit:Ee,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:D,type:"text",value:f,onChange:F=>y(F.target.value),placeholder:L,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!f.trim()||x,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(Fg,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Ql(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,p=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!p)return {...l,present:i};let u=[...l.past,l.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),d=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let p=n.past[n.past.length-1],l=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:p,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:l}});},[]),m=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:d,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function ed({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=d=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,m=c?d.metaKey:d.ctrlKey;if(m&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!c&&m&&d.key==="y"){d.preventDefault(),t();return}if(c&&m&&d.shiftKey&&d.key==="z"){d.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var Wg={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${ae.formatDate(e.startDate)} - ${ae.formatDate(e.endDate)}`);let a=ae.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=>ae.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function td(e){return {...Wg,...e}}var Yg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},od=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:c="comfortable",showThemeSelector:m=true,showExportButton:n=true,availableUsers:p=[],templates:l,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:f,showCreateTaskButton:y=false,createTaskLabel:x,onCreateTask:b,onThemeChange:g,onTaskClick:C,onTaskDblClick:D,onTaskContextMenu:h,onTaskUpdate:A,onProgressChange:w,onTaskEdit:L,onTaskAddSubtask:T,onTaskMarkIncomplete:U,onTaskSetInProgress:H,onDependencyCreate:$,onDependencyDelete:E,onBeforeTaskAdd:J,onAfterTaskAdd:ge,onBeforeTaskUpdate:ke,onAfterTaskUpdate:Le,onBeforeTaskDelete:Ee,onAfterTaskDelete:de}=a,F=react.useContext(Co)?.theme,[M,V]=react.useState(F||s||"dark"),[P,W]=react.useState(d),[le,te]=react.useState(c),[Se,ne]=react.useState(1),[Ve,be]=react.useState(0),[tt,Tt]=react.useState(false),[Dt,yt]=react.useState(null),[Nt,Mt]=react.useState({isOpen:false,x:0,y:0,task:null}),[ra,mt]=react.useState(null),[rt,Lt]=react.useState(null);react.useEffect(()=>{F&&F!==M&&V(F);},[F]),react.useEffect(()=>{s&&s!==M&&V(s);},[s]);let Ht=react.useCallback(N=>{V(N),g?.(N);},[g]),{state:we,setState:O,undo:Te,redo:Ue,canUndo:$e,canRedo:pt,clearHistory:X}=Ql(t,50);react.useEffect(()=>{O(t);},[t,O]);let Q=react.useRef(t),ve=react.useRef(true);react.useEffect(()=>{if(ve.current){ve.current=false,Q.current=we;return}if(!r)return;let N=JSON.stringify(Q.current),z=JSON.stringify(we);N!==z&&(Q.current=we,r(we));},[we,r]);let fe=react.useMemo(()=>es(v,f),[v,f]),ee=react.useCallback(N=>[{id:"name",label:N.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:N.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:N.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:N.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:N.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:N.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:N.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:N.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ce,B]=react.useState(()=>ee(fe));react.useEffect(()=>{B(N=>N.map(z=>({...z,label:fe.columns[z.id==="name"?"taskName":z.id]||z.label})));},[fe]);let G=react.useMemo(()=>Ce.filter(N=>N.visible).reduce((N,z)=>N+z.width,0)+60,[Ce]),K=react.useMemo(()=>Dt!==null?Math.max(280,Dt,G):Math.max(280,G),[Dt,G]),oe=react.useRef(null),q=react.useRef(null),xe=react.useRef(null),se=react.useMemo(()=>Cl(M),[M]),R=react.useMemo(()=>({theme:se,themeName:M}),[se,M]),ie=react.useMemo(()=>td(l),[l]),Ae=react.useMemo(()=>{if(!i)return we;let N=ae.calculateCriticalPath(we),z=Y=>Y.map(ce=>({...ce,isCriticalPath:N.includes(ce.id),subtasks:ce.subtasks?z(ce.subtasks):void 0}));return z(we)},[we,i]),at=Yg(le);ed({undo:Te,redo:Ue,canUndo:$e,canRedo:pt,enabled:true}),react.useImperativeHandle(o,()=>({getTask:N=>ae.findTaskById(we,N),addTask:(N,z)=>{O(Y=>{if(!z)return [...Y,{...N,level:0}];let ce=he=>he.map(Ne=>Ne.id===z?{...Ne,subtasks:[...Ne.subtasks||[],{...N,parentId:z,level:(Ne.level||0)+1}],isExpanded:true}:Ne.subtasks?{...Ne,subtasks:ce(Ne.subtasks)}:Ne);return ce(Y)});},updateTask:(N,z)=>{O(Y=>{let ce=he=>he.map(Ne=>Ne.id===N?{...Ne,...z}:Ne.subtasks?{...Ne,subtasks:ce(Ne.subtasks)}:Ne);return ce(Y)});},deleteTask:N=>{O(z=>{let Y=ce=>ce.filter(he=>he.id===N?false:(he.subtasks&&(he.subtasks=Y(he.subtasks)),true));return Y(z)});},deleteTasks:N=>{O(z=>is(z,N));},duplicateTask:N=>{O(z=>ls(z,[N]));},splitTask:(N,z,Y=3)=>{O(ce=>ae.splitTask(ce,N,z,Y));},calculateEndDate:ae.calculateEndDate,calculateDuration:ae.calculateDuration,validateDependency:(N,z)=>!ae.validateDependencies(we,N,z),getAllTasks:()=>ae.flattenTasks(we),getTasksByStatus:N=>ae.flattenTasks(we).filter(z=>z.status===N),getTasksByParent:N=>N?ae.findTaskById(we,N)?.subtasks||[]:we.filter(Y=>!Y.parentId),getCriticalPath:()=>ae.flattenTasks(we).filter(N=>N.isCriticalPath),indentTask:N=>{O(z=>os(z,[N]));},outdentTask:N=>{O(z=>ns(z,[N]));},moveTask:(N,z)=>{O(Y=>ss(Y,[N],z));},createSubtask:async N=>{let{tasks:z,newTask:Y}=ms(we,N);if(J){let ce=J({...Y,parentId:N});if((ce instanceof Promise?await ce:ce)===false)return}O(z),ge&&ge({...Y,parentId:N});},scrollToTask:N=>{let Y=ae.flattenTasks(we).findIndex(ce=>ce.id===N);if(Y!==-1&&oe.current){let ce=Y*at;oe.current.scrollTo({top:ce,behavior:"smooth"}),q.current&&q.current.scrollTo({top:ce,behavior:"smooth"});}},highlightTask:(N,z=2e3)=>{},expandTask:N=>{O(z=>{let Y=ce=>ce.map(he=>he.id===N?{...he,isExpanded:true}:he.subtasks?{...he,subtasks:Y(he.subtasks)}:he);return Y(z)});},collapseTask:N=>{O(z=>{let Y=ce=>ce.map(he=>he.id===N?{...he,isExpanded:false}:he.subtasks?{...he,subtasks:Y(he.subtasks)}:he);return Y(z)});},expandAll:()=>{O(N=>{let z=Y=>Y.map(ce=>({...ce,isExpanded:true,subtasks:ce.subtasks?z(ce.subtasks):void 0}));return z(N)});},collapseAll:()=>{O(N=>{let z=Y=>Y.map(ce=>({...ce,isExpanded:false,subtasks:ce.subtasks?z(ce.subtasks):void 0}));return z(N)});},undo:Te,redo:Ue,canUndo:()=>$e,canRedo:()=>pt,clearHistory:X,exportToPNG:async()=>{if(!xe.current)throw new Error("Gantt container not found");let N=await rd__default.default(xe.current,{backgroundColor:se.bgPrimary,scale:2});return new Promise((z,Y)=>{N.toBlob(ce=>{ce?z(ce):Y(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await ae.exportToPDF(we,N);},exportToExcel:async N=>{await ae.exportToExcel(we,N);},exportToJSON:()=>ae.exportToJSON(we),exportToCSV:()=>ae.exportToCSV(we),importFromJSON:N=>{let z=ae.importFromJSON(N);O(z);},getTasks:()=>we,refresh:()=>{O(N=>[...N]);},clearAll:()=>{O([]);}}),[we,Te,Ue,$e,pt,X,se,at]);let De=react.useCallback(N=>{B(z=>z.map(Y=>Y.id===N?{...Y,visible:!Y.visible}:Y));},[]),ja=react.useCallback((N,z)=>{B(Y=>Y.map(ce=>{if(ce.id!==N)return ce;let he=ce.minWidth??100,Ne=ce.maxWidth??800,kt=Math.max(he,Math.min(Ne,z));return {...ce,width:kt}}));},[]),cr=react.useCallback(N=>{O(z=>cs(z,N)),a.onTaskToggleExpand?.(N);},[a]),mr=react.useCallback((N,z)=>{if(ke&&ke(N,z)===false)return;let ce=ae.findTaskById(we,N)?.progress,he=kt=>kt.map(Ut=>Ut.id===N?{...Ut,...z}:Ut.subtasks?{...Ut,subtasks:he(Ut.subtasks)}:Ut);O(he(we));let Ne=ae.findTaskById(he(we),N);Ne&&(A?.(Ne),Le?.(Ne),z.progress!==void 0&&ce!==void 0&&z.progress!==ce&&w?.(N,ce,z.progress));},[we,A,ke,Le,w]),yc=react.useCallback(N=>{N.length!==0&&(O(z=>os(z,N)),a.onTaskIndent?.(N[0]));},[a]),vc=react.useCallback(N=>{N.length!==0&&(O(z=>ns(z,N)),a.onTaskOutdent?.(N[0]));},[a]),xc=react.useCallback((N,z,Y)=>{O(ce=>Hl(ce,N,z,Y)),a.onTaskReparent?.(N,z,Y);},[a]),kc=react.useCallback((N,z)=>{N.length!==0&&(O(Y=>ss(Y,N,z)),a.onTaskMove?.(N[0],z));},[a]),ln=react.useCallback(async N=>{let z=[];for(let Y of N)Ee&&await Promise.resolve(Ee(Y))===false||z.push(Y);z.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(z):(O(Y=>is(Y,z)),z.forEach(Y=>a.onTaskDelete?.(Y))),de&&z.forEach(Y=>de(Y)));},[a,Ee,de]),wc=react.useCallback(N=>{O(z=>ls(z,N)),N.forEach(z=>a.onTaskDuplicate?.(z));},[a]),Cc=react.useCallback((N,z)=>{O(Y=>{let{tasks:ce,newTask:he}=Gl(Y,N,z);return J&&J(he)===false?Y:(a.onTaskCreate?.(he.parentId,he.position||0),ge?.(he),ce)});},[a,J,ge]),Tc=react.useCallback((N,z)=>{O(Y=>ds(Y,N,z)),a.onTaskRename?.(N,z);},[a]),dn=react.useCallback(N=>{O(z=>{let{tasks:Y}=ms(z,N);return a.onTaskCreate?.(N,0),Y});},[a]),Dc=react.useCallback((N,z,Y)=>{let ce=N.startDate?Math.round((z.getTime()-N.startDate.getTime())/864e5):0,he=Ut=>Ut.map(da=>da.id===N.id?{...da,startDate:z,endDate:Y,...N.segments&&{segments:N.segments}}:da.subtasks?{...da,subtasks:he(da.subtasks)}:da),Ne=he(we);Ne=ae.autoScheduleDependents(Ne,N.id,ce),O(Ne);let kt={...N,startDate:z,endDate:Y};A?.(kt);},[we,A]),Nc=react.useCallback((N,z)=>{h?.(N,z),Mt({isOpen:true,x:z.clientX,y:z.clientY,task:N});},[h]),Sc=react.useCallback((N,z)=>{let Y=ae.splitTask(we,N.id,z);O(Y),Mt({isOpen:false,x:0,y:0,task:null});},[we]),pi=react.useCallback(N=>{D?.(N),L||mt(N);},[D,L]),ui=react.useCallback((N,z,Y)=>{let ce=new Map,he=ca=>{ca.forEach(Na=>{Na.dependencies&&ce.set(Na.id,Na.dependencies),Na.subtasks&&he(Na.subtasks);});};he(Y);let Ne=ce.get(z)||[];ce.set(z,[...Ne,N]);let kt=new Set,Ut=new Set,da=ca=>{if(!kt.has(ca)){kt.add(ca),Ut.add(ca);let Na=ce.get(ca)||[];for(let Lr of Na){if(!kt.has(Lr)&&da(Lr))return true;if(Ut.has(Lr))return true}}return Ut.delete(ca),false};return da(z)},[]),gi=react.useCallback((N,z)=>{if(ui(N.id,z,we)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
276
|
+
</Project>`,p=new Blob([n],{type:"application/xml;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(p),l.download=a,l.click(),URL.revokeObjectURL(l.href);},calculateCriticalPath:e=>{let t=ae.flattenTasks(e),a=t.filter(n=>n.startDate&&n.endDate);if(a.length===0)return [];let r=new Map,o=n=>{if(r.has(n.id))return;let p=n.startDate&&n.endDate?ae.calculateDuration(n.startDate,n.endDate):0,l=0;if(n.dependencies&&n.dependencies.length>0)for(let u of n.dependencies){let v=t.find(f=>f.id===u);if(v){o(v);let f=r.get(u)?.ef||0;l=Math.max(l,f);}}let i=l+p;r.set(n.id,{es:l,ef:i});};a.forEach(o);let s=Math.max(...Array.from(r.values()).map(n=>n.ef)),d=new Map,c=n=>{if(d.has(n.id))return;let p=n.startDate&&n.endDate?ae.calculateDuration(n.startDate,n.endDate):0,l=t.filter(v=>v.dependencies&&v.dependencies.includes(n.id)),i=s;if(l.length>0)for(let v of l){c(v);let f=d.get(v.id)?.ls||0;i=Math.min(i,f);}let u=i-p;d.set(n.id,{ls:u,lf:i});};a.forEach(c);let m=[];for(let n of a){let p=r.get(n.id),l=d.get(n.id);if(p&&l){let i=l.ls-p.es;Math.abs(i)<.01&&m.push(n.id);}}return m},calculateSlack:(e,t)=>{let a=ae.findTaskById(e,t);if(!a||!a.startDate||!a.endDate)return null;if(ae.calculateCriticalPath(e).includes(t))return 0;let o=ae.getDependentTasks(e,t);if(o.length===0){let c=ae.getLatestEndDate(e);if(!c)return null;let m=ae.calculateDuration(a.endDate,c);return Math.max(0,m)}let s=o.filter(c=>c.startDate).map(c=>c.startDate.getTime()).sort((c,m)=>c-m)[0];if(!s)return null;let d=ae.calculateDuration(a.endDate,new Date(s));return Math.max(0,d)},isOnCriticalPath:(e,t)=>ae.calculateCriticalPath(e).includes(t),autoScheduleDependents:(e,t,a)=>{let r=ae.findTaskById(e,t);if(!r||!r.endDate)return e;let o=ae.getDependentTasks(e,t);if(o.length===0)return e;let s=[...e];for(let d of o){if(!d.startDate||!d.endDate)continue;let c=ae.calculateDuration(d.startDate,d.endDate),m;a!==void 0?(m=new Date(d.startDate),m.setDate(m.getDate()+a)):(m=new Date(r.endDate),m.setDate(m.getDate()+1));let n=ae.calculateEndDate(m,c),p=l=>l.map(i=>i.id===d.id?{...i,startDate:m,endDate:n}:i.subtasks?{...i,subtasks:p(i.subtasks)}:i);s=p(s),s=ae.autoScheduleDependents(s,d.id,a);}return s},calculateCascadePreview:(e,t,a,r,o,s,d,c)=>{if(a===0)return [];let m=[],n=o.getTime(),p=1e3*60*60*24,l=ae.findTaskById(e,t);if(!l||!l.endDate)return [];let i=(u,v,f=new Set)=>{if(f.has(u))return;f.add(u);let y=ae.getDependentTasks(e,u);for(let x of y){if(!x.startDate||!x.endDate)continue;let b=r.findIndex(U=>U.id===x.id);if(b===-1)continue;let g=x.startDate.getTime(),D=(x.endDate.getTime()-g)/p,A=(g-n)/p*s,w=A+v*s,L=Math.max(D*s,s),T=c+b*d+12;m.push({taskId:x.id,taskName:x.name,originalX:A,previewX:w,width:L,y:T,rowIndex:b,daysDelta:v,color:x.color}),i(x.id,v,f);}};return i(t,a),m},splitTask:(e,t,a,r=3)=>{let o=ae.findTaskById(e,t);if(!o||!o.startDate||!o.endDate)return e;if(a<=o.startDate||a>=o.endDate)return console.warn("Split date must be between task start and end dates"),e;let s=new Date(a);s.setDate(s.getDate()-1);let d=new Date(a);d.setDate(d.getDate()+r);let c=new Date(o.endDate);c.setDate(c.getDate()+r);let m=[{startDate:new Date(o.startDate),endDate:s},{startDate:d,endDate:c}],n=p=>p.map(l=>l.id===o.id?{...l,endDate:c,segments:m}:l.subtasks?{...l,subtasks:n(l.subtasks)}:l);return n(e)}};function Oo({tasks:e,theme:t,rowHeight:a,timeScale:r,startDate:o,endDate:s,zoom:d,templates:c,onTaskClick:m,onTaskDblClick:n,onTaskContextMenu:p,onTaskDateChange:l,onDependencyCreate:i,onDependencyDelete:u}){let[f,y]=react.useState([]),[x,b]=react.useState(null),[g,C]=react.useState(null),D=react.useCallback(S=>{b(S);},[]),h=react.useCallback(S=>{C(S);},[]),A=Math.ceil((s.getTime()-o.getTime())/(1e3*60*60*24)),w=r==="day"?60:r==="week"?20:8,L=A*w*d,T=S=>{let F=new Date(Date.UTC(S.getFullYear(),S.getMonth(),S.getDate())),M=F.getUTCDay()||7;F.setUTCDate(F.getUTCDate()+4-M);let V=new Date(Date.UTC(F.getUTCFullYear(),0,1));return Math.ceil(((F.getTime()-V.getTime())/864e5+1)/7)},U=S=>{let F=S.getDay();return F===0||F===6},H=react.useCallback(S=>{let F=Math.round(S/(w*d)),M=new Date(o);return M.setDate(M.getDate()+F),M},[o,w,d]),$=react.useCallback((S,F)=>{if(F.startDate&&F.endDate)return;let M=S.currentTarget.ownerSVGElement;if(!M)return;let V=M.createSVGPoint();V.x=S.clientX,V.y=S.clientY;let P=V.matrixTransform(M.getScreenCTM()?.inverse()),W=H(P.x),le=new Date(W);le.setDate(le.getDate()+1),l?.(F,W,le);},[H,l]),E=react.useMemo(()=>{let S=P=>P.map(W=>{if(W.subtasks&&W.subtasks.length>0){let le=S(W.subtasks),te=le.filter(Se=>Se.startDate&&Se.endDate);if(te.length>0){let Se=te.map(tt=>tt.startDate.getTime()),ne=te.map(tt=>tt.endDate.getTime()),Ve=new Date(Math.min(...Se)),be=new Date(Math.max(...ne));return {...W,subtasks:le,startDate:Ve,endDate:be}}return {...W,subtasks:le}}return W}),F=(P,W=[])=>{for(let le of P)W.push(le),le.subtasks&&le.subtasks.length>0&&(le.isExpanded===void 0||le.isExpanded)&&F(le.subtasks,W);return W},M=S(e);return F(M)},[e]),J=react.useCallback(S=>{if(!S.startDate||!S.endDate)return {x:0,width:0};let F=S.startDate.getTime(),M=S.endDate.getTime(),V=o.getTime(),P=(F-V)/(1e3*60*60*24),W=(M-F)/(1e3*60*60*24),le=P*w*d,te=Math.max(w*d,40),Se=Math.max(W*w*d,te);return {x:le,width:Se}},[o,w,d]),ge=react.useMemo(()=>E.filter(S=>S.startDate&&S.endDate).map(S=>{let{x:F,width:M}=J(S),P=E.findIndex(W=>W.id===S.id)*a+12;return {id:S.id,x:F,y:P,width:M,height:32}}),[E,J]),ke=react.useCallback((S,F,M)=>{if(!M||F===0){y([]);return}let V=ae.calculateCascadePreview(e,S,F,E,o,w*d,a,48);y(V);},[e,E,o,w,d,a,48]),Le=react.useMemo(()=>{let S=[],F=new Date(o);for(;F<=s;){let P=(F.getTime()-o.getTime())/864e5*w*d;if(r==="day")S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{day:"numeric",month:"short"}),x:P}),F.setDate(F.getDate()+1);else if(r==="week"){let W=T(F);S.push({date:new Date(F),label:`Week ${W}`,x:P}),F.setDate(F.getDate()+7);}else S.push({date:new Date(F),label:F.toLocaleDateString("en-US",{month:"short",year:"numeric"}),x:P}),F.setMonth(F.getMonth()+1);}return S},[o,s,r,w,d]),Ee=react.useMemo(()=>(new Date().getTime()-o.getTime())/(1e3*60*60*24)*w*d,[o,w,d]),de=Math.max(E.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(L,1e3),height:47,style:{display:"block"},children:[jsxRuntime.jsx("rect",{x:0,y:0,width:Math.max(L,1e3),height:48,fill:t.bgGrid}),Le.map((S,F)=>jsxRuntime.jsxs("g",{children:[F>0&&jsxRuntime.jsx("line",{x1:S.x,y1:0,x2:S.x,y2:48,stroke:t.border,strokeWidth:1,opacity:.1}),jsxRuntime.jsx("text",{x:S.x+8,y:48/2,fill:t.textTertiary,fontSize:"11",fontFamily:"'JetBrains Mono', ui-monospace, monospace",fontWeight:"500",dominantBaseline:"middle",children:S.label})]},`header-${F}`)),Ee>=0&&Ee<=L&&jsxRuntime.jsx("circle",{cx:Ee,cy:38,r:6,fill:t.today,opacity:1})]})}),jsxRuntime.jsxs("svg",{width:Math.max(L,1e3),height:de,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(L,1e3),height:de,fill:t.bgPrimary}),Le.map((S,F)=>{let M=Le[F+1]?.x||L,V=U(S.date);return jsxRuntime.jsxs("g",{children:[V&&jsxRuntime.jsx("rect",{x:S.x,y:0,width:M-S.x,height:E.length*a,fill:t.bgWeekend,opacity:1}),F>0&&jsxRuntime.jsx("line",{x1:S.x,y1:0,x2:S.x,y2:E.length*a,stroke:t.border,strokeWidth:1,opacity:.1})]},F)}),Ee>=0&&Ee<=L&&jsxRuntime.jsx("line",{x1:Ee,y1:0,x2:Ee,y2:E.length*a,stroke:t.today,strokeWidth:2,opacity:1}),E.map((S,F)=>{let M=S.startDate&&S.endDate;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:L,height:a,fill:F%2===0?"transparent":t.bgSecondary,opacity:1,style:{pointerEvents:"none"}},`row-${S.id}`),!M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:0,y:F*a,width:L,height:a,fill:"transparent",style:{cursor:"pointer",pointerEvents:"all"},onClick:V=>$(V,S),onMouseEnter:V=>{V.currentTarget.setAttribute("fill",t.accentLight),V.currentTarget.setAttribute("opacity","0.5");},onMouseLeave:V=>{V.currentTarget.setAttribute("fill","transparent"),V.currentTarget.setAttribute("opacity","1");}},`clickable-${S.id}`),jsxRuntime.jsx("text",{x:Ee>0?Ee:100,y:F*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-${S.id}`)]})]},`row-group-${S.id}`)}),E.map((S,F)=>!S.dependencies||S.dependencies.length===0||!S.startDate||!S.endDate?null:S.dependencies.map(M=>{let V=E.find(te=>te.id===M);if(!V||!V.startDate||!V.endDate)return null;let P=E.findIndex(te=>te.id===M),W=J(V),le=J(S);return jsxRuntime.jsx(Lo,{x1:W.x+W.width,y1:P*a+a/2,x2:le.x,y2:F*a+a/2,theme:t,onDelete:()=>u?.(S.id,M),onHoverChange:h},`dep-${M}-${S.id}`)})),E.map((S,F)=>{if(!S.startDate||!S.endDate)return null;let{x:M,width:V}=J(S),P=F*a+12,W=S.subtasks&&S.subtasks.length>0&&!S.isMilestone;return S.isMilestone?jsxRuntime.jsx(Bo,{task:S,x:M+V/2,y:P+16,theme:t,onClick:m},S.id):W?jsxRuntime.jsxs("g",{onClick:()=>m?.(S),onContextMenu:le=>{le.preventDefault(),le.stopPropagation(),p?.(S,le);},style:{cursor:"default"},children:[jsxRuntime.jsx("rect",{x:M,y:P,width:V,height:32,fill:t.primary,opacity:.25,rx:6}),jsxRuntime.jsx("line",{x1:M,y1:P,x2:M+V,y2:P,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:M,y1:P,x2:M,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:M+V,y1:P,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:M,y1:P+32,x2:M+V,y2:P+32,stroke:t.primary,strokeWidth:3,opacity:.9,strokeLinecap:"round"}),V>60&&jsxRuntime.jsx("text",{x:M+12,y:P+16,dominantBaseline:"middle",fill:"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:S.name})]},S.id):jsxRuntime.jsx(Mo,{task:S,x:M,y:P,width:V,theme:t,dayWidth:w*d,startDate:o,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:ge,onDragMove:ke,onHoverChange:D},S.id)}),f.map(S=>jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("rect",{x:S.previewX,y:S.y-48,width:S.width,height:32,rx:8,fill:S.color||t.accent,opacity:.3,stroke:t.accent,strokeWidth:2,strokeDasharray:"4 2"}),Math.abs(S.daysDelta)>0&&jsxRuntime.jsx("text",{x:S.previewX+S.width/2,y:S.y-48+16,textAnchor:"middle",dominantBaseline:"middle",fill:t.accent,fontSize:"10",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{userSelect:"none"},children:S.daysDelta>0?`+${S.daysDelta}d`:`${S.daysDelta}d`})]},`cascade-preview-${S.taskId}`)),g&&(()=>{let{x1:S,y1:F,x2:M,y2:V,onDelete:P}=g,W=M-S,le=V-F,te=S+W/2,Se=(F+V)/2,ne=`M ${S} ${F} C ${te} ${F}, ${te} ${V}, ${M} ${V}`,Ve=6,be=Math.atan2(le,W),tt=M-Ve*Math.cos(be-Math.PI/6),Tt=V-Ve*Math.sin(be-Math.PI/6),Dt=M-Ve*Math.cos(be+Math.PI/6),yt=V-Ve*Math.sin(be+Math.PI/6),Nt=t.dependency;return jsxRuntime.jsxs("g",{style:{pointerEvents:"none"},children:[jsxRuntime.jsx("path",{d:ne,fill:"none",stroke:Nt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsxRuntime.jsx("path",{d:`M ${M} ${V} L ${tt} ${Tt} M ${M} ${V} L ${Dt} ${yt}`,fill:"none",stroke:Nt,strokeWidth:3,strokeLinecap:"round",opacity:1}),jsxRuntime.jsx("circle",{cx:M,cy:V,r:5,fill:Nt}),jsxRuntime.jsxs(framerMotion.motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:Mt=>{Mt.stopPropagation(),P();},style:{cursor:"pointer",pointerEvents:"auto"},children:[jsxRuntime.jsx("circle",{cx:te,cy:Se,r:10,fill:t.bgSecondary,stroke:t.error||"#ef4444",strokeWidth:2}),jsxRuntime.jsx("line",{x1:te-4,y1:Se-4,x2:te+4,y2:Se+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsxRuntime.jsx("line",{x1:te+4,y1:Se-4,x2:te-4,y2:Se+4,stroke:t.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})})(),x&&jsxRuntime.jsx(Kl,{tooltipData:x,theme:t})]})]})}var $o=[{name:"Azul",value:"#6366F1",light:"#818CF8"},{name:"P\xFArpura",value:"#A855F7",light:"#C084FC"},{name:"Rosa",value:"#EC4899",light:"#F472B6"},{name:"Rojo",value:"#EF4444",light:"#F87171"},{name:"Naranja",value:"#F59E0B",light:"#FBBF24"},{name:"Amarillo",value:"#EAB308",light:"#FACC15"},{name:"Lima",value:"#84CC16",light:"#A3E635"},{name:"Verde",value:"#10B981",light:"#34D399"},{name:"Esmeralda",value:"#059669",light:"#10B981"},{name:"Cyan",value:"#06B6D4",light:"#22D3EE"},{name:"Azul Cielo",value:"#0EA5E9",light:"#38BDF8"},{name:"\xCDndigo",value:"#4F46E5",light:"#6366F1"},{name:"Violeta",value:"#8B5CF6",light:"#A78BFA"},{name:"Fucsia",value:"#D946EF",light:"#E879F9"},{name:"Coral",value:"#F97316",light:"#FB923C"},{name:"Magenta",value:"#E11D48",light:"#FB7185"}];var bs=[{id:"todo",title:"Por Hacer",color:"#6B7280"},{id:"in-progress",title:"En Progreso",color:"#F59E0B"},{id:"completed",title:"Completada",color:"#10B981"}],hs=[{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 zo({isOpen:e,onClose:t,task:a,availableTasks:r=[],availableUsers:o=[],onSubmit:s,isLoading:d=false,mode:c=a?"edit":"create",theme:m="dark",customStatuses:n=[]}){let p=[...bs,...n.filter(P=>!bs.some(W=>W.id===P.id))],l=Oe[m]||Oe.dark,[i,u]=react.useState(false),[v,f]=react.useState(false),[y,x]=react.useState(false),[b,g]=react.useState(false),[C,D]=react.useState(null),[h,A]=react.useState(new Date),[w,L]=react.useState(false),T=react.useRef(null),U=react.useRef(null),H=react.useRef(null),$=react.useRef(null),[E,J]=react.useState({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),[ge,ke]=react.useState({});react.useEffect(()=>{a?(J({name:a.name,description:a.description||"",startDate:a.startDate,endDate:a.endDate,progress:a.progress,status:a.status||"todo",priority:a.priority||"medium",isMilestone:a.isMilestone||false,color:a.color||"#6366F1",assignees:a.assignees||[],dependencies:a.dependencies||[]}),(a.dependencies&&a.dependencies.length>0||a.isMilestone)&&L(true)):(J({name:"",description:"",progress:0,status:"todo",priority:"medium",isMilestone:false,color:"#6366F1",assignees:[],dependencies:[]}),L(false));},[a,e]),react.useEffect(()=>{let P=W=>{T.current&&!T.current.contains(W.target)&&u(false),U.current&&!U.current.contains(W.target)&&f(false),H.current&&!H.current.contains(W.target)&&x(false),$.current&&!$.current.contains(W.target)&&g(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let Le=()=>{let P={};return E.name.trim()||(P.name="El nombre es requerido"),E.startDate&&E.endDate&&E.startDate>E.endDate&&(P.endDate="La fecha de fin debe ser posterior a la de inicio"),ke(P),Object.keys(P).length===0},Ee=async P=>{if(P.preventDefault(),!!Le())try{await s(E),t();}catch(W){console.error("Error submitting task:",W);}},de=(P,W)=>{J(le=>{let te={...le,[P]:W};if(P==="status"){let Se=W;Se==="todo"?te.progress=0:Se==="in-progress"?(le.progress===0||le.progress===100)&&(te.progress=50):Se==="completed"||Se==="closed"?te.progress=100:(Se==="in-review"||Se==="review")&&(te.progress=75);}if(P==="progress"){let Se=typeof W=="number"?W:parseInt(W,10);Se===100&&le.status!=="completed"?te.status="completed":Se>0&&Se<100&&le.status==="todo"?te.status="in-progress":Se===0&&le.status!=="todo"&&(te.status="todo");}return te}),ge[P]&&ke(le=>{let te={...le};return delete te[P],te});},S=p.find(P=>P.id===E.status)??bs[0],F=hs.find(P=>P.id===E.priority)??hs[1],M=$o.find(P=>P.value===E.color)??$o[0],V={backgroundColor:l.bgSecondary,border:`1px solid ${l.borderLight}`,color:l.textPrimary};return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-50",onClick:t}),jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:jsxRuntime.jsxs("div",{className:"w-full max-w-xl rounded-xl shadow-2xl pointer-events-auto overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${l.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:S.color||l.accent}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textSecondary},children:c==="create"?"Nueva tarea":"Editar tarea"})]}),jsxRuntime.jsx("button",{onClick:t,className:"p-1.5 rounded-lg transition-colors",style:{color:l.textTertiary},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=l.hoverBg,P.currentTarget.style.color=l.textPrimary;},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=l.textTertiary;},disabled:d,children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:Ee,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:E.name,onChange:P=>de("name",P.target.value),className:"w-full text-lg font-medium bg-transparent border-none focus:outline-none focus:ring-0 placeholder:opacity-50",style:{color:l.textPrimary},placeholder:"Nombre de la tarea",disabled:d,autoFocus:true}),ge.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"}),ge.name]})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("textarea",{value:E.description||"",onChange:P=>de("description",P.target.value),className:"w-full text-sm bg-transparent border-none focus:outline-none focus:ring-0 resize-none placeholder:opacity-40",style:{color:l.textSecondary},placeholder:"Agregar descripci\xF3n...",rows:2,disabled:d})}),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.borderLight}`}}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsxs("div",{ref:T,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&u(!i),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:{...V,borderColor:S.color,backgroundColor:`${S.color}15`},disabled:d,children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:S.color}}),jsxRuntime.jsx("span",{style:{color:S.color},children:S.title}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:S.color}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:i&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[140px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:p.map(P=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("status",P.id),u(false);},children:[jsxRuntime.jsx(lucideReact.CircleDot,{className:"w-3.5 h-3.5",style:{color:P.color}}),P.title,E.status===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),jsxRuntime.jsxs("div",{ref:U,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&f(!v),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsxRuntime.jsx(lucideReact.Flag,{className:"w-3.5 h-3.5",style:{color:F.color}}),jsxRuntime.jsx("span",{children:F.label}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:v&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[130px] rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:hs.map(P=>jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:W=>W.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:W=>W.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("priority",P.id),f(false);},children:[jsxRuntime.jsx("span",{children:P.icon}),P.label,E.priority===P.id&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 ml-auto",style:{color:l.accent}})]},P.id))})})]}),o.length>0&&jsxRuntime.jsxs("div",{ref:H,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&x(!y),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[E.assignees&&E.assignees.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex -space-x-1",children:E.assignees.slice(0,3).map((P,W)=>jsxRuntime.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] text-white font-medium border-2",style:{backgroundColor:P.color||l.accent,borderColor:l.bgSecondary},children:P.initials},W))}),E.assignees.length>3&&jsxRuntime.jsxs("span",{style:{color:l.textTertiary},children:["+",E.assignees.length-3]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(lucideReact.Users,{className:"w-3.5 h-3.5",style:{color:l.textTertiary}}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"Asignar"})]}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:y&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"absolute left-0 top-full mt-1 z-50 min-w-[180px] max-h-[200px] overflow-y-auto rounded-lg shadow-xl",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},children:o.map(P=>{let W=E.assignees?.some(le=>le.name===P.name);return jsxRuntime.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",style:{color:l.textPrimary},onMouseEnter:le=>le.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:le=>le.currentTarget.style.backgroundColor="transparent",onClick:()=>{let le=W?(E.assignees||[]).filter(te=>te.name!==P.name):[...E.assignees||[],{name:P.name,avatar:P.avatar,initials:P.name.split(" ").map(te=>te[0]).join("").toUpperCase().slice(0,2),color:l.accent}];de("assignees",le);},children:[jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs text-white font-medium",style:{backgroundColor:l.accent},children:P.name.charAt(0).toUpperCase()}),jsxRuntime.jsx("span",{className:"truncate flex-1",children:P.name}),W&&jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5",style:{color:l.accent}})]},P.id)})})})]}),jsxRuntime.jsxs("div",{ref:$,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>!d&&g(!b),className:"flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-all hover:opacity-80",style:V,disabled:d,children:[jsxRuntime.jsx("div",{className:"w-3.5 h-3.5 rounded-full",style:{backgroundColor:E.color}}),jsxRuntime.jsx("span",{children:M.name}),jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3",style:{color:l.textTertiary}})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:b&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},transition:{duration:.12},className:"absolute left-0 top-full mt-1.5 z-50 rounded-lg",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.25)"},children:jsxRuntime.jsx("div",{className:"p-3",children:jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:$o.slice(0,16).map(P=>{let W=E.color===P.value;return jsxRuntime.jsx(framerMotion.motion.button,{type:"button",onClick:()=>{de("color",P.value),g(false);},className:"w-6 h-6 rounded-full",style:{backgroundColor:P.value,boxShadow:W?`0 0 0 2px ${l.bgPrimary}, 0 0 0 3px ${P.value}`:"none"},whileHover:{scale:1.1},whileTap:{scale:.95},title:P.name},P.value)})})})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Calendar,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 relative",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(C==="start"?null:"start"),A(E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.startDate?E.startDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Inicio"}),jsxRuntime.jsx("span",{style:{color:l.textTertiary},children:"\u2192"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{!d&&!E.isMilestone&&(D(C==="end"?null:"end"),A(E.endDate||E.startDate||new Date));},className:"px-3 py-1.5 rounded-lg text-sm transition-colors",style:{...V,opacity:E.isMilestone?.5:1,cursor:E.isMilestone?"not-allowed":"pointer"},disabled:d||E.isMilestone,children:E.endDate?E.endDate.toLocaleDateString("es-ES",{day:"numeric",month:"short"}):"Fin"}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:C&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>D(null)}),jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute left-0 top-full mt-2 z-50 rounded-xl shadow-2xl overflow-hidden flex",style:{backgroundColor:l.bgPrimary,border:`1px solid ${l.border}`},onClick:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:"w-40 py-2",style:{borderRight:`1px solid ${l.border}`},children:[(()=>{let P=new Date,W=new Date(P);W.setDate(P.getDate()+1);let le=new Date(P);le.setDate(P.getDate()+7);let te=new Date(P);return te.setDate(P.getDate()+14),[{label:"Hoy",date:P},{label:"Ma\xF1ana",date:W},{label:"Pr\xF3xima semana",date:le},{label:"2 semanas",date:te}].map((ne,Ve)=>jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:l.textPrimary},onMouseEnter:be=>be.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:be=>be.currentTarget.style.backgroundColor="transparent",onClick:()=>{C==="start"?(de("startDate",ne.date),(!E.endDate||ne.date>E.endDate)&&de("endDate",ne.date),D("end")):(de("endDate",ne.date),(!E.startDate||ne.date<E.startDate)&&de("startDate",ne.date),D(null));},children:ne.label},Ve))})(),jsxRuntime.jsx("div",{style:{borderTop:`1px solid ${l.border}`,margin:"0.5rem 0"}}),jsxRuntime.jsx("button",{type:"button",className:"w-full px-3 py-2 text-sm text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",onClick:()=>{de("startDate",void 0),de("endDate",void 0),D(null);},children:"Borrar fechas"})]}),jsxRuntime.jsxs("div",{className:"p-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()-1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronLeft,{className:"w-4 h-4",style:{color:l.textSecondary}})}),jsxRuntime.jsx("span",{className:"text-sm font-medium",style:{color:l.textPrimary},children:h.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>A(new Date(h.getFullYear(),h.getMonth()+1)),className:"p-1 rounded hover:bg-white/10",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4",style:{color:l.textSecondary}})})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:["D","L","M","M","J","V","S"].map((P,W)=>jsxRuntime.jsx("div",{className:"w-7 h-7 flex items-center justify-center text-xs",style:{color:l.textTertiary},children:P},W))}),jsxRuntime.jsx("div",{className:"grid grid-cols-7 gap-1",children:(()=>{let P=h.getFullYear(),W=h.getMonth(),le=new Date(P,W,1).getDay(),te=new Date(P,W+1,0).getDate(),Se=new Date,ne=[];for(let be=le-1;be>=0;be--)ne.push({day:new Date(P,W,-be).getDate(),date:new Date(P,W-1,new Date(P,W,-be).getDate()),isCurrentMonth:false});for(let be=1;be<=te;be++)ne.push({day:be,date:new Date(P,W,be),isCurrentMonth:true});let Ve=42-ne.length;for(let be=1;be<=Ve;be++)ne.push({day:be,date:new Date(P,W+1,be),isCurrentMonth:false});return ne.map((be,tt)=>{let Tt=be.date.toDateString()===Se.toDateString(),Dt=E.startDate?.toDateString()===be.date.toDateString(),yt=E.endDate?.toDateString()===be.date.toDateString(),Nt=E.startDate&&E.endDate&&be.date>=E.startDate&&be.date<=E.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:be.isCurrentMonth?Dt||yt?"#FFF":l.textPrimary:l.textTertiary,backgroundColor:Dt?"#3B82F6":yt?"#7C3AED":Nt?"rgba(124, 58, 237, 0.2)":"transparent",boxShadow:Tt&&!Dt&&!yt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{C==="start"?(de("startDate",be.date),E.endDate&&be.date>E.endDate&&de("endDate",be.date),D("end")):(de("endDate",be.date),E.startDate&&be.date<E.startDate&&de("startDate",be.date),D(null));},children:be.day},tt)})})()})]})]})]})})]}),ge.endDate&&jsxRuntime.jsx("span",{className:"text-xs text-red-400",children:ge.endDate})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4",style:{color:l.textTertiary}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[jsxRuntime.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:E.progress,onChange:P=>de("progress",parseInt(P.target.value)),className:"flex-1 h-1.5 rounded-full appearance-none cursor-pointer",style:{backgroundColor:l.bgSecondary,accentColor:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},disabled:d}),jsxRuntime.jsxs("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full min-w-[45px] text-center",style:{backgroundColor:`${E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"}20`,color:E.progress<30?"#EF4444":E.progress<70?"#F59E0B":"#10B981"},children:[E.progress,"%"]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>L(!w),className:"flex items-center gap-2 text-xs w-full py-2 transition-colors",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3 h-3 transition-transform ${w?"rotate-180":""}`}),"Opciones avanzadas"]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:w&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:jsxRuntime.jsxs("div",{className:"pt-3 space-y-3",children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-3 cursor-pointer p-2 rounded-lg transition-colors hover:bg-white/5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:E.isMilestone,onChange:P=>de("isMilestone",P.target.checked),className:"w-4 h-4 rounded",style:{accentColor:l.accent},disabled:d}),jsxRuntime.jsx(lucideReact.Milestone,{className:"w-4 h-4 text-yellow-500"}),jsxRuntime.jsx("span",{className:"text-sm",style:{color:l.textPrimary},children:"Marcar como hito"})]}),r.length>0&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"flex items-center gap-2 text-xs mb-2",style:{color:l.textTertiary},children:[jsxRuntime.jsx(lucideReact.Link2,{className:"w-3.5 h-3.5"}),"Dependencias"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-24 overflow-y-auto p-2 rounded-lg",style:{backgroundColor:l.bgSecondary},children:r.filter(P=>P.id!==a?.id).map(P=>{let W=E.dependencies?.includes(P.id);return jsxRuntime.jsx("button",{type:"button",onClick:()=>{let le=W?(E.dependencies||[]).filter(te=>te!==P.id):[...E.dependencies||[],P.id];de("dependencies",le);},className:"px-2 py-1 rounded-full text-xs transition-colors",style:{backgroundColor:W?`${l.accent}30`:l.bgPrimary,color:W?l.accent:l.textSecondary,border:`1px solid ${W?l.accent:l.borderLight}`},disabled:d,children:P.name},P.id)})})]})]})})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3",style:{borderTop:`1px solid ${l.border}`},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm rounded-lg transition-colors",style:{color:l.textSecondary},onMouseEnter:P=>P.currentTarget.style.backgroundColor=l.hoverBg,onMouseLeave:P=>P.currentTarget.style.backgroundColor="transparent",disabled:d,children:"Cancelar"}),jsxRuntime.jsx("button",{type:"submit",disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:l.accent,color:"#FFF"},onMouseEnter:P=>!d&&(P.currentTarget.style.opacity="0.9"),onMouseLeave:P=>!d&&(P.currentTarget.style.opacity="1"),children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Guardando..."]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:c==="create"?"Crear tarea":"Guardar"})})]})]})]})})]})})}var Lg=['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"'],Zl=()=>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"})]}),Fg=()=>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"})}),Bg=()=>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"})}),Rg=()=>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"})}),Og=()=>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 Wo({tasks:e,theme:t,config:a,onTasksUpdate:r,onTaskUpdate:o,onTaskCreate:s,onTaskDelete:d,onDependencyCreate:c,onDependencyDelete:m}){let[n,p]=react.useState(false),[l,i]=react.useState(false),[u,v]=react.useState([]),[f,y]=react.useState(""),[x,b]=react.useState(false),[g,C]=react.useState(true),D=react.useRef(null),h=react.useRef(null),A=react.useRef(null),{enabled:w=true,placeholder:L='Ask AI to edit tasks... (e.g., "Move Design to next week")',position:T="bottom-right",onCommand:U,suggestions:H=Lg,maxHistory:$=50,persistHistory:E}=a,J=E?.storageKey||"gantt-ai-history",ge=E?.maxMessages??5;react.useEffect(()=>{if(E?.enabled)try{let F=localStorage.getItem(J);if(F){let V=JSON.parse(F).map(P=>({...P,timestamp:new Date(P.timestamp)}));v(V.slice(-ge));}}catch(F){console.warn("[GanttAIAssistant] Failed to load persisted history:",F);}},[E?.enabled,J,ge]),react.useEffect(()=>{if(E?.enabled&&u.length>0)try{let F=u.filter(M=>!M.isLoading).slice(-ge);localStorage.setItem(J,JSON.stringify(F));}catch(F){console.warn("[GanttAIAssistant] Failed to persist history:",F);}},[u,E?.enabled,J,ge]),react.useEffect(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"});},[u]),react.useEffect(()=>{n&&!l&&D.current&&setTimeout(()=>D.current?.focus(),100);},[n,l]);let ke=react.useCallback(F=>{if(F.success)switch(F.type){case "move_task":case "resize_task":case "rename_task":case "set_progress":case "set_status":case "assign_task":F.taskId&&F.updates&&o?.(F.taskId,F.updates);break;case "create_task":F.newTask&&s?.(F.newTask);break;case "delete_task":F.taskId&&d?.(F.taskId);break;case "link_tasks":F.dependencyFrom&&F.dependencyTo&&c?.(F.dependencyFrom,F.dependencyTo);break;case "unlink_tasks":F.taskId&&F.dependencyFrom&&m?.(F.taskId,F.dependencyFrom);break}},[o,s,d,c,m]),Le=react.useCallback(async F=>{if(!F.trim()||x)return;let M={id:`user-${Date.now()}`,role:"user",content:F,timestamp:new Date};v(P=>[...P.slice(-($-1)),M]),y(""),C(false),b(true);let V={id:`loading-${Date.now()}`,role:"assistant",content:"",timestamp:new Date,isLoading:true};v(P=>[...P,V]);try{if(U){let P=await U(F,e);v(W=>{let le=W.filter(Se=>!Se.isLoading),te={id:`assistant-${Date.now()}`,role:"assistant",content:P.message,timestamp:new Date,command:P};return [...le,te]}),ke(P);}else v(P=>[...P.filter(le=>!le.isLoading),{id:`assistant-${Date.now()}`,role:"assistant",content:"AI handler not configured. Please provide an onCommand handler in the aiAssistant config.",timestamp:new Date}]);}catch(P){v(W=>[...W.filter(te=>!te.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${P instanceof Error?P.message:"Unknown error"}`,timestamp:new Date}]);}finally{b(false);}},[x,$,U,e,ke]),Ee=F=>{F.preventDefault(),Le(f);},de=F=>{y(F),D.current?.focus();};if(react.useEffect(()=>{let F=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&(M.preventDefault(),p(V=>!V),n||i(false)),M.key==="Escape"&&n&&p(false);};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n]),react.useEffect(()=>{if(!n)return;let F=V=>{let P=V.target;A.current&&!A.current.contains(P)&&p(false);},M=setTimeout(()=>{document.addEventListener("mousedown",F);},100);return ()=>{clearTimeout(M),document.removeEventListener("mousedown",F);}},[n]),!w)return null;let S={"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(Ke,{children:[jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!n&&jsxRuntime.jsxs(framerMotion.motion.button,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},className:`fixed ${S[T]} z-[99999] flex items-center gap-2 px-4 py-3 rounded-full shadow-lg transition-colors`,style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"white",boxShadow:"0 4px 20px rgba(59, 130, 246, 0.4)"},onClick:()=>p(true),children:[jsxRuntime.jsx(Zl,{}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"AI Assistant"}),jsxRuntime.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono rounded bg-white/20",children:"\u2318K"})]})}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:n&&jsxRuntime.jsxs(framerMotion.motion.div,{ref:A,initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1,height:l?"auto":500},exit:{opacity:0,y:20,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:`fixed ${S[T]} z-[99999] w-96 rounded-2xl overflow-hidden shadow-2xl flex flex-col`,style:{background:t.bgPrimary,border:`1px solid ${t.border}`,boxShadow:`0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px ${t.border}`},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-white",children:[jsxRuntime.jsx(Zl,{}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Gantt AI Assistant"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>i(F=>!F),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Rg,{})}),jsxRuntime.jsx("button",{onClick:()=>p(false),className:"p-1.5 rounded-lg hover:bg-white/20 text-white/80 hover:text-white transition-colors",children:jsxRuntime.jsx(Bg,{})})]})]}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:!l&&jsxRuntime.jsxs(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"flex flex-col flex-1 min-h-0",children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",style:{maxHeight:350},children:[u.length===0&&g&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("p",{className:"text-sm text-center",style:{color:t.textSecondary},children:"Try asking me to edit your Gantt chart:"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:H.slice(0,4).map((F,M)=>jsxRuntime.jsx("button",{onClick:()=>de(F),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:F.length>30?F.slice(0,30)+"...":F},M))})]}),u.map(F=>jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex ${F.role==="user"?"justify-end":"justify-start"}`,children:jsxRuntime.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${F.role==="user"?"rounded-br-md":"rounded-bl-md"}`,style:{background:F.role==="user"?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":t.bgSecondary,color:F.role==="user"?"white":t.textPrimary},children:[F.isLoading?jsxRuntime.jsx(Og,{}):jsxRuntime.jsx("p",{className:"text-sm whitespace-pre-wrap",children:F.content}),F.command&&jsxRuntime.jsxs("div",{className:"mt-2 text-xs px-2 py-1 rounded-md inline-flex items-center gap-1",style:{background:F.command.success?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)",color:F.command.success?"#10B981":"#EF4444"},children:[F.command.success?"\u2713":"\u2717",jsxRuntime.jsx("span",{className:"capitalize",children:F.command.type.replace(/_/g," ")})]})]})},F.id)),jsxRuntime.jsx("div",{ref:h})]}),jsxRuntime.jsxs("form",{onSubmit:Ee,className:"p-3 border-t",style:{borderColor:t.border},children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-4 py-2",style:{background:t.bgSecondary,border:`1px solid ${t.border}`},children:[jsxRuntime.jsx("input",{ref:D,type:"text",value:f,onChange:F=>y(F.target.value),placeholder:L,disabled:x,className:"flex-1 bg-transparent text-sm outline-none",style:{color:t.textPrimary}}),jsxRuntime.jsx("button",{type:"submit",disabled:!f.trim()||x,className:"p-2 rounded-lg transition-all disabled:opacity-50",style:{background:f.trim()?"linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%)":"transparent",color:f.trim()?"white":t.textSecondary},children:jsxRuntime.jsx(Fg,{})})]}),jsxRuntime.jsx("p",{className:"text-[10px] text-center mt-2",style:{color:t.textTertiary},children:"Press Enter to send \u2022 Esc to close"})]})]})})]})})]})}function Ql(e,t=50){let[a,r]=react.useState({past:[],present:e,future:[]}),o=react.useRef(false),s=react.useCallback((n,p=true)=>{r(l=>{let i=typeof n=="function"?n(l.present):n;if(o.current)return {...l,present:i};if(!p)return {...l,present:i};let u=[...l.past,l.present];return u.length>t&&u.shift(),{past:u,present:i,future:[]}});},[t]),d=react.useCallback(()=>{r(n=>{if(n.past.length===0)return n;let p=n.past[n.past.length-1],l=n.past.slice(0,n.past.length-1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:l,present:p,future:[n.present,...n.future]}});},[]),c=react.useCallback(()=>{r(n=>{if(n.future.length===0)return n;let p=n.future[0],l=n.future.slice(1);return o.current=true,setTimeout(()=>{o.current=false;},0),{past:[...n.past,n.present],present:p,future:l}});},[]),m=react.useCallback(()=>{r(n=>({past:[],present:n.present,future:[]}));},[]);return {state:a.present,setState:s,undo:d,redo:c,canUndo:a.past.length>0,canRedo:a.future.length>0,clearHistory:m}}function ed({undo:e,redo:t,canUndo:a,canRedo:r,enabled:o=true}){react.useEffect(()=>{if(!o)return;let s=d=>{let c=navigator.platform.toUpperCase().indexOf("MAC")>=0,m=c?d.metaKey:d.ctrlKey;if(m&&d.key==="z"&&!d.shiftKey&&a){d.preventDefault(),e();return}if(r){if(!c&&m&&d.key==="y"){d.preventDefault(),t();return}if(c&&m&&d.shiftKey&&d.key==="z"){d.preventDefault(),t();return}}};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s);}},[e,t,a,r,o]);}var Wg={taskTooltip:e=>{let t=[`<strong>${e.name}</strong>`];if(e.startDate&&e.endDate){t.push(`${ae.formatDate(e.startDate)} - ${ae.formatDate(e.endDate)}`);let a=ae.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=>ae.formatDate(e),durationFormat:e=>e===1?"1 day":`${e} days`,progressFormat:e=>`${e}%`};function td(e){return {...Wg,...e}}var Yg=e=>{switch(e){case "compact":return 44;case "comfortable":return 52;case "spacious":return 60;default:return 52}},od=react.forwardRef(function({tasks:t,config:a={},onTasksChange:r},o){let{theme:s,timeScale:d="week",rowDensity:c="comfortable",showThemeSelector:m=true,showExportButton:n=true,availableUsers:p=[],templates:l,enableAutoCriticalPath:i=true,aiAssistant:u,locale:v="en",customTranslations:f,showCreateTaskButton:y=false,createTaskLabel:x,onCreateTask:b,onThemeChange:g,onTaskClick:C,onTaskDblClick:D,onTaskContextMenu:h,onTaskUpdate:A,onProgressChange:w,onTaskEdit:L,onTaskAddSubtask:T,onTaskMarkIncomplete:U,onTaskSetInProgress:H,onDependencyCreate:$,onDependencyDelete:E,onBeforeTaskAdd:J,onAfterTaskAdd:ge,onBeforeTaskUpdate:ke,onAfterTaskUpdate:Le,onBeforeTaskDelete:Ee,onAfterTaskDelete:de}=a,F=react.useContext(Co)?.theme,[M,V]=react.useState(F||s||"dark"),[P,W]=react.useState(d),[le,te]=react.useState(c),[Se,ne]=react.useState(1),[Ve,be]=react.useState(0),[tt,Tt]=react.useState(false),[Dt,yt]=react.useState(null),[Nt,Mt]=react.useState({isOpen:false,x:0,y:0,task:null}),[ra,mt]=react.useState(null),[rt,Lt]=react.useState(null);react.useEffect(()=>{F&&F!==M&&V(F);},[F]),react.useEffect(()=>{s&&s!==M&&V(s);},[s]);let Ht=react.useCallback(N=>{V(N),g?.(N);},[g]),{state:we,setState:O,undo:Te,redo:Ue,canUndo:$e,canRedo:pt,clearHistory:X}=Ql(t,50);react.useEffect(()=>{O(t);},[t,O]);let Q=react.useRef(t),ve=react.useRef(true);react.useEffect(()=>{if(ve.current){ve.current=false,Q.current=we;return}if(!r)return;let N=JSON.stringify(Q.current),z=JSON.stringify(we);N!==z&&(Q.current=we,r(we));},[we,r]);let fe=react.useMemo(()=>es(v,f),[v,f]),ee=react.useCallback(N=>[{id:"name",label:N.columns.taskName,width:400,minWidth:200,maxWidth:2e3,visible:true,sortable:true,resizable:true},{id:"startDate",label:N.columns.startDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"endDate",label:N.columns.endDate,width:110,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"duration",label:N.columns.duration,width:80,minWidth:60,maxWidth:150,visible:false,sortable:true,resizable:true},{id:"assignees",label:N.columns.assignees,width:120,minWidth:80,maxWidth:300,visible:false,sortable:false,resizable:true},{id:"status",label:N.columns.status,width:100,minWidth:70,maxWidth:180,visible:false,sortable:true,resizable:true},{id:"progress",label:N.columns.progress,width:120,minWidth:80,maxWidth:200,visible:false,sortable:true,resizable:true},{id:"priority",label:N.columns.priority,width:90,minWidth:70,maxWidth:150,visible:false,sortable:true,resizable:true}],[]),[Ce,B]=react.useState(()=>ee(fe));react.useEffect(()=>{B(N=>N.map(z=>({...z,label:fe.columns[z.id==="name"?"taskName":z.id]||z.label})));},[fe]);let G=react.useMemo(()=>Ce.filter(N=>N.visible).reduce((N,z)=>N+z.width,0)+60,[Ce]),K=react.useMemo(()=>Dt!==null?Math.max(280,Dt,G):Math.max(280,G),[Dt,G]),oe=react.useRef(null),q=react.useRef(null),xe=react.useRef(null),se=react.useMemo(()=>Cl(M),[M]),R=react.useMemo(()=>({theme:se,themeName:M}),[se,M]),ie=react.useMemo(()=>td(l),[l]),Ae=react.useMemo(()=>{if(!i)return we;let N=ae.calculateCriticalPath(we),z=Y=>Y.map(ce=>({...ce,isCriticalPath:N.includes(ce.id),subtasks:ce.subtasks?z(ce.subtasks):void 0}));return z(we)},[we,i]),at=Yg(le);ed({undo:Te,redo:Ue,canUndo:$e,canRedo:pt,enabled:true}),react.useImperativeHandle(o,()=>({getTask:N=>ae.findTaskById(we,N),addTask:(N,z)=>{O(Y=>{if(!z)return [...Y,{...N,level:0}];let ce=he=>he.map(Ne=>Ne.id===z?{...Ne,subtasks:[...Ne.subtasks||[],{...N,parentId:z,level:(Ne.level||0)+1}],isExpanded:true}:Ne.subtasks?{...Ne,subtasks:ce(Ne.subtasks)}:Ne);return ce(Y)});},updateTask:(N,z)=>{O(Y=>{let ce=he=>he.map(Ne=>Ne.id===N?{...Ne,...z}:Ne.subtasks?{...Ne,subtasks:ce(Ne.subtasks)}:Ne);return ce(Y)});},deleteTask:N=>{O(z=>{let Y=ce=>ce.filter(he=>he.id===N?false:(he.subtasks&&(he.subtasks=Y(he.subtasks)),true));return Y(z)});},deleteTasks:N=>{O(z=>is(z,N));},duplicateTask:N=>{O(z=>ls(z,[N]));},splitTask:(N,z,Y=3)=>{O(ce=>ae.splitTask(ce,N,z,Y));},calculateEndDate:ae.calculateEndDate,calculateDuration:ae.calculateDuration,validateDependency:(N,z)=>!ae.validateDependencies(we,N,z),getAllTasks:()=>ae.flattenTasks(we),getTasksByStatus:N=>ae.flattenTasks(we).filter(z=>z.status===N),getTasksByParent:N=>N?ae.findTaskById(we,N)?.subtasks||[]:we.filter(Y=>!Y.parentId),getCriticalPath:()=>ae.flattenTasks(we).filter(N=>N.isCriticalPath),indentTask:N=>{O(z=>os(z,[N]));},outdentTask:N=>{O(z=>ns(z,[N]));},moveTask:(N,z)=>{O(Y=>ss(Y,[N],z));},createSubtask:async N=>{let{tasks:z,newTask:Y}=ms(we,N);if(J){let ce=J({...Y,parentId:N});if((ce instanceof Promise?await ce:ce)===false)return}O(z),ge&&ge({...Y,parentId:N});},scrollToTask:N=>{let Y=ae.flattenTasks(we).findIndex(ce=>ce.id===N);if(Y!==-1&&oe.current){let ce=Y*at;oe.current.scrollTo({top:ce,behavior:"smooth"}),q.current&&q.current.scrollTo({top:ce,behavior:"smooth"});}},highlightTask:(N,z=2e3)=>{},expandTask:N=>{O(z=>{let Y=ce=>ce.map(he=>he.id===N?{...he,isExpanded:true}:he.subtasks?{...he,subtasks:Y(he.subtasks)}:he);return Y(z)});},collapseTask:N=>{O(z=>{let Y=ce=>ce.map(he=>he.id===N?{...he,isExpanded:false}:he.subtasks?{...he,subtasks:Y(he.subtasks)}:he);return Y(z)});},expandAll:()=>{O(N=>{let z=Y=>Y.map(ce=>({...ce,isExpanded:true,subtasks:ce.subtasks?z(ce.subtasks):void 0}));return z(N)});},collapseAll:()=>{O(N=>{let z=Y=>Y.map(ce=>({...ce,isExpanded:false,subtasks:ce.subtasks?z(ce.subtasks):void 0}));return z(N)});},undo:Te,redo:Ue,canUndo:()=>$e,canRedo:()=>pt,clearHistory:X,exportToPNG:async()=>{if(!xe.current)throw new Error("Gantt container not found");let N=await rd__default.default(xe.current,{backgroundColor:se.bgPrimary,scale:2});return new Promise((z,Y)=>{N.toBlob(ce=>{ce?z(ce):Y(new Error("Failed to create blob from canvas"));},"image/png");})},exportToPDF:async N=>{await ae.exportToPDF(we,N);},exportToExcel:async N=>{await ae.exportToExcel(we,N);},exportToJSON:()=>ae.exportToJSON(we),exportToCSV:()=>ae.exportToCSV(we),importFromJSON:N=>{let z=ae.importFromJSON(N);O(z);},getTasks:()=>we,refresh:()=>{O(N=>[...N]);},clearAll:()=>{O([]);}}),[we,Te,Ue,$e,pt,X,se,at]);let De=react.useCallback(N=>{B(z=>z.map(Y=>Y.id===N?{...Y,visible:!Y.visible}:Y));},[]),ja=react.useCallback((N,z)=>{B(Y=>Y.map(ce=>{if(ce.id!==N)return ce;let he=ce.minWidth??100,Ne=ce.maxWidth??800,kt=Math.max(he,Math.min(Ne,z));return {...ce,width:kt}}));},[]),cr=react.useCallback(N=>{O(z=>cs(z,N)),a.onTaskToggleExpand?.(N);},[a]),mr=react.useCallback((N,z)=>{if(ke&&ke(N,z)===false)return;let ce=ae.findTaskById(we,N)?.progress,he=kt=>kt.map(Ut=>Ut.id===N?{...Ut,...z}:Ut.subtasks?{...Ut,subtasks:he(Ut.subtasks)}:Ut);O(he(we));let Ne=ae.findTaskById(he(we),N);Ne&&(A?.(Ne),Le?.(Ne),z.progress!==void 0&&ce!==void 0&&z.progress!==ce&&w?.(N,ce,z.progress));},[we,A,ke,Le,w]),yc=react.useCallback(N=>{N.length!==0&&(O(z=>os(z,N)),a.onTaskIndent?.(N[0]));},[a]),vc=react.useCallback(N=>{N.length!==0&&(O(z=>ns(z,N)),a.onTaskOutdent?.(N[0]));},[a]),xc=react.useCallback((N,z,Y)=>{O(ce=>Hl(ce,N,z,Y)),a.onTaskReparent?.(N,z,Y);},[a]),kc=react.useCallback((N,z)=>{N.length!==0&&(O(Y=>ss(Y,N,z)),a.onTaskMove?.(N[0],z));},[a]),ln=react.useCallback(async N=>{let z=[];for(let Y of N)Ee&&await Promise.resolve(Ee(Y))===false||z.push(Y);z.length!==0&&(a.onMultiTaskDelete?a.onMultiTaskDelete(z):(O(Y=>is(Y,z)),z.forEach(Y=>a.onTaskDelete?.(Y))),de&&z.forEach(Y=>de(Y)));},[a,Ee,de]),wc=react.useCallback(N=>{O(z=>ls(z,N)),N.forEach(z=>a.onTaskDuplicate?.(z));},[a]),Cc=react.useCallback((N,z)=>{O(Y=>{let{tasks:ce,newTask:he}=Gl(Y,N,z);return J&&J(he)===false?Y:(a.onTaskCreate?.(he.parentId,he.position||0),ge?.(he),ce)});},[a,J,ge]),Tc=react.useCallback((N,z)=>{O(Y=>ds(Y,N,z)),a.onTaskRename?.(N,z);},[a]),dn=react.useCallback(N=>{O(z=>{let{tasks:Y}=ms(z,N);return a.onTaskCreate?.(N,0),Y});},[a]),Dc=react.useCallback((N,z,Y)=>{let ce=N.startDate?Math.round((z.getTime()-N.startDate.getTime())/864e5):0,he=Ut=>Ut.map(da=>da.id===N.id?{...da,startDate:z,endDate:Y,...N.segments&&{segments:N.segments}}:da.subtasks?{...da,subtasks:he(da.subtasks)}:da),Ne=he(we);Ne=ae.autoScheduleDependents(Ne,N.id,ce),O(Ne);let kt={...N,startDate:z,endDate:Y};A?.(kt);},[we,A]),Nc=react.useCallback((N,z)=>{h?.(N,z),Mt({isOpen:true,x:z.clientX,y:z.clientY,task:N});},[h]),Sc=react.useCallback((N,z)=>{let Y=ae.splitTask(we,N.id,z);O(Y),Mt({isOpen:false,x:0,y:0,task:null});},[we]),pi=react.useCallback(N=>{D?.(N),L||mt(N);},[D,L]),ui=react.useCallback((N,z,Y)=>{let ce=new Map,he=ca=>{ca.forEach(Na=>{Na.dependencies&&ce.set(Na.id,Na.dependencies),Na.subtasks&&he(Na.subtasks);});};he(Y);let Ne=ce.get(z)||[];ce.set(z,[...Ne,N]);let kt=new Set,Ut=new Set,da=ca=>{if(!kt.has(ca)){kt.add(ca),Ut.add(ca);let Na=ce.get(ca)||[];for(let Lr of Na){if(!kt.has(Lr)&&da(Lr))return true;if(Ut.has(Lr))return true}}return Ut.delete(ca),false};return da(z)},[]),gi=react.useCallback((N,z)=>{if(ui(N.id,z,we)){console.warn("Cannot create dependency: would create a circular dependency"),alert(`Cannot create this dependency: it would create a circular dependency chain.
|
|
277
277
|
|
|
278
278
|
Task dependencies must flow in one direction only.`);return}let Y=ce=>ce.map(he=>{if(he.id===z){let Ne=he.dependencies||[];if(!Ne.includes(N.id))return {...he,dependencies:[...Ne,N.id]}}return he.subtasks?{...he,subtasks:Y(he.subtasks)}:he});O(Y(we)),$?.(N.id,z);},[we,$,ui]),fi=react.useCallback((N,z)=>{let Y=ce=>ce.map(he=>{if(he.id===N&&he.dependencies){let Ne=he.dependencies.filter(kt=>kt!==z);return {...he,dependencies:Ne}}return he.subtasks?{...he,subtasks:Y(he.subtasks)}:he});O(Y(we)),E?.(N,z);},[we,E]),{startDate:Ec,endDate:Pc}=react.useMemo(()=>{let N=we.filter(Ne=>Ne.startDate&&Ne.endDate);if(N.length===0){let Ne=new Date,kt=new Date(Ne);kt.setDate(kt.getDate()-30);let Ut=new Date(Ne);return Ut.setDate(Ut.getDate()+60),{startDate:kt,endDate:Ut}}let z=N.flatMap(Ne=>[Ne.startDate,Ne.endDate]).filter(Ne=>Ne!==void 0),Y=new Date(Math.min(...z.map(Ne=>Ne.getTime()))),ce=new Date(Math.max(...z.map(Ne=>Ne.getTime()))),he=P==="day"?7:P==="week"?14:30;return Y.setDate(Y.getDate()-he),ce.setDate(ce.getDate()+he),{startDate:Y,endDate:ce}},[we,P]),Mc=react.useCallback(async()=>{if(!xe.current)return;let N=await rd__default.default(xe.current,{backgroundColor:se.bgPrimary,scale:2}),z=document.createElement("a");z.download="gantt-chart.png",z.href=N.toDataURL("image/png"),z.click();},[se]),Ac=react.useCallback(async()=>{await ae.exportToPDF(we);},[we]),Ic=react.useCallback(async()=>{await ae.exportToExcel(we);},[we]),Lc=react.useCallback(()=>{let N=ae.exportToCSV(we),z=new Blob([N],{type:"text/csv;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(z),Y.download="gantt-chart.csv",Y.click(),URL.revokeObjectURL(Y.href);},[we]),Fc=react.useCallback(()=>{let N=ae.exportToJSON(we),z=new Blob([N],{type:"application/json;charset=utf-8;"}),Y=document.createElement("a");Y.href=URL.createObjectURL(z),Y.download="gantt-chart.json",Y.click(),URL.revokeObjectURL(Y.href);},[we]),Bc=react.useCallback(()=>{ae.exportToMSProject(we,"Gantt Project","project.xml");},[we]),Rc=N=>{N.preventDefault(),Tt(true);};return react.useEffect(()=>{let N=q.current,z=oe.current;if(!N||!z)return;let Y=z.querySelector(".gantt-taskgrid-content"),ce=()=>{let kt=N.scrollTop;be(kt),Y&&(Y.style.transform=`translateY(-${kt}px)`);},he=kt=>{if(tt&&z){let da=z.parentElement?.getBoundingClientRect()?.left||0,ca=kt.clientX-da,Na=280,Lr=Math.min(window.innerWidth-300,800);ca>=Na&&ca<=Lr&&yt(ca);}},Ne=()=>{Tt(false);};return N.addEventListener("scroll",ce),document.addEventListener("mousemove",he),document.addEventListener("mouseup",Ne),()=>{N.removeEventListener("scroll",ce),document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Ne);}},[tt]),jsxRuntime.jsx(wr.Provider,{value:fe,children:jsxRuntime.jsx(gn.Provider,{value:R,children:jsxRuntime.jsxs("div",{ref:xe,className:"flex flex-col h-full w-full",style:{backgroundColor:se.bgPrimary,fontFamily:"Inter, sans-serif",minHeight:0,...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:[jsxRuntime.jsx(Do,{theme:se,timeScale:P,onTimeScaleChange:W,zoom:Se,onZoomChange:ne,currentTheme:M,onThemeChange:Ht,rowDensity:le,onRowDensityChange:te,showThemeSelector:m,showCreateTaskButton:y,createTaskLabel:x,onCreateTask:b,onExportPNG:n?Mc:void 0,onExportPDF:n?Ac:void 0,onExportExcel:n?Ic:void 0,onExportCSV:n?Lc:void 0,onExportJSON:n?Fc:void 0,onExportMSProject:n?Bc:void 0}),jsxRuntime.jsxs("div",{ref:oe,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:K,overflow:"hidden"},children:jsxRuntime.jsx(Po,{tasks:Ae,theme:se,rowHeight:at,availableUsers:p,templates:ie,onTaskClick:C,onTaskDblClick:pi,onTaskContextMenu:h,onTaskToggle:cr,scrollTop:Ve,columns:Ce,onToggleColumn:De,onColumnResize:ja,onTaskUpdate:mr,onTaskIndent:yc,onTaskOutdent:vc,onTaskMove:kc,onMultiTaskDelete:ln,onTaskDuplicate:wc,onTaskCreate:Cc,onTaskRename:Tc,onCreateSubtask:dn,onOpenTaskModal:C?N=>C(N):void 0,onDeleteRequest:(N,z)=>Lt({taskId:N,taskName:z}),onTaskReparent:xc})}),jsxRuntime.jsx("div",{className:"flex-shrink-0 cursor-col-resize",style:{width:6,marginLeft:-3,zIndex:10},onMouseDown:Rc}),jsxRuntime.jsx("div",{ref:q,className:"gantt-timeline-scroll flex-1",style:{minHeight:0,overflowX:"auto",overflowY:"auto",...a.disableScrollSync&&{scrollBehavior:"auto",overflowAnchor:"none"}},children:jsxRuntime.jsx(Oo,{tasks:Ae,theme:se,rowHeight:at,timeScale:P,startDate:Ec,endDate:Pc,zoom:Se,templates:ie,onTaskClick:C,onTaskDblClick:pi,onTaskContextMenu:Nc,onTaskDateChange:Dc,onDependencyCreate:gi,onDependencyDelete:fi})})]}),Nt.task&&jsxRuntime.jsx(Cr,{isOpen:Nt.isOpen,x:Nt.x,y:Nt.y,theme:se,onClose:()=>Mt({isOpen:false,x:0,y:0,task:null}),items:(()=>{let N=Nt.task;return N?N.subtasks&&N.subtasks.length>0?[{id:"addSubtask",label:fe.contextMenu?.addSubtask||"Add Subtask",icon:it.Add,onClick:()=>{T?T(N):dn(N.id);}},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:fe.contextMenu?.deleteTask||"Delete Task",icon:it.Delete,onClick:()=>{Lt({taskId:N.id,taskName:N.name});}}]:[{id:"edit",label:fe.contextMenu?.editTask||"Edit Task",icon:it.Pencil,onClick:()=>{L?L(N):mt(N);}},{id:"addSubtask",label:fe.contextMenu?.addSubtask||"Add Subtask",icon:it.Add,onClick:()=>{T?T(N):dn(N.id);}},{id:"separator-status",label:"",separator:true,onClick:()=>{}},{id:"markIncomplete",label:fe.contextMenu?.markIncomplete||"Mark Incomplete",icon:it.MarkIncomplete,onClick:()=>{U?U(N):mr(N.id,{status:"todo",progress:0});},disabled:N.status==="todo"},{id:"setInProgress",label:fe.contextMenu?.setInProgress||"Set In Progress",icon:it.SetInProgress,onClick:()=>{H?H(N):mr(N.id,{status:"in-progress"});},disabled:N.status==="in-progress"},{id:"markComplete",label:fe.contextMenu?.markComplete||"Mark Complete",icon:it.MarkComplete,onClick:()=>{mr(N.id,{status:"completed",progress:100});},disabled:N.status==="completed"},{id:"separator-advanced",label:"",separator:true,onClick:()=>{}},{id:"split",label:fe.contextMenu?.splitTask||"Split Task",icon:it.Split,onClick:()=>{if(!N.startDate||!N.endDate){console.warn("Cannot split task without dates");return}let Y=N.startDate.getTime(),ce=N.endDate.getTime(),he=Y+(ce-Y)/2,Ne=new Date(he);Sc(N,Ne);},disabled:!N.startDate||!N.endDate},{id:"separator-delete",label:"",separator:true,onClick:()=>{}},{id:"delete",label:fe.contextMenu?.deleteTask||"Delete Task",icon:it.Delete,onClick:()=>{Lt({taskId:N.id,taskName:N.name});}}]:[]})()}),ra&&jsxRuntime.jsx(zo,{isOpen:true,onClose:()=>mt(null),task:ra,onSubmit:N=>{mr(ra.id,N),mt(null);},mode:"edit",theme:M}),jsxRuntime.jsx(framerMotion.AnimatePresence,{children:rt&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[10000] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0, 0, 0, 0.6)"},onClick:()=>Lt(null),children:jsxRuntime.jsxs(framerMotion.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.2,ease:"easeOut"},onClick:N=>N.stopPropagation(),className:"w-full max-w-md rounded-xl shadow-2xl overflow-hidden",style:{backgroundColor:se.bgSecondary,border:`1px solid ${se.border}`},children:[jsxRuntime.jsx("div",{className:"px-6 py-4",style:{borderBottom:`1px solid ${se.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:se.textPrimary,fontFamily:"Inter, sans-serif"},children:[fe.contextMenu?.deleteTask||"Delete Task","?"]}),jsxRuntime.jsx("p",{className:"text-sm mt-1",style:{color:se.textSecondary,fontFamily:"Inter, sans-serif"},children:v==="es"?"Esta acci\xF3n no se puede deshacer":"This action cannot be undone"})]})]})}),jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsxs("p",{className:"text-sm leading-relaxed",style:{color:se.textSecondary,fontFamily:"Inter, sans-serif"},children:[v==="es"?"Est\xE1s a punto de eliminar la tarea":"You are about to delete the task"," ",jsxRuntime.jsxs("span",{className:"font-semibold",style:{color:se.textPrimary},children:['"',rt.taskName,'"']}),"."]})}),jsxRuntime.jsxs("div",{className:"px-6 py-4 flex items-center justify-end gap-3",style:{backgroundColor:se.bgPrimary,borderTop:`1px solid ${se.border}`},children:[jsxRuntime.jsx("button",{onClick:()=>Lt(null),className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors",style:{color:se.textSecondary,fontFamily:"Inter, sans-serif"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor=se.hoverBg;},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="transparent";},children:v==="es"?"Cancelar":"Cancel"}),jsxRuntime.jsxs("button",{onClick:()=>{ln([rt.taskId]),Lt(null);},className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors flex items-center gap-2",style:{backgroundColor:"#EF4444",fontFamily:"Inter, sans-serif"},onMouseEnter:N=>{N.currentTarget.style.backgroundColor="#DC2626";},onMouseLeave:N=>{N.currentTarget.style.backgroundColor="#EF4444";},children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),v==="es"?"Eliminar":"Delete"]})]})]})})}),u?.enabled&&jsxRuntime.jsx(Wo,{tasks:we,theme:se,config:u,onTasksUpdate:O,onTaskUpdate:mr,onTaskCreate:N=>{O(z=>[...z,N]);},onTaskDelete:N=>{ln([N]);},onDependencyCreate:(N,z)=>{let Y=ae.findTaskById(we,N);Y&&gi(Y,z);},onDependencyDelete:fi})]})})})});var nd=`You are a Gantt chart AI assistant. You help users edit project tasks using natural language commands.
|
|
279
279
|
|