@libxai/board 0.17.372 → 0.17.373

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.js CHANGED
@@ -108,7 +108,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
108
108
  1.
109
109
 
110
110
  **Action items:**
111
- - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function Vs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function i(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=i=>{t(i),o(false);},m=e.reduce((i,u)=>{let d=u.category||"Other";return i[d]||(i[d]=[]),i[d].push(u),i},{});return jsxs("div",{className:f("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",i.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",i.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:f("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(m).map(([i,u])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:i})}),jsx("div",{children:u.map(d=>jsxs("button",{onClick:()=>p(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},i)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function Ks({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,p]=useState("export"),[m,i]=useState("json"),[u,d]=useState(null),g=useRef(null);if(!t)return null;let h=async()=>{let T=o?.current||void 0,c=await Sl(e,m,T);El(c,m);},C=async T=>{let c=T.target.files?.[0];if(c){try{let b=await Al(c),y=c.name.endsWith(".json")?"json":"csv",l=Ml(b,y);d(l),l.success&&r&&r(l,b);}catch(b){d({success:false,errors:[`Failed to read file: ${b instanceof Error?b.message:"Unknown error"}`]});}g.current&&(g.current.value="");}};return jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>p("export"),className:f("flex-1 px-6 py-4 font-semibold transition-colors",n==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>p("import"),className:f("flex-1 px-6 py-4 font-semibold transition-colors",n==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[n==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(T=>jsxs("button",{onClick:()=>i(T),className:f("p-4 rounded-lg border-2 transition-all text-center",m===T?"border-blue-500 bg-blue-500/20 text-white":"border-white/20 hover:border-white/40 text-white/70 hover:text-white"),children:[jsxs("div",{className:"text-2xl mb-2",children:[T==="json"&&"\u{1F4C4}",T==="csv"&&"\u{1F4CA}",T==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:T})]},T))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:h,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:g,type:"file",accept:".json,.csv",onChange:C,className:"hidden"}),jsxs("button",{onClick:()=>g.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),u&&jsxs("div",{className:f("p-4 rounded-lg",u.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:f("font-semibold mb-2",u.success?"text-green-400":"text-red-400"),children:u.success?"\u2713 Import Successful":"\u2717 Import Failed"}),u.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",u.cardsImported]}),jsxs("div",{children:["Columns imported: ",u.columnsImported]})]}),u.errors&&u.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:u.errors.map((T,c)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",T]},c))})]})]})]})]})]})}var Hg=["URGENT","HIGH","MEDIUM","LOW"],Wg=[{value:"none",label:"None"},{value:"created",label:"Date Created"},{value:"priority",label:"Priority"},{value:"dueDate",label:"Due Date"},{value:"title",label:"Title"},{value:"estimate",label:"Estimate"}],Gg=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ys({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:p,availableUsers:m=[],availableLabels:i=[],availableColumns:u=[],showQuickFilters:d=true,compact:g=false,groupBy:h="none",onGroupByChange:C}){let[T,c]=useState(true),b=useCallback(S=>{a({search:S.target.value});},[a]),y=useCallback(S=>{a({dateFilter:S.target.value});},[a]),l=useCallback(S=>{r({by:S.target.value});},[r]),x=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),v=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${g?"filter-bar--compact":""} ${T?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>c(!T),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:T?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:T?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s",color:"var(--theme-text-secondary)"},children:jsx("polyline",{points:"6 9 12 15 18 9"})}),jsx("span",{className:"filter-bar__label",style:{fontWeight:500,fontSize:"0.875rem",color:"var(--theme-text-primary)"},children:"Filters & Grouping"}),v&&jsxs("span",{style:{color:"var(--theme-accent-primary)",fontSize:"0.75rem",fontWeight:600},children:["(",[e.search&&"search",e.dateFilter!=="all"&&"date",e.priorities.length>0&&"priority",e.assignees.length>0&&"assignee",e.labels.length>0&&"label",t.by!=="none"&&"sort"].filter(Boolean).length," active)"]})]}),!T&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),p&&jsx("button",{onClick:p,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:b,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:y,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:S=>{let k=S.target.value;a({priorities:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Hg.map(S=>jsx("option",{value:S,children:S},S))]})}),m.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:S=>{let k=S.target.value;a({assignees:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),m.map(S=>jsx("option",{value:S.id,children:S.name},S.id))]})}),i.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:S=>{let k=S.target.value;a({labels:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),i.map(S=>jsx("option",{value:S,children:S},S))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:l,className:"filter-bar__select filter-bar__select--sm",children:Wg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))}),t.by!=="none"&&jsx("button",{onClick:x,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),C&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:h,onChange:S=>C(S.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Gg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))})}),v&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function qs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:p,onExportGanttCSV:m}){let[i,u]=useState(false),d=useRef(null);useEffect(()=>{let h=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return i&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[i]);let g=h=>{h(),u(false);};return jsxs("div",{className:f("relative",r),ref:d,children:[jsxs("button",{onClick:()=>u(!i),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",h.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",h.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":i,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),i&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>g(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>g(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>g(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>g(async()=>await p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>g(()=>m?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>g(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>g(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var Xs={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Js={name:"light",displayName:"Light (Standard)",emoji:"\u2600\uFE0F",colors:{bgPrimary:"#FFFFFF",bgSecondary:"#F7F7F8",bgTertiary:"#EEEFF1",bgCard:"#ffffff",bgHover:"#f3f4f6",bgActive:"#e5e7eb",bgInput:"#f9fafb",textPrimary:"#1A1A1A",textSecondary:"#5A5A5A",textTertiary:"#8A8A8A",textDisabled:"#d1d5db",textInverse:"#ffffff",borderPrimary:"rgba(0, 0, 0, 0.1)",borderSecondary:"rgba(0, 0, 0, 0.05)",borderDefault:"#e5e7eb",borderHover:"#d1d5db",borderSubtle:"#f3f4f6",accentPrimary:"#5E6AD2",accentHover:"#4A56B8",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.08)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.15)",success:"#059669",warning:"#D97706",error:"#DC2626",info:"#2563EB",danger:"#dc2626",dangerBorder:"rgba(220, 38, 38, 0.3)",dangerBackground:"rgba(220, 38, 38, 0.08)",dangerBackgroundHover:"rgba(220, 38, 38, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.12)",md:"0 4px 12px rgba(0, 0, 0, 0.15)",lg:"0 12px 32px rgba(0, 0, 0, 0.2)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Qs={name:"neutral",emoji:"\u26AA",displayName:"Neutral (Zen)",colors:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgTertiary:"#E7E5E4",bgCard:"#FEFEFE",bgHover:"#F0EFEE",bgActive:"#E7E5E4",bgInput:"#FAFAF9",textPrimary:"#1C1917",textSecondary:"#57534E",textTertiary:"#A8A29E",textDisabled:"#D6D3D1",textInverse:"#FAFAF9",borderPrimary:"#E7E5E4",borderSecondary:"#F0EFEE",borderDefault:"#E7E5E4",borderHover:"#D6D3D1",borderSubtle:"#F5F5F4",accentPrimary:"#292524",accentHover:"#44403C",interactivePrimary:"#292524",interactivePrimaryHover:"#44403C",interactivePrimaryBorder:"rgba(41, 37, 36, 0.3)",interactivePrimaryBackground:"rgba(41, 37, 36, 0.06)",interactivePrimaryBackgroundHover:"rgba(41, 37, 36, 0.12)",success:"#15803D",warning:"#CA8A04",error:"#B91C1C",info:"#1D4ED8",danger:"#B91C1C",dangerBorder:"rgba(185, 28, 28, 0.3)",dangerBackground:"rgba(185, 28, 28, 0.08)",dangerBackgroundHover:"rgba(185, 28, 28, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.1)",md:"0 4px 12px rgba(0, 0, 0, 0.12)",lg:"0 12px 32px rgba(0, 0, 0, 0.15)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Kr={dark:Xs,light:Js,neutral:Qs},yn="dark";var vn=createContext(void 0),Zg="asakaa-theme";function zd({children:e,defaultTheme:t=yn,storageKey:a=Zg}){let[r,o]=useState(()=>{if(typeof window<"u"){let p=localStorage.getItem(a);if(p&&(p==="dark"||p==="light"||p==="neutral"))return p}return t}),s=useCallback(p=>{o(p),typeof window<"u"&&localStorage.setItem(a,p);},[a]);useEffect(()=>{if(typeof window>"u")return;let p=document.documentElement,m=Kr[r];Object.entries(m.colors).forEach(([u,d])=>{d&&p.style.setProperty(`--theme-${ef(u)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([u,d])=>{let g=m.colors[u];g&&p.style.setProperty(d,g);}),p.setAttribute("data-theme",r),p.classList.remove("theme-dark","theme-light","theme-neutral"),p.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:Kr};return jsx(vn.Provider,{value:n,children:e})}function go(){let e=useContext(vn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function ef(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Zs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=go();return e?jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",a),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative rounded-2xl border shadow-2xl max-w-md w-full mx-4",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between",style:{borderColor:"var(--theme-border-primary)"},children:[jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--theme-text-primary)"},children:"Select Theme"}),jsx("button",{onClick:t,className:"text-2xl leading-none p-2 hover:bg-white/10 rounded-lg transition-colors",style:{color:"var(--theme-text-secondary)"},"aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"p-6 space-y-3",children:Object.entries(Kr).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:f("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:n.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:n.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Ud(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Ye[e]||Ye.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",Ye[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Ye[e].bgSecondary),bgGrid:r("--theme-bg-card",Ye[e].bgGrid),bgWeekend:r("--theme-bg-hover",Ye[e].bgWeekend),border:r("--theme-border-primary",Ye[e].border),borderLight:r("--theme-border-subtle",Ye[e].borderLight),textPrimary:r("--theme-text-primary",Ye[e].textPrimary),textSecondary:r("--theme-text-secondary",Ye[e].textSecondary),textTertiary:r("--theme-text-tertiary",Ye[e].textTertiary),accent:r("--theme-accent-primary",Ye[e].accent),accentHover:r("--theme-accent-hover",Ye[e].accentHover),accentLight:r("--theme-accent-primary",Ye[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Ye[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Ye[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Ye[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Ye[e].dependency),dependencyHover:r("--theme-border-secondary",Ye[e].dependencyHover),criticalPath:r("--theme-error",Ye[e].criticalPath),criticalPathLight:r("--theme-error",Ye[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Ye[e].today):e==="neutral"?r("--theme-text-primary",Ye[e].today):r("--theme-error",Ye[e].today),todayLight:e==="light"?r("--theme-accent-primary",Ye[e].todayLight):e==="neutral"?r("--theme-text-primary",Ye[e].todayLight):r("--theme-error",Ye[e].todayLight),milestone:r("--theme-warning",Ye[e].milestone),milestoneLight:r("--theme-warning",Ye[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Ye[e].statusTodo),statusInProgress:r("--theme-accent-primary",Ye[e].statusInProgress),statusCompleted:r("--theme-success",Ye[e].statusCompleted),hoverBg:r("--theme-bg-hover",Ye[e].hoverBg),focusRing:r("--theme-accent-primary",Ye[e].focusRing)}}var xn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious",filterAll:"All",filterIncomplete:"Incomplete",filterInProgress:"In Progress",filterCompleted:"Completed",filter:"Filter",filterBy:"Filter by status",filterAllDesc:"Show all tasks",filterIncompleteDesc:"Hide completed tasks",filterInProgressDesc:"Tasks currently being worked on",filterCompletedDesc:"Only show finished tasks",clearFilter:"Clear filter"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Hd={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso",filterAll:"Todas",filterIncomplete:"Sin completar",filterInProgress:"En progreso",filterCompleted:"Completadas",filter:"Filtrar",filterBy:"Filtrar por estado",filterAllDesc:"Mostrar todas las tareas",filterIncompleteDesc:"Ocultar tareas completadas",filterInProgressDesc:"Tareas en las que se est\xE1 trabajando",filterCompletedDesc:"Solo mostrar tareas terminadas",clearFilter:"Limpiar filtro"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},ei={en:xn,es:Hd};function Wd(e){return ei[e]||ei.en}function ti(e,t){let a=Wd(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},contextMenu:{...a.contextMenu,...t.contextMenu},actions:{...a.actions,...t.actions},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},ai:{...a.ai,...t.ai,suggestions:{...a.ai.suggestions,...t.ai?.suggestions},errors:{...a.ai.errors,...t.ai?.errors}},export:{...a.export,...t.export},dateFormat:{...a.dateFormat,...t.dateFormat}}:a}var ho=createContext(xn);function bo(){return useContext(ho)}function bf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[p,m]=useState(false),[i,u]=useState(null),d=useRef(null),g=bo();if(useEffect(()=>{let c=b=>{d.current&&!d.current.contains(b.target)&&m(false);};return p&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[p]),!(t||a||r||o||s||n))return null;let C=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(c=>c.handler),T=async(c,b)=>{if(b){u(c);try{await b();}catch(y){console.error(`Export ${c} failed:`,y);}finally{u(null),m(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>m(!p),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:p?e.accent:e.bgSecondary,border:`1px solid ${p?e.accent:e.borderLight}`,color:p?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:g.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:p?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:p&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:C.map((c,b)=>jsxs(motion.button,{onClick:()=>T(c.id,c.handler),disabled:i!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:b<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:b*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:i===c.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):c.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:c.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:c.description})]})]},c.id))})})})]})}function yf({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let n=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:n?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:n?600:500,zIndex:n?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[n&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function vf({options:e,value:t,onChange:a,theme:r}){return jsx("div",{className:"inline-flex items-center gap-1",children:e.map(o=>{let s=t===o.value;return jsxs(motion.button,{onClick:()=>a(o.value),className:"relative px-3 py-1.5 text-xs transition-all",style:{color:s?r.accent:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:s?600:500},whileHover:{color:s?r.accent:r.textSecondary},whileTap:{scale:.98},children:[jsx("span",{children:o.label}),s&&jsx(motion.div,{layoutId:"timeScaleUnderline",className:"absolute bottom-0 left-1 right-1 h-0.5 rounded-full",style:{backgroundColor:r.accent},transition:{type:"spring",stiffness:400,damping:30}})]},o.value)})})}function xf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();useEffect(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],m=p.find(i=>i.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${m}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:p.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:u<p.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:i.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},i.value)})})})})]})}function kf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();useEffect(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=[{value:"all",label:n.toolbar.filterAll||"All tasks",description:n.toolbar.filterAllDesc||"Show all tasks"},{value:"incomplete",label:n.toolbar.filterIncomplete||"Incomplete only",description:n.toolbar.filterIncompleteDesc||"Hide completed tasks"},{value:"in_progress",label:n.toolbar.filterInProgress||"In progress",description:n.toolbar.filterInProgressDesc||"Tasks currently being worked on"},{value:"completed",label:n.toolbar.filterCompleted||"Completed",description:n.toolbar.filterCompletedDesc||"Only show finished tasks"}],m=t!=="all";return jsxs("div",{ref:s,className:"relative",children:[jsxs(motion.button,{onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:m||r?e.accentLight:e.bgSecondary,border:`1px solid ${m||r?e.accent:e.borderLight}`,color:m||r?e.accent:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{backgroundColor:e.accentLight,borderColor:e.accent,color:e.accent,scale:1.02},whileTap:{scale:.98},children:[jsx(Filter,{className:"w-3.5 h-3.5"}),jsx("span",{children:n.toolbar.filter||"Filter"}),m&&jsx(motion.span,{initial:{scale:0},animate:{scale:1},className:"flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold",style:{backgroundColor:e.accent,color:"#FFFFFF"},children:"1"}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:r?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:r&&jsxs(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-56 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:e.borderLight},children:jsx("span",{className:"text-xs font-medium",style:{color:e.textTertiary},children:n.toolbar.filterBy||"Filter by status"})}),jsx("div",{className:"py-1",children:p.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-start gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"flex items-center justify-center w-4 h-4 rounded border mt-0.5 flex-shrink-0",style:{borderColor:d?e.accent:e.border,backgroundColor:d?e.accent:"transparent"},children:d&&jsx(Check,{className:"w-3 h-3",style:{color:"#FFFFFF"}})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium",style:{color:d?e.accent:e.textPrimary},children:i.label}),jsx("div",{className:"text-[10px] mt-0.5",style:{color:e.textTertiary},children:i.description})]})]},i.value)})}),m&&jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:e.borderLight},children:jsx(motion.button,{onClick:()=>{a("all"),o(false);},className:"w-full text-xs py-1.5 rounded-md",style:{color:e.textTertiary},whileHover:{backgroundColor:e.hoverBg,color:e.textSecondary},children:n.toolbar.clearFilter||"Clear filter"})})]})})]})}function wn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:p,onRowDensityChange:m,showThemeSelector:i=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:g,taskFilter:h="all",onTaskFilterChange:C,onExportPNG:T,onExportPDF:c,onExportExcel:b,onExportCSV:y,onExportJSON:l,onExportMSProject:x}){let v=bo(),S=T||c||b||y||l||x,k=[{value:"day",label:v.toolbar.day},{value:"week",label:v.toolbar.week},{value:"month",label:v.toolbar.month}],w=[{value:"dark",label:"Dark",icon:jsx(Moon,{className:"w-3.5 h-3.5"})},{value:"light",label:"Light",icon:jsx(Sun,{className:"w-3.5 h-3.5"})},{value:"neutral",label:"Zen",icon:jsx(Palette,{className:"w-3.5 h-3.5"})}];return jsxs("div",{className:"h-12 px-4 flex items-center justify-between border-b",style:{backgroundColor:e.bgGrid,borderColor:e.border},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(vf,{options:k,value:t,onChange:R=>a(R),theme:e}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(motion.button,{onClick:()=>o(Math.max(.5,r-.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomOut,{className:"w-3.5 h-3.5"})}),jsxs("div",{className:"px-2 py-0.5 rounded text-xs tabular-nums min-w-[42px] text-center",style:{color:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},children:[Math.round(r*100),"%"]}),jsx(motion.button,{onClick:()=>o(Math.min(2,r+.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomIn,{className:"w-3.5 h-3.5"})})]}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(xf,{theme:e,value:p,onChange:m}),C&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(kf,{theme:e,value:h,onChange:C})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[u&&g&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:g,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||v.toolbar.createTask})]}),(S||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),S&&jsxs(Fragment,{children:[jsx(bf,{theme:e,onExportPNG:T,onExportPDF:c,onExportExcel:b,onExportCSV:y,onExportJSON:l,onExportMSProject:x}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(yf,{options:w,value:s,onChange:R=>n(R),theme:e})]})]})}function Cn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),p=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{p.current&&!p.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);let i=e.filter(u=>u.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:m,onClick:()=>{if(!r&&m.current){let u=m.current.getBoundingClientRect();n({x:u.left,y:u.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(lt,{children:jsx(motion.div,{ref:p,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),i.map(u=>jsxs("button",{onClick:()=>{t(u.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:u.label}),u.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},u.id))]})})})})]})}function yo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[p,m]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,g=8,h=window.innerWidth,C=window.innerHeight,T=t,c=a;t+u+g>h&&(T=t-u,T<g&&(T=g)),a+d+g>C&&(c=C-d-g,c<g&&(c=g)),m({x:T,y:c});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let u=g=>{n.current&&!n.current.contains(g.target)&&o();},d=g=>{g.key==="Escape"&&o();};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let i=u=>u.startsWith("#")&&(u.length===7||u.length===4)?u:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${p.x}px`,top:`${p.y}px`,backgroundColor:i(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(u=>jsxs("div",{children:[u.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{u.disabled||(u.onClick(),o());},disabled:u.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:u.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:u.disabled?"not-allowed":"pointer",opacity:u.disabled?.5:1},onMouseEnter:d=>{u.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[u.icon&&jsx("span",{style:{color:s.textSecondary},children:u.icon}),jsx("span",{className:"flex-1",children:u.label}),u.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},u.id))})})})}var Rt={Edit:jsx(Edit3,{className:"w-4 h-4"}),Pencil:jsx(Pencil,{className:"w-4 h-4"}),Delete:jsx(Trash2,{className:"w-4 h-4"}),Add:jsx(Plus,{className:"w-4 h-4"}),AddSubtask:jsx(Plus,{className:"w-4 h-4"}),Remove:jsx(Minus,{className:"w-4 h-4"}),Link:jsx(Link2,{className:"w-4 h-4"}),Progress:jsx(BarChart3,{className:"w-4 h-4"}),Sort:jsx(ArrowUpDown,{className:"w-4 h-4"}),SortAsc:jsx(ArrowUp,{className:"w-4 h-4"}),SortDesc:jsx(ArrowDown,{className:"w-4 h-4"}),Hide:jsx(EyeOff,{className:"w-4 h-4"}),Show:jsx(Eye,{className:"w-4 h-4"}),Settings:jsx(Settings,{className:"w-4 h-4"}),Split:jsx(Scissors,{className:"w-4 h-4"}),MarkIncomplete:jsx(Circle,{className:"w-4 h-4"}),SetInProgress:jsx(PlayCircle,{className:"w-4 h-4"}),MarkComplete:jsx(CheckCircle2,{className:"w-4 h-4"})};function Zd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:p,onTaskOutdent:m,onTaskRename:i,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:g=true}){let h=useRef(false),C=useCallback(l=>{h.current=l;},[]),T=useCallback(l=>{let x=[],v=S=>{for(let k of S)x.push(k),k.subtasks&&k.subtasks.length>0&&k.isExpanded&&v(k.subtasks);};return v(l),x},[]),c=useCallback(()=>{let l=T(e);for(let x of l)if(t.has(x.id))return x;return null},[e,t,T]),b=useCallback((l,x)=>{let v=T(e);if(v.length===0)return;let S=c();if(!S){a(v[0].id,false);return}let k=v.findIndex(M=>M.id===S.id);if(k===-1)return;let w=l==="up"?k-1:k+1;if(w<0||w>=v.length)return;let R=v[w];a(R.id,x);},[e,c,T,a]),y=useCallback(l=>{if(!g)return;let x=l.target;if(x.tagName==="INPUT"||x.tagName==="TEXTAREA"||x.isContentEditable||h.current){l.key==="Escape"&&(x.blur(),h.current=false);return}let k=navigator.platform.toUpperCase().indexOf("MAC")>=0?l.metaKey:l.ctrlKey,w=Array.from(t),R=c();if(l.key==="ArrowUp"){l.preventDefault(),b("up",l.shiftKey);return}if(l.key==="ArrowDown"){l.preventDefault(),b("down",l.shiftKey);return}if(R&&(l.key==="ArrowRight"||l.key==="ArrowLeft")){R.subtasks&&R.subtasks.length>0&&(l.preventDefault(),(l.key==="ArrowRight"&&!R.isExpanded||l.key==="ArrowLeft"&&R.isExpanded)&&u(R.id));return}if(l.altKey&&(l.key==="ArrowUp"||l.key==="ArrowDown")){w.length>0&&(l.preventDefault(),n(w,l.key==="ArrowUp"?"up":"down"));return}if(l.key==="Tab"&&!l.shiftKey){w.length>0&&(l.preventDefault(),p(w));return}if(l.key==="Tab"&&l.shiftKey){w.length>0&&(l.preventDefault(),m(w));return}if(l.key==="Enter"&&!l.shiftKey&&!k){R&&(l.preventDefault(),r(R.id,"below"));return}if(l.key==="Enter"&&l.shiftKey&&!k){R&&(l.preventDefault(),r(R.id,"above"));return}if(l.key==="Enter"&&k){R&&(l.preventDefault(),d(R.id));return}if(l.key==="F2"){R&&(l.preventDefault(),i(R.id));return}if(l.key==="Delete"||l.key==="Backspace"&&k){w.length>0&&(l.preventDefault(),o(w));return}if(l.key==="d"&&k&&!l.shiftKey){w.length>0&&(l.preventDefault(),s(w));return}},[g,t,c,b,r,o,s,n,p,m,i,u,d]);return useEffect(()=>{if(g)return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y);}},[g,y]),{setIsEditing:C}}function tc(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(g=>{let h=new Set(g);return h.has(d)?h.delete(d):h.add(d),h}),r(d);},[]),n=useCallback((d,g)=>{if(!a){o(d);return}let h=g.indexOf(a),C=g.indexOf(d);if(h===-1||C===-1){o(d);return}let T=Math.min(h,C),c=Math.max(h,C),b=g.slice(T,c+1);t(new Set(b)),r(d);},[a,o]),p=useCallback((d,g,h,C)=>{C?n(d,g):h?s(d):o(d);},[o,s,n]),m=useCallback((d,g)=>{g?t(h=>{let C=new Set(h);return C.add(d),C}):o(d);},[o]),i=useCallback(()=>{t(new Set),r(null);},[]),u=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:p,handleKeyboardSelection:m,clearSelection:i,isTaskSelected:u}}function vo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let p={...r[n],parentId:o,level:s,position:n};t.push(p),p.subtasks&&p.subtasks.length>0&&p.isExpanded&&a(p.subtasks,p.id,s+1);}};return a(e),t}function ac(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ac(a.subtasks,t);if(r)return r}}return null}function ii(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=ii(a.subtasks,t);if(r)return r}return null}function li(e,t){if(t.length===0)return e;let a=vo(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],n=(d,g)=>{let h=[];return {tasks:d.filter(T=>{if(g.has(T.id))return h.push(T),false;if(T.subtasks){let c=n(T.subtasks,g);T.subtasks=c.tasks,h.push(...c.removed);}return true}),removed:h}},p=(d,g,h)=>d.map(C=>C.id===g?{...C,subtasks:[...C.subtasks||[],...h],isExpanded:true}:C.subtasks?{...C,subtasks:p(C.subtasks,g,h)}:C),m=new Set(t),{tasks:i,removed:u}=n(e,m);return p(i,s.id,u)}function di(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=ii(a,r);if(!o)continue;let s=ii(a,o.id),n=(i,u,d)=>{for(let g=0;g<i.length;g++){let h=i[g];if(h.id===u&&h.subtasks){let C=h.subtasks.findIndex(T=>T.id===d);if(C!==-1){let[T]=h.subtasks.splice(C,1);return T}}if(h.subtasks){let C=n(h.subtasks,u,d);if(C)return C}}return null},p=(i,u,d)=>{let g=i.findIndex(h=>h.id===u);if(g!==-1)return i.splice(g+1,0,d),i;for(let h of i)h.subtasks&&p(h.subtasks,u,d);return i},m=n(a,o.id,r);m&&(s&&s.subtasks?p(s.subtasks,o.id,m):p(a,o.id,m));}return a}function ci(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,p,m)=>{let i=n.findIndex(d=>d.id===p);if(i===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,p,m))return true;return false}let u=m==="up"?i-1:i+1;return u<0||u>=n.length?false:([n[i],n[u]]=[n[u],n[i]],true)};return s(r,o,a),r}function mi(e,t){let a=new Set(t),r=o=>o.filter(s=>!a.has(s.id)).map(s=>s.subtasks?{...s,subtasks:r(s.subtasks)}:s);return r(e)}function pi(e,t){let a=[...e];for(let r of t){let o=n=>{let p=n.findIndex(u=>u.id===r);if(p===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let m=n[p],i={...m,id:`${m.id}-copy-${Date.now()}`,name:`${m.name} (Copy)`,subtasks:m.subtasks?s(m.subtasks):void 0};return n.splice(p+1,0,i),true},s=n=>n.map(p=>({...p,id:`${p.id}-copy-${Date.now()}`,subtasks:p.subtasks?s(p.subtasks):void 0}));o(a);}return a}function rc(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},p=m=>{let i=m.findIndex(d=>d.id===t);if(i===-1){for(let d of m)if(d.subtasks&&p(d.subtasks))return true;return false}let u=a==="above"?i:i+1;return m.splice(u,0,n),true};return p(r),{tasks:r,newTask:n}}function ui(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:ui(r.subtasks,t,a)}:r)}function gi(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:gi(a.subtasks,t)}:a)}function fi(e,t){let a=u=>{for(let d of u){if(d.id===t)return d;if(d.subtasks){let g=a(d.subtasks);if(g)return g}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,p=r?.endDate||s,m={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(p),color:r?.color||"#3B82F6"},i=u=>u.map(d=>{if(d.id===t){let g=d.subtasks||[];return {...d,subtasks:[...g,m],isExpanded:true}}return d.subtasks?{...d,subtasks:i(d.subtasks)}:d});return {tasks:i(e),newTask:m}}function oc(e,t,a,r){if(t===a)return e;let o=ac(e,t);if(!o)return e;if(a){let p=(m,i)=>{if(!m.subtasks)return false;for(let u of m.subtasks)if(u.id===i||p(u,i))return true;return false};if(p(o,a))return e}let s=p=>p.filter(m=>m.id!==t).map(m=>m.subtasks&&m.subtasks.length>0?{...m,subtasks:s(m.subtasks)}:m),n=s(e);if(a===null){let p=r!==void 0?r:n.length;n.splice(p,0,{...o,parentId:void 0});}else {let p=m=>m.map(i=>{if(i.id===a){let u=i.subtasks||[],d=r!==void 0?r:u.length,g=[...u];return g.splice(d,0,{...o,parentId:a}),{...i,subtasks:g,isExpanded:true}}return i.subtasks&&i.subtasks.length>0?{...i,subtasks:p(i.subtasks)}:i});n=p(n);}return n}function Dn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:p,onTaskToggle:m,scrollTop:i,columns:u,onToggleColumn:d,onColumnResize:g,onTaskUpdate:h,onTaskIndent:C,onTaskOutdent:T,onTaskMove:c,onMultiTaskDelete:b,onTaskDuplicate:y,onTaskCreate:l,onTaskRename:x,onCreateSubtask:v,onOpenTaskModal:S,onDeleteRequest:k,onTaskReparent:w}){let R=useContext(ho),[M,D]=useState(null),[I,B]=useState(null),[K,te]=useState(""),ie=useRef(null),[de,be]=useState(null),[$,J]=useState(0),[U,G]=useState(0),[A,Q]=useState({isOpen:false,x:0,y:0,type:"header"}),[X,H]=useState(null),[Ce,Me]=useState(null),[Oe,ve]=useState(null),Ke=useRef(0),We=5,et=useRef(false),[vt,Mt]=useState(null),[mt,O]=useState(false),[le,xe]=useState(null),[Pe,ze]=useState(false),at=useRef(null);useEffect(()=>{function _(ae){at.current&&!at.current.contains(ae.target)&&ze(false);}if(Pe)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[Pe]),useEffect(()=>{I&&ie.current&&(ie.current.focus(),ie.current.select());},[I]),useEffect(()=>{if(!de)return;let _=Ee=>{let Ue=Ee.clientX-$,He=U+Ue;g?.(de,He);},ae=()=>{be(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",ae),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",ae),document.body.style.cursor="",document.body.style.userSelect="";}},[de,$,U,g]);let{selectedTaskIds:Et,handleTaskClick:Fe,isTaskSelected:Xt}=tc(),{setIsEditing:Ot}=Zd({tasks:e,selectedTaskIds:Et,onTaskSelect:(_,ae)=>{let Ue=vo(e).map(He=>He.id);Fe(_,Ue,ae||false,false);},onTaskCreate:l||(()=>{}),onTaskDelete:b||(()=>{}),onTaskDuplicate:y||(()=>{}),onTaskMove:c||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:T||(()=>{}),onTaskRename:_=>{let ae=vo(e).find(Ee=>Ee.id===_);ae&&ue(ae);},onTaskToggleExpand:m||(()=>{}),onOpenTaskModal:_=>{let ae=vo(e).find(Ee=>Ee.id===_);ae&&S&&S(ae);},enableKeyboard:true}),Nt=(_,ae=0)=>{let Ee=[];for(let Ue of _)Ee.push({task:Ue,level:ae}),Ue.subtasks&&Ue.subtasks.length>0&&Ue.isExpanded&&Ee.push(...Nt(Ue.subtasks,ae+1));return Ee},ct=Nt(e),Jt=48,Ea=Math.max(ct.length*a,600-Jt),oe=_=>!_.startDate||!_.endDate?"-":`${Math.ceil((_.endDate.getTime()-_.startDate.getTime())/(1e3*60*60*24))}d`,ue=_=>{B(_.id),te(_.name),Ot(true);},pa=_=>{K.trim()&&K!==e.find(ae=>ae.id===_)?.name&&x?.(_,K.trim()),B(null),te(""),Ot(false);},ya=()=>{B(null),te(""),Ot(false);},N=(_,ae)=>{ae.stopPropagation(),v?.(_.id);},ee=(_,ae)=>{ae.preventDefault(),Ke.current=ae.clientY,H(_),et.current=false,O(false),Mt({x:ae.clientX,y:ae.clientY});},se=_=>{if(!X||(Math.abs(_.clientY-Ke.current)>We&&!et.current&&(et.current=true,O(true)),Mt({x:_.clientX,y:_.clientY}),!et.current))return;let Ee=document.querySelectorAll("[data-task-row]"),Ue=null,He=null;Ee.forEach(W=>{let ce=W.getBoundingClientRect(),Ie=W.getAttribute("data-task-row");if(Ie&&Ie!==X&&_.clientY>=ce.top&&_.clientY<=ce.bottom){Ue=Ie;let Dt=_.clientY-ce.top,Je=ce.height;Dt<Je*.25?He="above":Dt>Je*.75?He="below":He="child";}}),Me(Ue),ve(He);},De=()=>{if(et.current&&X&&Ce&&Oe){if(Oe==="child")w?.(X,Ce);else if(Oe==="above"||Oe==="below"){let _=(Ue,He,W=null)=>{for(let ce of Ue){if(ce.id===He)return W;if(ce.subtasks){let Ie=_(ce.subtasks,He,ce.id);if(Ie!==void 0)return Ie}}},ae=_(e,Ce,null),Ee=(Ue,He)=>{let W=Ue.findIndex(ce=>ce.id===He);return Oe==="below"?W+1:W};if(ae===null){let Ue=Ee(e,Ce);w?.(X,null,Ue);}else {let Ue=ct.find(He=>He.task.id===ae)?.task;if(Ue?.subtasks){let He=Ee(Ue.subtasks,Ce);w?.(X,ae,He);}}}}H(null),Me(null),ve(null),Mt(null),et.current=false,O(false);};useEffect(()=>{if(X)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",De),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",De),document.body.style.cursor="",document.body.style.userSelect="";}},[X,Ce,Oe]);let $e=(_,ae,Ee)=>{switch(_.id){case "name":let Ue=I===ae.id,He=M===ae.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Ee*20}px`},children:[w&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:He?1:.3},onMouseDown:q=>ee(ae.id,q),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),ae.subtasks&&ae.subtasks.length>0?jsx("button",{onClick:q=>{q.stopPropagation(),m?.(ae.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:ae.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:ae.color||"#3B82F6",opacity:ae.parentId?.6:1,borderColor:ae.isMilestone?t.accent:"transparent",borderWidth:ae.isMilestone?"2px":"0px"},title:ae.isMilestone?"Milestone":ae.parentId?"Subtask":"Task"})}),Ue?jsx("input",{ref:ie,type:"text",value:K,onChange:q=>te(q.target.value),onKeyDown:q=>{q.key==="Enter"?pa(ae.id):q.key==="Escape"&&ya();},onBlur:()=>pa(ae.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:q=>q.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:ae.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:ae.parentId?"13px":"14px",fontWeight:ae.isMilestone?600:ae.parentId?400:600,letterSpacing:ae.parentId?"0":"-0.01em"},title:ae.name,children:ae.name}),He&&!Ue&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:q=>q.stopPropagation(),children:[jsx("button",{onClick:q=>N(ae,q),className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Create subtask",children:jsx(Plus,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:q=>{q.stopPropagation(),ue(ae);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let ce=_.id==="startDate"?"startDate":"endDate",Ie=ae[ce],Dt=le?.taskId===ae.id&&le?.field===ce,Je=q=>q?(typeof q=="string"?new Date(q):q).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:q=>q.stopPropagation(),children:[jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors hover:bg-white/5",style:{color:t.textSecondary},onClick:q=>{if(Dt)xe(null);else {let Ae=q.currentTarget.getBoundingClientRect();xe({taskId:ae.id,field:ce,month:Ie?typeof Ie=="string"?new Date(Ie):Ie:new Date,position:{top:Ae.bottom+4,left:Ae.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Je(Ie)})]}),Dt&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>xe(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"fixed z-[9999] rounded-xl shadow-2xl overflow-visible flex",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,top:le?.position.top,left:le?.position.left},onClick:q=>q.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let q=new Date,Ae=new Date(q);Ae.setDate(q.getDate()+1);let ot=new Date(q);ot.setDate(q.getDate()+7);let ne=new Date(q);return ne.setDate(q.getDate()+14),[{label:"Hoy",date:q},{label:"Ma\xF1ana",date:Ae},{label:"Pr\xF3xima semana",date:ot},{label:"2 semanas",date:ne}].map((xt,Le)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:At=>At.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:At=>At.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[ce]:xt.date}),xe(null);},children:xt.label},Le))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:q=>q.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:q=>q.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[ce]:void 0}),xe(null);},children:"Borrar"})]}),jsxs("div",{className:"p-2",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("button",{type:"button",onClick:()=>xe(q=>q?{...q,month:new Date(q.month.getFullYear(),q.month.getMonth()-1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})}),jsx("span",{className:"text-xs font-medium",style:{color:t.textPrimary},children:le?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>xe(q=>q?{...q,month:new Date(q.month.getFullYear(),q.month.getMonth()+1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:["D","L","M","M","J","V","S"].map((q,Ae)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:q},Ae))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let q=le?.month||new Date,Ae=q.getFullYear(),ot=q.getMonth(),ne=new Date(Ae,ot,1).getDay(),Re=new Date(Ae,ot+1,0).getDate(),xt=new Date,Le=[];for(let st=ne-1;st>=0;st--)Le.push({day:new Date(Ae,ot,-st).getDate(),date:new Date(Ae,ot-1,new Date(Ae,ot,-st).getDate()),isCurrentMonth:false});for(let st=1;st<=Re;st++)Le.push({day:st,date:new Date(Ae,ot,st),isCurrentMonth:true});let At=42-Le.length;for(let st=1;st<=At;st++)Le.push({day:st,date:new Date(Ae,ot+1,st),isCurrentMonth:false});return Le.map((st,ga)=>{let zt=st.date.toDateString()===xt.toDateString(),kt=(Ie?typeof Ie=="string"?new Date(Ie):Ie:null)?.toDateString()===st.date.toDateString();return jsx("button",{type:"button",className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",style:{color:st.isCurrentMonth?kt?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:kt?"#3B82F6":"transparent",boxShadow:zt&&!kt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{h?.(ae.id,{[ce]:st.date}),xe(null);},children:st.day},ga)})})()})]})]})]}),document.body)]});case "duration":return jsx("div",{className:"flex items-center justify-center w-full",children:jsx("span",{className:"text-xs tabular-nums",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:600},children:oe(ae)})});case "assignees":let va=r.filter(q=>ae.assignees?.some(Ae=>Ae.name===q.name||Ae.initials===q.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(Hr,{assignedUsers:va,availableUsers:r,onChange:q=>{let Ae=q.map(ot=>({id:ot.id,name:ot.name,initials:ot.initials,color:ot.color}));h?.(ae.id,{assignees:Ae.length>0?Ae:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(Xl,{status:ae.status||"todo",onChange:q=>{h?.(ae.id,{status:q,progress:q==="completed"?100:ae.progress});}})});case "progress":return jsxs("div",{className:"flex items-center justify-center gap-2 w-full",children:[jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden max-w-[60px]",style:{backgroundColor:t.bgSecondary},children:jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ae.progress}%`,backgroundColor:ae.progress===100?t.statusCompleted:t.accent}})}),jsxs("span",{className:"text-xs tabular-nums min-w-[35px] text-right",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:[ae.progress,"%"]})]});case "priority":let ua={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},E={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},ye=ua[ae.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(zr,{priority:ye,onChange:q=>{q&&h?.(ae.id,{priority:E[q]||"medium"});}})});default:return null}},tt=_=>[{id:"hide",label:"Hide Column",icon:Rt.Hide,onClick:()=>d(_),disabled:_==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Rt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Rt.SortDesc,onClick:()=>{}}],Ge=_=>_.subtasks&&_.subtasks.length>0?[{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Rt.Add,onClick:()=>{v?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Rt.Delete,onClick:()=>{k?k(_.id,_.name):b?.([_.id]);}}]:[{id:"edit",label:R?.contextMenu?.editTask||"Edit Task",icon:Rt.Pencil,onClick:()=>{n?.(_);}},{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Rt.Add,onClick:()=>{v?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:R?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Rt.MarkIncomplete,onClick:()=>{h?.(_.id,{status:"todo",progress:0});},disabled:_.status==="todo"},{id:"setInProgress",label:R?.contextMenu?.setInProgress||"Set In Progress",icon:Rt.SetInProgress,onClick:()=>{h?.(_.id,{status:"in-progress"});},disabled:_.status==="in-progress"},{id:"markComplete",label:R?.contextMenu?.markComplete||"Mark Complete",icon:Rt.MarkComplete,onClick:()=>{h?.(_.id,{status:"completed",progress:100});},disabled:_.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:R?.contextMenu?.splitTask||"Split Task",icon:Rt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Rt.Delete,onClick:()=>{k?k(_.id,_.name):b?.([_.id]);}}],Be=u.filter(_=>_.visible),rt=Be.reduce((_,ae)=>_+ae.width,0);return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:rt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${Jt}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:Be.map((_,ae)=>{let Ee=ae===Be.length-1,Ue=_.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Ue?"":"justify-center"}`,style:{width:`${_.width}px`,minWidth:`${_.minWidth??(Ue?200:60)}px`,maxWidth:`${_.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Ee?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:He=>{He.preventDefault(),Q({isOpen:true,x:He.clientX,y:He.clientY,type:"header",columnId:_.id});},onMouseEnter:He=>{He.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:He=>{He.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:_.label,children:_.label}),_.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:de===_.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:He=>{He.preventDefault(),He.stopPropagation(),be(_.id),J(He.clientX),G(_.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},_.id)})}),jsxs("div",{className:"flex items-center gap-1 px-2",style:{position:"sticky",right:0,height:"100%",backgroundColor:t.bgGrid,zIndex:5},children:[jsx(Cn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>ze(!Pe),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Pe&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:_=>_.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>ze(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",style:{minHeight:Ea},children:ct.map(({task:_,level:ae},Ee)=>{let Ue=Xt(_.id),He=Ce===_.id,W=He&&Oe==="above",ce=He&&Oe==="below",Ie=He&&Oe==="child",Dt={};return Ie&&(Dt.backgroundColor=`${t.accent}15`,Dt.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":_.id,className:`flex items-center cursor-pointer group ${X===_.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Ue?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Ue?t.accentLight:Ie?`${t.accent}15`:Ee%2===0?t.bgPrimary:t.bgGrid,...Dt},onMouseEnter:()=>D(_.id),onMouseLeave:()=>D(null),onClick:Je=>{let ua=vo(e).map(q=>q.id),ye=navigator.platform.toUpperCase().indexOf("MAC")>=0?Je.metaKey:Je.ctrlKey;Fe(_.id,ua,ye,Je.shiftKey),s?.(_);},onDoubleClick:Je=>{Je.stopPropagation(),n?.(_);},onContextMenu:Je=>{Je.preventDefault(),Q({isOpen:true,x:Je.clientX,y:Je.clientY,type:"task",task:_}),p?.(_,Je);},whileHover:{backgroundColor:Ue?t.accentLight:t.hoverBg},children:[W&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ce&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Be.map((Je,va)=>{let ua=va===Be.length-1,E=Je.id==="name";return jsx("div",{className:`px-4 flex items-center ${E?"justify-start":"justify-center"}`,style:{width:`${Je.width}px`,minWidth:`${Je.minWidth??(E?200:60)}px`,maxWidth:`${Je.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:ua?"none":`1px solid ${M===_.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:$e(Je,_,E?ae:0)},`${_.id}-${Je.id}`)})]},_.id)})}),jsx(yo,{isOpen:A.isOpen,x:A.x,y:A.y,items:A.type==="header"&&A.columnId?tt(A.columnId):A.type==="task"&&A.task?Ge(A.task):[],onClose:()=>Q({...A,isOpen:false}),theme:t}),mt&&vt&&X&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:vt.x+12,top:vt.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let _=ct.find(ae=>ae.task.id===X)?.task;return _?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:_.name})}):null})()}),document.body)]})}function dc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,p]=useState(e),[m,i]=useState(t),[u,d]=useState(null),[g,h]=useState(null),[C,T]=useState(null),[c,b]=useState(null),[y,l]=useState(0),[x,v]=useState(0),[S,k]=useState(null),[w,R]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:p,ghostWidth:m,setGhostWidth:i,connectionLine:u,setConnectionLine:d,hoveredTaskId:g,setHoveredTaskId:h,activeZone:C,setActiveZone:T,draggedSegmentIndex:c,setDraggedSegmentIndex:b,draggedSegmentStartX:y,setDraggedSegmentStartX:l,segmentDragOffsetX:x,setSegmentDragOffsetX:v,hoveredSegmentIndex:S,setHoveredSegmentIndex:k,isHovered:w,setIsHovered:R,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(K,te)=>{r("none"),d(null),h(null),p(K),i(te),v(0),b(null),l(0);}}}function Sn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:p,onClick:m,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:h=[],onDragMove:C,onHoverChange:T}){let c=dc(t,r),b=useRef(null),{dragMode:y,setDragMode:l,dragOffset:x,setDragOffset:v,ghostX:S,setGhostX:k,ghostWidth:w,setGhostWidth:R,connectionLine:M,setConnectionLine:D,hoveredTaskId:I,setHoveredTaskId:B,activeZone:K,setActiveZone:te,draggedSegmentIndex:ie,setDraggedSegmentIndex:de,draggedSegmentStartX:be,setDraggedSegmentStartX:$,segmentDragOffsetX:J,setSegmentDragOffsetX:U,hoveredSegmentIndex:G,setHoveredSegmentIndex:A,isHovered:Q,setIsHovered:X,isDragging:H,isResizing:Ce,isConnecting:Me,resetDragState:Oe}=c,ve=32,Ke=8,We=e.endDate&&e.endDate<new Date&&e.progress<100,et=e.isCriticalPath,vt=o.name==="neutral"||o.today==="#1C1917",Mt=e.status==="completed"||e.progress===100,mt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},le=e.isCriticalPath||We?"#DC2626":e.color?e.color:e.priority&&mt[e.priority]?mt[e.priority]:o.taskBarPrimary,Pe=(N=>N>=80?20:N>=60?15:N>=50?12:10)(r),ze=r<50,at=r<40;useEffect(()=>{if(T)if(Q&&!H&&!e.segments){let N=a<100;T({task:e,x:t,y:a,width:r,height:ve,showBelow:N});}else T(null);},[Q,H,e,t,a,r,ve,T]);let Et=N=>N.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Fe=()=>{let N=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${N} day${N!==1?"s":""}`},Xt=N=>Math.round(N/s)*s,Ot=N=>{let ee=Math.round(N/s),se=new Date(n);return se.setDate(se.getDate()+ee),se},Nt=(N,ee)=>{for(let se of h){if(se.id===e.id)continue;let De=5;if(N>=se.x-De&&N<=se.x+se.width+De&&ee>=se.y-De&&ee<=se.y+se.height+De)return se.id}return null},ct=useCallback((N,ee,se)=>{N.preventDefault(),N.stopPropagation();let De=b.current?.ownerSVGElement;if(!De)return;let $e=De.createSVGPoint();$e.x=N.clientX,$e.y=N.clientY;let tt=$e.matrixTransform(De.getScreenCTM()?.inverse()),Ge=se!==void 0?se:t,Be=ee;if(!Be){let rt=tt.x-Ge;N.shiftKey?(Be="connect",D({x:t+r,y:a+ve/2})):N.ctrlKey||N.metaKey?Be="move":N.altKey?Be=rt<r/2?"resize-start":"resize-end":at?rt<r/2?Be="move":Be="resize-end":ze?rt<=Pe/2?Be="resize-start":rt>=r-Pe/2?Be="resize-end":Be="move":rt<=Pe?Be="resize-start":rt>=r-Pe?Be="resize-end":Be="move";}l(Be),X(false),te(null),Be==="move"?v(tt.x-Ge):Be==="connect"?D({x:t+r,y:a+ve/2}):v(0),k(Ge),R(r);},[t,r,a,ve]),Jt=useCallback(N=>{if(y==="none")return;let ee=b.current?.ownerSVGElement;if(!ee)return;let se=ee.createSVGPoint();se.x=N.clientX,se.y=N.clientY;let De=se.matrixTransform(ee.getScreenCTM()?.inverse());if(y==="connect"){D({x:De.x,y:De.y});let $e=Nt(De.x,De.y);B($e);}else if(y==="move"){let $e=De.x-x,tt=Xt($e);k(tt),R(r);let Ge=Math.round((tt-t)/s);if(C?.(e.id,Ge,true),e.segments&&e.segments.length>0&&ie!==null){let Be=tt-be;U(Be);}}else if(y==="resize-start"){let $e=De.x,tt=Xt($e),Ge=t+r-tt;Ge>=s&&(k(tt),R(Ge));}else if(y==="resize-end"){let $e=De.x,Ge=Xt($e)-t;Ge>=s&&R(Ge);}},[y,t,r,s,x,e,Xt,ie,be,Nt,B,D,k,R,U,C]),Ea=useCallback(()=>{if(y!=="none"){if(y==="connect")I&&g&&g(e,I),D(null),B(null);else {let N=e.endDate.getTime()-e.startDate.getTime(),ee,se,De=true;if(y==="move"){if(ee=Ot(S),se=new Date(ee.getTime()+N),e.segments&&e.segments.length>0&&ie!==null){let $e=Math.round(J/s),tt=e.segments.map((_,ae)=>{if(ae===ie){let Ee=new Date(_.startDate),Ue=new Date(_.endDate);return Ee.setDate(Ee.getDate()+$e),Ue.setDate(Ue.getDate()+$e),{startDate:Ee,endDate:Ue}}return _}),Ge=tt.flatMap(_=>[_.startDate,_.endDate]),Be=new Date(Math.min(...Ge.map(_=>_.getTime()))),rt=new Date(Math.max(...Ge.map(_=>_.getTime())));d?.({...e,segments:tt},Be,rt),Oe(t,r);return}}else y==="resize-start"?(ee=Ot(S),se=e.endDate,ee>se&&(console.warn("Invalid date range: start date must be before or equal to end date"),De=false)):y==="resize-end"?(ee=e.startDate,se=Ot(S+w),se<ee&&(console.warn("Invalid date range: end date must be after or equal to start date"),De=false)):De=false;De&&ee&&se&&(se.getTime()<ee.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,ee,se));}C?.(e.id,0,false),Oe(t,r);}},[y,S,w,e,d,I,g,t,r,s,Ot,J,ie,Oe,C]);useEffect(()=>{if(y==="none")return;let N=se=>{Jt(se);},ee=()=>{Ea();};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",ee),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",ee);}},[y,Jt,Ea]);let oe=H&&!Me?S:t,ue=H&&!Me?w:r,pa=p.taskClass(e);return jsxs("g",{ref:b,onClick:()=>!H&&m?.(e),onDoubleClick:N=>{H||(N.stopPropagation(),i?.(e));},onContextMenu:N=>{N.preventDefault(),u?.(e,N);},onMouseEnter:()=>!H&&X(true),onMouseLeave:()=>{H||(X(false),te(null));},children:[jsx("rect",{x:t,y:a,width:r+24,height:ve,fill:"transparent",style:{pointerEvents:"all"}}),Q&&!H&&!ze&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Pe,height:ve,fill:K==="resize-start"?o.accent:"transparent",opacity:K==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-start"),onMouseDown:N=>ct(N,"resize-start")}),jsx("rect",{x:t+Pe,y:a,width:r-Pe*2,height:ve,fill:K==="move"?o.accent:"transparent",opacity:K==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:N=>ct(N,"move")}),jsx("rect",{x:t+r-Pe,y:a,width:Pe,height:ve,fill:K==="resize-end"?o.accent:"transparent",opacity:K==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:N=>ct(N,"resize-end")})]}),Q&&!H&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ve,fill:K==="move"?o.accent:"transparent",opacity:K==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:N=>ct(N,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ve,fill:K==="resize-end"?o.accent:"transparent",opacity:K==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:N=>ct(N,"resize-end")}),Q&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ve-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),H&&!Me&&!e.segments&&jsx(motion.rect,{x:S,y:a,width:w,height:ve,rx:Ke,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:oe,y:a,width:ue,height:ve,rx:Ke,fill:le,"data-task-class":pa,initial:{opacity:0,scale:.95},animate:{opacity:H&&!Me?.15:e.parentId?.6:Q?.9:.8,scale:Q&&!H?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:N=>ct(N),style:{cursor:H?Me?"crosshair":Ce?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:oe,y:a,width:ue*(e.progress/100),height:ve,rx:Ke,fill:le,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((N,ee)=>{let se=(N.startDate.getTime()-n.getTime())/864e5*s,$e=(N.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-se+s,tt=H&&y==="move"&&ie===ee,Ge=G===ee,Be=tt?se+J:se;return jsxs("g",{onMouseEnter:()=>!H&&A(ee),onMouseLeave:()=>!H&&A(null),children:[jsx(motion.rect,{x:Be,y:a,width:$e,height:ve,rx:Ke,fill:le,initial:{opacity:0,scale:.95},animate:{opacity:tt||e.parentId?.6:Ge?.9:.8,scale:Ge&&!H?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:rt=>{rt.stopPropagation(),de(ee),$(se),ct(rt,void 0,se);},style:{cursor:H?Me?"crosshair":Ce?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Be,y:a,width:$e*(e.progress/100),height:ve,rx:Ke,fill:le,opacity:1,style:{pointerEvents:"none"}})]},`segment-${ee}`)}),vt&&(We||et)&&!e.segments&&jsxs(Fragment,{children:[et&&!We&&jsx("rect",{x:oe,y:a,width:ue,height:ve,rx:Ke,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),We&&jsx("rect",{x:oe,y:a,width:ue,height:ve,rx:Ke,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ue>60&&!e.segments&&(()=>{let N=p.taskLabel(e),ee=typeof N=="string"?N:e.name,se=ee.length>Math.floor(ue/8)?`${ee.substring(0,Math.floor(ue/8))}...`:ee;return jsx("text",{x:oe+12,y:a+ve/2,dominantBaseline:"middle",fill:Mt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Mt?"line-through":"none"},children:se})})(),ue>100&&e.progress>0&&e.progress<100&&!H&&!e.segments&&jsxs("text",{x:oe+ue-12,y:a+ve/2,dominantBaseline:"middle",textAnchor:"end",fill:"rgba(255, 255, 255, 0.9)",fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:[e.progress,"%"]}),e.status&&ue>80&&!H&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:oe+ue-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:oe+ue-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(Q||Ce)&&!Me&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{children:[jsx("rect",{x:oe-2,y:a,width:16,height:ve,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>te("resize-start"),onMouseLeave:()=>te(null),onMouseDown:N=>{N.stopPropagation(),ct(N,"resize-start");}}),jsx(motion.rect,{x:oe+4,y:a+8,width:3,height:ve-16,rx:1.5,fill:K==="resize-start"||y==="resize-start"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]}),jsxs("g",{children:[jsx("rect",{x:oe+ue-14,y:a,width:16,height:ve,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>te("resize-end"),onMouseLeave:()=>te(null),onMouseDown:N=>{N.stopPropagation(),ct(N,"resize-end");}}),jsx(motion.rect,{x:oe+ue-7,y:a+8,width:3,height:ve-16,rx:1.5,fill:K==="resize-end"||y==="resize-end"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]})]}),jsx(AnimatePresence,{children:Q&&!H&&!e.segments&&jsxs(motion.g,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx("circle",{cx:t+r+10,cy:a+ve/2,r:10,fill:"transparent",style:{cursor:"crosshair"},onMouseEnter:()=>te("connect"),onMouseLeave:()=>te(null),onMouseDown:N=>{N.stopPropagation(),ct(N,"connect");}}),jsx(motion.circle,{cx:t+r+10,cy:a+ve/2,r:4,fill:o.accent,stroke:"#FFFFFF",strokeWidth:1.5,style:{pointerEvents:"none"},initial:{scale:0},animate:{scale:K==="connect"?1.4:1},exit:{scale:0},transition:{duration:.15,type:"spring",stiffness:500,damping:30}})]})}),Me&&M&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ve/2,x2:M.x,y2:M.y,stroke:I?o.statusCompleted:o.accent,strokeWidth:I?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:I?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:M.x,cy:M.y,r:I?8:6,fill:I?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),I&&jsx(motion.text,{x:M.x+15,y:M.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:M.x+10},animate:{opacity:1,x:M.x+15},transition:{duration:.2},children:"Connect"})]}),(Q||H)&&!Me&&!e.segments&&jsx(motion.rect,{x:oe-2,y:a-2,width:ue+4,height:ve+4,rx:Ke+2,fill:"none",stroke:H?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:H?.6:.4,initial:{opacity:0},animate:{opacity:H?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Ce&&jsxs(Fragment,{children:[jsx("line",{x1:S,y1:0,x2:S,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:S+w,y1:0,x2:S+w,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:Q&&!H&&!e.segments&&!T&&(()=>{let se=a<100,De=se?a+ve+13:a-82-13,$e=se?`M ${oe+ue/2-6} ${a+ve+3} L ${oe+ue/2} ${a+ve+13} L ${oe+ue/2+6} ${a+ve+3}`:`M ${oe+ue/2-6} ${a-13} L ${oe+ue/2} ${a-3} L ${oe+ue/2+6} ${a-13}`,tt=De+22,Ge=De+40,Be=De+55,rt=De+70,_=se?De+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:se?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:se?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:$e,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:oe+ue/2-120,y:De,width:240,height:82,rx:8,fill:o.bgSecondary,stroke:o.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:oe+ue/2,y:tt,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:oe+ue/2-110,y:Ge,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:oe+ue/2-70,y:Ge,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Et(e.startDate)}),jsx("text",{x:oe+ue/2-110,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:oe+ue/2-70,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Et(e.endDate)}),jsx("text",{x:oe+ue/2+10,y:Ge,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:oe+ue/2+65,y:Ge,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Fe()}),jsx("text",{x:oe+ue/2+10,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:oe+ue/2+65,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:oe+ue/2-110,y:rt,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:oe+ue/2-50,y:rt,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(ae=>ae.name).join(", ").substring(0,30),e.assignees.map(ae=>ae.name).join(", ").length>30?"...":""]})]}),!se&&jsx("text",{x:oe+ue/2,y:_,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":ze?"Drag to move \u2022 Hold ALT + drag edge to resize":"Drag edges to resize \u2022 Drag center to move \u2022 Click \u26AB to link"})]})})()})]})}function pc({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:p}=e,m=82,i=13,u=p?o+n+i:o-m-i,d=p?`M ${r+s/2-6} ${o+n+3} L ${r+s/2} ${o+n+13} L ${r+s/2+6} ${o+n+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,g=u+22,h=u+40,C=u+55,T=u+70,c=x=>x.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let x=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${x} day${x!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:p?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:p?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:u,width:240,height:m,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:g,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?c(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?c(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:T,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:T,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(x=>x.name).join(", ").substring(0,30),a.assignees.map(x=>x.name).join(", ").length>30?"...":""]})]})]})})}function Mn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,lineStyle:n="curved",isHoverLayer:p=false}){let[m,i]=useState(false),[u,d]=useState(null),g=r-t,h=g>0,C=Math.abs(g)<5,c=5,b=20,y=!C&&a<=e,l,x;if(C)if(x=(e+a)/2,n==="squared")l=`M ${e} ${t} L ${a} ${r}`;else {let ie=Math.min(Math.abs(a-e)/3,30);l=`M ${e} ${t} C ${e+ie} ${t}, ${a-ie} ${r}, ${a} ${r}`;}else if(x=a-b,y){let de=e+15,be=a-b,$=h?t+20:t-20;x=be,n==="squared"?l=`M ${e} ${t} L ${de} ${t} L ${de} ${$} L ${be} ${$} L ${be} ${r} L ${a} ${r}`:h?l=`M ${e} ${t} L ${de-c} ${t} Q ${de} ${t} ${de} ${t+c} L ${de} ${$-c} Q ${de} ${$} ${de-c} ${$} L ${be+c} ${$} Q ${be} ${$} ${be} ${$+c} L ${be} ${r-c} Q ${be} ${r} ${be+c} ${r} L ${a} ${r}`:l=`M ${e} ${t} L ${de-c} ${t} Q ${de} ${t} ${de} ${t-c} L ${de} ${$+c} Q ${de} ${$} ${de-c} ${$} L ${be+c} ${$} Q ${be} ${$} ${be} ${$-c} L ${be} ${r+c} Q ${be} ${r} ${be+c} ${r} L ${a} ${r}`;}else n==="squared"?l=`M ${e} ${t} L ${x} ${t} L ${x} ${r} L ${a} ${r}`:h?l=`M ${e} ${t} L ${x-c} ${t} Q ${x} ${t} ${x} ${t+c} L ${x} ${r-c} Q ${x} ${r} ${x+c} ${r} L ${a} ${r}`:l=`M ${e} ${t} L ${x-c} ${t} Q ${x} ${t} ${x} ${t-c} L ${x} ${r+c} Q ${x} ${r} ${x+c} ${r} L ${a} ${r}`;let v=5,S=`M ${a} ${r} L ${a-v} ${r-v*.5} M ${a} ${r} L ${a-v} ${r+v*.5}`,k=o.dependency,w=o.dependencyHover||k,R="#f87171",M="rgba(248, 113, 113, 0.15)",D=x,I=(t+r)/2;if(u)if(C)D=Math.max(e+10,Math.min(a-10,u.x)),I=t;else if(y){let ie=e+15,de=a-b,be=h?t+20:t-20,$=[[e,t,ie,t],[ie,t,ie,be],[ie,be,de,be],[de,be,de,r],[de,r,a,r]],J=1/0,U={x:D,y:I};for(let G of $){let A=B(u.x,u.y,G[0],G[1],G[2],G[3]),Q=Math.hypot(u.x-A.x,u.y-A.y);Q<J&&(J=Q,U=A);}D=U.x,I=U.y;}else {let ie=[[e,t,x,t],[x,t,x,r],[x,r,a,r]],de=1/0,be={x:D,y:I};for(let $ of ie){let J=B(u.x,u.y,$[0],$[1],$[2],$[3]),U=Math.hypot(u.x-J.x,u.y-J.y);U<de&&(de=U,be=J);}D=be.x,I=be.y;}function B(ie,de,be,$,J,U){let G=J-be,A=U-$,Q=G*G+A*A;if(Q===0)return {x:be,y:$};let X=((ie-be)*G+(de-$)*A)/Q;return X=Math.max(0,Math.min(1,X)),{x:be+X*G,y:$+X*A}}let K=ie=>{let de=ie.currentTarget.ownerSVGElement;if(!de)return;let be=de.getBoundingClientRect();d({x:ie.clientX-be.left,y:ie.clientY-be.top});},te=()=>{i(false),d(null);};return p?jsxs("g",{onMouseLeave:te,onMouseMove:K,children:[jsx("path",{d:l,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("path",{d:l,fill:"none",stroke:w,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:l,fill:"none",stroke:w,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:S,fill:"none",stroke:w,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:a,cy:r,r:4,fill:w,opacity:.9,style:{pointerEvents:"none"}}),s&&jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ie=>{ie.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:D,cy:I,r:9,fill:M,stroke:R,strokeWidth:1.5}),jsx("line",{x1:D-3,y1:I-3,x2:D+3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:D+3,y1:I-3,x2:D-3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"})]})]}):jsxs("g",{onMouseEnter:()=>i(true),onMouseLeave:te,onMouseMove:K,style:{cursor:s?"pointer":"default"},children:[jsx("path",{d:l,fill:"none",stroke:"transparent",strokeWidth:16,strokeLinecap:"round",style:{cursor:s?"pointer":"default"}}),jsx(motion.path,{d:l,fill:"none",stroke:m?w:k,strokeWidth:m?2.5:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2}}}),jsx(motion.path,{d:S,fill:"none",stroke:m?w:k,strokeWidth:m?2.5:2,strokeLinecap:"round",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.3}}),jsx(motion.circle,{cx:a,cy:r,r:m?4:3,fill:m?w:k,initial:{scale:0},animate:{scale:1},transition:{delay:.3,duration:.15}}),m&&s&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.15},onClick:ie=>{ie.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:D,cy:I,r:9,fill:M,stroke:R,strokeWidth:1.5}),jsx("line",{x1:D-3,y1:I-3,x2:D+3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:D+3,y1:I-3,x2:D-3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"})]})]})}function Fn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),p=16,m=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:p+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-p/2,y:a+16-p/2,width:p,height:p,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(p+4)/2,y:a+16-(p+4)/2,width:p+4,height:p+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:m(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var fe={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=i=>{i.forEach(u=>{u.dependencies&&r.set(u.id,u.dependencies),u.subtasks&&o(u.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,p=new Set,m=i=>{if(!n.has(i)){n.add(i),p.add(i);let u=r.get(i)||[];for(let d of u){if(!n.has(d)&&m(d))return true;if(p.has(d))return true}}return p.delete(i),false};return m(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=fe.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=fe.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=fe.findTaskById(e,o);if(s)a.unshift(s),o=s.parentId;else break}return a},exportToJSON:e=>JSON.stringify(e,null,2),importFromJSON:e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw new Error("Invalid JSON: expected an array of tasks");return t.forEach((a,r)=>{if(!a.id||!a.name)throw new Error(`Invalid task at index ${r}: missing required fields (id, name)`)}),t}catch(t){throw new Error(`Failed to import tasks: ${t instanceof Error?t.message:"Unknown error"}`)}},exportToCSV:e=>{let t=fe.flattenTasks(e),r=[["ID","Name","Start Date","End Date","Progress","Status","Dependencies"].join(",")];return t.forEach(o=>{let s=[o.id,`"${o.name.replace(/"/g,'""')}"`,o.startDate?o.startDate.toISOString().split("T")[0]:"",o.endDate?o.endDate.toISOString().split("T")[0]:"",o.progress.toString(),o.status||"",o.dependencies?.join(";")||""];r.push(s.join(","));}),r.join(`
111
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function Vs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),n=useRef(null);useEffect(()=>{function i(u){s.current&&!s.current.contains(u.target)&&n.current&&!n.current.contains(u.target)&&o(false);}if(r)return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=i=>{t(i),o(false);},m=e.reduce((i,u)=>{let d=u.category||"Other";return i[d]||(i[d]=[]),i[d].push(u),i},{});return jsxs("div",{className:f("relative inline-block",a),children:[jsxs("button",{ref:n,onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-2 rounded-lg border transition-all text-sm font-medium shadow-lg",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-primary)"},onMouseEnter:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",i.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",i.currentTarget.style.borderColor="var(--theme-border-primary)";},title:"Create from template",children:[jsx("span",{className:"text-base leading-none",children:"\u{1F4CB}"}),jsx("span",{children:"Templates"}),jsx("svg",{className:f("w-4 h-4 transition-transform",r&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxs("div",{ref:s,className:"absolute top-full left-0 mt-2 min-w-[320px] max-w-[400px] rounded-xl backdrop-blur-xl border shadow-2xl z-50 overflow-hidden max-h-[500px] overflow-y-auto",style:{backgroundColor:"var(--theme-bg-primary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-4 py-3 border-b sticky top-0 backdrop-blur-sm",style:{borderColor:"var(--theme-border-primary)",backgroundColor:"var(--theme-bg-secondary)"},children:[jsx("span",{className:"text-sm font-bold uppercase tracking-wider",style:{color:"var(--theme-text-primary)"},children:"Card Templates"}),jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:"Quick start with pre-configured cards"})]}),Object.entries(m).map(([i,u])=>jsxs("div",{className:"py-2",children:[jsx("div",{className:"px-4 py-2",children:jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--theme-text-secondary)"},children:i})}),jsx("div",{children:u.map(d=>jsxs("button",{onClick:()=>p(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},i)),e.length===0&&jsx("div",{className:"px-4 py-8 text-center",style:{color:"var(--theme-text-tertiary)"},children:jsx("p",{className:"text-sm",children:"No templates available"})})]})]})}function Ks({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[n,p]=useState("export"),[m,i]=useState("json"),[u,d]=useState(null),g=useRef(null);if(!t)return null;let h=async()=>{let T=o?.current||void 0,c=await Sl(e,m,T);El(c,m);},C=async T=>{let c=T.target.files?.[0];if(c){try{let b=await Al(c),y=c.name.endsWith(".json")?"json":"csv",l=Ml(b,y);d(l),l.success&&r&&r(l,b);}catch(b){d({success:false,errors:[`Failed to read file: ${b instanceof Error?b.message:"Unknown error"}`]});}g.current&&(g.current.value="");}};return jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",s),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a}),jsxs("div",{className:"relative bg-gradient-to-br from-gray-900/95 to-gray-800/95 backdrop-blur-xl rounded-2xl border border-white/20 shadow-2xl max-w-2xl w-full mx-4",children:[jsxs("div",{className:"px-6 py-5 border-b border-white/10 flex items-center justify-between",children:[jsxs("div",{children:[jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[jsx("span",{className:"text-3xl",children:"\u{1F4E6}"}),"Export / Import"]}),jsx("p",{className:"text-sm text-white/60 mt-1",children:"Transfer your board data"})]}),jsx("button",{onClick:a,className:"text-white/50 hover:text-white transition-colors text-2xl leading-none p-2 hover:bg-white/10 rounded-lg","aria-label":"Close",children:"\xD7"})]}),jsxs("div",{className:"flex border-b border-white/10",children:[jsx("button",{onClick:()=>p("export"),className:f("flex-1 px-6 py-4 font-semibold transition-colors",n==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>p("import"),className:f("flex-1 px-6 py-4 font-semibold transition-colors",n==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[n==="export"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Select format"}),jsx("div",{className:"grid grid-cols-3 gap-3",children:["json","csv","pdf"].map(T=>jsxs("button",{onClick:()=>i(T),className:f("p-4 rounded-lg border-2 transition-all text-center",m===T?"border-blue-500 bg-blue-500/20 text-white":"border-white/20 hover:border-white/40 text-white/70 hover:text-white"),children:[jsxs("div",{className:"text-2xl mb-2",children:[T==="json"&&"\u{1F4C4}",T==="csv"&&"\u{1F4CA}",T==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:T})]},T))})]}),jsxs("div",{className:"bg-white/5 rounded-lg p-4",children:[jsx("h3",{className:"text-sm font-semibold text-white/90 mb-2",children:"Preview"}),jsxs("div",{className:"text-xs text-white/60",children:[jsxs("div",{children:["Board: ",jsx("span",{className:"text-white/90",children:e.title||"Untitled"})]}),jsxs("div",{children:["Columns: ",jsx("span",{className:"text-white/90",children:e.columns.length})]}),jsxs("div",{children:["Cards: ",jsx("span",{className:"text-white/90",children:e.cards.length})]})]})]}),jsx("button",{onClick:h,className:"w-full py-3 px-4 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-500 hover:to-blue-600 text-white font-semibold rounded-lg transition-all shadow-lg shadow-blue-500/20",children:"Export Board"})]}),n==="import"&&jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-sm font-semibold text-white/90 mb-3",children:"Upload file"}),jsx("input",{ref:g,type:"file",accept:".json,.csv",onChange:C,className:"hidden"}),jsxs("button",{onClick:()=>g.current?.click(),className:"w-full py-12 px-4 border-2 border-dashed border-white/30 hover:border-white/50 rounded-lg transition-colors text-white/70 hover:text-white",children:[jsx("div",{className:"text-5xl mb-3",children:"\u{1F4C1}"}),jsx("div",{className:"font-semibold mb-1",children:"Click to select file"}),jsx("div",{className:"text-xs text-white/50",children:"Supports JSON and CSV files"})]})]}),u&&jsxs("div",{className:f("p-4 rounded-lg",u.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:f("font-semibold mb-2",u.success?"text-green-400":"text-red-400"),children:u.success?"\u2713 Import Successful":"\u2717 Import Failed"}),u.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",u.cardsImported]}),jsxs("div",{children:["Columns imported: ",u.columnsImported]})]}),u.errors&&u.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:u.errors.map((T,c)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",T]},c))})]})]})]})]})]})}var Hg=["URGENT","HIGH","MEDIUM","LOW"],Wg=[{value:"none",label:"None"},{value:"created",label:"Date Created"},{value:"priority",label:"Priority"},{value:"dueDate",label:"Due Date"},{value:"title",label:"Title"},{value:"estimate",label:"Estimate"}],Gg=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Ys({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:n,onFilterHighPriority:p,availableUsers:m=[],availableLabels:i=[],availableColumns:u=[],showQuickFilters:d=true,compact:g=false,groupBy:h="none",onGroupByChange:C}){let[T,c]=useState(true),b=useCallback(S=>{a({search:S.target.value});},[a]),y=useCallback(S=>{a({dateFilter:S.target.value});},[a]),l=useCallback(S=>{r({by:S.target.value});},[r]),x=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),v=e.search||e.dateFilter!=="all"||e.priorities.length>0||e.assignees.length>0||e.labels.length>0||t.by!=="none";return jsxs("div",{className:`filter-bar ${g?"filter-bar--compact":""} ${T?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>c(!T),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:T?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:T?"rotate(-90deg)":"rotate(0deg)",transition:"transform 0.2s",color:"var(--theme-text-secondary)"},children:jsx("polyline",{points:"6 9 12 15 18 9"})}),jsx("span",{className:"filter-bar__label",style:{fontWeight:500,fontSize:"0.875rem",color:"var(--theme-text-primary)"},children:"Filters & Grouping"}),v&&jsxs("span",{style:{color:"var(--theme-accent-primary)",fontSize:"0.75rem",fontWeight:600},children:["(",[e.search&&"search",e.dateFilter!=="all"&&"date",e.priorities.length>0&&"priority",e.assignees.length>0&&"assignee",e.labels.length>0&&"label",t.by!=="none"&&"sort"].filter(Boolean).length," active)"]})]}),!T&&jsxs("div",{className:"filter-bar__content",children:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),n&&jsx("button",{onClick:n,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),p&&jsx("button",{onClick:p,className:"filter-bar__quick-btn",title:"Show high priority tasks",children:"High Priority"})]}),jsxs("div",{className:"filter-bar__main",children:[jsx("div",{className:"filter-bar__field",children:jsx("input",{type:"text",placeholder:"Search tasks...",value:e.search,onChange:b,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:y,className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Dates"}),jsx("option",{value:"overdue",children:"Overdue"}),jsx("option",{value:"today",children:"Today"}),jsx("option",{value:"this-week",children:"This Week"})]})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.priorities[0]||"all",onChange:S=>{let k=S.target.value;a({priorities:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Hg.map(S=>jsx("option",{value:S,children:S},S))]})}),m.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:S=>{let k=S.target.value;a({assignees:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),m.map(S=>jsx("option",{value:S.id,children:S.name},S.id))]})}),i.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:S=>{let k=S.target.value;a({labels:k==="all"?[]:[k]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),i.map(S=>jsx("option",{value:S,children:S},S))]})}),jsxs("div",{className:"filter-bar__field filter-bar__sort",children:[jsx("span",{className:"filter-bar__label",style:{color:"var(--theme-text-secondary)"},children:"Sort:"}),jsx("select",{value:t.by,onChange:l,className:"filter-bar__select filter-bar__select--sm",children:Wg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))}),t.by!=="none"&&jsx("button",{onClick:x,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),C&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:h,onChange:S=>C(S.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Gg.map(S=>jsx("option",{value:S.value,children:S.label},S.value))})}),v&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function qs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:n,onExportGanttPNG:p,onExportGanttCSV:m}){let[i,u]=useState(false),d=useRef(null);useEffect(()=>{let h=C=>{d.current&&!d.current.contains(C.target)&&u(false);};return i&&document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[i]);let g=h=>{h(),u(false);};return jsxs("div",{className:f("relative",r),ref:d,children:[jsxs("button",{onClick:()=>u(!i),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all border",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)",color:"var(--theme-text-secondary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",h.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",h.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":i,children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"3"}),jsx("path",{d:"M12 1v6m0 6v6M5.6 5.6l4.2 4.2m4.2 4.2l4.2 4.2M1 12h6m6 0h6M5.6 18.4l4.2-4.2m4.2-4.2l4.2-4.2"})]}),jsx("span",{children:"Config"})]}),i&&jsxs("div",{className:"absolute right-0 mt-2 w-48 rounded-lg border shadow-lg overflow-hidden z-50",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[o==="kanban"?jsxs("button",{onClick:()=>g(e),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Export"]}):jsxs(Fragment,{children:[jsxs("button",{onClick:()=>g(async()=>await s?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),jsx("polyline",{points:"10 9 9 9 8 9"})]}),"Export PDF"]}),jsxs("button",{onClick:()=>g(async()=>await n?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}),"Export Excel"]}),jsxs("button",{onClick:()=>g(async()=>await p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Export PNG"]}),jsxs("button",{onClick:()=>g(()=>m?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"}),jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),jsx("line",{x1:"8",y1:"17",x2:"16",y2:"17"})]}),"Export CSV"]})]}),jsxs("button",{onClick:()=>g(t),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v6m0 6v6m8.5-8.5L17 15M7 9L3.5 5.5M7 15l-3.5 3.5M20.5 5.5L17 9m3.5 11.5L17 17"})]}),"Themes"]}),jsxs("button",{onClick:()=>g(a),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M8 12h.01M12 12h.01M16 12h.01M7 16h10"})]}),"Shortcuts"]})]})]})}var Xs={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Js={name:"light",displayName:"Light (Standard)",emoji:"\u2600\uFE0F",colors:{bgPrimary:"#FFFFFF",bgSecondary:"#F7F7F8",bgTertiary:"#EEEFF1",bgCard:"#ffffff",bgHover:"#f3f4f6",bgActive:"#e5e7eb",bgInput:"#f9fafb",textPrimary:"#1A1A1A",textSecondary:"#5A5A5A",textTertiary:"#8A8A8A",textDisabled:"#d1d5db",textInverse:"#ffffff",borderPrimary:"rgba(0, 0, 0, 0.1)",borderSecondary:"rgba(0, 0, 0, 0.05)",borderDefault:"#e5e7eb",borderHover:"#d1d5db",borderSubtle:"#f3f4f6",accentPrimary:"#5E6AD2",accentHover:"#4A56B8",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.08)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.15)",success:"#059669",warning:"#D97706",error:"#DC2626",info:"#2563EB",danger:"#dc2626",dangerBorder:"rgba(220, 38, 38, 0.3)",dangerBackground:"rgba(220, 38, 38, 0.08)",dangerBackgroundHover:"rgba(220, 38, 38, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.12)",md:"0 4px 12px rgba(0, 0, 0, 0.15)",lg:"0 12px 32px rgba(0, 0, 0, 0.2)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Qs={name:"neutral",emoji:"\u26AA",displayName:"Neutral (Zen)",colors:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgTertiary:"#E7E5E4",bgCard:"#FEFEFE",bgHover:"#F0EFEE",bgActive:"#E7E5E4",bgInput:"#FAFAF9",textPrimary:"#1C1917",textSecondary:"#57534E",textTertiary:"#A8A29E",textDisabled:"#D6D3D1",textInverse:"#FAFAF9",borderPrimary:"#E7E5E4",borderSecondary:"#F0EFEE",borderDefault:"#E7E5E4",borderHover:"#D6D3D1",borderSubtle:"#F5F5F4",accentPrimary:"#292524",accentHover:"#44403C",interactivePrimary:"#292524",interactivePrimaryHover:"#44403C",interactivePrimaryBorder:"rgba(41, 37, 36, 0.3)",interactivePrimaryBackground:"rgba(41, 37, 36, 0.06)",interactivePrimaryBackgroundHover:"rgba(41, 37, 36, 0.12)",success:"#15803D",warning:"#CA8A04",error:"#B91C1C",info:"#1D4ED8",danger:"#B91C1C",dangerBorder:"rgba(185, 28, 28, 0.3)",dangerBackground:"rgba(185, 28, 28, 0.08)",dangerBackgroundHover:"rgba(185, 28, 28, 0.15)"},shadows:{sm:"0 1px 3px rgba(0, 0, 0, 0.1)",md:"0 4px 12px rgba(0, 0, 0, 0.12)",lg:"0 12px 32px rgba(0, 0, 0, 0.15)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},Kr={dark:Xs,light:Js,neutral:Qs},yn="dark";var vn=createContext(void 0),Zg="asakaa-theme";function zd({children:e,defaultTheme:t=yn,storageKey:a=Zg}){let[r,o]=useState(()=>{if(typeof window<"u"){let p=localStorage.getItem(a);if(p&&(p==="dark"||p==="light"||p==="neutral"))return p}return t}),s=useCallback(p=>{o(p),typeof window<"u"&&localStorage.setItem(a,p);},[a]);useEffect(()=>{if(typeof window>"u")return;let p=document.documentElement,m=Kr[r];Object.entries(m.colors).forEach(([u,d])=>{d&&p.style.setProperty(`--theme-${ef(u)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([u,d])=>{let g=m.colors[u];g&&p.style.setProperty(d,g);}),p.setAttribute("data-theme",r),p.classList.remove("theme-dark","theme-light","theme-neutral"),p.classList.add(`theme-${r}`);},[r]);let n={theme:r,setTheme:s,themes:Kr};return jsx(vn.Provider,{value:n,children:e})}function go(){let e=useContext(vn);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function ef(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Zs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=go();return e?jsxs("div",{className:f("fixed inset-0 z-[9999] flex items-center justify-center",a),children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative rounded-2xl border shadow-2xl max-w-md w-full mx-4",style:{backgroundColor:"var(--theme-bg-secondary)",borderColor:"var(--theme-border-primary)"},children:[jsxs("div",{className:"px-6 py-5 border-b flex items-center justify-between",style:{borderColor:"var(--theme-border-primary)"},children:[jsx("h2",{className:"text-2xl font-bold",style:{color:"var(--theme-text-primary)"},children:"Select Theme"}),jsx("button",{onClick:t,className:"text-2xl leading-none p-2 hover:bg-white/10 rounded-lg transition-colors",style:{color:"var(--theme-text-secondary)"},"aria-label":"Close",children:"\xD7"})]}),jsx("div",{className:"p-6 space-y-3",children:Object.entries(Kr).map(([s,n])=>jsxs("button",{onClick:()=>{o(s),t();},className:f("w-full p-4 rounded-lg border-2 transition-all flex items-center gap-4",r===s?"border-blue-500 bg-blue-500/20":"border-white/20 hover:border-white/40"),style:{backgroundColor:r===s?"var(--theme-accent-primary)20":"transparent"},children:[jsx("div",{className:"text-3xl",children:n.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:n.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Ud(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Ye[e]||Ye.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,n)=>a.getPropertyValue(s).trim()||n;return {bgPrimary:r("--theme-bg-primary",Ye[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Ye[e].bgSecondary),bgGrid:r("--theme-bg-card",Ye[e].bgGrid),bgWeekend:r("--theme-bg-hover",Ye[e].bgWeekend),border:r("--theme-border-primary",Ye[e].border),borderLight:r("--theme-border-subtle",Ye[e].borderLight),textPrimary:r("--theme-text-primary",Ye[e].textPrimary),textSecondary:r("--theme-text-secondary",Ye[e].textSecondary),textTertiary:r("--theme-text-tertiary",Ye[e].textTertiary),accent:r("--theme-accent-primary",Ye[e].accent),accentHover:r("--theme-accent-hover",Ye[e].accentHover),accentLight:r("--theme-accent-primary",Ye[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Ye[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Ye[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Ye[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Ye[e].dependency),dependencyHover:r("--theme-border-secondary",Ye[e].dependencyHover),criticalPath:r("--theme-error",Ye[e].criticalPath),criticalPathLight:r("--theme-error",Ye[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Ye[e].today):e==="neutral"?r("--theme-text-primary",Ye[e].today):r("--theme-error",Ye[e].today),todayLight:e==="light"?r("--theme-accent-primary",Ye[e].todayLight):e==="neutral"?r("--theme-text-primary",Ye[e].todayLight):r("--theme-error",Ye[e].todayLight),milestone:r("--theme-warning",Ye[e].milestone),milestoneLight:r("--theme-warning",Ye[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Ye[e].statusTodo),statusInProgress:r("--theme-accent-primary",Ye[e].statusInProgress),statusCompleted:r("--theme-success",Ye[e].statusCompleted),hoverBg:r("--theme-bg-hover",Ye[e].hoverBg),focusRing:r("--theme-accent-primary",Ye[e].focusRing)}}var xn={columns:{taskName:"TASK NAME",startDate:"Start Date",endDate:"End Date",duration:"Duration",assignees:"Assignees",status:"Status",progress:"% Complete",priority:"Priority"},toolbar:{today:"Today",day:"Day",week:"Week",month:"Month",export:"Export",exportPdf:"Export to PDF",exportPng:"Export to PNG",exportCsv:"Export to CSV",exportExcel:"Export to Excel",exportMsProject:"Export to MS Project",undo:"Undo",redo:"Redo",createTask:"New Task",density:"Row Density",compact:"Compact",normal:"Normal",spacious:"Spacious",filterAll:"All",filterIncomplete:"Incomplete",filterInProgress:"In Progress",filterCompleted:"Completed",filter:"Filter",filterBy:"Filter by status",filterAllDesc:"Show all tasks",filterIncompleteDesc:"Hide completed tasks",filterInProgressDesc:"Tasks currently being worked on",filterCompletedDesc:"Only show finished tasks",clearFilter:"Clear filter"},contextMenu:{editTask:"Edit Task",addSubtask:"Add Subtask",markIncomplete:"Mark Incomplete",setInProgress:"Set In Progress",markComplete:"Mark Complete",splitTask:"Split Task",deleteTask:"Delete Task"},actions:{edit:"Edit",delete:"Delete",duplicate:"Duplicate",addSubtask:"Add Subtask",indent:"Indent",outdent:"Outdent",moveUp:"Move Up",moveDown:"Move Down",splitTask:"Split Task",linkTasks:"Link Tasks",unlinkTasks:"Unlink Tasks"},status:{todo:"To Do",inProgress:"In Progress",completed:"Completed"},labels:{progress:"Progress",duration:"Duration",days:"days",day:"day",assigned:"Assigned",milestone:"Milestone",criticalPath:"Critical Path",subtask:"Subtask",task:"Task",noTasks:"No tasks yet",addTask:"Add task",newTask:"New Task",loading:"Loading...",error:"Error",today:"Today"},ai:{placeholder:'Ask AI to edit tasks... (e.g., "Move Design to next week")',thinking:"Thinking...",suggestions:{moveTask:'Move "Task Name" to next Monday',extendTask:'Extend "Task Name" by 3 days',renameTask:'Rename "Old Name" to "New Name"',setProgress:'Set "Task Name" progress to 50%',linkTasks:'Link "Task A" to "Task B"',createTask:'Create a new task called "New Task"',deleteTask:'Delete "Task Name"',assignTask:'Assign John to "Task Name"'},errors:{taskNotFound:"Task not found",invalidDate:"Invalid date",invalidDuration:"Invalid duration",invalidProgress:"Invalid progress value",unknownCommand:"Unknown command",processingError:"Error processing command"}},export:{projectName:"Gantt Project",ganttTasks:"Gantt Tasks",taskId:"Task ID",taskName:"Task Name",startDate:"Start Date",endDate:"End Date",isMilestone:"Is Milestone",parentId:"Parent ID",yes:"Yes",no:"No",noTasksToExport:"No tasks available to export"},dateFormat:{short:"MM/dd",medium:"MMM d",long:"MMMM d, yyyy"}},Hd={columns:{taskName:"NOMBRE DE TAREA",startDate:"Fecha Inicio",endDate:"Fecha Fin",duration:"Duraci\xF3n",assignees:"Asignados",status:"Estado",progress:"% Completado",priority:"Prioridad"},toolbar:{today:"Hoy",day:"D\xEDa",week:"Semana",month:"Mes",export:"Exportar",exportPdf:"Exportar a PDF",exportPng:"Exportar a PNG",exportCsv:"Exportar a CSV",exportExcel:"Exportar a Excel",exportMsProject:"Exportar a MS Project",undo:"Deshacer",redo:"Rehacer",createTask:"Nueva Tarea",density:"Densidad",compact:"Compacto",normal:"Normal",spacious:"Espacioso",filterAll:"Todas",filterIncomplete:"Sin completar",filterInProgress:"En progreso",filterCompleted:"Completadas",filter:"Filtrar",filterBy:"Filtrar por estado",filterAllDesc:"Mostrar todas las tareas",filterIncompleteDesc:"Ocultar tareas completadas",filterInProgressDesc:"Tareas en las que se est\xE1 trabajando",filterCompletedDesc:"Solo mostrar tareas terminadas",clearFilter:"Limpiar filtro"},contextMenu:{editTask:"Editar Tarea",addSubtask:"Agregar Subtarea",markIncomplete:"Marcar Incompleta",setInProgress:"Marcar En Progreso",markComplete:"Marcar Completada",splitTask:"Dividir Tarea",deleteTask:"Eliminar Tarea"},actions:{edit:"Editar",delete:"Eliminar",duplicate:"Duplicar",addSubtask:"Agregar Subtarea",indent:"Aumentar Nivel",outdent:"Disminuir Nivel",moveUp:"Mover Arriba",moveDown:"Mover Abajo",splitTask:"Dividir Tarea",linkTasks:"Vincular Tareas",unlinkTasks:"Desvincular Tareas"},status:{todo:"Por Hacer",inProgress:"En Progreso",completed:"Completado"},labels:{progress:"Progreso",duration:"Duraci\xF3n",days:"d\xEDas",day:"d\xEDa",assigned:"Asignado",milestone:"Hito",criticalPath:"Ruta Cr\xEDtica",subtask:"Subtarea",task:"Tarea",noTasks:"Sin tareas a\xFAn",addTask:"Agregar tarea",newTask:"Nueva Tarea",loading:"Cargando...",error:"Error",today:"Hoy"},ai:{placeholder:'P\xEDdele a la IA que edite tareas... (ej: "Mover Dise\xF1o a la pr\xF3xima semana")',thinking:"Pensando...",suggestions:{moveTask:'Mover "Nombre de Tarea" al pr\xF3ximo lunes',extendTask:'Extender "Nombre de Tarea" por 3 d\xEDas',renameTask:'Renombrar "Nombre Anterior" a "Nombre Nuevo"',setProgress:'Establecer progreso de "Nombre de Tarea" al 50%',linkTasks:'Vincular "Tarea A" con "Tarea B"',createTask:'Crear una nueva tarea llamada "Nueva Tarea"',deleteTask:'Eliminar "Nombre de Tarea"',assignTask:'Asignar a Juan a "Nombre de Tarea"'},errors:{taskNotFound:"Tarea no encontrada",invalidDate:"Fecha inv\xE1lida",invalidDuration:"Duraci\xF3n inv\xE1lida",invalidProgress:"Valor de progreso inv\xE1lido",unknownCommand:"Comando desconocido",processingError:"Error procesando el comando"}},export:{projectName:"Proyecto Gantt",ganttTasks:"Tareas Gantt",taskId:"ID de Tarea",taskName:"Nombre de Tarea",startDate:"Fecha Inicio",endDate:"Fecha Fin",isMilestone:"Es Hito",parentId:"ID Padre",yes:"S\xED",no:"No",noTasksToExport:"No hay tareas disponibles para exportar"},dateFormat:{short:"dd/MM",medium:"d MMM",long:"d de MMMM de yyyy"}},ei={en:xn,es:Hd};function Wd(e){return ei[e]||ei.en}function ti(e,t){let a=Wd(e);return t?{columns:{...a.columns,...t.columns},toolbar:{...a.toolbar,...t.toolbar},contextMenu:{...a.contextMenu,...t.contextMenu},actions:{...a.actions,...t.actions},status:{...a.status,...t.status},labels:{...a.labels,...t.labels},ai:{...a.ai,...t.ai,suggestions:{...a.ai.suggestions,...t.ai?.suggestions},errors:{...a.ai.errors,...t.ai?.errors}},export:{...a.export,...t.export},dateFormat:{...a.dateFormat,...t.dateFormat}}:a}var ho=createContext(xn);function bo(){return useContext(ho)}function bf({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:n}){let[p,m]=useState(false),[i,u]=useState(null),d=useRef(null),g=bo();if(useEffect(()=>{let c=b=>{d.current&&!d.current.contains(b.target)&&m(false);};return p&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[p]),!(t||a||r||o||s||n))return null;let C=[{id:"png",label:"PNG",description:"Image",icon:jsx(FileImage,{className:"w-4 h-4"}),handler:t},{id:"pdf",label:"PDF",description:"Document",icon:jsx(FileText,{className:"w-4 h-4"}),handler:a},{id:"excel",label:"Excel",description:"Spreadsheet",icon:jsx(FileSpreadsheet,{className:"w-4 h-4"}),handler:r},{id:"csv",label:"CSV",description:"Comma-separated",icon:jsx(FileText,{className:"w-4 h-4"}),handler:o},{id:"json",label:"JSON",description:"Data",icon:jsx(FileJson,{className:"w-4 h-4"}),handler:s},{id:"msproject",label:"MS Project",description:"XML",icon:jsx(FolderKanban,{className:"w-4 h-4"}),handler:n}].filter(c=>c.handler),T=async(c,b)=>{if(b){u(c);try{await b();}catch(y){console.error(`Export ${c} failed:`,y);}finally{u(null),m(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>m(!p),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:p?e.accent:e.bgSecondary,border:`1px solid ${p?e.accent:e.borderLight}`,color:p?"#FFFFFF":e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{scale:1.02,backgroundColor:e.accent,color:"#FFFFFF"},whileTap:{scale:.98},children:[jsx(Download,{className:"w-3.5 h-3.5"}),jsx("span",{children:g.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:p?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:p&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute right-0 mt-2 w-48 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:C.map((c,b)=>jsxs(motion.button,{onClick:()=>T(c.id,c.handler),disabled:i!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:b<C.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:b*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:i===c.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):c.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:c.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:c.description})]})]},c.id))})})})]})}function yf({options:e,value:t,onChange:a,theme:r,layoutId:o="activeSegment"}){return jsx("div",{className:"inline-flex p-1 rounded-lg relative",style:{backgroundColor:r.bgSecondary,border:`1px solid ${r.borderLight}`},children:e.map(s=>{let n=t===s.value;return jsxs(motion.button,{onClick:()=>a(s.value),className:"relative px-3 py-1.5 rounded-md text-xs transition-all flex items-center gap-1.5 min-w-[70px] justify-center",style:{color:n?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:n?600:500,zIndex:n?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[n&&jsx(motion.div,{layoutId:o,className:"absolute inset-0 rounded-md",style:{backgroundColor:r.accent,boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},transition:{type:"spring",stiffness:400,damping:30}}),s.icon&&jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:n?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function vf({options:e,value:t,onChange:a,theme:r}){return jsx("div",{className:"inline-flex items-center gap-1",children:e.map(o=>{let s=t===o.value;return jsxs(motion.button,{onClick:()=>a(o.value),className:"relative px-3 py-1.5 text-xs transition-all",style:{color:s?r.accent:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:s?600:500},whileHover:{color:s?r.accent:r.textSecondary},whileTap:{scale:.98},children:[jsx("span",{children:o.label}),s&&jsx(motion.div,{layoutId:"timeScaleUnderline",className:"absolute bottom-0 left-1 right-1 h-0.5 rounded-full",style:{backgroundColor:r.accent},transition:{type:"spring",stiffness:400,damping:30}})]},o.value)})})}function xf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();useEffect(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=[{value:"compact",label:n.toolbar.compact||"Compact"},{value:"comfortable",label:n.toolbar.normal||"Normal"},{value:"spacious",label:n.toolbar.spacious||"Spacious"}],m=p.find(i=>i.value===t)?.label||"Normal";return jsxs("div",{ref:s,className:"relative",children:[jsx(motion.button,{onClick:()=>o(!r),className:"flex items-center justify-center p-2 rounded-lg transition-all",style:{backgroundColor:r?e.accentLight:e.bgSecondary,border:`1px solid ${r?e.accent:e.borderLight}`,color:r?e.accent:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.02},whileTap:{scale:.98},title:`${n.toolbar.density||"Density"}: ${m}`,children:jsx(Rows3,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-36 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:jsx("div",{className:"py-1",children:p.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent",borderBottom:u<p.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:i.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},i.value)})})})})]})}function kf({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),n=bo();useEffect(()=>{let i=u=>{s.current&&!s.current.contains(u.target)&&o(false);};return r&&document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[r]);let p=[{value:"all",label:n.toolbar.filterAll||"All tasks",description:n.toolbar.filterAllDesc||"Show all tasks"},{value:"incomplete",label:n.toolbar.filterIncomplete||"Incomplete only",description:n.toolbar.filterIncompleteDesc||"Hide completed tasks"},{value:"in_progress",label:n.toolbar.filterInProgress||"In progress",description:n.toolbar.filterInProgressDesc||"Tasks currently being worked on"},{value:"completed",label:n.toolbar.filterCompleted||"Completed",description:n.toolbar.filterCompletedDesc||"Only show finished tasks"}],m=t!=="all";return jsxs("div",{ref:s,className:"relative",children:[jsxs(motion.button,{onClick:()=>o(!r),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:m||r?e.accentLight:e.bgSecondary,border:`1px solid ${m||r?e.accent:e.borderLight}`,color:m||r?e.accent:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},whileHover:{backgroundColor:e.accentLight,borderColor:e.accent,color:e.accent,scale:1.02},whileTap:{scale:.98},children:[jsx(Filter,{className:"w-3.5 h-3.5"}),jsx("span",{children:n.toolbar.filter||"Filter"}),m&&jsx(motion.span,{initial:{scale:0},animate:{scale:1},className:"flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold",style:{backgroundColor:e.accent,color:"#FFFFFF"},children:"1"}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:r?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:r&&jsxs(motion.div,{initial:{opacity:0,y:-8,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.95},transition:{duration:.15,ease:"easeOut"},className:"absolute left-0 mt-2 w-56 rounded-lg overflow-hidden z-50",style:{backgroundColor:e.bgSecondary,border:`1px solid ${e.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.25)"},children:[jsx("div",{className:"px-3 py-2 border-b",style:{borderColor:e.borderLight},children:jsx("span",{className:"text-xs font-medium",style:{color:e.textTertiary},children:n.toolbar.filterBy||"Filter by status"})}),jsx("div",{className:"py-1",children:p.map((i,u)=>{let d=t===i.value;return jsxs(motion.button,{onClick:()=>{a(i.value),o(false);},className:"w-full flex items-start gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:d?e.accentLight:"transparent"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:u*.03},children:[jsx("div",{className:"flex items-center justify-center w-4 h-4 rounded border mt-0.5 flex-shrink-0",style:{borderColor:d?e.accent:e.border,backgroundColor:d?e.accent:"transparent"},children:d&&jsx(Check,{className:"w-3 h-3",style:{color:"#FFFFFF"}})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium",style:{color:d?e.accent:e.textPrimary},children:i.label}),jsx("div",{className:"text-[10px] mt-0.5",style:{color:e.textTertiary},children:i.description})]})]},i.value)})}),m&&jsx("div",{className:"px-3 py-2 border-t",style:{borderColor:e.borderLight},children:jsx(motion.button,{onClick:()=>{a("all"),o(false);},className:"w-full text-xs py-1.5 rounded-md",style:{color:e.textTertiary},whileHover:{backgroundColor:e.hoverBg,color:e.textSecondary},children:n.toolbar.clearFilter||"Clear filter"})})]})})]})}function wn({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:n,rowDensity:p,onRowDensityChange:m,showThemeSelector:i=false,showCreateTaskButton:u=false,createTaskLabel:d,onCreateTask:g,taskFilter:h="all",onTaskFilterChange:C,onExportPNG:T,onExportPDF:c,onExportExcel:b,onExportCSV:y,onExportJSON:l,onExportMSProject:x}){let v=bo(),S=T||c||b||y||l||x,k=[{value:"day",label:v.toolbar.day},{value:"week",label:v.toolbar.week},{value:"month",label:v.toolbar.month}],w=[{value:"dark",label:"Dark",icon:jsx(Moon,{className:"w-3.5 h-3.5"})},{value:"light",label:"Light",icon:jsx(Sun,{className:"w-3.5 h-3.5"})},{value:"neutral",label:"Zen",icon:jsx(Palette,{className:"w-3.5 h-3.5"})}];return jsxs("div",{className:"h-12 px-4 flex items-center justify-between border-b",style:{backgroundColor:e.bgGrid,borderColor:e.border},children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(vf,{options:k,value:t,onChange:R=>a(R),theme:e}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsxs("div",{className:"flex items-center gap-1",children:[jsx(motion.button,{onClick:()=>o(Math.max(.5,r-.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomOut,{className:"w-3.5 h-3.5"})}),jsxs("div",{className:"px-2 py-0.5 rounded text-xs tabular-nums min-w-[42px] text-center",style:{color:e.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:500},children:[Math.round(r*100),"%"]}),jsx(motion.button,{onClick:()=>o(Math.min(2,r+.1)),className:"p-1.5 rounded-md transition-all",style:{backgroundColor:"transparent",color:e.textSecondary},whileHover:{backgroundColor:e.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(ZoomIn,{className:"w-3.5 h-3.5"})})]}),jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(xf,{theme:e,value:p,onChange:m}),C&&jsxs(Fragment,{children:[jsx("div",{className:"w-px h-5",style:{backgroundColor:e.borderLight}}),jsx(kf,{theme:e,value:h,onChange:C})]})]}),jsxs("div",{className:"flex items-center gap-3",children:[u&&g&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:g,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{background:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)",color:"#FFFFFF",fontFamily:"Inter, sans-serif",fontWeight:500,boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"},whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(59, 130, 246, 0.4)"},whileTap:{scale:.98},children:[jsx(Plus,{className:"w-3.5 h-3.5"}),jsx("span",{children:d||v.toolbar.createTask})]}),(S||i)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),S&&jsxs(Fragment,{children:[jsx(bf,{theme:e,onExportPNG:T,onExportPDF:c,onExportExcel:b,onExportCSV:y,onExportJSON:l,onExportMSProject:x}),i&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),i&&jsx(yf,{options:w,value:s,onChange:R=>n(R),theme:e})]})]})}function Cn({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,n]=useState({x:0,y:0}),p=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let u=d=>{p.current&&!p.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);let i=e.filter(u=>u.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:m,onClick:()=>{if(!r&&m.current){let u=m.current.getBoundingClientRect();n({x:u.left,y:u.bottom+4});}o(!r);},className:"p-2 rounded-md transition-colors flex items-center gap-1",style:{backgroundColor:a.bgSecondary,border:`1px solid ${a.borderLight}`,color:a.textSecondary},whileHover:{backgroundColor:a.hoverBg,scale:1.05},whileTap:{scale:.95},children:jsx(Plus,{className:"w-4 h-4"})}),jsx(AnimatePresence,{children:r&&jsx(lt,{children:jsx(motion.div,{ref:p,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15},className:"column-manager-menu fixed min-w-[180px] rounded-lg shadow-xl z-[9999]",style:{left:`${s.x}px`,top:`${s.y}px`,backgroundColor:a.bgSecondary,border:`1px solid ${a.border}`},children:jsxs("div",{className:"py-1",children:[jsx("div",{className:"px-3 py-2 text-xs uppercase tracking-wider",style:{color:a.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:"Add Column"}),i.map(u=>jsxs("button",{onClick:()=>{t(u.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:u.label}),u.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},u.id))]})})})})]})}function yo({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let n=useRef(null),[p,m]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let u=200,d=r.length*36+8,g=8,h=window.innerWidth,C=window.innerHeight,T=t,c=a;t+u+g>h&&(T=t-u,T<g&&(T=g)),a+d+g>C&&(c=C-d-g,c<g&&(c=g)),m({x:T,y:c});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let u=g=>{n.current&&!n.current.contains(g.target)&&o();},d=g=>{g.key==="Escape"&&o();};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let i=u=>u.startsWith("#")&&(u.length===7||u.length===4)?u:s.bgPrimary?.includes("1")||s.bgPrimary?.includes("2")||s.textPrimary?.toLowerCase().includes("fff")||s.textPrimary?.toLowerCase().includes("white")?"#1E2128":"#FFFFFF";return jsx(AnimatePresence,{children:jsx(motion.div,{ref:n,initial:{opacity:0,scale:.95,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-10},transition:{duration:.15,ease:[.4,0,.2,1]},className:"fixed z-[9999] min-w-[200px] rounded-lg",style:{left:`${p.x}px`,top:`${p.y}px`,backgroundColor:i(s.bgSecondary),border:`1px solid ${s.border}`,boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2)",backdropFilter:"none"},children:jsx("div",{className:"py-1",children:r.map(u=>jsxs("div",{children:[u.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{u.disabled||(u.onClick(),o());},disabled:u.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:u.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:u.disabled?"not-allowed":"pointer",opacity:u.disabled?.5:1},onMouseEnter:d=>{u.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[u.icon&&jsx("span",{style:{color:s.textSecondary},children:u.icon}),jsx("span",{className:"flex-1",children:u.label}),u.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},u.id))})})})}var Rt={Edit:jsx(Edit3,{className:"w-4 h-4"}),Pencil:jsx(Pencil,{className:"w-4 h-4"}),Delete:jsx(Trash2,{className:"w-4 h-4"}),Add:jsx(Plus,{className:"w-4 h-4"}),AddSubtask:jsx(Plus,{className:"w-4 h-4"}),Remove:jsx(Minus,{className:"w-4 h-4"}),Link:jsx(Link2,{className:"w-4 h-4"}),Progress:jsx(BarChart3,{className:"w-4 h-4"}),Sort:jsx(ArrowUpDown,{className:"w-4 h-4"}),SortAsc:jsx(ArrowUp,{className:"w-4 h-4"}),SortDesc:jsx(ArrowDown,{className:"w-4 h-4"}),Hide:jsx(EyeOff,{className:"w-4 h-4"}),Show:jsx(Eye,{className:"w-4 h-4"}),Settings:jsx(Settings,{className:"w-4 h-4"}),Split:jsx(Scissors,{className:"w-4 h-4"}),MarkIncomplete:jsx(Circle,{className:"w-4 h-4"}),SetInProgress:jsx(PlayCircle,{className:"w-4 h-4"}),MarkComplete:jsx(CheckCircle2,{className:"w-4 h-4"})};function Zd({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:n,onTaskIndent:p,onTaskOutdent:m,onTaskRename:i,onTaskToggleExpand:u,onOpenTaskModal:d,enableKeyboard:g=true}){let h=useRef(false),C=useCallback(l=>{h.current=l;},[]),T=useCallback(l=>{let x=[],v=S=>{for(let k of S)x.push(k),k.subtasks&&k.subtasks.length>0&&k.isExpanded&&v(k.subtasks);};return v(l),x},[]),c=useCallback(()=>{let l=T(e);for(let x of l)if(t.has(x.id))return x;return null},[e,t,T]),b=useCallback((l,x)=>{let v=T(e);if(v.length===0)return;let S=c();if(!S){a(v[0].id,false);return}let k=v.findIndex(M=>M.id===S.id);if(k===-1)return;let w=l==="up"?k-1:k+1;if(w<0||w>=v.length)return;let R=v[w];a(R.id,x);},[e,c,T,a]),y=useCallback(l=>{if(!g)return;let x=l.target;if(x.tagName==="INPUT"||x.tagName==="TEXTAREA"||x.isContentEditable||h.current){l.key==="Escape"&&(x.blur(),h.current=false);return}let k=navigator.platform.toUpperCase().indexOf("MAC")>=0?l.metaKey:l.ctrlKey,w=Array.from(t),R=c();if(l.key==="ArrowUp"){l.preventDefault(),b("up",l.shiftKey);return}if(l.key==="ArrowDown"){l.preventDefault(),b("down",l.shiftKey);return}if(R&&(l.key==="ArrowRight"||l.key==="ArrowLeft")){R.subtasks&&R.subtasks.length>0&&(l.preventDefault(),(l.key==="ArrowRight"&&!R.isExpanded||l.key==="ArrowLeft"&&R.isExpanded)&&u(R.id));return}if(l.altKey&&(l.key==="ArrowUp"||l.key==="ArrowDown")){w.length>0&&(l.preventDefault(),n(w,l.key==="ArrowUp"?"up":"down"));return}if(l.key==="Tab"&&!l.shiftKey){w.length>0&&(l.preventDefault(),p(w));return}if(l.key==="Tab"&&l.shiftKey){w.length>0&&(l.preventDefault(),m(w));return}if(l.key==="Enter"&&!l.shiftKey&&!k){R&&(l.preventDefault(),r(R.id,"below"));return}if(l.key==="Enter"&&l.shiftKey&&!k){R&&(l.preventDefault(),r(R.id,"above"));return}if(l.key==="Enter"&&k){R&&(l.preventDefault(),d(R.id));return}if(l.key==="F2"){R&&(l.preventDefault(),i(R.id));return}if(l.key==="Delete"||l.key==="Backspace"&&k){w.length>0&&(l.preventDefault(),o(w));return}if(l.key==="d"&&k&&!l.shiftKey){w.length>0&&(l.preventDefault(),s(w));return}},[g,t,c,b,r,o,s,n,p,m,i,u,d]);return useEffect(()=>{if(g)return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y);}},[g,y]),{setIsEditing:C}}function tc(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(g=>{let h=new Set(g);return h.has(d)?h.delete(d):h.add(d),h}),r(d);},[]),n=useCallback((d,g)=>{if(!a){o(d);return}let h=g.indexOf(a),C=g.indexOf(d);if(h===-1||C===-1){o(d);return}let T=Math.min(h,C),c=Math.max(h,C),b=g.slice(T,c+1);t(new Set(b)),r(d);},[a,o]),p=useCallback((d,g,h,C)=>{C?n(d,g):h?s(d):o(d);},[o,s,n]),m=useCallback((d,g)=>{g?t(h=>{let C=new Set(h);return C.add(d),C}):o(d);},[o]),i=useCallback(()=>{t(new Set),r(null);},[]),u=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:n,handleTaskClick:p,handleKeyboardSelection:m,clearSelection:i,isTaskSelected:u}}function vo(e){let t=[],a=(r,o,s=0)=>{for(let n=0;n<r.length;n++){let p={...r[n],parentId:o,level:s,position:n};t.push(p),p.subtasks&&p.subtasks.length>0&&p.isExpanded&&a(p.subtasks,p.id,s+1);}};return a(e),t}function ac(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=ac(a.subtasks,t);if(r)return r}}return null}function ii(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=ii(a.subtasks,t);if(r)return r}return null}function li(e,t){if(t.length===0)return e;let a=vo(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],n=(d,g)=>{let h=[];return {tasks:d.filter(T=>{if(g.has(T.id))return h.push(T),false;if(T.subtasks){let c=n(T.subtasks,g);T.subtasks=c.tasks,h.push(...c.removed);}return true}),removed:h}},p=(d,g,h)=>d.map(C=>C.id===g?{...C,subtasks:[...C.subtasks||[],...h],isExpanded:true}:C.subtasks?{...C,subtasks:p(C.subtasks,g,h)}:C),m=new Set(t),{tasks:i,removed:u}=n(e,m);return p(i,s.id,u)}function di(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=ii(a,r);if(!o)continue;let s=ii(a,o.id),n=(i,u,d)=>{for(let g=0;g<i.length;g++){let h=i[g];if(h.id===u&&h.subtasks){let C=h.subtasks.findIndex(T=>T.id===d);if(C!==-1){let[T]=h.subtasks.splice(C,1);return T}}if(h.subtasks){let C=n(h.subtasks,u,d);if(C)return C}}return null},p=(i,u,d)=>{let g=i.findIndex(h=>h.id===u);if(g!==-1)return i.splice(g+1,0,d),i;for(let h of i)h.subtasks&&p(h.subtasks,u,d);return i},m=n(a,o.id,r);m&&(s&&s.subtasks?p(s.subtasks,o.id,m):p(a,o.id,m));}return a}function ci(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(n,p,m)=>{let i=n.findIndex(d=>d.id===p);if(i===-1){for(let d of n)if(d.subtasks&&s(d.subtasks,p,m))return true;return false}let u=m==="up"?i-1:i+1;return u<0||u>=n.length?false:([n[i],n[u]]=[n[u],n[i]],true)};return s(r,o,a),r}function mi(e,t){let a=new Set(t),r=o=>o.filter(s=>!a.has(s.id)).map(s=>s.subtasks?{...s,subtasks:r(s.subtasks)}:s);return r(e)}function pi(e,t){let a=[...e];for(let r of t){let o=n=>{let p=n.findIndex(u=>u.id===r);if(p===-1){for(let u of n)if(u.subtasks&&o(u.subtasks))return true;return false}let m=n[p],i={...m,id:`${m.id}-copy-${Date.now()}`,name:`${m.name} (Copy)`,subtasks:m.subtasks?s(m.subtasks):void 0};return n.splice(p+1,0,i),true},s=n=>n.map(p=>({...p,id:`${p.id}-copy-${Date.now()}`,subtasks:p.subtasks?s(p.subtasks):void 0}));o(a);}return a}function rc(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},p=m=>{let i=m.findIndex(d=>d.id===t);if(i===-1){for(let d of m)if(d.subtasks&&p(d.subtasks))return true;return false}let u=a==="above"?i:i+1;return m.splice(u,0,n),true};return p(r),{tasks:r,newTask:n}}function ui(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:ui(r.subtasks,t,a)}:r)}function gi(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:gi(a.subtasks,t)}:a)}function fi(e,t){let a=u=>{for(let d of u){if(d.id===t)return d;if(d.subtasks){let g=a(d.subtasks);if(g)return g}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let n=r?.startDate||o,p=r?.endDate||s,m={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(n),endDate:new Date(p),color:r?.color||"#3B82F6"},i=u=>u.map(d=>{if(d.id===t){let g=d.subtasks||[];return {...d,subtasks:[...g,m],isExpanded:true}}return d.subtasks?{...d,subtasks:i(d.subtasks)}:d});return {tasks:i(e),newTask:m}}function oc(e,t,a,r){if(t===a)return e;let o=ac(e,t);if(!o)return e;if(a){let p=(m,i)=>{if(!m.subtasks)return false;for(let u of m.subtasks)if(u.id===i||p(u,i))return true;return false};if(p(o,a))return e}let s=p=>p.filter(m=>m.id!==t).map(m=>m.subtasks&&m.subtasks.length>0?{...m,subtasks:s(m.subtasks)}:m),n=s(e);if(a===null){let p=r!==void 0?r:n.length;n.splice(p,0,{...o,parentId:void 0});}else {let p=m=>m.map(i=>{if(i.id===a){let u=i.subtasks||[],d=r!==void 0?r:u.length,g=[...u];return g.splice(d,0,{...o,parentId:a}),{...i,subtasks:g,isExpanded:true}}return i.subtasks&&i.subtasks.length>0?{...i,subtasks:p(i.subtasks)}:i});n=p(n);}return n}function Dn({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:n,onTaskContextMenu:p,onTaskToggle:m,scrollTop:i,columns:u,onToggleColumn:d,onColumnResize:g,onTaskUpdate:h,onTaskIndent:C,onTaskOutdent:T,onTaskMove:c,onMultiTaskDelete:b,onTaskDuplicate:y,onTaskCreate:l,onTaskRename:x,onCreateSubtask:v,onOpenTaskModal:S,onDeleteRequest:k,onTaskReparent:w}){let R=useContext(ho),[M,D]=useState(null),[I,B]=useState(null),[K,te]=useState(""),ie=useRef(null),[de,be]=useState(null),[$,J]=useState(0),[U,G]=useState(0),[A,Q]=useState({isOpen:false,x:0,y:0,type:"header"}),[X,H]=useState(null),[Ce,Me]=useState(null),[Oe,ve]=useState(null),Ke=useRef(0),We=5,et=useRef(false),[vt,Mt]=useState(null),[mt,O]=useState(false),[le,xe]=useState(null),[Pe,ze]=useState(false),at=useRef(null);useEffect(()=>{function _(ae){at.current&&!at.current.contains(ae.target)&&ze(false);}if(Pe)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[Pe]),useEffect(()=>{I&&ie.current&&(ie.current.focus(),ie.current.select());},[I]),useEffect(()=>{if(!de)return;let _=Ee=>{let Ue=Ee.clientX-$,He=U+Ue;g?.(de,He);},ae=()=>{be(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",ae),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",ae),document.body.style.cursor="",document.body.style.userSelect="";}},[de,$,U,g]);let{selectedTaskIds:Et,handleTaskClick:Fe,isTaskSelected:Xt}=tc(),{setIsEditing:Ot}=Zd({tasks:e,selectedTaskIds:Et,onTaskSelect:(_,ae)=>{let Ue=vo(e).map(He=>He.id);Fe(_,Ue,ae||false,false);},onTaskCreate:l||(()=>{}),onTaskDelete:b||(()=>{}),onTaskDuplicate:y||(()=>{}),onTaskMove:c||(()=>{}),onTaskIndent:C||(()=>{}),onTaskOutdent:T||(()=>{}),onTaskRename:_=>{let ae=vo(e).find(Ee=>Ee.id===_);ae&&ue(ae);},onTaskToggleExpand:m||(()=>{}),onOpenTaskModal:_=>{let ae=vo(e).find(Ee=>Ee.id===_);ae&&S&&S(ae);},enableKeyboard:true}),Nt=(_,ae=0)=>{let Ee=[];for(let Ue of _)Ee.push({task:Ue,level:ae}),Ue.subtasks&&Ue.subtasks.length>0&&Ue.isExpanded&&Ee.push(...Nt(Ue.subtasks,ae+1));return Ee},ct=Nt(e),Jt=48,Ea=Math.max(ct.length*a,600-Jt),oe=_=>!_.startDate||!_.endDate?"-":`${Math.ceil((_.endDate.getTime()-_.startDate.getTime())/(1e3*60*60*24))}d`,ue=_=>{B(_.id),te(_.name),Ot(true);},pa=_=>{K.trim()&&K!==e.find(ae=>ae.id===_)?.name&&x?.(_,K.trim()),B(null),te(""),Ot(false);},ya=()=>{B(null),te(""),Ot(false);},N=(_,ae)=>{ae.stopPropagation(),v?.(_.id);},ee=(_,ae)=>{ae.preventDefault(),Ke.current=ae.clientY,H(_),et.current=false,O(false),Mt({x:ae.clientX,y:ae.clientY});},se=_=>{if(!X||(Math.abs(_.clientY-Ke.current)>We&&!et.current&&(et.current=true,O(true)),Mt({x:_.clientX,y:_.clientY}),!et.current))return;let Ee=document.querySelectorAll("[data-task-row]"),Ue=null,He=null;Ee.forEach(W=>{let ce=W.getBoundingClientRect(),Ie=W.getAttribute("data-task-row");if(Ie&&Ie!==X&&_.clientY>=ce.top&&_.clientY<=ce.bottom){Ue=Ie;let Dt=_.clientY-ce.top,Je=ce.height;Dt<Je*.25?He="above":Dt>Je*.75?He="below":He="child";}}),Me(Ue),ve(He);},De=()=>{if(et.current&&X&&Ce&&Oe){if(Oe==="child")w?.(X,Ce);else if(Oe==="above"||Oe==="below"){let _=(Ue,He,W=null)=>{for(let ce of Ue){if(ce.id===He)return W;if(ce.subtasks){let Ie=_(ce.subtasks,He,ce.id);if(Ie!==void 0)return Ie}}},ae=_(e,Ce,null),Ee=(Ue,He)=>{let W=Ue.findIndex(ce=>ce.id===He);return Oe==="below"?W+1:W};if(ae===null){let Ue=Ee(e,Ce);w?.(X,null,Ue);}else {let Ue=ct.find(He=>He.task.id===ae)?.task;if(Ue?.subtasks){let He=Ee(Ue.subtasks,Ce);w?.(X,ae,He);}}}}H(null),Me(null),ve(null),Mt(null),et.current=false,O(false);};useEffect(()=>{if(X)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",De),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",De),document.body.style.cursor="",document.body.style.userSelect="";}},[X,Ce,Oe]);let $e=(_,ae,Ee)=>{switch(_.id){case "name":let Ue=I===ae.id,He=M===ae.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${Ee*20}px`},children:[w&&jsx("div",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-white/10 transition-all flex-shrink-0",style:{color:t.textTertiary,opacity:He?1:.3},onMouseDown:q=>ee(ae.id,q),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),ae.subtasks&&ae.subtasks.length>0?jsx("button",{onClick:q=>{q.stopPropagation(),m?.(ae.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:ae.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:ae.color||"#3B82F6",opacity:ae.parentId?.6:1,borderColor:ae.isMilestone?t.accent:"transparent",borderWidth:ae.isMilestone?"2px":"0px"},title:ae.isMilestone?"Milestone":ae.parentId?"Subtask":"Task"})}),Ue?jsx("input",{ref:ie,type:"text",value:K,onChange:q=>te(q.target.value),onKeyDown:q=>{q.key==="Enter"?pa(ae.id):q.key==="Escape"&&ya();},onBlur:()=>pa(ae.id),className:"flex-1 px-2 py-1 rounded border outline-none",style:{backgroundColor:t.bgPrimary,borderColor:t.accent,color:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:"13px",fontWeight:500},onClick:q=>q.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:ae.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:ae.parentId?"13px":"14px",fontWeight:ae.isMilestone?600:ae.parentId?400:600,letterSpacing:ae.parentId?"0":"-0.01em"},title:ae.name,children:ae.name}),He&&!Ue&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:q=>q.stopPropagation(),children:[jsx("button",{onClick:q=>N(ae,q),className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Create subtask",children:jsx(Plus,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:q=>{q.stopPropagation(),ue(ae);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let ce=_.id==="startDate"?"startDate":"endDate",Ie=ae[ce],Dt=le?.taskId===ae.id&&le?.field===ce,Je=q=>q?(typeof q=="string"?new Date(q):q).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:q=>q.stopPropagation(),children:[jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors hover:bg-white/5",style:{color:t.textSecondary},onClick:q=>{if(Dt)xe(null);else {let Ae=q.currentTarget.getBoundingClientRect();xe({taskId:ae.id,field:ce,month:Ie?typeof Ie=="string"?new Date(Ie):Ie:new Date,position:{top:Ae.bottom+4,left:Ae.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Je(Ie)})]}),Dt&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>xe(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"fixed z-[9999] rounded-xl shadow-2xl overflow-visible flex",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,top:le?.position.top,left:le?.position.left},onClick:q=>q.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let q=new Date,Ae=new Date(q);Ae.setDate(q.getDate()+1);let ot=new Date(q);ot.setDate(q.getDate()+7);let ne=new Date(q);return ne.setDate(q.getDate()+14),[{label:"Hoy",date:q},{label:"Ma\xF1ana",date:Ae},{label:"Pr\xF3xima semana",date:ot},{label:"2 semanas",date:ne}].map((xt,Le)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:At=>At.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:At=>At.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[ce]:xt.date}),xe(null);},children:xt.label},Le))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:q=>q.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:q=>q.currentTarget.style.backgroundColor="transparent",onClick:()=>{h?.(ae.id,{[ce]:void 0}),xe(null);},children:"Borrar"})]}),jsxs("div",{className:"p-2",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("button",{type:"button",onClick:()=>xe(q=>q?{...q,month:new Date(q.month.getFullYear(),q.month.getMonth()-1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})}),jsx("span",{className:"text-xs font-medium",style:{color:t.textPrimary},children:le?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>xe(q=>q?{...q,month:new Date(q.month.getFullYear(),q.month.getMonth()+1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:["D","L","M","M","J","V","S"].map((q,Ae)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:q},Ae))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let q=le?.month||new Date,Ae=q.getFullYear(),ot=q.getMonth(),ne=new Date(Ae,ot,1).getDay(),Re=new Date(Ae,ot+1,0).getDate(),xt=new Date,Le=[];for(let st=ne-1;st>=0;st--)Le.push({day:new Date(Ae,ot,-st).getDate(),date:new Date(Ae,ot-1,new Date(Ae,ot,-st).getDate()),isCurrentMonth:false});for(let st=1;st<=Re;st++)Le.push({day:st,date:new Date(Ae,ot,st),isCurrentMonth:true});let At=42-Le.length;for(let st=1;st<=At;st++)Le.push({day:st,date:new Date(Ae,ot+1,st),isCurrentMonth:false});return Le.map((st,ga)=>{let zt=st.date.toDateString()===xt.toDateString(),kt=(Ie?typeof Ie=="string"?new Date(Ie):Ie:null)?.toDateString()===st.date.toDateString();return jsx("button",{type:"button",className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",style:{color:st.isCurrentMonth?kt?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:kt?"#3B82F6":"transparent",boxShadow:zt&&!kt?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{h?.(ae.id,{[ce]:st.date}),xe(null);},children:st.day},ga)})})()})]})]})]}),document.body)]});case "duration":return jsx("div",{className:"flex items-center justify-center w-full",children:jsx("span",{className:"text-xs tabular-nums",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:600},children:oe(ae)})});case "assignees":let va=r.filter(q=>ae.assignees?.some(Ae=>Ae.name===q.name||Ae.initials===q.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(Hr,{assignedUsers:va,availableUsers:r,onChange:q=>{let Ae=q.map(ot=>({id:ot.id,name:ot.name,initials:ot.initials,color:ot.color}));h?.(ae.id,{assignees:Ae.length>0?Ae:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(Xl,{status:ae.status||"todo",onChange:q=>{h?.(ae.id,{status:q,progress:q==="completed"?100:ae.progress});}})});case "progress":return jsxs("div",{className:"flex items-center justify-center gap-2 w-full",children:[jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden max-w-[60px]",style:{backgroundColor:t.bgSecondary},children:jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ae.progress}%`,backgroundColor:ae.progress===100?t.statusCompleted:t.accent}})}),jsxs("span",{className:"text-xs tabular-nums min-w-[35px] text-right",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600},children:[ae.progress,"%"]})]});case "priority":let ua={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},E={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},ye=ua[ae.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:q=>q.stopPropagation(),children:jsx(zr,{priority:ye,onChange:q=>{q&&h?.(ae.id,{priority:E[q]||"medium"});}})});default:return null}},tt=_=>[{id:"hide",label:"Hide Column",icon:Rt.Hide,onClick:()=>d(_),disabled:_==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Rt.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Rt.SortDesc,onClick:()=>{}}],Ge=_=>_.subtasks&&_.subtasks.length>0?[{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Rt.Add,onClick:()=>{v?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Rt.Delete,onClick:()=>{k?k(_.id,_.name):b?.([_.id]);}}]:[{id:"edit",label:R?.contextMenu?.editTask||"Edit Task",icon:Rt.Pencil,onClick:()=>{n?.(_);}},{id:"addSubtask",label:R?.contextMenu?.addSubtask||"Add Subtask",icon:Rt.Add,onClick:()=>{v?.(_.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:R?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Rt.MarkIncomplete,onClick:()=>{h?.(_.id,{status:"todo",progress:0});},disabled:_.status==="todo"},{id:"setInProgress",label:R?.contextMenu?.setInProgress||"Set In Progress",icon:Rt.SetInProgress,onClick:()=>{h?.(_.id,{status:"in-progress"});},disabled:_.status==="in-progress"},{id:"markComplete",label:R?.contextMenu?.markComplete||"Mark Complete",icon:Rt.MarkComplete,onClick:()=>{h?.(_.id,{status:"completed",progress:100});},disabled:_.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:R?.contextMenu?.splitTask||"Split Task",icon:Rt.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:R?.contextMenu?.deleteTask||"Delete Task",icon:Rt.Delete,onClick:()=>{k?k(_.id,_.name):b?.([_.id]);}}],Be=u.filter(_=>_.visible),rt=Be.reduce((_,ae)=>_+ae.width,0);return jsxs("div",{className:"gantt-taskgrid-content",style:{backgroundColor:t.bgPrimary,minWidth:rt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${Jt}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[jsx("div",{className:"flex items-center flex-1 min-w-0",children:Be.map((_,ae)=>{let Ee=ae===Be.length-1,Ue=_.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${Ue?"":"justify-center"}`,style:{width:`${_.width}px`,minWidth:`${_.minWidth??(Ue?200:60)}px`,maxWidth:`${_.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:Ee?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:He=>{He.preventDefault(),Q({isOpen:true,x:He.clientX,y:He.clientY,type:"header",columnId:_.id});},onMouseEnter:He=>{He.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:He=>{He.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:_.label,children:_.label}),_.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:de===_.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:He=>{He.preventDefault(),He.stopPropagation(),be(_.id),J(He.clientX),G(_.width);},title:"Drag to resize column",children:jsx("div",{className:"absolute top-2 bottom-2 opacity-0 group-hover:opacity-100 transition-opacity",style:{left:"3px",width:"2px",backgroundColor:t.accent,borderRadius:"1px"}})})]},_.id)})}),jsxs("div",{className:"flex items-center gap-1 px-2",style:{position:"sticky",right:0,height:"100%",backgroundColor:t.bgGrid,zIndex:5},children:[jsx(Cn,{columns:u,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>ze(!Pe),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Pe&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:_=>_.stopPropagation(),children:[jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b",style:{borderColor:t.border},children:[jsx("h3",{className:"font-semibold text-sm",style:{color:t.textPrimary},children:"Keyboard Shortcuts"}),jsx("button",{onClick:()=>ze(false),className:"text-xs px-2 py-1 rounded hover:bg-opacity-10",style:{color:t.textTertiary},children:"Close"})]}),jsxs("div",{className:"space-y-3 text-xs",children:[jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Navigation"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move focus up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Select range"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Toggle selection"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Click"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Hierarchy"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Indent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Outdent task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Tab"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Expand/Collapse"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"\u2192 / \u2190"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Editing"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task below"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Create task above"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Shift + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Open task modal"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + Enter"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Rename task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"F2"})]})]})]}),jsxs("div",{children:[jsx("div",{className:"font-semibold mb-1.5",style:{color:t.textSecondary},children:"Actions"}),jsxs("div",{className:"space-y-1",children:[jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Move task up/down"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Alt + \u2191 / \u2193"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Delete task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Delete"})]}),jsxs("div",{className:"flex justify-between",children:[jsx("span",{style:{color:t.textTertiary},children:"Duplicate task"}),jsx("kbd",{className:"px-2 py-0.5 rounded font-mono text-xs",style:{backgroundColor:t.bgGrid,color:t.textPrimary},children:"Cmd/Ctrl + D"})]})]})]})]})]})]})]}),jsx("div",{className:"gantt-taskgrid-content",style:{minHeight:Ea},children:ct.map(({task:_,level:ae},Ee)=>{let Ue=Xt(_.id),He=Ce===_.id,W=He&&Oe==="above",ce=He&&Oe==="below",Ie=He&&Oe==="child",Dt={};return Ie&&(Dt.backgroundColor=`${t.accent}15`,Dt.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":_.id,className:`flex items-center cursor-pointer group ${X===_.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:Ue?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:Ue?t.accentLight:Ie?`${t.accent}15`:Ee%2===0?t.bgPrimary:t.bgGrid,...Dt},onMouseEnter:()=>D(_.id),onMouseLeave:()=>D(null),onClick:Je=>{let ua=vo(e).map(q=>q.id),ye=navigator.platform.toUpperCase().indexOf("MAC")>=0?Je.metaKey:Je.ctrlKey;Fe(_.id,ua,ye,Je.shiftKey),s?.(_);},onDoubleClick:Je=>{Je.stopPropagation(),n?.(_);},onContextMenu:Je=>{Je.preventDefault(),Q({isOpen:true,x:Je.clientX,y:Je.clientY,type:"task",task:_}),p?.(_,Je);},whileHover:{backgroundColor:Ue?t.accentLight:t.hoverBg},children:[W&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),ce&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Be.map((Je,va)=>{let ua=va===Be.length-1,E=Je.id==="name";return jsx("div",{className:`px-4 flex items-center ${E?"justify-start":"justify-center"}`,style:{width:`${Je.width}px`,minWidth:`${Je.minWidth??(E?200:60)}px`,maxWidth:`${Je.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:ua?"none":`1px solid ${M===_.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:$e(Je,_,E?ae:0)},`${_.id}-${Je.id}`)})]},_.id)})}),jsx(yo,{isOpen:A.isOpen,x:A.x,y:A.y,items:A.type==="header"&&A.columnId?tt(A.columnId):A.type==="task"&&A.task?Ge(A.task):[],onClose:()=>Q({...A,isOpen:false}),theme:t}),mt&&vt&&X&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:vt.x+12,top:vt.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let _=ct.find(ae=>ae.task.id===X)?.task;return _?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:_.name})}):null})()}),document.body)]})}function dc(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[n,p]=useState(e),[m,i]=useState(t),[u,d]=useState(null),[g,h]=useState(null),[C,T]=useState(null),[c,b]=useState(null),[y,l]=useState(0),[x,v]=useState(0),[S,k]=useState(null),[w,R]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:n,setGhostX:p,ghostWidth:m,setGhostWidth:i,connectionLine:u,setConnectionLine:d,hoveredTaskId:g,setHoveredTaskId:h,activeZone:C,setActiveZone:T,draggedSegmentIndex:c,setDraggedSegmentIndex:b,draggedSegmentStartX:y,setDraggedSegmentStartX:l,segmentDragOffsetX:x,setSegmentDragOffsetX:v,hoveredSegmentIndex:S,setHoveredSegmentIndex:k,isHovered:w,setIsHovered:R,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(K,te)=>{r("none"),d(null),h(null),p(K),i(te),v(0),b(null),l(0);}}}function Sn({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:n,templates:p,onClick:m,onDoubleClick:i,onContextMenu:u,onDateChange:d,onDependencyCreate:g,allTaskPositions:h=[],onDragMove:C,onHoverChange:T}){let c=dc(t,r),b=useRef(null),{dragMode:y,setDragMode:l,dragOffset:x,setDragOffset:v,ghostX:S,setGhostX:k,ghostWidth:w,setGhostWidth:R,connectionLine:M,setConnectionLine:D,hoveredTaskId:I,setHoveredTaskId:B,activeZone:K,setActiveZone:te,draggedSegmentIndex:ie,setDraggedSegmentIndex:de,draggedSegmentStartX:be,setDraggedSegmentStartX:$,segmentDragOffsetX:J,setSegmentDragOffsetX:U,hoveredSegmentIndex:G,setHoveredSegmentIndex:A,isHovered:Q,setIsHovered:X,isDragging:H,isResizing:Ce,isConnecting:Me,resetDragState:Oe}=c,ve=32,Ke=8,We=e.endDate&&e.endDate<new Date&&e.progress<100,et=e.isCriticalPath,vt=o.name==="neutral"||o.today==="#1C1917",Mt=e.status==="completed"||e.progress===100,mt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},le=e.isCriticalPath||We?"#DC2626":e.color?e.color:e.priority&&mt[e.priority]?mt[e.priority]:o.taskBarPrimary,Pe=(N=>N>=80?20:N>=60?15:N>=50?12:10)(r),ze=r<50,at=r<40;useEffect(()=>{if(T)if(Q&&!H&&!e.segments){let N=a<100;T({task:e,x:t,y:a,width:r,height:ve,showBelow:N});}else T(null);},[Q,H,e,t,a,r,ve,T]);let Et=N=>N.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Fe=()=>{let N=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${N} day${N!==1?"s":""}`},Xt=N=>Math.round(N/s)*s,Ot=N=>{let ee=Math.round(N/s),se=new Date(n);return se.setDate(se.getDate()+ee),se},Nt=(N,ee)=>{for(let se of h){if(se.id===e.id)continue;let De=5;if(N>=se.x-De&&N<=se.x+se.width+De&&ee>=se.y-De&&ee<=se.y+se.height+De)return se.id}return null},ct=useCallback((N,ee,se)=>{N.preventDefault(),N.stopPropagation();let De=b.current?.ownerSVGElement;if(!De)return;let $e=De.createSVGPoint();$e.x=N.clientX,$e.y=N.clientY;let tt=$e.matrixTransform(De.getScreenCTM()?.inverse()),Ge=se!==void 0?se:t,Be=ee;if(!Be){let rt=tt.x-Ge;N.shiftKey?(Be="connect",D({x:t+r,y:a+ve/2})):N.ctrlKey||N.metaKey?Be="move":N.altKey?Be=rt<r/2?"resize-start":"resize-end":at?rt<r/2?Be="move":Be="resize-end":ze?rt<=Pe/2?Be="resize-start":rt>=r-Pe/2?Be="resize-end":Be="move":rt<=Pe?Be="resize-start":rt>=r-Pe?Be="resize-end":Be="move";}l(Be),X(false),te(null),Be==="move"?v(tt.x-Ge):Be==="connect"?D({x:t+r,y:a+ve/2}):v(0),k(Ge),R(r);},[t,r,a,ve]),Jt=useCallback(N=>{if(y==="none")return;let ee=b.current?.ownerSVGElement;if(!ee)return;let se=ee.createSVGPoint();se.x=N.clientX,se.y=N.clientY;let De=se.matrixTransform(ee.getScreenCTM()?.inverse());if(y==="connect"){D({x:De.x,y:De.y});let $e=Nt(De.x,De.y);B($e);}else if(y==="move"){let $e=De.x-x,tt=Xt($e);k(tt),R(r);let Ge=Math.round((tt-t)/s);if(C?.(e.id,Ge,true),e.segments&&e.segments.length>0&&ie!==null){let Be=tt-be;U(Be);}}else if(y==="resize-start"){let $e=De.x,tt=Xt($e),Ge=t+r-tt;Ge>=s&&(k(tt),R(Ge));}else if(y==="resize-end"){let $e=De.x,Ge=Xt($e)-t;Ge>=s&&R(Ge);}},[y,t,r,s,x,e,Xt,ie,be,Nt,B,D,k,R,U,C]),Ea=useCallback(()=>{if(y!=="none"){if(y==="connect")I&&g&&g(e,I),D(null),B(null);else {let N=e.endDate.getTime()-e.startDate.getTime(),ee,se,De=true;if(y==="move"){if(ee=Ot(S),se=new Date(ee.getTime()+N),e.segments&&e.segments.length>0&&ie!==null){let $e=Math.round(J/s),tt=e.segments.map((_,ae)=>{if(ae===ie){let Ee=new Date(_.startDate),Ue=new Date(_.endDate);return Ee.setDate(Ee.getDate()+$e),Ue.setDate(Ue.getDate()+$e),{startDate:Ee,endDate:Ue}}return _}),Ge=tt.flatMap(_=>[_.startDate,_.endDate]),Be=new Date(Math.min(...Ge.map(_=>_.getTime()))),rt=new Date(Math.max(...Ge.map(_=>_.getTime())));d?.({...e,segments:tt},Be,rt),Oe(t,r);return}}else y==="resize-start"?(ee=Ot(S),se=e.endDate,ee>se&&(console.warn("Invalid date range: start date must be before or equal to end date"),De=false)):y==="resize-end"?(ee=e.startDate,se=Ot(S+w),se<ee&&(console.warn("Invalid date range: end date must be after or equal to start date"),De=false)):De=false;De&&ee&&se&&(se.getTime()<ee.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,ee,se));}C?.(e.id,0,false),Oe(t,r);}},[y,S,w,e,d,I,g,t,r,s,Ot,J,ie,Oe,C]);useEffect(()=>{if(y==="none")return;let N=se=>{Jt(se);},ee=()=>{Ea();};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",ee),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",ee);}},[y,Jt,Ea]);let oe=H&&!Me?S:t,ue=H&&!Me?w:r,pa=p.taskClass(e);return jsxs("g",{ref:b,onClick:()=>!H&&m?.(e),onDoubleClick:N=>{H||(N.stopPropagation(),i?.(e));},onContextMenu:N=>{N.preventDefault(),u?.(e,N);},onMouseEnter:()=>!H&&X(true),onMouseLeave:()=>{H||(X(false),te(null));},children:[jsx("rect",{x:t,y:a,width:r+24,height:ve,fill:"transparent",style:{pointerEvents:"all"}}),Q&&!H&&!ze&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Pe,height:ve,fill:K==="resize-start"?o.accent:"transparent",opacity:K==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-start"),onMouseDown:N=>ct(N,"resize-start")}),jsx("rect",{x:t+Pe,y:a,width:r-Pe*2,height:ve,fill:K==="move"?o.accent:"transparent",opacity:K==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:N=>ct(N,"move")}),jsx("rect",{x:t+r-Pe,y:a,width:Pe,height:ve,fill:K==="resize-end"?o.accent:"transparent",opacity:K==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:N=>ct(N,"resize-end")})]}),Q&&!H&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:ve,fill:K==="move"?o.accent:"transparent",opacity:K==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>te("move"),onMouseDown:N=>ct(N,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:ve,fill:K==="resize-end"?o.accent:"transparent",opacity:K==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>te("resize-end"),onMouseDown:N=>ct(N,"resize-end")}),Q&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+ve-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),H&&!Me&&!e.segments&&jsx(motion.rect,{x:S,y:a,width:w,height:ve,rx:Ke,fill:o.accent,opacity:.5,stroke:o.accent,strokeWidth:2,strokeDasharray:"4 4",initial:{opacity:0},animate:{opacity:.6},transition:{duration:.15},style:{pointerEvents:"none"}}),!e.segments&&jsx(motion.rect,{x:oe,y:a,width:ue,height:ve,rx:Ke,fill:le,"data-task-class":pa,initial:{opacity:0,scale:.95},animate:{opacity:H&&!Me?.15:e.parentId?.6:Q?.9:.8,scale:Q&&!H?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:N=>ct(N),style:{cursor:H?Me?"crosshair":Ce?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:oe,y:a,width:ue*(e.progress/100),height:ve,rx:Ke,fill:le,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((N,ee)=>{let se=(N.startDate.getTime()-n.getTime())/864e5*s,$e=(N.endDate.getTime()-n.getTime())/(1e3*60*60*24)*s-se+s,tt=H&&y==="move"&&ie===ee,Ge=G===ee,Be=tt?se+J:se;return jsxs("g",{onMouseEnter:()=>!H&&A(ee),onMouseLeave:()=>!H&&A(null),children:[jsx(motion.rect,{x:Be,y:a,width:$e,height:ve,rx:Ke,fill:le,initial:{opacity:0,scale:.95},animate:{opacity:tt||e.parentId?.6:Ge?.9:.8,scale:Ge&&!H?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:rt=>{rt.stopPropagation(),de(ee),$(se),ct(rt,void 0,se);},style:{cursor:H?Me?"crosshair":Ce?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Be,y:a,width:$e*(e.progress/100),height:ve,rx:Ke,fill:le,opacity:1,style:{pointerEvents:"none"}})]},`segment-${ee}`)}),vt&&(We||et)&&!e.segments&&jsxs(Fragment,{children:[et&&!We&&jsx("rect",{x:oe,y:a,width:ue,height:ve,rx:Ke,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),We&&jsx("rect",{x:oe,y:a,width:ue,height:ve,rx:Ke,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ue>60&&!e.segments&&(()=>{let N=p.taskLabel(e),ee=typeof N=="string"?N:e.name,se=ee.length>Math.floor(ue/8)?`${ee.substring(0,Math.floor(ue/8))}...`:ee;return jsx("text",{x:oe+12,y:a+ve/2,dominantBaseline:"middle",fill:Mt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Mt?"line-through":"none"},children:se})})(),ue>100&&e.progress>0&&e.progress<100&&!H&&!e.segments&&jsxs("text",{x:oe+ue-12,y:a+ve/2,dominantBaseline:"middle",textAnchor:"end",fill:"rgba(255, 255, 255, 0.9)",fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:[e.progress,"%"]}),e.status&&ue>80&&!H&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:oe+ue-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:oe+ue-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(Q||Ce)&&!Me&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{children:[jsx("rect",{x:oe-2,y:a,width:16,height:ve,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>te("resize-start"),onMouseLeave:()=>te(null),onMouseDown:N=>{N.stopPropagation(),ct(N,"resize-start");}}),jsx(motion.rect,{x:oe+4,y:a+8,width:3,height:ve-16,rx:1.5,fill:K==="resize-start"||y==="resize-start"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]}),jsxs("g",{children:[jsx("rect",{x:oe+ue-14,y:a,width:16,height:ve,fill:"transparent",style:{cursor:"ew-resize"},onMouseEnter:()=>te("resize-end"),onMouseLeave:()=>te(null),onMouseDown:N=>{N.stopPropagation(),ct(N,"resize-end");}}),jsx(motion.rect,{x:oe+ue-7,y:a+8,width:3,height:ve-16,rx:1.5,fill:K==="resize-end"||y==="resize-end"?"#ffffff":"rgba(255,255,255,0.5)",style:{pointerEvents:"none"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.15}})]})]}),jsx(AnimatePresence,{children:Q&&!H&&!e.segments&&jsxs(motion.g,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx("circle",{cx:t+r+10,cy:a+ve/2,r:10,fill:"transparent",style:{cursor:"crosshair"},onMouseEnter:()=>te("connect"),onMouseLeave:()=>te(null),onMouseDown:N=>{N.stopPropagation(),ct(N,"connect");}}),jsx(motion.circle,{cx:t+r+10,cy:a+ve/2,r:4,fill:o.accent,stroke:"#FFFFFF",strokeWidth:1.5,style:{pointerEvents:"none"},initial:{scale:0},animate:{scale:K==="connect"?1.4:1},exit:{scale:0},transition:{duration:.15,type:"spring",stiffness:500,damping:30}})]})}),Me&&M&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+ve/2,x2:M.x,y2:M.y,stroke:I?o.statusCompleted:o.accent,strokeWidth:I?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:I?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:M.x,cy:M.y,r:I?8:6,fill:I?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),I&&jsx(motion.text,{x:M.x+15,y:M.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:M.x+10},animate:{opacity:1,x:M.x+15},transition:{duration:.2},children:"Connect"})]}),(Q||H)&&!Me&&!e.segments&&jsx(motion.rect,{x:oe-2,y:a-2,width:ue+4,height:ve+4,rx:Ke+2,fill:"none",stroke:H?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:H?.6:.4,initial:{opacity:0},animate:{opacity:H?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),Ce&&jsxs(Fragment,{children:[jsx("line",{x1:S,y1:0,x2:S,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:S+w,y1:0,x2:S+w,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:Q&&!H&&!e.segments&&!T&&(()=>{let se=a<100,De=se?a+ve+13:a-82-13,$e=se?`M ${oe+ue/2-6} ${a+ve+3} L ${oe+ue/2} ${a+ve+13} L ${oe+ue/2+6} ${a+ve+3}`:`M ${oe+ue/2-6} ${a-13} L ${oe+ue/2} ${a-3} L ${oe+ue/2+6} ${a-13}`,tt=De+22,Ge=De+40,Be=De+55,rt=De+70,_=se?De+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:se?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:se?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:$e,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:oe+ue/2-120,y:De,width:240,height:82,rx:8,fill:o.bgSecondary,stroke:o.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:oe+ue/2,y:tt,textAnchor:"middle",fill:o.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>28?`${e.name.substring(0,28)}...`:e.name}),jsx("text",{x:oe+ue/2-110,y:Ge,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:oe+ue/2-70,y:Ge,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Et(e.startDate)}),jsx("text",{x:oe+ue/2-110,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:oe+ue/2-70,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Et(e.endDate)}),jsx("text",{x:oe+ue/2+10,y:Ge,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:oe+ue/2+65,y:Ge,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Fe()}),jsx("text",{x:oe+ue/2+10,y:Be,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:oe+ue/2+65,y:Be,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.progress,"%"]}),e.assignees&&e.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:oe+ue/2-110,y:rt,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:oe+ue/2-50,y:rt,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(ae=>ae.name).join(", ").substring(0,30),e.assignees.map(ae=>ae.name).join(", ").length>30?"...":""]})]}),!se&&jsx("text",{x:oe+ue/2,y:_,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":ze?"Drag to move \u2022 Hold ALT + drag edge to resize":"Drag edges to resize \u2022 Drag center to move \u2022 Click \u26AB to link"})]})})()})]})}function pc({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:n,showBelow:p}=e,m=82,i=13,u=p?o+n+i:o-m-i,d=p?`M ${r+s/2-6} ${o+n+3} L ${r+s/2} ${o+n+13} L ${r+s/2+6} ${o+n+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,g=u+22,h=u+40,C=u+55,T=u+70,c=x=>x.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let x=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${x} day${x!==1?"s":""}`};return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:p?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:p?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:u,width:240,height:m,rx:8,fill:t.bgSecondary,stroke:t.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("text",{x:r+s/2,y:g,textAnchor:"middle",fill:t.textPrimary,fontSize:"13",fontWeight:"600",fontFamily:"Inter, sans-serif",children:a.name.length>28?`${a.name.substring(0,28)}...`:a.name}),jsx("text",{x:r+s/2-110,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?c(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?c(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:h,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:h,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:C,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:C,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.progress,"%"]}),a.assignees&&a.assignees.length>0&&jsxs(Fragment,{children:[jsx("text",{x:r+s/2-110,y:T,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:T,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(x=>x.name).join(", ").substring(0,30),a.assignees.map(x=>x.name).join(", ").length>30?"...":""]})]})]})})}function Mn({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,lineStyle:n="curved",isHoverLayer:p=false}){let[m,i]=useState(false),[u,d]=useState(null),g=r-t,h=g>0,C=Math.abs(g)<5,c=5,b=20,y=!C&&a<=e,l,x;if(C)if(x=(e+a)/2,n==="squared")l=`M ${e} ${t} L ${a} ${r}`;else {let ie=Math.min(Math.abs(a-e)/3,30);l=`M ${e} ${t} C ${e+ie} ${t}, ${a-ie} ${r}, ${a} ${r}`;}else if(x=a-b,y){let de=e+15,be=a-b,$=h?t+20:t-20;x=be,n==="squared"?l=`M ${e} ${t} L ${de} ${t} L ${de} ${$} L ${be} ${$} L ${be} ${r} L ${a} ${r}`:h?l=`M ${e} ${t} L ${de-c} ${t} Q ${de} ${t} ${de} ${t+c} L ${de} ${$-c} Q ${de} ${$} ${de-c} ${$} L ${be+c} ${$} Q ${be} ${$} ${be} ${$+c} L ${be} ${r-c} Q ${be} ${r} ${be+c} ${r} L ${a} ${r}`:l=`M ${e} ${t} L ${de-c} ${t} Q ${de} ${t} ${de} ${t-c} L ${de} ${$+c} Q ${de} ${$} ${de-c} ${$} L ${be+c} ${$} Q ${be} ${$} ${be} ${$-c} L ${be} ${r+c} Q ${be} ${r} ${be+c} ${r} L ${a} ${r}`;}else n==="squared"?l=`M ${e} ${t} L ${x} ${t} L ${x} ${r} L ${a} ${r}`:h?l=`M ${e} ${t} L ${x-c} ${t} Q ${x} ${t} ${x} ${t+c} L ${x} ${r-c} Q ${x} ${r} ${x+c} ${r} L ${a} ${r}`:l=`M ${e} ${t} L ${x-c} ${t} Q ${x} ${t} ${x} ${t-c} L ${x} ${r+c} Q ${x} ${r} ${x+c} ${r} L ${a} ${r}`;let v=5,S=`M ${a} ${r} L ${a-v} ${r-v*.5} M ${a} ${r} L ${a-v} ${r+v*.5}`,k=o.dependency,w=o.dependencyHover||k,R="#f87171",M="rgba(248, 113, 113, 0.15)",D=x,I=(t+r)/2;if(u)if(C)D=Math.max(e+10,Math.min(a-10,u.x)),I=t;else if(y){let ie=e+15,de=a-b,be=h?t+20:t-20,$=[[e,t,ie,t],[ie,t,ie,be],[ie,be,de,be],[de,be,de,r],[de,r,a,r]],J=1/0,U={x:D,y:I};for(let G of $){let A=B(u.x,u.y,G[0],G[1],G[2],G[3]),Q=Math.hypot(u.x-A.x,u.y-A.y);Q<J&&(J=Q,U=A);}D=U.x,I=U.y;}else {let ie=[[e,t,x,t],[x,t,x,r],[x,r,a,r]],de=1/0,be={x:D,y:I};for(let $ of ie){let J=B(u.x,u.y,$[0],$[1],$[2],$[3]),U=Math.hypot(u.x-J.x,u.y-J.y);U<de&&(de=U,be=J);}D=be.x,I=be.y;}function B(ie,de,be,$,J,U){let G=J-be,A=U-$,Q=G*G+A*A;if(Q===0)return {x:be,y:$};let X=((ie-be)*G+(de-$)*A)/Q;return X=Math.max(0,Math.min(1,X)),{x:be+X*G,y:$+X*A}}let K=ie=>{let de=ie.currentTarget.ownerSVGElement;if(!de)return;let be=de.getBoundingClientRect();d({x:ie.clientX-be.left,y:ie.clientY-be.top});},te=()=>{i(false),d(null);};return p?jsxs("g",{onMouseLeave:te,onMouseMove:K,children:[jsx("path",{d:l,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx("path",{d:l,fill:"none",stroke:w,strokeWidth:8,strokeLinecap:"round",opacity:.15,style:{pointerEvents:"none",filter:"blur(4px)"}}),jsx("path",{d:l,fill:"none",stroke:w,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("path",{d:S,fill:"none",stroke:w,strokeWidth:2.5,strokeLinecap:"round",opacity:.9,style:{pointerEvents:"none"}}),jsx("circle",{cx:a,cy:r,r:4,fill:w,opacity:.9,style:{pointerEvents:"none"}}),s&&jsxs(motion.g,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.15,ease:"easeOut"},onClick:ie=>{ie.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:D,cy:I,r:9,fill:M,stroke:R,strokeWidth:1.5}),jsx("line",{x1:D-3,y1:I-3,x2:D+3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:D+3,y1:I-3,x2:D-3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"})]})]}):jsxs("g",{onMouseEnter:()=>i(true),onMouseLeave:te,onMouseMove:K,style:{cursor:s?"pointer":"default"},children:[jsx("path",{d:l,fill:"none",stroke:"transparent",strokeWidth:16,strokeLinecap:"round",style:{cursor:s?"pointer":"default"}}),jsx(motion.path,{d:l,fill:"none",stroke:m?w:k,strokeWidth:m?2.5:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:1},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2}}}),jsx(motion.path,{d:S,fill:"none",stroke:m?w:k,strokeWidth:m?2.5:2,strokeLinecap:"round",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.3}}),jsx(motion.circle,{cx:a,cy:r,r:m?4:3,fill:m?w:k,initial:{scale:0},animate:{scale:1},transition:{delay:.3,duration:.15}}),m&&s&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.15},onClick:ie=>{ie.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:D,cy:I,r:9,fill:M,stroke:R,strokeWidth:1.5}),jsx("line",{x1:D-3,y1:I-3,x2:D+3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"}),jsx("line",{x1:D+3,y1:I-3,x2:D-3,y2:I+3,stroke:R,strokeWidth:1.5,strokeLinecap:"round"})]})]})}function Fn({task:e,x:t,y:a,theme:r,onClick:o}){let[s,n]=useState(false),p=16,m=i=>i.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>n(true),onMouseLeave:()=>n(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:p+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-p/2,y:a+16-p/2,width:p,height:p,fill:e.isCriticalPath?r.criticalPath:r.milestone,stroke:r.bgGrid,strokeWidth:2,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:0,rotate:0},animate:{scale:s?1.15:1,rotate:45},transition:{duration:.3,type:"spring",stiffness:300,damping:20}}),s&&jsx(motion.rect,{x:t-(p+4)/2,y:a+16-(p+4)/2,width:p+4,height:p+4,fill:"none",stroke:e.isCriticalPath?r.criticalPath:r.milestone,strokeWidth:2,opacity:.5,transform:`rotate(45 ${t} ${a+16})`,initial:{scale:.8,opacity:0},animate:{scale:1,opacity:.5},transition:{duration:.2}}),jsx(AnimatePresence,{children:s&&jsxs(motion.g,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.2},children:[jsx("rect",{x:t-80,y:a-50,width:160,height:44,rx:8,fill:r.bgSecondary,stroke:r.border,strokeWidth:1,filter:"drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15))"}),jsx("path",{d:`M ${t-6} ${a-6} L ${t} ${a+4} L ${t+6} ${a-6}`,fill:r.bgSecondary,stroke:r.border,strokeWidth:1}),jsx("rect",{x:t-70,y:a-38,width:8,height:8,fill:e.isCriticalPath?r.criticalPath:r.milestone,transform:`rotate(45 ${t-66} ${a-34})`}),jsx("text",{x:t-55,y:a-32,fill:r.textPrimary,fontSize:"12",fontWeight:"600",fontFamily:"Inter, sans-serif",children:e.name.length>18?`${e.name.substring(0,18)}...`:e.name}),jsx("text",{x:t-55,y:a-18,fill:r.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",children:m(e.startDate)}),e.isCriticalPath&&jsxs("g",{children:[jsx("rect",{x:t+10,y:a-40,width:60,height:16,rx:4,fill:r.criticalPathLight}),jsx("text",{x:t+40,y:a-30,textAnchor:"middle",fill:r.criticalPath,fontSize:"9",fontWeight:"700",fontFamily:"Inter, sans-serif",letterSpacing:"0.5",children:"CRITICAL"})]})]})})]})}var fe={calculateEndDate:(e,t)=>{let a=new Date(e);return a.setDate(a.getDate()+t),a},calculateDuration:(e,t)=>{let a=t.getTime()-e.getTime();return Math.ceil(a/(1e3*60*60*24))},calculateWorkingDays:(e,t)=>{let a=0,r=new Date(e);for(;r<=t;){let o=r.getDay();o!==0&&o!==6&&a++,r.setDate(r.getDate()+1);}return a},addWorkingDays:(e,t)=>{let a=new Date(e),r=0;for(;r<t;){a.setDate(a.getDate()+1);let o=a.getDay();o!==0&&o!==6&&r++;}return a},isWeekend:e=>{let t=e.getDay();return t===0||t===6},validateDependencies:(e,t,a)=>{let r=new Map,o=i=>{i.forEach(u=>{u.dependencies&&r.set(u.id,u.dependencies),u.subtasks&&o(u.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let n=new Set,p=new Set,m=i=>{if(!n.has(i)){n.add(i),p.add(i);let u=r.get(i)||[];for(let d of u){if(!n.has(d)&&m(d))return true;if(p.has(d))return true}}return p.delete(i),false};return m(a)},flattenTasks:e=>{let t=[],a=r=>{r.forEach(o=>{t.push(o),o.subtasks&&o.subtasks.length>0&&a(o.subtasks);});};return a(e),t},findTaskById:(e,t)=>{for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=fe.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=fe.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=fe.findTaskById(e,o);if(s)a.unshift(s),o=s.parentId;else break}return a},exportToJSON:e=>JSON.stringify(e,null,2),importFromJSON:e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw new Error("Invalid JSON: expected an array of tasks");return t.forEach((a,r)=>{if(!a.id||!a.name)throw new Error(`Invalid task at index ${r}: missing required fields (id, name)`)}),t}catch(t){throw new Error(`Failed to import tasks: ${t instanceof Error?t.message:"Unknown error"}`)}},exportToCSV:e=>{let t=fe.flattenTasks(e),r=[["ID","Name","Start Date","End Date","Progress","Status","Dependencies"].join(",")];return t.forEach(o=>{let s=[o.id,`"${o.name.replace(/"/g,'""')}"`,o.startDate?o.startDate.toISOString().split("T")[0]:"",o.endDate?o.endDate.toISOString().split("T")[0]:"",o.progress.toString(),o.status||"",o.dependencies?.join(";")||""];r.push(s.join(","));}),r.join(`
112
112
  `)},formatDate:e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return `${t}-${a}-${r}`},parseDate:e=>new Date(e),getTaskDateRange:e=>!e.startDate||!e.endDate?null:{start:e.startDate,end:e.endDate},getEarliestStartDate:e=>{let a=fe.flattenTasks(e).filter(r=>r.startDate);return a.length===0?null:new Date(Math.min(...a.map(r=>r.startDate.getTime())))},getLatestEndDate:e=>{let a=fe.flattenTasks(e).filter(r=>r.endDate);return a.length===0?null:new Date(Math.max(...a.map(r=>r.endDate.getTime())))},tasksOverlap:(e,t)=>!e.startDate||!e.endDate||!t.startDate||!t.endDate?false:e.startDate<=t.endDate&&t.startDate<=e.endDate,getDependentTasks:(e,t)=>fe.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=fe.findTaskById(e,t);return !a||!a.dependencies?[]:fe.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>fe.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>fe.flattenTasks(e).filter(r=>!r.startDate||!r.endDate?false:r.startDate<=a&&r.endDate>=t),sortByStartDate:(e,t=true)=>[...e].sort((a,r)=>{if(!a.startDate||!r.startDate)return 0;let o=a.startDate.getTime()-r.startDate.getTime();return t?o:-o}),sortByEndDate:(e,t=true)=>[...e].sort((a,r)=>{if(!a.endDate||!r.endDate)return 0;let o=a.endDate.getTime()-r.endDate.getTime();return t?o:-o}),sortByProgress:(e,t=true)=>[...e].sort((a,r)=>{let o=a.progress-r.progress;return t?o:-o}),calculateTotalProgress:e=>{let t=fe.flattenTasks(e);if(t.length===0)return 0;let a=t.reduce((r,o)=>r+o.progress,0);return Math.round(a/t.length)},getTaskByPath:(e,t)=>{let a=e,r;for(let o=0;o<t.length;o++){let s=t[o];if(!a||s===void 0||s>=a.length||(r=a[s],!r))return;o<t.length-1&&(a=r.subtasks||[]);}return r},cloneTask:(e,t)=>({...e,id:t||`${e.id}-copy`,subtasks:e.subtasks?.map(a=>fe.cloneTask(a))}),exportToPDF:async(e,t="gantt-chart.pdf")=>{try{if(!e||e.length===0){alert("No tasks available to export to PDF");return}let{jsPDF:a}=await import('jspdf'),{default:r}=await import('jspdf-autotable'),o=new a,s=fe.flattenTasks(e);if(s.length===0){alert("No tasks found to export");return}o.setFontSize(16),o.text("Gantt Chart - Task List",14,20);let n=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],p=s.map(m=>{let i=m.startDate&&m.endDate?fe.calculateDuration(m.startDate,m.endDate):0;return [m.name,m.startDate?fe.formatDate(m.startDate):"N/A",m.endDate?fe.formatDate(m.endDate):"N/A",i>0?`${i} days`:"N/A",`${m.progress}%`,m.status||"N/A"]});r(o,{head:n,body:p,startY:30,styles:{fontSize:9,cellPadding:3},headStyles:{fillColor:[66,139,202],textColor:255,fontStyle:"bold"},alternateRowStyles:{fillColor:[245,245,245]},columnStyles:{0:{cellWidth:60},1:{cellWidth:30},2:{cellWidth:30},3:{cellWidth:25},4:{cellWidth:20},5:{cellWidth:25}}}),o.save(t);}catch(a){throw a}},exportToExcel:async(e,t="gantt-chart.xlsx")=>{let a=await import('xlsx'),o=fe.flattenTasks(e).map(m=>{let i=m.startDate&&m.endDate?fe.calculateDuration(m.startDate,m.endDate):0;return {"Task ID":m.id,"Task Name":m.name,"Start Date":m.startDate?fe.formatDate(m.startDate):"","End Date":m.endDate?fe.formatDate(m.endDate):"","Duration (days)":i>0?i:"","Progress (%)":m.progress,Status:m.status||"",Assignees:m.assignees?.map(u=>u.name).join(", ")||"",Dependencies:m.dependencies?.join(", ")||"","Is Milestone":m.isMilestone?"Yes":"No","Parent ID":m.parentId||"",Level:m.level||0}}),s=a.utils.json_to_sheet(o),n=[{wch:15},{wch:40},{wch:12},{wch:12},{wch:15},{wch:12},{wch:15},{wch:30},{wch:20},{wch:12},{wch:15},{wch:8}];s["!cols"]=n;let p=a.utils.book_new();a.utils.book_append_sheet(p,s,"Gantt Tasks"),a.writeFile(p,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=fe.flattenTasks(e),o=new Map;r.forEach((g,h)=>{o.set(g.id,h+1);});let s=g=>g.toISOString().replace("Z",""),n=fe.getEarliestStartDate(e)||new Date,p=fe.getLatestEndDate(e)||new Date,m=r.map((g,h)=>{let C=o.get(g.id),T=g.startDate&&g.endDate?fe.calculateDuration(g.startDate,g.endDate):0,c=(g.dependencies||[]).filter(b=>o.has(b)).map(b=>`
113
113
  <PredecessorLink>
114
114
  <PredecessorUID>${o.get(b)}</PredecessorUID>