@libxai/board 0.17.127 → 0.17.128

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
@@ -42,7 +42,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
42
42
  1.
43
43
 
44
44
  **Action items:**
45
- - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function _n({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),d=useRef(null);useEffect(()=>{function n(p){s.current&&!s.current.contains(p.target)&&d.current&&!d.current.contains(p.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},m=e.reduce((n,p)=>{let l=p.category||"Other";return n[l]||(n[l]=[]),n[l].push(p),n},{});return jsxs("div",{className:k("relative inline-block",a),children:[jsxs("button",{ref:d,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:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",n.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",n.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:k("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(([n,p])=>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:n})}),jsx("div",{children:p.map(l=>jsxs("button",{onClick:()=>c(l),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:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:l.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:l.name}),l.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:l.description})]})]},l.id))})]},n)),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 jn({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[d,c]=useState("export"),[m,n]=useState("json"),[p,l]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,y=await xi(e,m,f);ki(y,m);},v=async f=>{let y=f.target.files?.[0];if(y){try{let x=await Ti(y),b=y.name.endsWith(".json")?"json":"csv",g=Ci(x,b);l(g),g.success&&r&&r(g,x);}catch(x){l({success:false,errors:[`Failed to read file: ${x instanceof Error?x.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:k("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:()=>c("export"),className:k("flex-1 px-6 py-4 font-semibold transition-colors",d==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:k("flex-1 px-6 py-4 font-semibold transition-colors",d==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[d==="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(f=>jsxs("button",{onClick:()=>n(f),className:k("p-4 rounded-lg border-2 transition-all text-center",m===f?"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:[f==="json"&&"\u{1F4C4}",f==="csv"&&"\u{1F4CA}",f==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:f})]},f))})]}),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:u,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"})]}),d==="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:i,type:"file",accept:".json,.csv",onChange:v,className:"hidden"}),jsxs("button",{onClick:()=>i.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"})]})]}),p&&jsxs("div",{className:k("p-4 rounded-lg",p.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:k("font-semibold mb-2",p.success?"text-green-400":"text-red-400"),children:p.success?"\u2713 Import Successful":"\u2717 Import Failed"}),p.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",p.cardsImported]}),jsxs("div",{children:["Columns imported: ",p.columnsImported]})]}),p.errors&&p.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:p.errors.map((f,y)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},y))})]})]})]})]})]})}var Xp=["URGENT","HIGH","MEDIUM","LOW"],Jp=[{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"}],Zp=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Kn({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:d,onFilterHighPriority:c,availableUsers:m=[],availableLabels:n=[],availableColumns:p=[],showQuickFilters:l=true,compact:i=false,groupBy:u="none",onGroupByChange:v}){let[f,y]=useState(true),x=useCallback(h=>{a({search:h.target.value});},[a]),b=useCallback(h=>{a({dateFilter:h.target.value});},[a]),g=useCallback(h=>{r({by:h.target.value});},[r]),C=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),D=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 ${i?"filter-bar--compact":""} ${f?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>y(!f),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:f?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:f?"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"}),D&&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)"]})]}),!f&&jsxs("div",{className:"filter-bar__content",children:[l&&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"}),d&&jsx("button",{onClick:d,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,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:x,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:b,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:h=>{let A=h.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Xp.map(h=>jsx("option",{value:h,children:h},h))]})}),m.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:h=>{let A=h.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),m.map(h=>jsx("option",{value:h.id,children:h.name},h.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:h=>{let A=h.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(h=>jsx("option",{value:h,children:h},h))]})}),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:g,className:"filter-bar__select filter-bar__select--sm",children:Jp.map(h=>jsx("option",{value:h.value,children:h.label},h.value))}),t.by!=="none"&&jsx("button",{onClick:C,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),v&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:h=>v(h.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Zp.map(h=>jsx("option",{value:h.value,children:h.label},h.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Yn({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:d,onExportGanttPNG:c,onExportGanttCSV:m}){let[n,p]=useState(false),l=useRef(null);useEffect(()=>{let u=v=>{l.current&&!l.current.contains(v.target)&&p(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),p(false);};return jsxs("div",{className:k("relative",r),ref:l,children:[jsxs("button",{onClick:()=>p(!n),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",u.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",u.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":n,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"})]}),n&&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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await d?.()),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await c?.()),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(()=>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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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 qn={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"}},Xn={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"}},Jn={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"}},er={dark:qn,light:Xn,neutral:Jn},wo="dark";var Co=createContext(void 0),lu="asakaa-theme";function wl({children:e,defaultTheme:t=wo,storageKey:a=lu}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,m=er[r];Object.entries(m.colors).forEach(([p,l])=>{l&&c.style.setProperty(`--theme-${du(p)}`,l);}),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(([p,l])=>{let i=m.colors[p];i&&c.style.setProperty(l,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let d={theme:r,setTheme:s,themes:er};return jsx(Co.Provider,{value:d,children:e})}function xr(){let e=useContext(Co);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function du(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Zn({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=xr();return e?jsxs("div",{className:k("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(er).map(([s,d])=>jsxs("button",{onClick:()=>{o(s),t();},className:k("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:d.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:d.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}var Oe={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"rgba(180, 185, 197, 0.25)",dependencyHover:"rgba(180, 185, 197, 0.45)",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#06B6D4",todayLight:"rgba(6, 182, 212, 0.12)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.1)",statusTodo:"#64748B",statusInProgress:"#3B82F6",statusCompleted:"#10B981",hoverBg:"rgba(255, 255, 255, 0.06)",focusRing:"#3B82F6"},light:{bgPrimary:"#FFFFFF",bgSecondary:"#F8FAFC",bgGrid:"#F1F5F9",bgWeekend:"rgba(37, 99, 235, 0.03)",border:"#CBD5E1",borderLight:"#E2E8F0",textPrimary:"#0F172A",textSecondary:"#334155",textTertiary:"#64748B",accent:"#2563EB",accentHover:"#1D4ED8",accentLight:"rgba(37, 99, 235, 0.08)",taskBarPrimary:"#2563EB",taskBarProgress:"#1E40AF",taskBarHandle:"#FFFFFF",dependency:"rgba(75, 85, 99, 0.25)",dependencyHover:"rgba(75, 85, 99, 0.45)",criticalPath:"#DC2626",criticalPathLight:"rgba(220, 38, 38, 0.1)",today:"#0891B2",todayLight:"rgba(8, 145, 178, 0.1)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.08)",statusTodo:"#64748B",statusInProgress:"#2563EB",statusCompleted:"#059669",hoverBg:"rgba(0, 0, 0, 0.04)",focusRing:"#2563EB"},neutral:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgGrid:"#EFEDEC",bgWeekend:"rgba(41, 37, 36, 0.02)",border:"#D6D3D1",borderLight:"#E7E5E4",textPrimary:"#0C0A09",textSecondary:"#44403C",textTertiary:"#78716C",accent:"#292524",accentHover:"#44403C",accentLight:"rgba(41, 37, 36, 0.08)",taskBarPrimary:"#292524",taskBarProgress:"#1C1917",taskBarHandle:"#FFFFFF",dependency:"rgba(87, 83, 78, 0.25)",dependencyHover:"rgba(87, 83, 78, 0.4)",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};function Cl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Oe[e]||Oe.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,d)=>a.getPropertyValue(s).trim()||d;return {bgPrimary:r("--theme-bg-primary",Oe[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Oe[e].bgSecondary),bgGrid:r("--theme-bg-card",Oe[e].bgGrid),bgWeekend:r("--theme-bg-hover",Oe[e].bgWeekend),border:r("--theme-border-primary",Oe[e].border),borderLight:r("--theme-border-subtle",Oe[e].borderLight),textPrimary:r("--theme-text-primary",Oe[e].textPrimary),textSecondary:r("--theme-text-secondary",Oe[e].textSecondary),textTertiary:r("--theme-text-tertiary",Oe[e].textTertiary),accent:r("--theme-accent-primary",Oe[e].accent),accentHover:r("--theme-accent-hover",Oe[e].accentHover),accentLight:r("--theme-accent-primary",Oe[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Oe[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Oe[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Oe[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Oe[e].dependency),dependencyHover:r("--theme-border-secondary",Oe[e].dependencyHover),criticalPath:r("--theme-error",Oe[e].criticalPath),criticalPathLight:r("--theme-error",Oe[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Oe[e].today):e==="neutral"?r("--theme-text-primary",Oe[e].today):r("--theme-error",Oe[e].today),todayLight:e==="light"?r("--theme-accent-primary",Oe[e].todayLight):e==="neutral"?r("--theme-text-primary",Oe[e].todayLight):r("--theme-error",Oe[e].todayLight),milestone:r("--theme-warning",Oe[e].milestone),milestoneLight:r("--theme-warning",Oe[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Oe[e].statusTodo),statusInProgress:r("--theme-accent-primary",Oe[e].statusInProgress),statusCompleted:r("--theme-success",Oe[e].statusCompleted),hoverBg:r("--theme-bg-hover",Oe[e].hoverBg),focusRing:r("--theme-accent-primary",Oe[e].focusRing)}}var To={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"},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"}},Tl={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"},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"}},Qn={en:To,es:Tl};function Dl(e){return Qn[e]||Qn.en}function es(e,t){let a=Dl(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 wr=createContext(To);function jr(){return useContext(wr)}function Nu({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:d}){let[c,m]=useState(false),[n,p]=useState(null),l=useRef(null),i=jr();if(useEffect(()=>{let y=x=>{l.current&&!l.current.contains(x.target)&&m(false);};return c&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[c]),!(t||a||r||o||s||d))return null;let v=[{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:d}].filter(y=>y.handler),f=async(y,x)=>{if(x){p(y);try{await x();}catch(b){console.error(`Export ${y} failed:`,b);}finally{p(null),m(false);}}};return jsxs("div",{ref:l,className:"relative",children:[jsxs(motion.button,{onClick:()=>m(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#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:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&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:v.map((y,x)=>jsxs(motion.button,{onClick:()=>f(y.id,y.handler),disabled:n!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:x<v.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:x*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:n===y.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):y.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:y.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:y.description})]})]},y.id))})})})]})}function Su({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 d=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:d?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500,zIndex:d?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[d&&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:d?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:d?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function Eu({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 Pu({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),d=jr();useEffect(()=>{let n=p=>{s.current&&!s.current.contains(p.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:d.toolbar.compact||"Compact"},{value:"comfortable",label:d.toolbar.normal||"Normal"},{value:"spacious",label:d.toolbar.spacious||"Spacious"}],m=c.find(n=>n.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:`${d.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:c.map((n,p)=>{let l=t===n.value;return jsxs(motion.button,{onClick:()=>{a(n.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:l?e.accentLight:"transparent",borderBottom:p<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:l?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:p*.03},children:[jsx("span",{className:"text-xs",style:{color:l?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500},children:n.label}),l&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function Do({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:d,rowDensity:c,onRowDensityChange:m,showThemeSelector:n=false,showCreateTaskButton:p=false,createTaskLabel:l,onCreateTask:i,onExportPNG:u,onExportPDF:v,onExportExcel:f,onExportCSV:y,onExportJSON:x,onExportMSProject:b}){let g=jr(),C=u||v||f||y||x||b,D=[{value:"day",label:g.toolbar.day},{value:"week",label:g.toolbar.week},{value:"month",label:g.toolbar.month}],h=[{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(Eu,{options:D,value:t,onChange:A=>a(A),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(Pu,{theme:e,value:c,onChange:m})]}),jsxs("div",{className:"flex items-center gap-3",children:[p&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,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:l||g.toolbar.createTask})]}),(C||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),C&&jsxs(Fragment,{children:[jsx(Nu,{theme:e,onExportPNG:u,onExportPDF:v,onExportExcel:f,onExportCSV:y,onExportJSON:x,onExportMSProject:b}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(Su,{options:h,value:s,onChange:A=>d(A),theme:e})]})]})}function No({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,d]=useState({x:0,y:0}),c=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let p=l=>{c.current&&!c.current.contains(l.target)&&o(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]);let n=e.filter(p=>p.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:m,onClick:()=>{if(!r&&m.current){let p=m.current.getBoundingClientRect();d({x:p.left,y:p.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(Ke,{children:jsx(motion.div,{ref:c,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"}),n.map(p=>jsxs("button",{onClick:()=>{t(p.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:l=>{l.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:p.label}),p.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},p.id))]})})})})]})}function Cr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let d=useRef(null),[c,m]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let p=200,l=r.length*36+8,i=8,u=window.innerWidth,v=window.innerHeight,f=t,y=a;t+p+i>u&&(f=t-p,f<i&&(f=i)),a+l+i>v&&(y=v-l-i,y<i&&(y=i)),m({x:f,y});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let p=i=>{d.current&&!d.current.contains(i.target)&&o();},l=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",p),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",l);}},[e,o]),!e)return null;let n=p=>p.startsWith("#")&&(p.length===7||p.length===4)?p: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:d,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:`${c.x}px`,top:`${c.y}px`,backgroundColor:n(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(p=>jsxs("div",{children:[p.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{p.disabled||(p.onClick(),o());},disabled:p.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:p.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:p.disabled?"not-allowed":"pointer",opacity:p.disabled?.5:1},onMouseEnter:l=>{p.disabled||(l.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[p.icon&&jsx("span",{style:{color:s.textSecondary},children:p.icon}),jsx("span",{className:"flex-1",children:p.label}),p.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},p.id))})})})}var it={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 Ul({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:d,onTaskIndent:c,onTaskOutdent:m,onTaskRename:n,onTaskToggleExpand:p,onOpenTaskModal:l,enableKeyboard:i=true}){let u=useRef(false),v=useCallback(g=>{u.current=g;},[]),f=useCallback(g=>{let C=[],D=h=>{for(let A of h)C.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(g),C},[]),y=useCallback(()=>{let g=f(e);for(let C of g)if(t.has(C.id))return C;return null},[e,t,f]),x=useCallback((g,C)=>{let D=f(e);if(D.length===0)return;let h=y();if(!h){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===h.id);if(A===-1)return;let w=g==="up"?A-1:A+1;if(w<0||w>=D.length)return;let L=D[w];a(L.id,C);},[e,y,f,a]),b=useCallback(g=>{if(!i)return;let C=g.target;if(C.tagName==="INPUT"||C.tagName==="TEXTAREA"||C.isContentEditable||u.current){g.key==="Escape"&&(C.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey,w=Array.from(t),L=y();if(g.key==="ArrowUp"){g.preventDefault(),x("up",g.shiftKey);return}if(g.key==="ArrowDown"){g.preventDefault(),x("down",g.shiftKey);return}if(L&&(g.key==="ArrowRight"||g.key==="ArrowLeft")){L.subtasks&&L.subtasks.length>0&&(g.preventDefault(),(g.key==="ArrowRight"&&!L.isExpanded||g.key==="ArrowLeft"&&L.isExpanded)&&p(L.id));return}if(g.altKey&&(g.key==="ArrowUp"||g.key==="ArrowDown")){w.length>0&&(g.preventDefault(),d(w,g.key==="ArrowUp"?"up":"down"));return}if(g.key==="Tab"&&!g.shiftKey){w.length>0&&(g.preventDefault(),c(w));return}if(g.key==="Tab"&&g.shiftKey){w.length>0&&(g.preventDefault(),m(w));return}if(g.key==="Enter"&&!g.shiftKey&&!A){L&&(g.preventDefault(),r(L.id,"below"));return}if(g.key==="Enter"&&g.shiftKey&&!A){L&&(g.preventDefault(),r(L.id,"above"));return}if(g.key==="Enter"&&A){L&&(g.preventDefault(),l(L.id));return}if(g.key==="F2"){L&&(g.preventDefault(),n(L.id));return}if(g.key==="Delete"||g.key==="Backspace"&&A){w.length>0&&(g.preventDefault(),o(w));return}if(g.key==="d"&&A&&!g.shiftKey){w.length>0&&(g.preventDefault(),s(w));return}},[i,t,y,x,r,o,s,d,c,m,n,p,l]);return useEffect(()=>{if(i)return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b);}},[i,b]),{setIsEditing:v}}function $l(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(l=>{t(new Set([l])),r(l);},[]),s=useCallback(l=>{t(i=>{let u=new Set(i);return u.has(l)?u.delete(l):u.add(l),u}),r(l);},[]),d=useCallback((l,i)=>{if(!a){o(l);return}let u=i.indexOf(a),v=i.indexOf(l);if(u===-1||v===-1){o(l);return}let f=Math.min(u,v),y=Math.max(u,v),x=i.slice(f,y+1);t(new Set(x)),r(l);},[a,o]),c=useCallback((l,i,u,v)=>{v?d(l,i):u?s(l):o(l);},[o,s,d]),m=useCallback((l,i)=>{i?t(u=>{let v=new Set(u);return v.add(l),v}):o(l);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),p=useCallback(l=>e.has(l),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:d,handleTaskClick:c,handleKeyboardSelection:m,clearSelection:n,isTaskSelected:p}}function Tr(e){let t=[],a=(r,o,s=0)=>{for(let d=0;d<r.length;d++){let c={...r[d],parentId:o,level:s,position:d};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function Wl(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Wl(a.subtasks,t);if(r)return r}}return null}function rs(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=rs(a.subtasks,t);if(r)return r}return null}function os(e,t){if(t.length===0)return e;let a=Tr(e),r=t[0],o=a.findIndex(l=>l.id===r);if(o<=0)return e;let s=a[o-1],d=(l,i)=>{let u=[];return {tasks:l.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let y=d(f.subtasks,i);f.subtasks=y.tasks,u.push(...y.removed);}return true}),removed:u}},c=(l,i,u)=>l.map(v=>v.id===i?{...v,subtasks:[...v.subtasks||[],...u],isExpanded:true}:v.subtasks?{...v,subtasks:c(v.subtasks,i,u)}:v),m=new Set(t),{tasks:n,removed:p}=d(e,m);return c(n,s.id,p)}function ns(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=rs(a,r);if(!o)continue;let s=rs(a,o.id),d=(n,p,l)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===p&&u.subtasks){let v=u.subtasks.findIndex(f=>f.id===l);if(v!==-1){let[f]=u.subtasks.splice(v,1);return f}}if(u.subtasks){let v=d(u.subtasks,p,l);if(v)return v}}return null},c=(n,p,l)=>{let i=n.findIndex(u=>u.id===p);if(i!==-1)return n.splice(i+1,0,l),n;for(let u of n)u.subtasks&&c(u.subtasks,p,l);return n},m=d(a,o.id,r);m&&(s&&s.subtasks?c(s.subtasks,o.id,m):c(a,o.id,m));}return a}function ss(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(d,c,m)=>{let n=d.findIndex(l=>l.id===c);if(n===-1){for(let l of d)if(l.subtasks&&s(l.subtasks,c,m))return true;return false}let p=m==="up"?n-1:n+1;return p<0||p>=d.length?false:([d[n],d[p]]=[d[p],d[n]],true)};return s(r,o,a),r}function is(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 ls(e,t){let a=[...e];for(let r of t){let o=d=>{let c=d.findIndex(p=>p.id===r);if(c===-1){for(let p of d)if(p.subtasks&&o(p.subtasks))return true;return false}let m=d[c],n={...m,id:`${m.id}-copy-${Date.now()}`,name:`${m.name} (Copy)`,subtasks:m.subtasks?s(m.subtasks):void 0};return d.splice(c+1,0,n),true},s=d=>d.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function Gl(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let d={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=m=>{let n=m.findIndex(l=>l.id===t);if(n===-1){for(let l of m)if(l.subtasks&&c(l.subtasks))return true;return false}let p=a==="above"?n:n+1;return m.splice(p,0,d),true};return c(r),{tasks:r,newTask:d}}function ds(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:ds(r.subtasks,t,a)}:r)}function cs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:cs(a.subtasks,t)}:a)}function ms(e,t){let a=p=>{for(let l of p){if(l.id===t)return l;if(l.subtasks){let i=a(l.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let d=r?.startDate||o,c=r?.endDate||s,m={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(d),endDate:new Date(c),color:r?.color||"#3B82F6"},n=p=>p.map(l=>{if(l.id===t){let i=l.subtasks||[];return {...l,subtasks:[...i,m],isExpanded:true}}return l.subtasks?{...l,subtasks:n(l.subtasks)}:l});return {tasks:n(e),newTask:m}}function Hl(e,t,a,r){if(t===a)return e;let o=Wl(e,t);if(!o)return e;if(a){let c=(m,n)=>{if(!m.subtasks)return false;for(let p of m.subtasks)if(p.id===n||c(p,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(m=>m.id!==t).map(m=>m.subtasks&&m.subtasks.length>0?{...m,subtasks:s(m.subtasks)}:m),d=s(e);if(a===null){let c=r!==void 0?r:d.length;d.splice(c,0,{...o,parentId:void 0});}else {let c=m=>m.map(n=>{if(n.id===a){let p=n.subtasks||[],l=r!==void 0?r:p.length,i=[...p];return i.splice(l,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});d=c(d);}return d}function Po({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:d,onTaskContextMenu:c,onTaskToggle:m,scrollTop:n,columns:p,onToggleColumn:l,onColumnResize:i,onTaskUpdate:u,onTaskIndent:v,onTaskOutdent:f,onTaskMove:y,onMultiTaskDelete:x,onTaskDuplicate:b,onTaskCreate:g,onTaskRename:C,onCreateSubtask:D,onOpenTaskModal:h,onDeleteRequest:A,onTaskReparent:w}){let L=useContext(wr),[T,z]=useState(null),[H,U]=useState(false),[E,J]=useState(null),[ge,ke]=useState(""),Le=useRef(null),Ee=useRef(null),[ce,S]=useState(null),[F,M]=useState(0),[V,P]=useState(0),[W,le]=useState({isOpen:false,x:0,y:0,type:"header"}),[te,Se]=useState(null),[se,Ve]=useState(null),[be,tt]=useState(null),Tt=useRef(0),Dt=5,yt=useRef(false);useEffect(()=>{function B(G){Le.current&&!Le.current.contains(G.target)&&U(false);}if(H)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[H]),useEffect(()=>{E&&Ee.current&&(Ee.current.focus(),Ee.current.select());},[E]),useEffect(()=>{if(!ce)return;let B=K=>{let ne=K.clientX-F,q=V+ne;i?.(ce,q);},G=()=>{S(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",G),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",G),document.body.style.cursor="",document.body.style.userSelect="";}},[ce,F,V,i]);let{selectedTaskIds:Nt,handleTaskClick:Mt,isTaskSelected:ra}=$l(),{setIsEditing:mt}=Ul({tasks:e,selectedTaskIds:Nt,onTaskSelect:(B,G)=>{let ne=Tr(e).map(q=>q.id);Mt(B,ne,G||false,false);},onTaskCreate:g||(()=>{}),onTaskDelete:x||(()=>{}),onTaskDuplicate:b||(()=>{}),onTaskMove:y||(()=>{}),onTaskIndent:v||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:B=>{let G=Tr(e).find(K=>K.id===B);G&&O(G);},onTaskToggleExpand:m||(()=>{}),onOpenTaskModal:B=>{let G=Tr(e).find(K=>K.id===B);G&&h&&h(G);},enableKeyboard:true}),rt=(B,G=0)=>{let K=[];for(let ne of B)K.push({task:ne,level:G}),ne.subtasks&&ne.subtasks.length>0&&ne.isExpanded&&K.push(...rt(ne.subtasks,G+1));return K},Lt=rt(e),Ht=48,we=B=>!B.startDate||!B.endDate?"-":`${Math.ceil((B.endDate.getTime()-B.startDate.getTime())/(1e3*60*60*24))}d`,O=B=>{J(B.id),ke(B.name),mt(true);},Te=B=>{ge.trim()&&ge!==e.find(G=>G.id===B)?.name&&C?.(B,ge.trim()),J(null),ke(""),mt(false);},ze=()=>{J(null),ke(""),mt(false);},Ue=(B,G)=>{G.stopPropagation(),D?.(B.id);},pt=(B,G)=>{G.preventDefault(),Tt.current=G.clientY,Se(B),yt.current=false;},X=B=>{if(!te||(Math.abs(B.clientY-Tt.current)>Dt&&(yt.current=true),!yt.current))return;let K=document.querySelectorAll("[data-task-row]"),ne=null,q=null;K.forEach(xe=>{let de=xe.getBoundingClientRect(),R=xe.getAttribute("data-task-row");if(R&&R!==te&&B.clientY>=de.top&&B.clientY<=de.bottom){ne=R;let ie=B.clientY-de.top,Ae=de.height;ie<Ae*.25?q="above":ie>Ae*.75?q="below":q="child";}}),Ve(ne),tt(q);},Q=()=>{if(yt.current&&te&&se&&be){if(be==="child")w?.(te,se);else if(be==="above"||be==="below"){let B=(ne,q,xe=null)=>{for(let de of ne){if(de.id===q)return xe;if(de.subtasks){let R=B(de.subtasks,q,de.id);if(R!==void 0)return R}}},G=B(e,se,null),K=(ne,q)=>{let xe=ne.findIndex(de=>de.id===q);return be==="below"?xe+1:xe};if(G===null){let ne=K(e,se);w?.(te,null,ne);}else {let ne=Lt.find(q=>q.task.id===G)?.task;if(ne?.subtasks){let q=K(ne.subtasks,se);w?.(te,G,q);}}}}Se(null),Ve(null),tt(null),yt.current=false;};useEffect(()=>{if(te)return document.addEventListener("mousemove",X),document.addEventListener("mouseup",Q),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",Q),document.body.style.cursor="",document.body.style.userSelect="";}},[te,se,be]);let ve=(B,G,K)=>{switch(B.id){case "name":let ne=E===G.id,q=T===G.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${K*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:q?1:.3},onMouseDown:De=>pt(G.id,De),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),G.subtasks&&G.subtasks.length>0?jsx("button",{onClick:De=>{De.stopPropagation(),m?.(G.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:G.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"}),!(G.subtasks&&G.subtasks.length>0)&&jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0 border",style:{backgroundColor:G.color||"#3B82F6",opacity:G.parentId?.6:1,borderColor:G.isMilestone?t.accent:"transparent",borderWidth:G.isMilestone?"2px":"0px"},title:G.isMilestone?"Milestone":G.parentId?"Subtask":"Task"}),ne?jsx("input",{ref:Ee,type:"text",value:ge,onChange:De=>ke(De.target.value),onKeyDown:De=>{De.key==="Enter"?Te(G.id):De.key==="Escape"&&ze();},onBlur:()=>Te(G.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:De=>De.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:G.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:G.parentId?"13px":"14px",fontWeight:G.isMilestone?600:G.parentId?400:600,letterSpacing:G.parentId?"0":"-0.01em"},title:G.name,children:G.name}),q&&!ne&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:De=>De.stopPropagation(),children:[jsx("button",{onClick:De=>Ue(G,De),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:De=>{De.stopPropagation(),O(G);},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":let xe=G.startDate?typeof G.startDate=="string"?G.startDate:G.startDate.toISOString().split("T")[0]:void 0;return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx("input",{type:"date",value:xe||"",onChange:De=>{u?.(G.id,{startDate:De.target.value?new Date(De.target.value):void 0});},className:"bg-transparent border-none text-xs cursor-pointer outline-none text-center",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif"}})});case "endDate":let de=G.endDate?typeof G.endDate=="string"?G.endDate:G.endDate.toISOString().split("T")[0]:void 0;return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx("input",{type:"date",value:de||"",onChange:De=>{u?.(G.id,{endDate:De.target.value?new Date(De.target.value):void 0});},className:"bg-transparent border-none text-xs cursor-pointer outline-none text-center",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif"}})});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:we(G)})});case "assignees":let R=r.filter(De=>G.assignees?.some(ja=>ja.name===De.name||ja.initials===De.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx(Xa,{assignedUsers:R,availableUsers:r,onChange:De=>{let ja=De.map(cr=>({id:cr.id,name:cr.name,initials:cr.initials,color:cr.color}));u?.(G.id,{assignees:ja.length>0?ja:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx(Hi,{status:G.status||"todo",onChange:De=>{u?.(G.id,{status:De,progress:De==="completed"?100:G.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:`${G.progress}%`,backgroundColor:G.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:[G.progress,"%"]})]});case "priority":let ie={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Ae={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},at=ie[G.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx(Ya,{priority:at,onChange:De=>{De&&u?.(G.id,{priority:Ae[De]||"medium"});}})});default:return null}},fe=B=>[{id:"hide",label:"Hide Column",icon:it.Hide,onClick:()=>l(B),disabled:B==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:it.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:it.SortDesc,onClick:()=>{}}],ee=B=>B.subtasks&&B.subtasks.length>0?[{id:"addSubtask",label:L?.contextMenu?.addSubtask||"Add Subtask",icon:it.Add,onClick:()=>{D?.(B.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:L?.contextMenu?.deleteTask||"Delete Task",icon:it.Delete,onClick:()=>{A?A(B.id,B.name):x?.([B.id]);}}]:[{id:"edit",label:L?.contextMenu?.editTask||"Edit Task",icon:it.Pencil,onClick:()=>{d?.(B);}},{id:"addSubtask",label:L?.contextMenu?.addSubtask||"Add Subtask",icon:it.Add,onClick:()=>{D?.(B.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:L?.contextMenu?.markIncomplete||"Mark Incomplete",icon:it.MarkIncomplete,onClick:()=>{u?.(B.id,{status:"todo",progress:0});},disabled:B.status==="todo"},{id:"setInProgress",label:L?.contextMenu?.setInProgress||"Set In Progress",icon:it.SetInProgress,onClick:()=>{u?.(B.id,{status:"in-progress"});},disabled:B.status==="in-progress"},{id:"markComplete",label:L?.contextMenu?.markComplete||"Mark Complete",icon:it.MarkComplete,onClick:()=>{u?.(B.id,{status:"completed",progress:100});},disabled:B.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:L?.contextMenu?.splitTask||"Split Task",icon:it.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:L?.contextMenu?.deleteTask||"Delete Task",icon:it.Delete,onClick:()=>{A?A(B.id,B.name):x?.([B.id]);}}],Ce=p.filter(B=>B.visible);return jsxs("div",{className:"h-full overflow-hidden",style:{backgroundColor:t.bgPrimary},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${Ht}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[Ce.map((B,G)=>jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${B.id==="name"?"":"justify-center"}`,style:{width:`${B.width}px`,minWidth:`${B.minWidth??(B.id==="name"?200:60)}px`,maxWidth:`${B.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:G<Ce.length-1?`1px solid ${t.borderLight}`:"none",height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:K=>{K.preventDefault(),le({isOpen:true,x:K.clientX,y:K.clientY,type:"header",columnId:B.id});},onMouseEnter:K=>{K.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:K=>{K.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:B.id==="name"?"80px":"0"},title:B.label,children:B.label}),B.id==="name"&&jsxs("div",{className:"absolute flex items-center gap-1",style:{right:"12px",top:"50%",transform:"translateY(-50%)"},children:[jsx(No,{columns:p,onToggleColumn:l,theme:t}),jsx("button",{onClick:()=>U(!H),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors relative group",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})})]}),B.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:ce===B.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:K=>{K.preventDefault(),K.stopPropagation(),S(B.id),M(K.clientX),P(B.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"}})})]},B.id)),H&&jsxs("div",{ref:Le,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:B=>B.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:()=>U(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",children:Lt.map(({task:B,level:G},K)=>{let ne=ra(B.id),q=se===B.id,xe={};return q&&be&&(be==="above"?(xe.borderTopWidth="2px",xe.borderTopStyle="solid",xe.borderTopColor=t.accent):be==="below"?(xe.borderBottomWidth="2px",xe.borderBottomStyle="solid",xe.borderBottomColor=t.accent):be==="child"&&(xe.backgroundColor=t.accentLight,xe.boxShadow=`inset 0 0 0 2px ${t.accent}`)),jsx(motion.div,{"data-task-row":B.id,className:`flex items-center cursor-pointer group ${te===B.id?"opacity-50":""}`,style:{height:`${a}px`,borderLeft:ne?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:ne||q&&be==="child"?t.accentLight:K%2===0?t.bgPrimary:t.bgGrid,...xe},onMouseEnter:()=>z(B.id),onMouseLeave:()=>z(null),onClick:de=>{let ie=Tr(e).map(De=>De.id),at=navigator.platform.toUpperCase().indexOf("MAC")>=0?de.metaKey:de.ctrlKey;Mt(B.id,ie,at,de.shiftKey),s?.(B);},onDoubleClick:de=>{de.stopPropagation(),d?.(B);},onContextMenu:de=>{de.preventDefault(),le({isOpen:true,x:de.clientX,y:de.clientY,type:"task",task:B}),c?.(B,de);},whileHover:{backgroundColor:ne?t.accentLight:t.hoverBg},children:Ce.map((de,R)=>jsx("div",{className:`px-4 flex items-center ${de.id==="name"?"justify-start":"justify-center"} ${R<Ce.length-1?"border-r":""}`,style:{width:`${de.width}px`,minWidth:`${de.minWidth??(de.id==="name"?200:60)}px`,maxWidth:`${de.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderColor:T===B.id?t.border:t.borderLight,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:ve(de,B,de.id==="name"?G:0)},`${B.id}-${de.id}`))},B.id)})}),jsx(Cr,{isOpen:W.isOpen,x:W.x,y:W.y,items:W.type==="header"&&W.columnId?fe(W.columnId):W.type==="task"&&W.task?ee(W.task):[],onClose:()=>le({...W,isOpen:false}),theme:t})]})}function _l(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[d,c]=useState(e),[m,n]=useState(t),[p,l]=useState(null),[i,u]=useState(null),[v,f]=useState(null),[y,x]=useState(null),[b,g]=useState(0),[C,D]=useState(0),[h,A]=useState(null),[w,L]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:d,setGhostX:c,ghostWidth:m,setGhostWidth:n,connectionLine:p,setConnectionLine:l,hoveredTaskId:i,setHoveredTaskId:u,activeZone:v,setActiveZone:f,draggedSegmentIndex:y,setDraggedSegmentIndex:x,draggedSegmentStartX:b,setDraggedSegmentStartX:g,segmentDragOffsetX:C,setSegmentDragOffsetX:D,hoveredSegmentIndex:h,setHoveredSegmentIndex:A,isHovered:w,setIsHovered:L,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(E,J)=>{r("none"),l(null),u(null),c(E),n(J),D(0),x(null),g(0);}}}function Mo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:d,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:v,onHoverChange:f}){let y=_l(t,r),x=useRef(null),{dragMode:b,setDragMode:g,dragOffset:C,setDragOffset:D,ghostX:h,setGhostX:A,ghostWidth:w,setGhostWidth:L,connectionLine:T,setConnectionLine:z,hoveredTaskId:H,setHoveredTaskId:U,activeZone:E,setActiveZone:J,draggedSegmentIndex:ge,setDraggedSegmentIndex:ke,draggedSegmentStartX:Le,setDraggedSegmentStartX:Ee,segmentDragOffsetX:ce,setSegmentDragOffsetX:S,hoveredSegmentIndex:F,setHoveredSegmentIndex:M,isHovered:V,setIsHovered:P,isDragging:W,isResizing:le,isConnecting:te,resetDragState:Se}=y,se=32,Ve=8,be=e.endDate&&e.endDate<new Date&&e.progress<100,tt=e.isCriticalPath,Tt=o.name==="neutral"||o.today==="#1C1917",Dt=e.status==="completed"||e.progress===100,yt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},Mt=e.isCriticalPath||be?"#DC2626":e.color?e.color:e.priority&&yt[e.priority]?yt[e.priority]:o.taskBarPrimary,mt=(ee=>ee>=80?20:ee>=60?15:ee>=50?12:10)(r),rt=r<50,Lt=r<40;useEffect(()=>{if(f)if(V&&!W&&!e.segments){let ee=a<100;f({task:e,x:t,y:a,width:r,height:se,showBelow:ee});}else f(null);},[V,W,e,t,a,r,se,f]);let Ht=ee=>ee.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),we=()=>{let ee=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ee} day${ee!==1?"s":""}`},O=ee=>Math.round(ee/s)*s,Te=ee=>{let Ce=Math.round(ee/s),B=new Date(d);return B.setDate(B.getDate()+Ce),B},ze=(ee,Ce)=>{for(let B of u){if(B.id===e.id)continue;let G=5;if(ee>=B.x-G&&ee<=B.x+B.width+G&&Ce>=B.y-G&&Ce<=B.y+B.height+G)return B.id}return null},Ue=useCallback((ee,Ce,B)=>{ee.preventDefault(),ee.stopPropagation();let G=x.current?.ownerSVGElement;if(!G)return;let K=G.createSVGPoint();K.x=ee.clientX,K.y=ee.clientY;let ne=K.matrixTransform(G.getScreenCTM()?.inverse()),q=B!==void 0?B:t,xe=Ce;if(!xe){let de=ne.x-q;ee.shiftKey?(xe="connect",z({x:t+r,y:a+se/2})):ee.ctrlKey||ee.metaKey?xe="move":ee.altKey?xe=de<r/2?"resize-start":"resize-end":Lt?de<r/2?xe="move":xe="resize-end":rt?de<=mt/2?xe="resize-start":de>=r-mt/2?xe="resize-end":xe="move":de<=mt?xe="resize-start":de>=r-mt?xe="resize-end":xe="move";}g(xe),P(false),J(null),xe==="move"?D(ne.x-q):xe==="connect"?z({x:t+r,y:a+se/2}):D(0),A(q),L(r);},[t,r,a,se]),pt=useCallback(ee=>{if(b==="none")return;let Ce=x.current?.ownerSVGElement;if(!Ce)return;let B=Ce.createSVGPoint();B.x=ee.clientX,B.y=ee.clientY;let G=B.matrixTransform(Ce.getScreenCTM()?.inverse());if(b==="connect"){z({x:G.x,y:G.y});let K=ze(G.x,G.y);U(K);}else if(b==="move"){let K=G.x-C,ne=O(K);A(ne),L(r);let q=Math.round((ne-t)/s);if(v?.(e.id,q,true),e.segments&&e.segments.length>0&&ge!==null){let xe=ne-Le;S(xe);}}else if(b==="resize-start"){let K=G.x,ne=O(K),q=t+r-ne;q>=s&&(A(ne),L(q));}else if(b==="resize-end"){let K=G.x,q=O(K)-t;q>=s&&L(q);}},[b,t,r,s,C,e,O,ge,Le,ze,U,z,A,L,S,v]),X=useCallback(()=>{if(b!=="none"){if(b==="connect")H&&i&&i(e,H),z(null),U(null);else {let ee=e.endDate.getTime()-e.startDate.getTime(),Ce,B,G=true;if(b==="move"){if(Ce=Te(h),B=new Date(Ce.getTime()+ee),e.segments&&e.segments.length>0&&ge!==null){let K=Math.round(ce/s),ne=e.segments.map((R,ie)=>{if(ie===ge){let Ae=new Date(R.startDate),at=new Date(R.endDate);return Ae.setDate(Ae.getDate()+K),at.setDate(at.getDate()+K),{startDate:Ae,endDate:at}}return R}),q=ne.flatMap(R=>[R.startDate,R.endDate]),xe=new Date(Math.min(...q.map(R=>R.getTime()))),de=new Date(Math.max(...q.map(R=>R.getTime())));l?.({...e,segments:ne},xe,de),Se(t,r);return}}else b==="resize-start"?(Ce=Te(h),B=e.endDate,Ce>=B&&(console.warn("Invalid date range: start date must be before end date"),G=false)):b==="resize-end"?(Ce=e.startDate,B=Te(h+w),B<=Ce&&(console.warn("Invalid date range: end date must be after start date"),G=false)):G=false;G&&Ce&&B&&(B.getTime()-Ce.getTime()<864e5?console.warn("Invalid date range: task must be at least 1 day long"):l?.(e,Ce,B));}v?.(e.id,0,false),Se(t,r);}},[b,h,w,e,l,H,i,t,r,s,Te,ce,ge,Se,v]);useEffect(()=>{if(b==="none")return;let ee=B=>{pt(B);},Ce=()=>{X();};return window.addEventListener("mousemove",ee),window.addEventListener("mouseup",Ce),()=>{window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",Ce);}},[b,pt,X]);let Q=W&&!te?h:t,ve=W&&!te?w:r,fe=c.taskClass(e);return jsxs("g",{ref:x,onMouseEnter:()=>!W&&P(true),onMouseLeave:()=>{W||(P(false),J(null));},onClick:()=>!W&&m?.(e),onDoubleClick:ee=>{W||(ee.stopPropagation(),n?.(e));},onContextMenu:ee=>{ee.preventDefault(),p?.(e,ee);},children:[V&&!W&&!rt&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:mt,height:se,fill:E==="resize-start"?o.accent:"transparent",opacity:E==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>J("resize-start"),onMouseDown:ee=>Ue(ee,"resize-start")}),jsx("rect",{x:t+mt,y:a,width:r-mt*2,height:se,fill:E==="move"?o.accent:"transparent",opacity:E==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>J("move"),onMouseDown:ee=>Ue(ee,"move")}),jsx("rect",{x:t+r-mt,y:a,width:mt,height:se,fill:E==="resize-end"?o.accent:"transparent",opacity:E==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>J("resize-end"),onMouseDown:ee=>Ue(ee,"resize-end")})]}),V&&!W&&Lt&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:se,fill:E==="move"?o.accent:"transparent",opacity:E==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>J("move"),onMouseDown:ee=>Ue(ee,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:se,fill:E==="resize-end"?o.accent:"transparent",opacity:E==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>J("resize-end"),onMouseDown:ee=>Ue(ee,"resize-end")}),V&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+se-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),W&&!te&&!e.segments&&jsx(motion.rect,{x:h,y:a,width:w,height:se,rx:Ve,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:Q,y:a,width:ve,height:se,rx:Ve,fill:Mt,"data-task-class":fe,initial:{opacity:0,scale:.95},animate:{opacity:W&&!te?.15:e.parentId?.6:V?.9:.8,scale:V&&!W?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ee=>Ue(ee),style:{cursor:W?te?"crosshair":le?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:Q,y:a,width:ve*(e.progress/100),height:se,rx:Ve,fill:Mt,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ee,Ce)=>{let B=(ee.startDate.getTime()-d.getTime())/864e5*s,K=(ee.endDate.getTime()-d.getTime())/(1e3*60*60*24)*s-B+s,ne=W&&b==="move"&&ge===Ce,q=F===Ce,xe=ne?B+ce:B;return jsxs("g",{onMouseEnter:()=>!W&&M(Ce),onMouseLeave:()=>!W&&M(null),children:[jsx(motion.rect,{x:xe,y:a,width:K,height:se,rx:Ve,fill:Mt,initial:{opacity:0,scale:.95},animate:{opacity:ne||e.parentId?.6:q?.9:.8,scale:q&&!W?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:de=>{de.stopPropagation(),ke(Ce),Ee(B),Ue(de,void 0,B);},style:{cursor:W?te?"crosshair":le?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:xe,y:a,width:K*(e.progress/100),height:se,rx:Ve,fill:Mt,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Ce}`)}),Tt&&(be||tt)&&!e.segments&&jsxs(Fragment,{children:[tt&&!be&&jsx("rect",{x:Q,y:a,width:ve,height:se,rx:Ve,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),be&&jsx("rect",{x:Q,y:a,width:ve,height:se,rx:Ve,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ve>60&&!e.segments&&(()=>{let ee=c.taskLabel(e),Ce=typeof ee=="string"?ee:e.name,B=Ce.length>Math.floor(ve/8)?`${Ce.substring(0,Math.floor(ve/8))}...`:Ce;return jsx("text",{x:Q+12,y:a+se/2,dominantBaseline:"middle",fill:Dt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Dt?"line-through":"none"},children:B})})(),ve>100&&e.progress>0&&e.progress<100&&!W&&!e.segments&&jsxs("text",{x:Q+ve-12,y:a+se/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&&ve>80&&!W&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:Q+ve-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:Q+ve-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(V||le)&&!te&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:rt?Q-15:Q-10,y:a-5,width:rt?25:20,height:se+10,fill:"transparent",onMouseDown:ee=>Ue(ee,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:rt?Q-8:Q-3,y:a+6,width:rt?8:6,height:rt?se-12:se-16,rx:3,fill:b==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Q+ve-10,y:a-5,width:rt?25:20,height:se+10,fill:"transparent",onMouseDown:ee=>Ue(ee,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:rt?Q+ve:Q+ve-3,y:a+6,width:rt?8:6,height:rt?se-12:se-16,rx:3,fill:b==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:V&&!W&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+se/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:ee=>{ee.stopPropagation(),Ue(ee,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+se/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),te&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+se/2,x2:T.x,y2:T.y,stroke:H?o.statusCompleted:o.accent,strokeWidth:H?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:H?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:H?8:6,fill:H?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),H&&jsx(motion.text,{x:T.x+15,y:T.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:T.x+10},animate:{opacity:1,x:T.x+15},transition:{duration:.2},children:"Connect"})]}),(V||W)&&!te&&!e.segments&&jsx(motion.rect,{x:Q-2,y:a-2,width:ve+4,height:se+4,rx:Ve+2,fill:"none",stroke:W?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:W?.6:.4,initial:{opacity:0},animate:{opacity:W?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),le&&jsxs(Fragment,{children:[jsx("line",{x1:h,y1:0,x2:h,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:h+w,y1:0,x2:h+w,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:V&&!W&&!e.segments&&!f&&(()=>{let B=a<100,G=B?a+se+13:a-82-13,K=B?`M ${Q+ve/2-6} ${a+se+3} L ${Q+ve/2} ${a+se+13} L ${Q+ve/2+6} ${a+se+3}`:`M ${Q+ve/2-6} ${a-13} L ${Q+ve/2} ${a-3} L ${Q+ve/2+6} ${a-13}`,ne=G+22,q=G+40,xe=G+55,de=G+70,R=B?G+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:B?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:B?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:K,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:Q+ve/2-120,y:G,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:Q+ve/2,y:ne,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:Q+ve/2-110,y:q,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:Q+ve/2-70,y:q,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ht(e.startDate)}),jsx("text",{x:Q+ve/2-110,y:xe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:Q+ve/2-70,y:xe,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ht(e.endDate)}),jsx("text",{x:Q+ve/2+10,y:q,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:Q+ve/2+65,y:q,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:we()}),jsx("text",{x:Q+ve/2+10,y:xe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:Q+ve/2+65,y:xe,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:Q+ve/2-110,y:de,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:Q+ve/2-50,y:de,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(ie=>ie.name).join(", ").substring(0,30),e.assignees.map(ie=>ie.name).join(", ").length>30?"...":""]})]}),!B&&jsx("text",{x:Q+ve/2,y:R,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Lt?"Left: move \u2022 Right: resize":rt?"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 Kl({tooltipData:e,theme:t}){if(!e)return null;let{task:a,x:r,y:o,width:s,height:d,showBelow:c}=e,m=82,n=13,p=c?o+d+n:o-m-n,l=c?`M ${r+s/2-6} ${o+d+3} L ${r+s/2} ${o+d+13} L ${r+s/2+6} ${o+d+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=p+22,u=p+40,v=p+55,f=p+70,y=c?p+m-5:o-18,x=D=>D.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let D=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${D} day${D!==1?"s":""}`},g=s<50,C=s<40;return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:l,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:p,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:i,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:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?x(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:v,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:v,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?x(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:v,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:v,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:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(D=>D.name).join(", ").substring(0,30),a.assignees.map(D=>D.name).join(", ").length>30?"...":""]})]}),!c&&jsx("text",{x:r+s/2,y,textAnchor:"middle",fill:t.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:C?"Left: move \u2022 Right: resize":g?"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 Lo({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:d}){let[c,m]=useState(false),n=a-e,p=r-t,l=e+n/2,i=`M ${e} ${t} C ${l} ${t}, ${l} ${r}, ${a} ${r}`,u=6,v=Math.atan2(p,n),f=a-u*Math.cos(v-Math.PI/6),y=r-u*Math.sin(v-Math.PI/6),x=a-u*Math.cos(v+Math.PI/6),b=r-u*Math.sin(v+Math.PI/6),g=o.dependency;return useEffect(()=>{d&&s&&d(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,d]),jsxs("g",{onMouseEnter:()=>m(true),onMouseLeave:()=>m(false),children:[jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&d?0:c?1:.6,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.15},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${y} M ${a} ${r} L ${x} ${b}`,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&d?0:c?1:.6,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.15}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:g,initial:{scale:0},animate:{scale:c&&d?0:c?1.33:1},transition:{scale:{delay:.3,duration:.15}}}),c&&s&&!d&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:C=>{C.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:l,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:l-4,y1:(t+r)/2-4,x2:l+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:l+4,y1:(t+r)/2-4,x2:l-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Bo({task:e,x:t,y:a,theme:r,onClick:o}){let[s,d]=useState(false),c=16,m=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,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-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+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 re={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=n=>{n.forEach(p=>{p.dependencies&&r.set(p.id,p.dependencies),p.subtasks&&o(p.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let d=new Set,c=new Set,m=n=>{if(!d.has(n)){d.add(n),c.add(n);let p=r.get(n)||[];for(let l of p){if(!d.has(l)&&m(l))return true;if(c.has(l))return true}}return c.delete(n),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=re.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=re.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=re.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=re.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(`
45
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function _n({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),d=useRef(null);useEffect(()=>{function n(p){s.current&&!s.current.contains(p.target)&&d.current&&!d.current.contains(p.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},m=e.reduce((n,p)=>{let l=p.category||"Other";return n[l]||(n[l]=[]),n[l].push(p),n},{});return jsxs("div",{className:k("relative inline-block",a),children:[jsxs("button",{ref:d,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:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",n.currentTarget.style.borderColor="var(--theme-border-secondary)";},onMouseLeave:n=>{n.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",n.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:k("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(([n,p])=>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:n})}),jsx("div",{children:p.map(l=>jsxs("button",{onClick:()=>c(l),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:i=>{i.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-2xl leading-none mt-0.5",children:l.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:l.name}),l.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:l.description})]})]},l.id))})]},n)),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 jn({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[d,c]=useState("export"),[m,n]=useState("json"),[p,l]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,y=await xi(e,m,f);ki(y,m);},v=async f=>{let y=f.target.files?.[0];if(y){try{let x=await Ti(y),b=y.name.endsWith(".json")?"json":"csv",g=Ci(x,b);l(g),g.success&&r&&r(g,x);}catch(x){l({success:false,errors:[`Failed to read file: ${x instanceof Error?x.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:k("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:()=>c("export"),className:k("flex-1 px-6 py-4 font-semibold transition-colors",d==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:k("flex-1 px-6 py-4 font-semibold transition-colors",d==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[d==="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(f=>jsxs("button",{onClick:()=>n(f),className:k("p-4 rounded-lg border-2 transition-all text-center",m===f?"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:[f==="json"&&"\u{1F4C4}",f==="csv"&&"\u{1F4CA}",f==="pdf"&&"\u{1F4DD}"]}),jsx("div",{className:"font-semibold uppercase text-xs",children:f})]},f))})]}),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:u,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"})]}),d==="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:i,type:"file",accept:".json,.csv",onChange:v,className:"hidden"}),jsxs("button",{onClick:()=>i.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"})]})]}),p&&jsxs("div",{className:k("p-4 rounded-lg",p.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:k("font-semibold mb-2",p.success?"text-green-400":"text-red-400"),children:p.success?"\u2713 Import Successful":"\u2717 Import Failed"}),p.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",p.cardsImported]}),jsxs("div",{children:["Columns imported: ",p.columnsImported]})]}),p.errors&&p.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:p.errors.map((f,y)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},y))})]})]})]})]})]})}var Xp=["URGENT","HIGH","MEDIUM","LOW"],Jp=[{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"}],Zp=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function Kn({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:d,onFilterHighPriority:c,availableUsers:m=[],availableLabels:n=[],availableColumns:p=[],showQuickFilters:l=true,compact:i=false,groupBy:u="none",onGroupByChange:v}){let[f,y]=useState(true),x=useCallback(h=>{a({search:h.target.value});},[a]),b=useCallback(h=>{a({dateFilter:h.target.value});},[a]),g=useCallback(h=>{r({by:h.target.value});},[r]),C=useCallback(()=>{r({order:t.order==="asc"?"desc":"asc"});},[t.order,r]),D=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 ${i?"filter-bar--compact":""} ${f?"filter-bar--collapsed":""}`,children:[jsxs("div",{className:"filter-bar__header",onClick:()=>y(!f),style:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",marginBottom:f?"0":"12px",padding:"4px 6px",borderRadius:"6px",transition:"all 0.2s ease"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},children:[jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:f?"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"}),D&&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)"]})]}),!f&&jsxs("div",{className:"filter-bar__content",children:[l&&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"}),d&&jsx("button",{onClick:d,className:"filter-bar__quick-btn",title:"Show overdue tasks",children:"Overdue"}),c&&jsx("button",{onClick:c,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:x,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:b,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:h=>{let A=h.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Xp.map(h=>jsx("option",{value:h,children:h},h))]})}),m.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:h=>{let A=h.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),m.map(h=>jsx("option",{value:h.id,children:h.name},h.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:h=>{let A=h.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(h=>jsx("option",{value:h,children:h},h))]})}),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:g,className:"filter-bar__select filter-bar__select--sm",children:Jp.map(h=>jsx("option",{value:h.value,children:h.label},h.value))}),t.by!=="none"&&jsx("button",{onClick:C,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),v&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:h=>v(h.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Zp.map(h=>jsx("option",{value:h.value,children:h.label},h.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function Yn({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:d,onExportGanttPNG:c,onExportGanttCSV:m}){let[n,p]=useState(false),l=useRef(null);useEffect(()=>{let u=v=>{l.current&&!l.current.contains(v.target)&&p(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),p(false);};return jsxs("div",{className:k("relative",r),ref:l,children:[jsxs("button",{onClick:()=>p(!n),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)",u.currentTarget.style.color="var(--theme-text-primary)";},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-secondary)",u.currentTarget.style.color="var(--theme-text-secondary)";},"aria-label":"Configuration Menu","aria-expanded":n,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"})]}),n&&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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await d?.()),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(async()=>await c?.()),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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(()=>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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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:()=>i(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:u=>{u.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:u=>{u.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 qn={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"}},Xn={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"}},Jn={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"}},er={dark:qn,light:Xn,neutral:Jn},wo="dark";var Co=createContext(void 0),lu="asakaa-theme";function wl({children:e,defaultTheme:t=wo,storageKey:a=lu}){let[r,o]=useState(()=>{if(typeof window<"u"){let c=localStorage.getItem(a);if(c&&(c==="dark"||c==="light"||c==="neutral"))return c}return t}),s=useCallback(c=>{o(c),typeof window<"u"&&localStorage.setItem(a,c);},[a]);useEffect(()=>{if(typeof window>"u")return;let c=document.documentElement,m=er[r];Object.entries(m.colors).forEach(([p,l])=>{l&&c.style.setProperty(`--theme-${du(p)}`,l);}),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(([p,l])=>{let i=m.colors[p];i&&c.style.setProperty(l,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let d={theme:r,setTheme:s,themes:er};return jsx(Co.Provider,{value:d,children:e})}function xr(){let e=useContext(Co);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function du(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Zn({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=xr();return e?jsxs("div",{className:k("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(er).map(([s,d])=>jsxs("button",{onClick:()=>{o(s),t();},className:k("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:d.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:d.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}var Oe={dark:{bgPrimary:"#1A1D21",bgSecondary:"#22262D",bgGrid:"#1E2126",bgWeekend:"rgba(59, 130, 246, 0.03)",border:"#334155",borderLight:"#2D3139",textPrimary:"#FFFFFF",textSecondary:"#CBD5E1",textTertiary:"#64748B",accent:"#3B82F6",accentHover:"#60A5FA",accentLight:"rgba(59, 130, 246, 0.12)",taskBarPrimary:"#3B82F6",taskBarProgress:"#2563EB",taskBarHandle:"#FFFFFF",dependency:"rgba(180, 185, 197, 0.25)",dependencyHover:"rgba(180, 185, 197, 0.45)",criticalPath:"#EF4444",criticalPathLight:"rgba(239, 68, 68, 0.12)",today:"#06B6D4",todayLight:"rgba(6, 182, 212, 0.12)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.1)",statusTodo:"#64748B",statusInProgress:"#3B82F6",statusCompleted:"#10B981",hoverBg:"rgba(255, 255, 255, 0.06)",focusRing:"#3B82F6"},light:{bgPrimary:"#FFFFFF",bgSecondary:"#F8FAFC",bgGrid:"#F1F5F9",bgWeekend:"rgba(37, 99, 235, 0.03)",border:"#CBD5E1",borderLight:"#E2E8F0",textPrimary:"#0F172A",textSecondary:"#334155",textTertiary:"#64748B",accent:"#2563EB",accentHover:"#1D4ED8",accentLight:"rgba(37, 99, 235, 0.08)",taskBarPrimary:"#2563EB",taskBarProgress:"#1E40AF",taskBarHandle:"#FFFFFF",dependency:"rgba(75, 85, 99, 0.25)",dependencyHover:"rgba(75, 85, 99, 0.45)",criticalPath:"#DC2626",criticalPathLight:"rgba(220, 38, 38, 0.1)",today:"#0891B2",todayLight:"rgba(8, 145, 178, 0.1)",milestone:"#F59E0B",milestoneLight:"rgba(245, 158, 11, 0.08)",statusTodo:"#64748B",statusInProgress:"#2563EB",statusCompleted:"#059669",hoverBg:"rgba(0, 0, 0, 0.04)",focusRing:"#2563EB"},neutral:{bgPrimary:"#FAFAF9",bgSecondary:"#F5F5F4",bgGrid:"#EFEDEC",bgWeekend:"rgba(41, 37, 36, 0.02)",border:"#D6D3D1",borderLight:"#E7E5E4",textPrimary:"#0C0A09",textSecondary:"#44403C",textTertiary:"#78716C",accent:"#292524",accentHover:"#44403C",accentLight:"rgba(41, 37, 36, 0.08)",taskBarPrimary:"#292524",taskBarProgress:"#1C1917",taskBarHandle:"#FFFFFF",dependency:"rgba(87, 83, 78, 0.25)",dependencyHover:"rgba(87, 83, 78, 0.4)",criticalPath:"#44403C",criticalPathLight:"rgba(68, 64, 60, 0.08)",today:"#1C1917",todayLight:"rgba(28, 25, 23, 0.06)",milestone:"#57534E",milestoneLight:"rgba(87, 83, 78, 0.08)",statusTodo:"#78716C",statusInProgress:"#292524",statusCompleted:"#15803D",hoverBg:"rgba(0, 0, 0, 0.035)",focusRing:"#292524"}};function Cl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return Oe[e]||Oe.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,d)=>a.getPropertyValue(s).trim()||d;return {bgPrimary:r("--theme-bg-primary",Oe[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",Oe[e].bgSecondary),bgGrid:r("--theme-bg-card",Oe[e].bgGrid),bgWeekend:r("--theme-bg-hover",Oe[e].bgWeekend),border:r("--theme-border-primary",Oe[e].border),borderLight:r("--theme-border-subtle",Oe[e].borderLight),textPrimary:r("--theme-text-primary",Oe[e].textPrimary),textSecondary:r("--theme-text-secondary",Oe[e].textSecondary),textTertiary:r("--theme-text-tertiary",Oe[e].textTertiary),accent:r("--theme-accent-primary",Oe[e].accent),accentHover:r("--theme-accent-hover",Oe[e].accentHover),accentLight:r("--theme-accent-primary",Oe[e].accentLight),taskBarPrimary:r("--theme-accent-primary",Oe[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",Oe[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",Oe[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",Oe[e].dependency),dependencyHover:r("--theme-border-secondary",Oe[e].dependencyHover),criticalPath:r("--theme-error",Oe[e].criticalPath),criticalPathLight:r("--theme-error",Oe[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",Oe[e].today):e==="neutral"?r("--theme-text-primary",Oe[e].today):r("--theme-error",Oe[e].today),todayLight:e==="light"?r("--theme-accent-primary",Oe[e].todayLight):e==="neutral"?r("--theme-text-primary",Oe[e].todayLight):r("--theme-error",Oe[e].todayLight),milestone:r("--theme-warning",Oe[e].milestone),milestoneLight:r("--theme-warning",Oe[e].milestoneLight),statusTodo:r("--theme-text-tertiary",Oe[e].statusTodo),statusInProgress:r("--theme-accent-primary",Oe[e].statusInProgress),statusCompleted:r("--theme-success",Oe[e].statusCompleted),hoverBg:r("--theme-bg-hover",Oe[e].hoverBg),focusRing:r("--theme-accent-primary",Oe[e].focusRing)}}var To={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"},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"}},Tl={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"},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"}},Qn={en:To,es:Tl};function Dl(e){return Qn[e]||Qn.en}function es(e,t){let a=Dl(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 wr=createContext(To);function jr(){return useContext(wr)}function Nu({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:d}){let[c,m]=useState(false),[n,p]=useState(null),l=useRef(null),i=jr();if(useEffect(()=>{let y=x=>{l.current&&!l.current.contains(x.target)&&m(false);};return c&&document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[c]),!(t||a||r||o||s||d))return null;let v=[{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:d}].filter(y=>y.handler),f=async(y,x)=>{if(x){p(y);try{await x();}catch(b){console.error(`Export ${y} failed:`,b);}finally{p(null),m(false);}}};return jsxs("div",{ref:l,className:"relative",children:[jsxs(motion.button,{onClick:()=>m(!c),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs transition-all",style:{backgroundColor:c?e.accent:e.bgSecondary,border:`1px solid ${c?e.accent:e.borderLight}`,color:c?"#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:i.toolbar.export}),jsx(ChevronDown,{className:"w-3 h-3 transition-transform",style:{transform:c?"rotate(180deg)":"rotate(0deg)"}})]}),jsx(AnimatePresence,{children:c&&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:v.map((y,x)=>jsxs(motion.button,{onClick:()=>f(y.id,y.handler),disabled:n!==null,className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-all",style:{backgroundColor:"transparent",borderBottom:x<v.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:x*.03},children:[jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-md",style:{backgroundColor:e.accentLight,color:e.accent},children:n===y.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):y.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:y.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:y.description})]})]},y.id))})})})]})}function Su({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 d=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:d?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500,zIndex:d?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[d&&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:d?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:d?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function Eu({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 Pu({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),d=jr();useEffect(()=>{let n=p=>{s.current&&!s.current.contains(p.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:d.toolbar.compact||"Compact"},{value:"comfortable",label:d.toolbar.normal||"Normal"},{value:"spacious",label:d.toolbar.spacious||"Spacious"}],m=c.find(n=>n.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:`${d.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:c.map((n,p)=>{let l=t===n.value;return jsxs(motion.button,{onClick:()=>{a(n.value),o(false);},className:"w-full flex items-center justify-between px-3 py-2 text-left transition-all",style:{backgroundColor:l?e.accentLight:"transparent",borderBottom:p<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:l?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:p*.03},children:[jsx("span",{className:"text-xs",style:{color:l?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500},children:n.label}),l&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function Do({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:d,rowDensity:c,onRowDensityChange:m,showThemeSelector:n=false,showCreateTaskButton:p=false,createTaskLabel:l,onCreateTask:i,onExportPNG:u,onExportPDF:v,onExportExcel:f,onExportCSV:y,onExportJSON:x,onExportMSProject:b}){let g=jr(),C=u||v||f||y||x||b,D=[{value:"day",label:g.toolbar.day},{value:"week",label:g.toolbar.week},{value:"month",label:g.toolbar.month}],h=[{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(Eu,{options:D,value:t,onChange:A=>a(A),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(Pu,{theme:e,value:c,onChange:m})]}),jsxs("div",{className:"flex items-center gap-3",children:[p&&i&&jsxs(Fragment,{children:[jsxs(motion.button,{onClick:i,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:l||g.toolbar.createTask})]}),(C||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),C&&jsxs(Fragment,{children:[jsx(Nu,{theme:e,onExportPNG:u,onExportPDF:v,onExportExcel:f,onExportCSV:y,onExportJSON:x,onExportMSProject:b}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(Su,{options:h,value:s,onChange:A=>d(A),theme:e})]})]})}function No({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,d]=useState({x:0,y:0}),c=useRef(null),m=useRef(null);useEffect(()=>{if(!r)return;let p=l=>{c.current&&!c.current.contains(l.target)&&o(false);};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[r]);let n=e.filter(p=>p.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:m,onClick:()=>{if(!r&&m.current){let p=m.current.getBoundingClientRect();d({x:p.left,y:p.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(Ke,{children:jsx(motion.div,{ref:c,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"}),n.map(p=>jsxs("button",{onClick:()=>{t(p.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:l=>{l.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:p.label}),p.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},p.id))]})})})})]})}function Cr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let d=useRef(null),[c,m]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let p=200,l=r.length*36+8,i=8,u=window.innerWidth,v=window.innerHeight,f=t,y=a;t+p+i>u&&(f=t-p,f<i&&(f=i)),a+l+i>v&&(y=v-l-i,y<i&&(y=i)),m({x:f,y});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let p=i=>{d.current&&!d.current.contains(i.target)&&o();},l=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",p),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",l);}},[e,o]),!e)return null;let n=p=>p.startsWith("#")&&(p.length===7||p.length===4)?p: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:d,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:`${c.x}px`,top:`${c.y}px`,backgroundColor:n(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(p=>jsxs("div",{children:[p.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{p.disabled||(p.onClick(),o());},disabled:p.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:p.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:p.disabled?"not-allowed":"pointer",opacity:p.disabled?.5:1},onMouseEnter:l=>{p.disabled||(l.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:l=>{l.currentTarget.style.backgroundColor="transparent";},children:[p.icon&&jsx("span",{style:{color:s.textSecondary},children:p.icon}),jsx("span",{className:"flex-1",children:p.label}),p.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},p.id))})})})}var it={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 Ul({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:d,onTaskIndent:c,onTaskOutdent:m,onTaskRename:n,onTaskToggleExpand:p,onOpenTaskModal:l,enableKeyboard:i=true}){let u=useRef(false),v=useCallback(g=>{u.current=g;},[]),f=useCallback(g=>{let C=[],D=h=>{for(let A of h)C.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(g),C},[]),y=useCallback(()=>{let g=f(e);for(let C of g)if(t.has(C.id))return C;return null},[e,t,f]),x=useCallback((g,C)=>{let D=f(e);if(D.length===0)return;let h=y();if(!h){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===h.id);if(A===-1)return;let w=g==="up"?A-1:A+1;if(w<0||w>=D.length)return;let L=D[w];a(L.id,C);},[e,y,f,a]),b=useCallback(g=>{if(!i)return;let C=g.target;if(C.tagName==="INPUT"||C.tagName==="TEXTAREA"||C.isContentEditable||u.current){g.key==="Escape"&&(C.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?g.metaKey:g.ctrlKey,w=Array.from(t),L=y();if(g.key==="ArrowUp"){g.preventDefault(),x("up",g.shiftKey);return}if(g.key==="ArrowDown"){g.preventDefault(),x("down",g.shiftKey);return}if(L&&(g.key==="ArrowRight"||g.key==="ArrowLeft")){L.subtasks&&L.subtasks.length>0&&(g.preventDefault(),(g.key==="ArrowRight"&&!L.isExpanded||g.key==="ArrowLeft"&&L.isExpanded)&&p(L.id));return}if(g.altKey&&(g.key==="ArrowUp"||g.key==="ArrowDown")){w.length>0&&(g.preventDefault(),d(w,g.key==="ArrowUp"?"up":"down"));return}if(g.key==="Tab"&&!g.shiftKey){w.length>0&&(g.preventDefault(),c(w));return}if(g.key==="Tab"&&g.shiftKey){w.length>0&&(g.preventDefault(),m(w));return}if(g.key==="Enter"&&!g.shiftKey&&!A){L&&(g.preventDefault(),r(L.id,"below"));return}if(g.key==="Enter"&&g.shiftKey&&!A){L&&(g.preventDefault(),r(L.id,"above"));return}if(g.key==="Enter"&&A){L&&(g.preventDefault(),l(L.id));return}if(g.key==="F2"){L&&(g.preventDefault(),n(L.id));return}if(g.key==="Delete"||g.key==="Backspace"&&A){w.length>0&&(g.preventDefault(),o(w));return}if(g.key==="d"&&A&&!g.shiftKey){w.length>0&&(g.preventDefault(),s(w));return}},[i,t,y,x,r,o,s,d,c,m,n,p,l]);return useEffect(()=>{if(i)return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b);}},[i,b]),{setIsEditing:v}}function $l(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(l=>{t(new Set([l])),r(l);},[]),s=useCallback(l=>{t(i=>{let u=new Set(i);return u.has(l)?u.delete(l):u.add(l),u}),r(l);},[]),d=useCallback((l,i)=>{if(!a){o(l);return}let u=i.indexOf(a),v=i.indexOf(l);if(u===-1||v===-1){o(l);return}let f=Math.min(u,v),y=Math.max(u,v),x=i.slice(f,y+1);t(new Set(x)),r(l);},[a,o]),c=useCallback((l,i,u,v)=>{v?d(l,i):u?s(l):o(l);},[o,s,d]),m=useCallback((l,i)=>{i?t(u=>{let v=new Set(u);return v.add(l),v}):o(l);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),p=useCallback(l=>e.has(l),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:d,handleTaskClick:c,handleKeyboardSelection:m,clearSelection:n,isTaskSelected:p}}function Tr(e){let t=[],a=(r,o,s=0)=>{for(let d=0;d<r.length;d++){let c={...r[d],parentId:o,level:s,position:d};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function Wl(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=Wl(a.subtasks,t);if(r)return r}}return null}function rs(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=rs(a.subtasks,t);if(r)return r}return null}function os(e,t){if(t.length===0)return e;let a=Tr(e),r=t[0],o=a.findIndex(l=>l.id===r);if(o<=0)return e;let s=a[o-1],d=(l,i)=>{let u=[];return {tasks:l.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let y=d(f.subtasks,i);f.subtasks=y.tasks,u.push(...y.removed);}return true}),removed:u}},c=(l,i,u)=>l.map(v=>v.id===i?{...v,subtasks:[...v.subtasks||[],...u],isExpanded:true}:v.subtasks?{...v,subtasks:c(v.subtasks,i,u)}:v),m=new Set(t),{tasks:n,removed:p}=d(e,m);return c(n,s.id,p)}function ns(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=rs(a,r);if(!o)continue;let s=rs(a,o.id),d=(n,p,l)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===p&&u.subtasks){let v=u.subtasks.findIndex(f=>f.id===l);if(v!==-1){let[f]=u.subtasks.splice(v,1);return f}}if(u.subtasks){let v=d(u.subtasks,p,l);if(v)return v}}return null},c=(n,p,l)=>{let i=n.findIndex(u=>u.id===p);if(i!==-1)return n.splice(i+1,0,l),n;for(let u of n)u.subtasks&&c(u.subtasks,p,l);return n},m=d(a,o.id,r);m&&(s&&s.subtasks?c(s.subtasks,o.id,m):c(a,o.id,m));}return a}function ss(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(d,c,m)=>{let n=d.findIndex(l=>l.id===c);if(n===-1){for(let l of d)if(l.subtasks&&s(l.subtasks,c,m))return true;return false}let p=m==="up"?n-1:n+1;return p<0||p>=d.length?false:([d[n],d[p]]=[d[p],d[n]],true)};return s(r,o,a),r}function is(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 ls(e,t){let a=[...e];for(let r of t){let o=d=>{let c=d.findIndex(p=>p.id===r);if(c===-1){for(let p of d)if(p.subtasks&&o(p.subtasks))return true;return false}let m=d[c],n={...m,id:`${m.id}-copy-${Date.now()}`,name:`${m.name} (Copy)`,subtasks:m.subtasks?s(m.subtasks):void 0};return d.splice(c+1,0,n),true},s=d=>d.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function Gl(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let d={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=m=>{let n=m.findIndex(l=>l.id===t);if(n===-1){for(let l of m)if(l.subtasks&&c(l.subtasks))return true;return false}let p=a==="above"?n:n+1;return m.splice(p,0,d),true};return c(r),{tasks:r,newTask:d}}function ds(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:ds(r.subtasks,t,a)}:r)}function cs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:cs(a.subtasks,t)}:a)}function ms(e,t){let a=p=>{for(let l of p){if(l.id===t)return l;if(l.subtasks){let i=a(l.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let d=r?.startDate||o,c=r?.endDate||s,m={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(d),endDate:new Date(c),color:r?.color||"#3B82F6"},n=p=>p.map(l=>{if(l.id===t){let i=l.subtasks||[];return {...l,subtasks:[...i,m],isExpanded:true}}return l.subtasks?{...l,subtasks:n(l.subtasks)}:l});return {tasks:n(e),newTask:m}}function Hl(e,t,a,r){if(t===a)return e;let o=Wl(e,t);if(!o)return e;if(a){let c=(m,n)=>{if(!m.subtasks)return false;for(let p of m.subtasks)if(p.id===n||c(p,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(m=>m.id!==t).map(m=>m.subtasks&&m.subtasks.length>0?{...m,subtasks:s(m.subtasks)}:m),d=s(e);if(a===null){let c=r!==void 0?r:d.length;d.splice(c,0,{...o,parentId:void 0});}else {let c=m=>m.map(n=>{if(n.id===a){let p=n.subtasks||[],l=r!==void 0?r:p.length,i=[...p];return i.splice(l,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});d=c(d);}return d}function Po({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:d,onTaskContextMenu:c,onTaskToggle:m,scrollTop:n,columns:p,onToggleColumn:l,onColumnResize:i,onTaskUpdate:u,onTaskIndent:v,onTaskOutdent:f,onTaskMove:y,onMultiTaskDelete:x,onTaskDuplicate:b,onTaskCreate:g,onTaskRename:C,onCreateSubtask:D,onOpenTaskModal:h,onDeleteRequest:A,onTaskReparent:w}){let L=useContext(wr),[T,z]=useState(null),[H,U]=useState(false),[E,J]=useState(null),[ge,ke]=useState(""),Le=useRef(null),Ee=useRef(null),[ce,S]=useState(null),[F,M]=useState(0),[V,P]=useState(0),[W,le]=useState({isOpen:false,x:0,y:0,type:"header"}),[te,Se]=useState(null),[se,Ve]=useState(null),[be,tt]=useState(null),Tt=useRef(0),Dt=5,yt=useRef(false);useEffect(()=>{function B(G){Le.current&&!Le.current.contains(G.target)&&U(false);}if(H)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[H]),useEffect(()=>{E&&Ee.current&&(Ee.current.focus(),Ee.current.select());},[E]),useEffect(()=>{if(!ce)return;let B=K=>{let ne=K.clientX-F,q=V+ne;i?.(ce,q);},G=()=>{S(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",G),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",G),document.body.style.cursor="",document.body.style.userSelect="";}},[ce,F,V,i]);let{selectedTaskIds:Nt,handleTaskClick:Mt,isTaskSelected:ra}=$l(),{setIsEditing:mt}=Ul({tasks:e,selectedTaskIds:Nt,onTaskSelect:(B,G)=>{let ne=Tr(e).map(q=>q.id);Mt(B,ne,G||false,false);},onTaskCreate:g||(()=>{}),onTaskDelete:x||(()=>{}),onTaskDuplicate:b||(()=>{}),onTaskMove:y||(()=>{}),onTaskIndent:v||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:B=>{let G=Tr(e).find(K=>K.id===B);G&&O(G);},onTaskToggleExpand:m||(()=>{}),onOpenTaskModal:B=>{let G=Tr(e).find(K=>K.id===B);G&&h&&h(G);},enableKeyboard:true}),rt=(B,G=0)=>{let K=[];for(let ne of B)K.push({task:ne,level:G}),ne.subtasks&&ne.subtasks.length>0&&ne.isExpanded&&K.push(...rt(ne.subtasks,G+1));return K},Lt=rt(e),Ht=48,we=B=>!B.startDate||!B.endDate?"-":`${Math.ceil((B.endDate.getTime()-B.startDate.getTime())/(1e3*60*60*24))}d`,O=B=>{J(B.id),ke(B.name),mt(true);},Te=B=>{ge.trim()&&ge!==e.find(G=>G.id===B)?.name&&C?.(B,ge.trim()),J(null),ke(""),mt(false);},ze=()=>{J(null),ke(""),mt(false);},Ue=(B,G)=>{G.stopPropagation(),D?.(B.id);},pt=(B,G)=>{G.preventDefault(),Tt.current=G.clientY,Se(B),yt.current=false;},X=B=>{if(!te||(Math.abs(B.clientY-Tt.current)>Dt&&(yt.current=true),!yt.current))return;let K=document.querySelectorAll("[data-task-row]"),ne=null,q=null;K.forEach(xe=>{let de=xe.getBoundingClientRect(),R=xe.getAttribute("data-task-row");if(R&&R!==te&&B.clientY>=de.top&&B.clientY<=de.bottom){ne=R;let ie=B.clientY-de.top,Ae=de.height;ie<Ae*.25?q="above":ie>Ae*.75?q="below":q="child";}}),Ve(ne),tt(q);},Q=()=>{if(yt.current&&te&&se&&be){if(be==="child")w?.(te,se);else if(be==="above"||be==="below"){let B=(ne,q,xe=null)=>{for(let de of ne){if(de.id===q)return xe;if(de.subtasks){let R=B(de.subtasks,q,de.id);if(R!==void 0)return R}}},G=B(e,se,null),K=(ne,q)=>{let xe=ne.findIndex(de=>de.id===q);return be==="below"?xe+1:xe};if(G===null){let ne=K(e,se);w?.(te,null,ne);}else {let ne=Lt.find(q=>q.task.id===G)?.task;if(ne?.subtasks){let q=K(ne.subtasks,se);w?.(te,G,q);}}}}Se(null),Ve(null),tt(null),yt.current=false;};useEffect(()=>{if(te)return document.addEventListener("mousemove",X),document.addEventListener("mouseup",Q),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",Q),document.body.style.cursor="",document.body.style.userSelect="";}},[te,se,be]);let ve=(B,G,K)=>{switch(B.id){case "name":let ne=E===G.id,q=T===G.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${K*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:q?1:.3},onMouseDown:De=>pt(G.id,De),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),G.subtasks&&G.subtasks.length>0?jsx("button",{onClick:De=>{De.stopPropagation(),m?.(G.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:G.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"}),!(G.subtasks&&G.subtasks.length>0)&&jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0 border",style:{backgroundColor:G.color||"#3B82F6",opacity:G.parentId?.6:1,borderColor:G.isMilestone?t.accent:"transparent",borderWidth:G.isMilestone?"2px":"0px"},title:G.isMilestone?"Milestone":G.parentId?"Subtask":"Task"}),ne?jsx("input",{ref:Ee,type:"text",value:ge,onChange:De=>ke(De.target.value),onKeyDown:De=>{De.key==="Enter"?Te(G.id):De.key==="Escape"&&ze();},onBlur:()=>Te(G.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:De=>De.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:G.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:G.parentId?"13px":"14px",fontWeight:G.isMilestone?600:G.parentId?400:600,letterSpacing:G.parentId?"0":"-0.01em"},title:G.name,children:G.name}),q&&!ne&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:De=>De.stopPropagation(),children:[jsx("button",{onClick:De=>Ue(G,De),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:De=>{De.stopPropagation(),O(G);},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":let xe=G.startDate?typeof G.startDate=="string"?G.startDate:G.startDate.toISOString().split("T")[0]:void 0;return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx("input",{type:"date",value:xe||"",onChange:De=>{u?.(G.id,{startDate:De.target.value?new Date(De.target.value):void 0});},className:"bg-transparent border-none text-xs cursor-pointer outline-none text-center",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif"}})});case "endDate":let de=G.endDate?typeof G.endDate=="string"?G.endDate:G.endDate.toISOString().split("T")[0]:void 0;return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx("input",{type:"date",value:de||"",onChange:De=>{u?.(G.id,{endDate:De.target.value?new Date(De.target.value):void 0});},className:"bg-transparent border-none text-xs cursor-pointer outline-none text-center",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif"}})});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:we(G)})});case "assignees":let R=r.filter(De=>G.assignees?.some(ja=>ja.name===De.name||ja.initials===De.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx(Xa,{assignedUsers:R,availableUsers:r,onChange:De=>{let ja=De.map(cr=>({id:cr.id,name:cr.name,initials:cr.initials,color:cr.color}));u?.(G.id,{assignees:ja.length>0?ja:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx(Hi,{status:G.status||"todo",onChange:De=>{u?.(G.id,{status:De,progress:De==="completed"?100:G.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:`${G.progress}%`,backgroundColor:G.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:[G.progress,"%"]})]});case "priority":let ie={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},Ae={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},at=ie[G.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:De=>De.stopPropagation(),children:jsx(Ya,{priority:at,onChange:De=>{De&&u?.(G.id,{priority:Ae[De]||"medium"});}})});default:return null}},fe=B=>[{id:"hide",label:"Hide Column",icon:it.Hide,onClick:()=>l(B),disabled:B==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:it.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:it.SortDesc,onClick:()=>{}}],ee=B=>B.subtasks&&B.subtasks.length>0?[{id:"addSubtask",label:L?.contextMenu?.addSubtask||"Add Subtask",icon:it.Add,onClick:()=>{D?.(B.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:L?.contextMenu?.deleteTask||"Delete Task",icon:it.Delete,onClick:()=>{A?A(B.id,B.name):x?.([B.id]);}}]:[{id:"edit",label:L?.contextMenu?.editTask||"Edit Task",icon:it.Pencil,onClick:()=>{d?.(B);}},{id:"addSubtask",label:L?.contextMenu?.addSubtask||"Add Subtask",icon:it.Add,onClick:()=>{D?.(B.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:L?.contextMenu?.markIncomplete||"Mark Incomplete",icon:it.MarkIncomplete,onClick:()=>{u?.(B.id,{status:"todo",progress:0});},disabled:B.status==="todo"},{id:"setInProgress",label:L?.contextMenu?.setInProgress||"Set In Progress",icon:it.SetInProgress,onClick:()=>{u?.(B.id,{status:"in-progress"});},disabled:B.status==="in-progress"},{id:"markComplete",label:L?.contextMenu?.markComplete||"Mark Complete",icon:it.MarkComplete,onClick:()=>{u?.(B.id,{status:"completed",progress:100});},disabled:B.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:L?.contextMenu?.splitTask||"Split Task",icon:it.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:L?.contextMenu?.deleteTask||"Delete Task",icon:it.Delete,onClick:()=>{A?A(B.id,B.name):x?.([B.id]);}}],Ce=p.filter(B=>B.visible);return jsxs("div",{className:"h-full overflow-hidden",style:{backgroundColor:t.bgPrimary},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${Ht}px`,paddingLeft:"3px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},children:[Ce.map((B,G)=>jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${B.id==="name"?"":"justify-center"}`,style:{width:`${B.width}px`,minWidth:`${B.minWidth??(B.id==="name"?200:60)}px`,maxWidth:`${B.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:G<Ce.length-1?`1px solid ${t.borderLight}`:"none",height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:K=>{K.preventDefault(),le({isOpen:true,x:K.clientX,y:K.clientY,type:"header",columnId:B.id});},onMouseEnter:K=>{K.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:K=>{K.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:B.id==="name"?"70px":"0"},title:B.label,children:B.label}),B.id==="name"&&jsxs("div",{className:"absolute flex items-center gap-1",style:{right:"4px",top:"50%",transform:"translateY(-50%)",zIndex:4},children:[jsx(No,{columns:p,onToggleColumn:l,theme:t}),jsx("button",{onClick:()=>U(!H),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors relative group",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})})]}),B.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:ce===B.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:K=>{K.preventDefault(),K.stopPropagation(),S(B.id),M(K.clientX),P(B.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"}})})]},B.id)),H&&jsxs("div",{ref:Le,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:B=>B.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:()=>U(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",children:Lt.map(({task:B,level:G},K)=>{let ne=ra(B.id),q=se===B.id,xe={};return q&&be&&(be==="above"?(xe.borderTopWidth="2px",xe.borderTopStyle="solid",xe.borderTopColor=t.accent):be==="below"?(xe.borderBottomWidth="2px",xe.borderBottomStyle="solid",xe.borderBottomColor=t.accent):be==="child"&&(xe.backgroundColor=t.accentLight,xe.boxShadow=`inset 0 0 0 2px ${t.accent}`)),jsx(motion.div,{"data-task-row":B.id,className:`flex items-center cursor-pointer group ${te===B.id?"opacity-50":""}`,style:{height:`${a}px`,borderLeft:ne?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:ne||q&&be==="child"?t.accentLight:K%2===0?t.bgPrimary:t.bgGrid,...xe},onMouseEnter:()=>z(B.id),onMouseLeave:()=>z(null),onClick:de=>{let ie=Tr(e).map(De=>De.id),at=navigator.platform.toUpperCase().indexOf("MAC")>=0?de.metaKey:de.ctrlKey;Mt(B.id,ie,at,de.shiftKey),s?.(B);},onDoubleClick:de=>{de.stopPropagation(),d?.(B);},onContextMenu:de=>{de.preventDefault(),le({isOpen:true,x:de.clientX,y:de.clientY,type:"task",task:B}),c?.(B,de);},whileHover:{backgroundColor:ne?t.accentLight:t.hoverBg},children:Ce.map((de,R)=>jsx("div",{className:`px-4 flex items-center ${de.id==="name"?"justify-start":"justify-center"} ${R<Ce.length-1?"border-r":""}`,style:{width:`${de.width}px`,minWidth:`${de.minWidth??(de.id==="name"?200:60)}px`,maxWidth:`${de.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderColor:T===B.id?t.border:t.borderLight,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:ve(de,B,de.id==="name"?G:0)},`${B.id}-${de.id}`))},B.id)})}),jsx(Cr,{isOpen:W.isOpen,x:W.x,y:W.y,items:W.type==="header"&&W.columnId?fe(W.columnId):W.type==="task"&&W.task?ee(W.task):[],onClose:()=>le({...W,isOpen:false}),theme:t})]})}function _l(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[d,c]=useState(e),[m,n]=useState(t),[p,l]=useState(null),[i,u]=useState(null),[v,f]=useState(null),[y,x]=useState(null),[b,g]=useState(0),[C,D]=useState(0),[h,A]=useState(null),[w,L]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:d,setGhostX:c,ghostWidth:m,setGhostWidth:n,connectionLine:p,setConnectionLine:l,hoveredTaskId:i,setHoveredTaskId:u,activeZone:v,setActiveZone:f,draggedSegmentIndex:y,setDraggedSegmentIndex:x,draggedSegmentStartX:b,setDraggedSegmentStartX:g,segmentDragOffsetX:C,setSegmentDragOffsetX:D,hoveredSegmentIndex:h,setHoveredSegmentIndex:A,isHovered:w,setIsHovered:L,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(E,J)=>{r("none"),l(null),u(null),c(E),n(J),D(0),x(null),g(0);}}}function Mo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:d,templates:c,onClick:m,onDoubleClick:n,onContextMenu:p,onDateChange:l,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:v,onHoverChange:f}){let y=_l(t,r),x=useRef(null),{dragMode:b,setDragMode:g,dragOffset:C,setDragOffset:D,ghostX:h,setGhostX:A,ghostWidth:w,setGhostWidth:L,connectionLine:T,setConnectionLine:z,hoveredTaskId:H,setHoveredTaskId:U,activeZone:E,setActiveZone:J,draggedSegmentIndex:ge,setDraggedSegmentIndex:ke,draggedSegmentStartX:Le,setDraggedSegmentStartX:Ee,segmentDragOffsetX:ce,setSegmentDragOffsetX:S,hoveredSegmentIndex:F,setHoveredSegmentIndex:M,isHovered:V,setIsHovered:P,isDragging:W,isResizing:le,isConnecting:te,resetDragState:Se}=y,se=32,Ve=8,be=e.endDate&&e.endDate<new Date&&e.progress<100,tt=e.isCriticalPath,Tt=o.name==="neutral"||o.today==="#1C1917",Dt=e.status==="completed"||e.progress===100,yt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},Mt=e.isCriticalPath||be?"#DC2626":e.color?e.color:e.priority&&yt[e.priority]?yt[e.priority]:o.taskBarPrimary,mt=(ee=>ee>=80?20:ee>=60?15:ee>=50?12:10)(r),rt=r<50,Lt=r<40;useEffect(()=>{if(f)if(V&&!W&&!e.segments){let ee=a<100;f({task:e,x:t,y:a,width:r,height:se,showBelow:ee});}else f(null);},[V,W,e,t,a,r,se,f]);let Ht=ee=>ee.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),we=()=>{let ee=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${ee} day${ee!==1?"s":""}`},O=ee=>Math.round(ee/s)*s,Te=ee=>{let Ce=Math.round(ee/s),B=new Date(d);return B.setDate(B.getDate()+Ce),B},ze=(ee,Ce)=>{for(let B of u){if(B.id===e.id)continue;let G=5;if(ee>=B.x-G&&ee<=B.x+B.width+G&&Ce>=B.y-G&&Ce<=B.y+B.height+G)return B.id}return null},Ue=useCallback((ee,Ce,B)=>{ee.preventDefault(),ee.stopPropagation();let G=x.current?.ownerSVGElement;if(!G)return;let K=G.createSVGPoint();K.x=ee.clientX,K.y=ee.clientY;let ne=K.matrixTransform(G.getScreenCTM()?.inverse()),q=B!==void 0?B:t,xe=Ce;if(!xe){let de=ne.x-q;ee.shiftKey?(xe="connect",z({x:t+r,y:a+se/2})):ee.ctrlKey||ee.metaKey?xe="move":ee.altKey?xe=de<r/2?"resize-start":"resize-end":Lt?de<r/2?xe="move":xe="resize-end":rt?de<=mt/2?xe="resize-start":de>=r-mt/2?xe="resize-end":xe="move":de<=mt?xe="resize-start":de>=r-mt?xe="resize-end":xe="move";}g(xe),P(false),J(null),xe==="move"?D(ne.x-q):xe==="connect"?z({x:t+r,y:a+se/2}):D(0),A(q),L(r);},[t,r,a,se]),pt=useCallback(ee=>{if(b==="none")return;let Ce=x.current?.ownerSVGElement;if(!Ce)return;let B=Ce.createSVGPoint();B.x=ee.clientX,B.y=ee.clientY;let G=B.matrixTransform(Ce.getScreenCTM()?.inverse());if(b==="connect"){z({x:G.x,y:G.y});let K=ze(G.x,G.y);U(K);}else if(b==="move"){let K=G.x-C,ne=O(K);A(ne),L(r);let q=Math.round((ne-t)/s);if(v?.(e.id,q,true),e.segments&&e.segments.length>0&&ge!==null){let xe=ne-Le;S(xe);}}else if(b==="resize-start"){let K=G.x,ne=O(K),q=t+r-ne;q>=s&&(A(ne),L(q));}else if(b==="resize-end"){let K=G.x,q=O(K)-t;q>=s&&L(q);}},[b,t,r,s,C,e,O,ge,Le,ze,U,z,A,L,S,v]),X=useCallback(()=>{if(b!=="none"){if(b==="connect")H&&i&&i(e,H),z(null),U(null);else {let ee=e.endDate.getTime()-e.startDate.getTime(),Ce,B,G=true;if(b==="move"){if(Ce=Te(h),B=new Date(Ce.getTime()+ee),e.segments&&e.segments.length>0&&ge!==null){let K=Math.round(ce/s),ne=e.segments.map((R,ie)=>{if(ie===ge){let Ae=new Date(R.startDate),at=new Date(R.endDate);return Ae.setDate(Ae.getDate()+K),at.setDate(at.getDate()+K),{startDate:Ae,endDate:at}}return R}),q=ne.flatMap(R=>[R.startDate,R.endDate]),xe=new Date(Math.min(...q.map(R=>R.getTime()))),de=new Date(Math.max(...q.map(R=>R.getTime())));l?.({...e,segments:ne},xe,de),Se(t,r);return}}else b==="resize-start"?(Ce=Te(h),B=e.endDate,Ce>=B&&(console.warn("Invalid date range: start date must be before end date"),G=false)):b==="resize-end"?(Ce=e.startDate,B=Te(h+w),B<=Ce&&(console.warn("Invalid date range: end date must be after start date"),G=false)):G=false;G&&Ce&&B&&(B.getTime()-Ce.getTime()<864e5?console.warn("Invalid date range: task must be at least 1 day long"):l?.(e,Ce,B));}v?.(e.id,0,false),Se(t,r);}},[b,h,w,e,l,H,i,t,r,s,Te,ce,ge,Se,v]);useEffect(()=>{if(b==="none")return;let ee=B=>{pt(B);},Ce=()=>{X();};return window.addEventListener("mousemove",ee),window.addEventListener("mouseup",Ce),()=>{window.removeEventListener("mousemove",ee),window.removeEventListener("mouseup",Ce);}},[b,pt,X]);let Q=W&&!te?h:t,ve=W&&!te?w:r,fe=c.taskClass(e);return jsxs("g",{ref:x,onMouseEnter:()=>!W&&P(true),onMouseLeave:()=>{W||(P(false),J(null));},onClick:()=>!W&&m?.(e),onDoubleClick:ee=>{W||(ee.stopPropagation(),n?.(e));},onContextMenu:ee=>{ee.preventDefault(),p?.(e,ee);},children:[V&&!W&&!rt&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:mt,height:se,fill:E==="resize-start"?o.accent:"transparent",opacity:E==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>J("resize-start"),onMouseDown:ee=>Ue(ee,"resize-start")}),jsx("rect",{x:t+mt,y:a,width:r-mt*2,height:se,fill:E==="move"?o.accent:"transparent",opacity:E==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>J("move"),onMouseDown:ee=>Ue(ee,"move")}),jsx("rect",{x:t+r-mt,y:a,width:mt,height:se,fill:E==="resize-end"?o.accent:"transparent",opacity:E==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>J("resize-end"),onMouseDown:ee=>Ue(ee,"resize-end")})]}),V&&!W&&Lt&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:se,fill:E==="move"?o.accent:"transparent",opacity:E==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>J("move"),onMouseDown:ee=>Ue(ee,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:se,fill:E==="resize-end"?o.accent:"transparent",opacity:E==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>J("resize-end"),onMouseDown:ee=>Ue(ee,"resize-end")}),V&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+se-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),W&&!te&&!e.segments&&jsx(motion.rect,{x:h,y:a,width:w,height:se,rx:Ve,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:Q,y:a,width:ve,height:se,rx:Ve,fill:Mt,"data-task-class":fe,initial:{opacity:0,scale:.95},animate:{opacity:W&&!te?.15:e.parentId?.6:V?.9:.8,scale:V&&!W?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:ee=>Ue(ee),style:{cursor:W?te?"crosshair":le?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:Q,y:a,width:ve*(e.progress/100),height:se,rx:Ve,fill:Mt,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((ee,Ce)=>{let B=(ee.startDate.getTime()-d.getTime())/864e5*s,K=(ee.endDate.getTime()-d.getTime())/(1e3*60*60*24)*s-B+s,ne=W&&b==="move"&&ge===Ce,q=F===Ce,xe=ne?B+ce:B;return jsxs("g",{onMouseEnter:()=>!W&&M(Ce),onMouseLeave:()=>!W&&M(null),children:[jsx(motion.rect,{x:xe,y:a,width:K,height:se,rx:Ve,fill:Mt,initial:{opacity:0,scale:.95},animate:{opacity:ne||e.parentId?.6:q?.9:.8,scale:q&&!W?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:de=>{de.stopPropagation(),ke(Ce),Ee(B),Ue(de,void 0,B);},style:{cursor:W?te?"crosshair":le?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:xe,y:a,width:K*(e.progress/100),height:se,rx:Ve,fill:Mt,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Ce}`)}),Tt&&(be||tt)&&!e.segments&&jsxs(Fragment,{children:[tt&&!be&&jsx("rect",{x:Q,y:a,width:ve,height:se,rx:Ve,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),be&&jsx("rect",{x:Q,y:a,width:ve,height:se,rx:Ve,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ve>60&&!e.segments&&(()=>{let ee=c.taskLabel(e),Ce=typeof ee=="string"?ee:e.name,B=Ce.length>Math.floor(ve/8)?`${Ce.substring(0,Math.floor(ve/8))}...`:Ce;return jsx("text",{x:Q+12,y:a+se/2,dominantBaseline:"middle",fill:Dt?"rgba(255, 255, 255, 0.6)":"#FFFFFF",fontSize:"13",fontWeight:"500",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none",textDecoration:Dt?"line-through":"none"},children:B})})(),ve>100&&e.progress>0&&e.progress<100&&!W&&!e.segments&&jsxs("text",{x:Q+ve-12,y:a+se/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&&ve>80&&!W&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:Q+ve-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:Q+ve-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(V||le)&&!te&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:rt?Q-15:Q-10,y:a-5,width:rt?25:20,height:se+10,fill:"transparent",onMouseDown:ee=>Ue(ee,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:rt?Q-8:Q-3,y:a+6,width:rt?8:6,height:rt?se-12:se-16,rx:3,fill:b==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-start"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]}),jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Q+ve-10,y:a-5,width:rt?25:20,height:se+10,fill:"transparent",onMouseDown:ee=>Ue(ee,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:rt?Q+ve:Q+ve-3,y:a+6,width:rt?8:6,height:rt?se-12:se-16,rx:3,fill:b==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:b==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:V&&!W&&!e.segments&&jsxs(motion.g,{style:{pointerEvents:"all"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[jsx(motion.circle,{cx:t+r+8,cy:a+se/2,r:6,fill:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},exit:{scale:0},transition:{duration:.2,type:"spring",stiffness:400,damping:25},onMouseDown:ee=>{ee.stopPropagation(),Ue(ee,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+se/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),te&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+se/2,x2:T.x,y2:T.y,stroke:H?o.statusCompleted:o.accent,strokeWidth:H?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:H?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:H?8:6,fill:H?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),H&&jsx(motion.text,{x:T.x+15,y:T.y,dominantBaseline:"middle",fill:o.statusCompleted,fontSize:"11",fontWeight:"600",fontFamily:"Inter, sans-serif",initial:{opacity:0,x:T.x+10},animate:{opacity:1,x:T.x+15},transition:{duration:.2},children:"Connect"})]}),(V||W)&&!te&&!e.segments&&jsx(motion.rect,{x:Q-2,y:a-2,width:ve+4,height:se+4,rx:Ve+2,fill:"none",stroke:W?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:W?.6:.4,initial:{opacity:0},animate:{opacity:W?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),le&&jsxs(Fragment,{children:[jsx("line",{x1:h,y1:0,x2:h,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:h+w,y1:0,x2:h+w,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:V&&!W&&!e.segments&&!f&&(()=>{let B=a<100,G=B?a+se+13:a-82-13,K=B?`M ${Q+ve/2-6} ${a+se+3} L ${Q+ve/2} ${a+se+13} L ${Q+ve/2+6} ${a+se+3}`:`M ${Q+ve/2-6} ${a-13} L ${Q+ve/2} ${a-3} L ${Q+ve/2+6} ${a-13}`,ne=G+22,q=G+40,xe=G+55,de=G+70,R=B?G+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:B?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:B?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:K,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:Q+ve/2-120,y:G,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:Q+ve/2,y:ne,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:Q+ve/2-110,y:q,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:Q+ve/2-70,y:q,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ht(e.startDate)}),jsx("text",{x:Q+ve/2-110,y:xe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:Q+ve/2-70,y:xe,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ht(e.endDate)}),jsx("text",{x:Q+ve/2+10,y:q,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:Q+ve/2+65,y:q,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:we()}),jsx("text",{x:Q+ve/2+10,y:xe,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:Q+ve/2+65,y:xe,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:Q+ve/2-110,y:de,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:Q+ve/2-50,y:de,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(ie=>ie.name).join(", ").substring(0,30),e.assignees.map(ie=>ie.name).join(", ").length>30?"...":""]})]}),!B&&jsx("text",{x:Q+ve/2,y:R,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:Lt?"Left: move \u2022 Right: resize":rt?"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 Kl({tooltipData:e,theme:t}){if(!e)return null;let{task:a,x:r,y:o,width:s,height:d,showBelow:c}=e,m=82,n=13,p=c?o+d+n:o-m-n,l=c?`M ${r+s/2-6} ${o+d+3} L ${r+s/2} ${o+d+13} L ${r+s/2+6} ${o+d+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=p+22,u=p+40,v=p+55,f=p+70,y=c?p+m-5:o-18,x=D=>D.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),b=()=>{if(!a.startDate||!a.endDate)return "N/A";let D=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${D} day${D!==1?"s":""}`},g=s<50,C=s<40;return jsx(AnimatePresence,{children:jsxs(motion.g,{initial:{opacity:0,y:c?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:c?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:l,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:p,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:i,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:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:r+s/2-70,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.startDate?x(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:v,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:v,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?x(a.endDate):"N/A"}),jsx("text",{x:r+s/2+10,y:u,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:r+s/2+65,y:u,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:b()}),jsx("text",{x:r+s/2+10,y:v,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:v,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:f,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:r+s/2-50,y:f,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[a.assignees.map(D=>D.name).join(", ").substring(0,30),a.assignees.map(D=>D.name).join(", ").length>30?"...":""]})]}),!c&&jsx("text",{x:r+s/2,y,textAnchor:"middle",fill:t.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:C?"Left: move \u2022 Right: resize":g?"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 Lo({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:d}){let[c,m]=useState(false),n=a-e,p=r-t,l=e+n/2,i=`M ${e} ${t} C ${l} ${t}, ${l} ${r}, ${a} ${r}`,u=6,v=Math.atan2(p,n),f=a-u*Math.cos(v-Math.PI/6),y=r-u*Math.sin(v-Math.PI/6),x=a-u*Math.cos(v+Math.PI/6),b=r-u*Math.sin(v+Math.PI/6),g=o.dependency;return useEffect(()=>{d&&s&&d(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,d]),jsxs("g",{onMouseEnter:()=>m(true),onMouseLeave:()=>m(false),children:[jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&d?0:c?1:.6,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.15},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${y} M ${a} ${r} L ${x} ${b}`,fill:"none",stroke:g,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&d?0:c?1:.6,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.15}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:g,initial:{scale:0},animate:{scale:c&&d?0:c?1.33:1},transition:{scale:{delay:.3,duration:.15}}}),c&&s&&!d&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:C=>{C.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:l,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:l-4,y1:(t+r)/2-4,x2:l+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:l+4,y1:(t+r)/2-4,x2:l-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function Bo({task:e,x:t,y:a,theme:r,onClick:o}){let[s,d]=useState(false),c=16,m=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false),onClick:()=>o?.(e),style:{cursor:"pointer"},children:[e.isCriticalPath&&jsx(motion.circle,{cx:t,cy:a+16,r:c+4,fill:r.criticalPathLight,initial:{scale:0},animate:{scale:s?1.2:1},transition:{duration:.3}}),jsx(motion.rect,{x:t-c/2,y:a+16-c/2,width:c,height:c,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-(c+4)/2,y:a+16-(c+4)/2,width:c+4,height:c+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 re={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=n=>{n.forEach(p=>{p.dependencies&&r.set(p.id,p.dependencies),p.subtasks&&o(p.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let d=new Set,c=new Set,m=n=>{if(!d.has(n)){d.add(n),c.add(n);let p=r.get(n)||[];for(let l of p){if(!d.has(l)&&m(l))return true;if(c.has(l))return true}}return c.delete(n),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=re.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=re.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=re.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=re.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(`
46
46
  `)},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=re.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=re.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)=>re.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=re.findTaskById(e,t);return !a||!a.dependencies?[]:re.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>re.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>re.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=re.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=>re.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=re.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 d=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(m=>{let n=m.startDate&&m.endDate?re.calculateDuration(m.startDate,m.endDate):0;return [m.name,m.startDate?re.formatDate(m.startDate):"N/A",m.endDate?re.formatDate(m.endDate):"N/A",n>0?`${n} days`:"N/A",`${m.progress}%`,m.status||"N/A"]});r(o,{head:d,body:c,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=re.flattenTasks(e).map(m=>{let n=m.startDate&&m.endDate?re.calculateDuration(m.startDate,m.endDate):0;return {"Task ID":m.id,"Task Name":m.name,"Start Date":m.startDate?re.formatDate(m.startDate):"","End Date":m.endDate?re.formatDate(m.endDate):"","Duration (days)":n>0?n:"","Progress (%)":m.progress,Status:m.status||"",Assignees:m.assignees?.map(p=>p.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),d=[{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"]=d;let c=a.utils.book_new();a.utils.book_append_sheet(c,s,"Gantt Tasks"),a.writeFile(c,t);},exportToMSProject:(e,t="Gantt Project",a="project.xml")=>{let r=re.flattenTasks(e),o=new Map;r.forEach((i,u)=>{o.set(i.id,u+1);});let s=i=>i.toISOString().replace("Z",""),d=re.getEarliestStartDate(e)||new Date,c=re.getLatestEndDate(e)||new Date,m=r.map((i,u)=>{let v=o.get(i.id),f=i.startDate&&i.endDate?re.calculateDuration(i.startDate,i.endDate):0,y=(i.dependencies||[]).filter(x=>o.has(x)).map(x=>`
47
47
  <PredecessorLink>
48
48
  <PredecessorUID>${o.get(x)}</PredecessorUID>