@libxai/board 0.17.203 → 0.17.205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -108,7 +108,7 @@ import {createRoot}from'react-dom/client';import {dragStore,BaseViewAdapter,sele
108
108
  1.
109
109
 
110
110
  **Action items:**
111
- - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function fs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null);useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},p=e.reduce((n,m)=>{let d=m.category||"Other";return n[d]||(n[d]=[]),n[d].push(m),n},{});return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,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:C("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(p).map(([n,m])=>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:m.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter: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:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},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 bs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[l,c]=useState("export"),[p,n]=useState("json"),[m,d]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,g=await Vi(e,p,f);ji(g,p);},x=async f=>{let g=f.target.files?.[0];if(g){try{let k=await qi(g),h=g.name.endsWith(".json")?"json":"csv",b=Yi(k,h);d(b),b.success&&r&&r(b,k);}catch(k){d({success:false,errors:[`Failed to read file: ${k instanceof Error?k.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:C("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:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[l==="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:C("p-4 rounded-lg border-2 transition-all text-center",p===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"})]}),l==="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:x,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"})]})]}),m&&jsxs("div",{className:C("p-4 rounded-lg",m.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:C("font-semibold mb-2",m.success?"text-green-400":"text-red-400"),children:m.success?"\u2713 Import Successful":"\u2717 Import Failed"}),m.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",m.cardsImported]}),jsxs("div",{children:["Columns imported: ",m.columnsImported]})]}),m.errors&&m.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:m.errors.map((f,g)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},g))})]})]})]})]})]})}var Nu=["URGENT","HIGH","MEDIUM","LOW"],Su=[{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"}],Eu=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function ys({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:l,onFilterHighPriority:c,availableUsers:p=[],availableLabels:n=[],availableColumns:m=[],showQuickFilters:d=true,compact:i=false,groupBy:u="none",onGroupByChange:x}){let[f,g]=useState(true),k=useCallback(N=>{a({search:N.target.value});},[a]),h=useCallback(N=>{a({dateFilter:N.target.value});},[a]),b=useCallback(N=>{r({by:N.target.value});},[r]),y=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:()=>g(!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:N=>{N.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:N=>{N.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:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),l&&jsx("button",{onClick:l,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:k,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:h,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:N=>{let A=N.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Nu.map(N=>jsx("option",{value:N,children:N},N))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:N=>{let A=N.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(N=>jsx("option",{value:N.id,children:N.name},N.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:N=>{let A=N.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(N=>jsx("option",{value:N,children:N},N))]})}),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:b,className:"filter-bar__select filter-bar__select--sm",children:Su.map(N=>jsx("option",{value:N.value,children:N.label},N.value))}),t.by!=="none"&&jsx("button",{onClick:y,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),x&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:N=>x(N.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Eu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function vs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:l,onExportGanttPNG:c,onExportGanttCSV:p}){let[n,m]=useState(false),d=useRef(null);useEffect(()=>{let u=x=>{d.current&&!d.current.contains(x.target)&&m(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),m(false);};return jsxs("div",{className:C("relative",r),ref:d,children:[jsxs("button",{onClick:()=>m(!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 l?.()),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(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter: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 xs={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},ks={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"}},ws={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"}},xr={dark:xs,light:ks,neutral:ws},Vo="dark";var jo=createContext(void 0),zu="asakaa-theme";function Jl({children:e,defaultTheme:t=Vo,storageKey:a=zu}){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,p=xr[r];Object.entries(p.colors).forEach(([m,d])=>{d&&c.style.setProperty(`--theme-${$u(m)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([m,d])=>{let i=p.colors[m];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let l={theme:r,setTheme:s,themes:xr};return jsx(jo.Provider,{value:l,children:e})}function _r(){let e=useContext(jo);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function $u(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Cs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=_r();return e?jsxs("div",{className:C("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(xr).map(([s,l])=>jsxs("button",{onClick:()=>{o(s),t();},className:C("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:l.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:l.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Zl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return _e[e]||_e.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,l)=>a.getPropertyValue(s).trim()||l;return {bgPrimary:r("--theme-bg-primary",_e[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",_e[e].bgSecondary),bgGrid:r("--theme-bg-card",_e[e].bgGrid),bgWeekend:r("--theme-bg-hover",_e[e].bgWeekend),border:r("--theme-border-primary",_e[e].border),borderLight:r("--theme-border-subtle",_e[e].borderLight),textPrimary:r("--theme-text-primary",_e[e].textPrimary),textSecondary:r("--theme-text-secondary",_e[e].textSecondary),textTertiary:r("--theme-text-tertiary",_e[e].textTertiary),accent:r("--theme-accent-primary",_e[e].accent),accentHover:r("--theme-accent-hover",_e[e].accentHover),accentLight:r("--theme-accent-primary",_e[e].accentLight),taskBarPrimary:r("--theme-accent-primary",_e[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",_e[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",_e[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",_e[e].dependency),dependencyHover:r("--theme-border-secondary",_e[e].dependencyHover),criticalPath:r("--theme-error",_e[e].criticalPath),criticalPathLight:r("--theme-error",_e[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",_e[e].today):e==="neutral"?r("--theme-text-primary",_e[e].today):r("--theme-error",_e[e].today),todayLight:e==="light"?r("--theme-accent-primary",_e[e].todayLight):e==="neutral"?r("--theme-text-primary",_e[e].todayLight):r("--theme-error",_e[e].todayLight),milestone:r("--theme-warning",_e[e].milestone),milestoneLight:r("--theme-warning",_e[e].milestoneLight),statusTodo:r("--theme-text-tertiary",_e[e].statusTodo),statusInProgress:r("--theme-accent-primary",_e[e].statusInProgress),statusCompleted:r("--theme-success",_e[e].statusCompleted),hoverBg:r("--theme-bg-hover",_e[e].hoverBg),focusRing:r("--theme-accent-primary",_e[e].focusRing)}}var Ko={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"}},Ql={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"}},Ts={en:Ko,es:Ql};function ed(e){return Ts[e]||Ts.en}function Ds(e,t){let a=ed(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 jr=createContext(Ko);function mo(){return useContext(jr)}function ag({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:l}){let[c,p]=useState(false),[n,m]=useState(null),d=useRef(null),i=mo();if(useEffect(()=>{let g=k=>{d.current&&!d.current.contains(k.target)&&p(false);};return c&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!(t||a||r||o||s||l))return null;let x=[{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:l}].filter(g=>g.handler),f=async(g,k)=>{if(k){m(g);try{await k();}catch(h){console.error(`Export ${g} failed:`,h);}finally{m(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!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:x.map((g,k)=>jsxs(motion.button,{onClick:()=>f(g.id,g.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:k<x.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:k*.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===g.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):g.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:g.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:g.description})]})]},g.id))})})})]})}function rg({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 l=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:l?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500,zIndex:l?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[l&&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:l?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function og({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 ng({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),l=mo();useEffect(()=>{let n=m=>{s.current&&!s.current.contains(m.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:l.toolbar.compact||"Compact"},{value:"comfortable",label:l.toolbar.normal||"Normal"},{value:"spacious",label:l.toolbar.spacious||"Spacious"}],p=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:`${l.toolbar.density||"Density"}: ${p}`,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,m)=>{let d=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:d?e.accentLight:"transparent",borderBottom:m<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:n.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function Yo({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:l,rowDensity:c,onRowDensityChange:p,showThemeSelector:n=false,showCreateTaskButton:m=false,createTaskLabel:d,onCreateTask:i,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}){let b=mo(),y=u||x||f||g||k||h,D=[{value:"day",label:b.toolbar.day},{value:"week",label:b.toolbar.week},{value:"month",label:b.toolbar.month}],N=[{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(og,{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(ng,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[m&&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:d||b.toolbar.createTask})]}),(y||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),y&&jsxs(Fragment,{children:[jsx(ag,{theme:e,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(rg,{options:N,value:s,onChange:A=>l(A),theme:e})]})]})}function qo({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let m=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);let n=e.filter(m=>m.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let m=p.current.getBoundingClientRect();l({x:m.left,y:m.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(rt,{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(m=>jsxs("button",{onClick:()=>{t(m.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:m.label}),m.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},m.id))]})})})})]})}function Kr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let l=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let m=200,d=r.length*36+8,i=8,u=window.innerWidth,x=window.innerHeight,f=t,g=a;t+m+i>u&&(f=t-m,f<i&&(f=i)),a+d+i>x&&(g=x-d-i,g<i&&(g=i)),p({x:f,y:g});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let m=i=>{l.current&&!l.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",m),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let n=m=>m.startsWith("#")&&(m.length===7||m.length===4)?m: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:l,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(m=>jsxs("div",{children:[m.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),o());},disabled:m.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:m.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:m.disabled?"not-allowed":"pointer",opacity:m.disabled?.5:1},onMouseEnter:d=>{m.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[m.icon&&jsx("span",{style:{color:s.textSecondary},children:m.icon}),jsx("span",{className:"flex-1",children:m.label}),m.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},m.id))})})})}var Ct={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 ud({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:l,onTaskIndent:c,onTaskOutdent:p,onTaskRename:n,onTaskToggleExpand:m,onOpenTaskModal:d,enableKeyboard:i=true}){let u=useRef(false),x=useCallback(b=>{u.current=b;},[]),f=useCallback(b=>{let y=[],D=N=>{for(let A of N)y.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(b),y},[]),g=useCallback(()=>{let b=f(e);for(let y of b)if(t.has(y.id))return y;return null},[e,t,f]),k=useCallback((b,y)=>{let D=f(e);if(D.length===0)return;let N=g();if(!N){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===N.id);if(A===-1)return;let v=b==="up"?A-1:A+1;if(v<0||v>=D.length)return;let B=D[v];a(B.id,y);},[e,g,f,a]),h=useCallback(b=>{if(!i)return;let y=b.target;if(y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.isContentEditable||u.current){b.key==="Escape"&&(y.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?b.metaKey:b.ctrlKey,v=Array.from(t),B=g();if(b.key==="ArrowUp"){b.preventDefault(),k("up",b.shiftKey);return}if(b.key==="ArrowDown"){b.preventDefault(),k("down",b.shiftKey);return}if(B&&(b.key==="ArrowRight"||b.key==="ArrowLeft")){B.subtasks&&B.subtasks.length>0&&(b.preventDefault(),(b.key==="ArrowRight"&&!B.isExpanded||b.key==="ArrowLeft"&&B.isExpanded)&&m(B.id));return}if(b.altKey&&(b.key==="ArrowUp"||b.key==="ArrowDown")){v.length>0&&(b.preventDefault(),l(v,b.key==="ArrowUp"?"up":"down"));return}if(b.key==="Tab"&&!b.shiftKey){v.length>0&&(b.preventDefault(),c(v));return}if(b.key==="Tab"&&b.shiftKey){v.length>0&&(b.preventDefault(),p(v));return}if(b.key==="Enter"&&!b.shiftKey&&!A){B&&(b.preventDefault(),r(B.id,"below"));return}if(b.key==="Enter"&&b.shiftKey&&!A){B&&(b.preventDefault(),r(B.id,"above"));return}if(b.key==="Enter"&&A){B&&(b.preventDefault(),d(B.id));return}if(b.key==="F2"){B&&(b.preventDefault(),n(B.id));return}if(b.key==="Delete"||b.key==="Backspace"&&A){v.length>0&&(b.preventDefault(),o(v));return}if(b.key==="d"&&A&&!b.shiftKey){v.length>0&&(b.preventDefault(),s(v));return}},[i,t,g,k,r,o,s,l,c,p,n,m,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h);}},[i,h]),{setIsEditing:x}}function fd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let u=new Set(i);return u.has(d)?u.delete(d):u.add(d),u}),r(d);},[]),l=useCallback((d,i)=>{if(!a){o(d);return}let u=i.indexOf(a),x=i.indexOf(d);if(u===-1||x===-1){o(d);return}let f=Math.min(u,x),g=Math.max(u,x),k=i.slice(f,g+1);t(new Set(k)),r(d);},[a,o]),c=useCallback((d,i,u,x)=>{x?l(d,i):u?s(d):o(d);},[o,s,l]),p=useCallback((d,i)=>{i?t(u=>{let x=new Set(u);return x.add(d),x}):o(d);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),m=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:l,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:n,isTaskSelected:m}}function Yr(e){let t=[],a=(r,o,s=0)=>{for(let l=0;l<r.length;l++){let c={...r[l],parentId:o,level:s,position:l};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function hd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=hd(a.subtasks,t);if(r)return r}}return null}function Es(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Es(a.subtasks,t);if(r)return r}return null}function Ps(e,t){if(t.length===0)return e;let a=Yr(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],l=(d,i)=>{let u=[];return {tasks:d.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let g=l(f.subtasks,i);f.subtasks=g.tasks,u.push(...g.removed);}return true}),removed:u}},c=(d,i,u)=>d.map(x=>x.id===i?{...x,subtasks:[...x.subtasks||[],...u],isExpanded:true}:x.subtasks?{...x,subtasks:c(x.subtasks,i,u)}:x),p=new Set(t),{tasks:n,removed:m}=l(e,p);return c(n,s.id,m)}function Ms(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Es(a,r);if(!o)continue;let s=Es(a,o.id),l=(n,m,d)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===m&&u.subtasks){let x=u.subtasks.findIndex(f=>f.id===d);if(x!==-1){let[f]=u.subtasks.splice(x,1);return f}}if(u.subtasks){let x=l(u.subtasks,m,d);if(x)return x}}return null},c=(n,m,d)=>{let i=n.findIndex(u=>u.id===m);if(i!==-1)return n.splice(i+1,0,d),n;for(let u of n)u.subtasks&&c(u.subtasks,m,d);return n},p=l(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function As(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(l,c,p)=>{let n=l.findIndex(d=>d.id===c);if(n===-1){for(let d of l)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let m=p==="up"?n-1:n+1;return m<0||m>=l.length?false:([l[n],l[m]]=[l[m],l[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=l=>{let c=l.findIndex(m=>m.id===r);if(c===-1){for(let m of l)if(m.subtasks&&o(m.subtasks))return true;return false}let p=l[c],n={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return l.splice(c+1,0,n),true},s=l=>l.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function bd(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let n=p.findIndex(d=>d.id===t);if(n===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let m=a==="above"?n:n+1;return p.splice(m,0,l),true};return c(r),{tasks:r,newTask:l}}function Fs(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Fs(r.subtasks,t,a)}:r)}function Bs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Bs(a.subtasks,t)}:a)}function Rs(e,t){let a=m=>{for(let d of m){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(l),endDate:new Date(c),color:r?.color||"#3B82F6"},n=m=>m.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:n(d.subtasks)}:d});return {tasks:n(e),newTask:p}}function yd(e,t,a,r){if(t===a)return e;let o=hd(e,t);if(!o)return e;if(a){let c=(p,n)=>{if(!p.subtasks)return false;for(let m of p.subtasks)if(m.id===n||c(m,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),l=s(e);if(a===null){let c=r!==void 0?r:l.length;l.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(n=>{if(n.id===a){let m=n.subtasks||[],d=r!==void 0?r:m.length,i=[...m];return i.splice(d,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});l=c(l);}return l}function Zo({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:l,onTaskContextMenu:c,onTaskToggle:p,scrollTop:n,columns:m,onToggleColumn:d,onColumnResize:i,onTaskUpdate:u,onTaskIndent:x,onTaskOutdent:f,onTaskMove:g,onMultiTaskDelete:k,onTaskDuplicate:h,onTaskCreate:b,onTaskRename:y,onCreateSubtask:D,onOpenTaskModal:N,onDeleteRequest:A,onTaskReparent:v}){let B=useContext(jr),[T,w]=useState(null),[R,P]=useState(null),[H,q]=useState(""),he=useRef(null),[xe,Ae]=useState(null),[Be,$]=useState(0),[F,W]=useState(0),[E,K]=useState({isOpen:false,x:0,y:0,type:"header"}),[X,U]=useState(null),[De,ke]=useState(null),[$e,be]=useState(null),tt=useRef(0),Pe=5,et=useRef(false),[ht,Dt]=useState(null),[dt,O]=useState(false),[re,de]=useState(null),[Ce,Ee]=useState(false),at=useRef(null);useEffect(()=>{function V(Z){at.current&&!at.current.contains(Z.target)&&Ee(false);}if(Ce)return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[Ce]),useEffect(()=>{R&&he.current&&(he.current.focus(),he.current.select());},[R]),useEffect(()=>{if(!xe)return;let V=nt=>{let fe=nt.clientX-Be,Ue=F+fe;i?.(xe,Ue);},Z=()=>{Ae(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",Z),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",Z),document.body.style.cursor="",document.body.style.userSelect="";}},[xe,Be,F,i]);let{selectedTaskIds:ut,handleTaskClick:Ie,isTaskSelected:I}=fd(),{setIsEditing:Y}=ud({tasks:e,selectedTaskIds:ut,onTaskSelect:(V,Z)=>{let fe=Yr(e).map(Ue=>Ue.id);Ie(V,fe,Z||false,false);},onTaskCreate:b||(()=>{}),onTaskDelete:k||(()=>{}),onTaskDuplicate:h||(()=>{}),onTaskMove:g||(()=>{}),onTaskIndent:x||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:V=>{let Z=Yr(e).find(nt=>nt.id===V);Z&&te(Z);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:V=>{let Z=Yr(e).find(nt=>nt.id===V);Z&&N&&N(Z);},enableKeyboard:true}),He=(V,Z=0)=>{let nt=[];for(let fe of V)nt.push({task:fe,level:Z}),fe.subtasks&&fe.subtasks.length>0&&fe.isExpanded&&nt.push(...He(fe.subtasks,Z+1));return nt},We=He(e),yt=48,Q=V=>!V.startDate||!V.endDate?"-":`${Math.ceil((V.endDate.getTime()-V.startDate.getTime())/(1e3*60*60*24))}d`,te=V=>{P(V.id),q(V.name),Y(true);},ve=V=>{H.trim()&&H!==e.find(Z=>Z.id===V)?.name&&y?.(V,H.trim()),P(null),q(""),Y(false);},Te=()=>{P(null),q(""),Y(false);},oe=(V,Z)=>{Z.stopPropagation(),D?.(V.id);},Se=(V,Z)=>{Z.preventDefault(),tt.current=Z.clientY,U(V),et.current=false,O(false),Dt({x:Z.clientX,y:Z.clientY});},ye=V=>{if(!X||(Math.abs(V.clientY-tt.current)>Pe&&!et.current&&(et.current=true,O(true)),Dt({x:V.clientX,y:V.clientY}),!et.current))return;let nt=document.querySelectorAll("[data-task-row]"),fe=null,Ue=null;nt.forEach(Je=>{let z=Je.getBoundingClientRect(),ne=Je.getAttribute("data-task-row");if(ne&&ne!==X&&V.clientY>=z.top&&V.clientY<=z.bottom){fe=ne;let Ge=V.clientY-z.top,Ke=z.height;Ge<Ke*.25?Ue="above":Ge>Ke*.75?Ue="below":Ue="child";}}),ke(fe),be(Ue);},Ne=()=>{if(et.current&&X&&De&&$e){if($e==="child")v?.(X,De);else if($e==="above"||$e==="below"){let V=(fe,Ue,Je=null)=>{for(let z of fe){if(z.id===Ue)return Je;if(z.subtasks){let ne=V(z.subtasks,Ue,z.id);if(ne!==void 0)return ne}}},Z=V(e,De,null),nt=(fe,Ue)=>{let Je=fe.findIndex(z=>z.id===Ue);return $e==="below"?Je+1:Je};if(Z===null){let fe=nt(e,De);v?.(X,null,fe);}else {let fe=We.find(Ue=>Ue.task.id===Z)?.task;if(fe?.subtasks){let Ue=nt(fe.subtasks,De);v?.(X,Z,Ue);}}}}U(null),ke(null),be(null),Dt(null),et.current=false,O(false);};useEffect(()=>{if(X)return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Ne),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect="";}},[X,De,$e]);let ie=(V,Z,nt)=>{switch(V.id){case "name":let fe=R===Z.id,Ue=T===Z.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${nt*20}px`},children:[v&&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:Ue?1:.3},onMouseDown:pe=>Se(Z.id,pe),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),Z.subtasks&&Z.subtasks.length>0?jsx("button",{onClick:pe=>{pe.stopPropagation(),p?.(Z.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:Z.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:Z.color||"#3B82F6",opacity:Z.parentId?.6:1,borderColor:Z.isMilestone?t.accent:"transparent",borderWidth:Z.isMilestone?"2px":"0px"},title:Z.isMilestone?"Milestone":Z.parentId?"Subtask":"Task"})}),fe?jsx("input",{ref:he,type:"text",value:H,onChange:pe=>q(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"?ve(Z.id):pe.key==="Escape"&&Te();},onBlur:()=>ve(Z.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:pe=>pe.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:Z.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:Z.parentId?"13px":"14px",fontWeight:Z.isMilestone?600:Z.parentId?400:600,letterSpacing:Z.parentId?"0":"-0.01em"},title:Z.name,children:Z.name}),Ue&&!fe&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:pe=>pe.stopPropagation(),children:[jsx("button",{onClick:pe=>oe(Z,pe),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:pe=>{pe.stopPropagation(),te(Z);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let z=V.id==="startDate"?"startDate":"endDate",ne=Z[z],Ge=re?.taskId===Z.id&&re?.field===z,Ke=pe=>pe?(typeof pe=="string"?new Date(pe):pe).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:pe=>pe.stopPropagation(),children:[jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors hover:bg-white/5",style:{color:t.textSecondary},onClick:pe=>{if(Ge)de(null);else {let Nt=pe.currentTarget.getBoundingClientRect();de({taskId:Z.id,field:z,month:ne?typeof ne=="string"?new Date(ne):ne:new Date,position:{top:Nt.bottom+4,left:Nt.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Ke(ne)})]}),Ge&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>de(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"fixed z-[9999] rounded-xl shadow-2xl overflow-visible flex",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,top:re?.position.top,left:re?.position.left},onClick:pe=>pe.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let pe=new Date,Nt=new Date(pe);Nt.setDate(pe.getDate()+1);let Jt=new Date(pe);Jt.setDate(pe.getDate()+7);let Ar=new Date(pe);return Ar.setDate(pe.getDate()+14),[{label:"Hoy",date:pe},{label:"Ma\xF1ana",date:Nt},{label:"Pr\xF3xima semana",date:Jt},{label:"2 semanas",date:Ar}].map((Lr,Ha)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:cr=>cr.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:cr=>cr.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(Z.id,{[z]:Lr.date}),de(null);},children:Lr.label},Ha))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:pe=>pe.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:pe=>pe.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(Z.id,{[z]:void 0}),de(null);},children:"Borrar"})]}),jsxs("div",{className:"p-2",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("button",{type:"button",onClick:()=>de(pe=>pe?{...pe,month:new Date(pe.month.getFullYear(),pe.month.getMonth()-1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})}),jsx("span",{className:"text-xs font-medium",style:{color:t.textPrimary},children:re?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>de(pe=>pe?{...pe,month:new Date(pe.month.getFullYear(),pe.month.getMonth()+1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:["D","L","M","M","J","V","S"].map((pe,Nt)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:pe},Nt))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let pe=re?.month||new Date,Nt=pe.getFullYear(),Jt=pe.getMonth(),Ar=new Date(Nt,Jt,1).getDay(),Ir=new Date(Nt,Jt+1,0).getDate(),Lr=new Date,Ha=[];for(let St=Ar-1;St>=0;St--)Ha.push({day:new Date(Nt,Jt,-St).getDate(),date:new Date(Nt,Jt-1,new Date(Nt,Jt,-St).getDate()),isCurrentMonth:false});for(let St=1;St<=Ir;St++)Ha.push({day:St,date:new Date(Nt,Jt,St),isCurrentMonth:true});let cr=42-Ha.length;for(let St=1;St<=cr;St++)Ha.push({day:St,date:new Date(Nt,Jt+1,St),isCurrentMonth:false});return Ha.map((St,Mn)=>{let An=St.date.toDateString()===Lr.toDateString(),Fr=(ne?typeof ne=="string"?new Date(ne):ne:null)?.toDateString()===St.date.toDateString();return jsx("button",{type:"button",className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",style:{color:St.isCurrentMonth?Fr?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Fr?"#3B82F6":"transparent",boxShadow:An&&!Fr?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{u?.(Z.id,{[z]:St.date}),de(null);},children:St.day},Mn)})})()})]})]})]}),document.body)]});case "duration":return jsx("div",{className:"flex items-center justify-center w-full",children:jsx("span",{className:"text-xs tabular-nums",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:600},children:Q(Z)})});case "assignees":let aa=r.filter(pe=>Z.assignees?.some(Nt=>Nt.name===pe.name||Nt.initials===pe.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(fr,{assignedUsers:aa,availableUsers:r,onChange:pe=>{let Nt=pe.map(Jt=>({id:Jt.id,name:Jt.name,initials:Jt.initials,color:Jt.color}));u?.(Z.id,{assignees:Nt.length>0?Nt:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(gl,{status:Z.status||"todo",onChange:pe=>{u?.(Z.id,{status:pe,progress:pe==="completed"?100:Z.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:`${Z.progress}%`,backgroundColor:Z.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:[Z.progress,"%"]})]});case "priority":let dr={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},qa={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},Ra=dr[Z.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(ur,{priority:Ra,onChange:pe=>{pe&&u?.(Z.id,{priority:qa[pe]||"medium"});}})});default:return null}},Fe=V=>[{id:"hide",label:"Hide Column",icon:Ct.Hide,onClick:()=>d(V),disabled:V==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Ct.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Ct.SortDesc,onClick:()=>{}}],Me=V=>V.subtasks&&V.subtasks.length>0?[{id:"addSubtask",label:B?.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{D?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:B?.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{A?A(V.id,V.name):k?.([V.id]);}}]:[{id:"edit",label:B?.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{l?.(V);}},{id:"addSubtask",label:B?.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{D?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:B?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{u?.(V.id,{status:"todo",progress:0});},disabled:V.status==="todo"},{id:"setInProgress",label:B?.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{u?.(V.id,{status:"in-progress"});},disabled:V.status==="in-progress"},{id:"markComplete",label:B?.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{u?.(V.id,{status:"completed",progress:100});},disabled:V.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:B?.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:B?.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{A?A(V.id,V.name):k?.([V.id]);}}],Re=m.filter(V=>V.visible),Mt=Re.reduce((V,Z)=>V+Z.width,0)+60;return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:Mt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${yt}px`,paddingLeft:"3px",paddingRight:"60px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box",position:"relative"},children:[jsxs("div",{className:"flex items-center gap-1 px-2 flex-shrink-0",style:{height:"100%",position:"absolute",right:0,top:0,zIndex:5,backgroundColor:t.bgGrid},children:[jsx(qo,{columns:m,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ee(!Ce),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Ce&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:V=>V.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:()=>Ee(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"})]})]})]})]})]})]}),Re.map((V,Z)=>{let nt=Z===Re.length-1,fe=V.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${fe?"":"justify-center"}`,style:{width:`${V.width}px`,minWidth:`${V.minWidth??(fe?200:60)}px`,maxWidth:`${V.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:nt?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:Ue=>{Ue.preventDefault(),K({isOpen:true,x:Ue.clientX,y:Ue.clientY,type:"header",columnId:V.id});},onMouseEnter:Ue=>{Ue.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:Ue=>{Ue.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:V.label,children:V.label}),V.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:xe===V.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:Ue=>{Ue.preventDefault(),Ue.stopPropagation(),Ae(V.id),$(Ue.clientX),W(V.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"}})})]},V.id)})]}),jsx("div",{className:"gantt-taskgrid-content",children:We.map(({task:V,level:Z},nt)=>{let fe=I(V.id),Ue=De===V.id,Je=Ue&&$e==="above",z=Ue&&$e==="below",ne=Ue&&$e==="child",Ge={};return ne&&(Ge.backgroundColor=`${t.accent}15`,Ge.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":V.id,className:`flex items-center cursor-pointer group ${X===V.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:fe?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:fe?t.accentLight:ne?`${t.accent}15`:nt%2===0?t.bgPrimary:t.bgGrid,...Ge},onMouseEnter:()=>w(V.id),onMouseLeave:()=>w(null),onClick:Ke=>{let dr=Yr(e).map(pe=>pe.id),Ra=navigator.platform.toUpperCase().indexOf("MAC")>=0?Ke.metaKey:Ke.ctrlKey;Ie(V.id,dr,Ra,Ke.shiftKey),s?.(V);},onDoubleClick:Ke=>{Ke.stopPropagation(),l?.(V);},onContextMenu:Ke=>{Ke.preventDefault(),K({isOpen:true,x:Ke.clientX,y:Ke.clientY,type:"task",task:V}),c?.(V,Ke);},whileHover:{backgroundColor:fe?t.accentLight:t.hoverBg},children:[Je&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),z&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Re.map((Ke,aa)=>{let dr=aa===Re.length-1,qa=Ke.id==="name";return jsx("div",{className:`px-4 flex items-center ${qa?"justify-start":"justify-center"}`,style:{width:`${Ke.width}px`,minWidth:`${Ke.minWidth??(qa?200:60)}px`,maxWidth:`${Ke.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:dr?"none":`1px solid ${T===V.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:ie(Ke,V,qa?Z:0)},`${V.id}-${Ke.id}`)})]},V.id)})}),jsx(Kr,{isOpen:E.isOpen,x:E.x,y:E.y,items:E.type==="header"&&E.columnId?Fe(E.columnId):E.type==="task"&&E.task?Me(E.task):[],onClose:()=>K({...E,isOpen:false}),theme:t}),dt&&ht&&X&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ht.x+12,top:ht.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let V=We.find(Z=>Z.task.id===X)?.task;return V?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:V.name})}):null})()}),document.body)]})}function Cd(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[l,c]=useState(e),[p,n]=useState(t),[m,d]=useState(null),[i,u]=useState(null),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(0),[y,D]=useState(0),[N,A]=useState(null),[v,B]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:l,setGhostX:c,ghostWidth:p,setGhostWidth:n,connectionLine:m,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:u,activeZone:x,setActiveZone:f,draggedSegmentIndex:g,setDraggedSegmentIndex:k,draggedSegmentStartX:h,setDraggedSegmentStartX:b,segmentDragOffsetX:y,setSegmentDragOffsetX:D,hoveredSegmentIndex:N,setHoveredSegmentIndex:A,isHovered:v,setIsHovered:B,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(H,q)=>{r("none"),d(null),u(null),c(H),n(q),D(0),k(null),b(0);}}}function Qo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:l,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:x,onHoverChange:f}){let g=Cd(t,r),k=useRef(null),{dragMode:h,setDragMode:b,dragOffset:y,setDragOffset:D,ghostX:N,setGhostX:A,ghostWidth:v,setGhostWidth:B,connectionLine:T,setConnectionLine:w,hoveredTaskId:R,setHoveredTaskId:P,activeZone:H,setActiveZone:q,draggedSegmentIndex:he,setDraggedSegmentIndex:xe,draggedSegmentStartX:Ae,setDraggedSegmentStartX:Be,segmentDragOffsetX:$,setSegmentDragOffsetX:F,hoveredSegmentIndex:W,setHoveredSegmentIndex:E,isHovered:K,setIsHovered:X,isDragging:U,isResizing:De,isConnecting:ke,resetDragState:$e}=g,be=32,tt=8,Pe=e.endDate&&e.endDate<new Date&&e.progress<100,et=e.isCriticalPath,ht=o.name==="neutral"||o.today==="#1C1917",Dt=e.status==="completed"||e.progress===100,dt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},re=e.isCriticalPath||Pe?"#DC2626":e.color?e.color:e.priority&&dt[e.priority]?dt[e.priority]:o.taskBarPrimary,Ce=(oe=>oe>=80?20:oe>=60?15:oe>=50?12:10)(r),Ee=r<50,at=r<40;useEffect(()=>{if(f)if(K&&!U&&!e.segments){let oe=a<100;f({task:e,x:t,y:a,width:r,height:be,showBelow:oe});}else f(null);},[K,U,e,t,a,r,be,f]);let ut=oe=>oe.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Ie=()=>{let oe=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${oe} day${oe!==1?"s":""}`},I=oe=>Math.round(oe/s)*s,Y=oe=>{let Se=Math.round(oe/s),ye=new Date(l);return ye.setDate(ye.getDate()+Se),ye},He=(oe,Se)=>{for(let ye of u){if(ye.id===e.id)continue;let Ne=5;if(oe>=ye.x-Ne&&oe<=ye.x+ye.width+Ne&&Se>=ye.y-Ne&&Se<=ye.y+ye.height+Ne)return ye.id}return null},We=useCallback((oe,Se,ye)=>{oe.preventDefault(),oe.stopPropagation();let Ne=k.current?.ownerSVGElement;if(!Ne)return;let ie=Ne.createSVGPoint();ie.x=oe.clientX,ie.y=oe.clientY;let Fe=ie.matrixTransform(Ne.getScreenCTM()?.inverse()),Me=ye!==void 0?ye:t,Re=Se;if(!Re){let Mt=Fe.x-Me;oe.shiftKey?(Re="connect",w({x:t+r,y:a+be/2})):oe.ctrlKey||oe.metaKey?Re="move":oe.altKey?Re=Mt<r/2?"resize-start":"resize-end":at?Mt<r/2?Re="move":Re="resize-end":Ee?Mt<=Ce/2?Re="resize-start":Mt>=r-Ce/2?Re="resize-end":Re="move":Mt<=Ce?Re="resize-start":Mt>=r-Ce?Re="resize-end":Re="move";}b(Re),X(false),q(null),Re==="move"?D(Fe.x-Me):Re==="connect"?w({x:t+r,y:a+be/2}):D(0),A(Me),B(r);},[t,r,a,be]),yt=useCallback(oe=>{if(h==="none")return;let Se=k.current?.ownerSVGElement;if(!Se)return;let ye=Se.createSVGPoint();ye.x=oe.clientX,ye.y=oe.clientY;let Ne=ye.matrixTransform(Se.getScreenCTM()?.inverse());if(h==="connect"){w({x:Ne.x,y:Ne.y});let ie=He(Ne.x,Ne.y);P(ie);}else if(h==="move"){let ie=Ne.x-y,Fe=I(ie);A(Fe),B(r);let Me=Math.round((Fe-t)/s);if(x?.(e.id,Me,true),e.segments&&e.segments.length>0&&he!==null){let Re=Fe-Ae;F(Re);}}else if(h==="resize-start"){let ie=Ne.x,Fe=I(ie),Me=t+r-Fe;Me>=s&&(A(Fe),B(Me));}else if(h==="resize-end"){let ie=Ne.x,Me=I(ie)-t;Me>=s&&B(Me);}},[h,t,r,s,y,e,I,he,Ae,He,P,w,A,B,F,x]),Q=useCallback(()=>{if(h!=="none"){if(h==="connect")R&&i&&i(e,R),w(null),P(null);else {let oe=e.endDate.getTime()-e.startDate.getTime(),Se,ye,Ne=true;if(h==="move"){if(Se=Y(N),ye=new Date(Se.getTime()+oe),e.segments&&e.segments.length>0&&he!==null){let ie=Math.round($/s),Fe=e.segments.map((V,Z)=>{if(Z===he){let nt=new Date(V.startDate),fe=new Date(V.endDate);return nt.setDate(nt.getDate()+ie),fe.setDate(fe.getDate()+ie),{startDate:nt,endDate:fe}}return V}),Me=Fe.flatMap(V=>[V.startDate,V.endDate]),Re=new Date(Math.min(...Me.map(V=>V.getTime()))),Mt=new Date(Math.max(...Me.map(V=>V.getTime())));d?.({...e,segments:Fe},Re,Mt),$e(t,r);return}}else h==="resize-start"?(Se=Y(N),ye=e.endDate,Se>ye&&(console.warn("Invalid date range: start date must be before or equal to end date"),Ne=false)):h==="resize-end"?(Se=e.startDate,ye=Y(N+v),ye<Se&&(console.warn("Invalid date range: end date must be after or equal to start date"),Ne=false)):Ne=false;Ne&&Se&&ye&&(ye.getTime()<Se.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,Se,ye));}x?.(e.id,0,false),$e(t,r);}},[h,N,v,e,d,R,i,t,r,s,Y,$,he,$e,x]);useEffect(()=>{if(h==="none")return;let oe=ye=>{yt(ye);},Se=()=>{Q();};return window.addEventListener("mousemove",oe),window.addEventListener("mouseup",Se),()=>{window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",Se);}},[h,yt,Q]);let te=U&&!ke?N:t,ve=U&&!ke?v:r,Te=c.taskClass(e);return jsxs("g",{ref:k,onMouseEnter:()=>!U&&X(true),onMouseLeave:()=>{U||(X(false),q(null));},onClick:()=>!U&&p?.(e),onDoubleClick:oe=>{U||(oe.stopPropagation(),n?.(e));},onContextMenu:oe=>{oe.preventDefault(),m?.(e,oe);},children:[K&&!U&&!Ee&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Ce,height:be,fill:H==="resize-start"?o.accent:"transparent",opacity:H==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-start"),onMouseDown:oe=>We(oe,"resize-start")}),jsx("rect",{x:t+Ce,y:a,width:r-Ce*2,height:be,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:oe=>We(oe,"move")}),jsx("rect",{x:t+r-Ce,y:a,width:Ce,height:be,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:oe=>We(oe,"resize-end")})]}),K&&!U&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:be,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:oe=>We(oe,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:be,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:oe=>We(oe,"resize-end")}),K&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+be-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),U&&!ke&&!e.segments&&jsx(motion.rect,{x:N,y:a,width:v,height:be,rx:tt,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:te,y:a,width:ve,height:be,rx:tt,fill:re,"data-task-class":Te,initial:{opacity:0,scale:.95},animate:{opacity:U&&!ke?.15:e.parentId?.6:K?.9:.8,scale:K&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:oe=>We(oe),style:{cursor:U?ke?"crosshair":De?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:te,y:a,width:ve*(e.progress/100),height:be,rx:tt,fill:re,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((oe,Se)=>{let ye=(oe.startDate.getTime()-l.getTime())/864e5*s,ie=(oe.endDate.getTime()-l.getTime())/(1e3*60*60*24)*s-ye+s,Fe=U&&h==="move"&&he===Se,Me=W===Se,Re=Fe?ye+$:ye;return jsxs("g",{onMouseEnter:()=>!U&&E(Se),onMouseLeave:()=>!U&&E(null),children:[jsx(motion.rect,{x:Re,y:a,width:ie,height:be,rx:tt,fill:re,initial:{opacity:0,scale:.95},animate:{opacity:Fe||e.parentId?.6:Me?.9:.8,scale:Me&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:Mt=>{Mt.stopPropagation(),xe(Se),Be(ye),We(Mt,void 0,ye);},style:{cursor:U?ke?"crosshair":De?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Re,y:a,width:ie*(e.progress/100),height:be,rx:tt,fill:re,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Se}`)}),ht&&(Pe||et)&&!e.segments&&jsxs(Fragment,{children:[et&&!Pe&&jsx("rect",{x:te,y:a,width:ve,height:be,rx:tt,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Pe&&jsx("rect",{x:te,y:a,width:ve,height:be,rx:tt,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ve>60&&!e.segments&&(()=>{let oe=c.taskLabel(e),Se=typeof oe=="string"?oe:e.name,ye=Se.length>Math.floor(ve/8)?`${Se.substring(0,Math.floor(ve/8))}...`:Se;return jsx("text",{x:te+12,y:a+be/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:ye})})(),ve>100&&e.progress>0&&e.progress<100&&!U&&!e.segments&&jsxs("text",{x:te+ve-12,y:a+be/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&&!U&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:te+ve-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:te+ve-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(K||De)&&!ke&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ee?te-15:te-10,y:a-5,width:Ee?25:20,height:be+10,fill:"transparent",onMouseDown:oe=>We(oe,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te-8:te-3,y:a+6,width:Ee?8:6,height:Ee?be-12:be-16,rx:3,fill:h==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="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:te+ve-10,y:a-5,width:Ee?25:20,height:be+10,fill:"transparent",onMouseDown:oe=>We(oe,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te+ve:te+ve-3,y:a+6,width:Ee?8:6,height:Ee?be-12:be-16,rx:3,fill:h==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:K&&!U&&!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+be/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:oe=>{oe.stopPropagation(),We(oe,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+be/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ke&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+be/2,x2:T.x,y2:T.y,stroke:R?o.statusCompleted:o.accent,strokeWidth:R?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:R?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:R?8:6,fill:R?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),R&&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"})]}),(K||U)&&!ke&&!e.segments&&jsx(motion.rect,{x:te-2,y:a-2,width:ve+4,height:be+4,rx:tt+2,fill:"none",stroke:U?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:U?.6:.4,initial:{opacity:0},animate:{opacity:U?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),De&&jsxs(Fragment,{children:[jsx("line",{x1:N,y1:0,x2:N,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:N+v,y1:0,x2:N+v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:K&&!U&&!e.segments&&!f&&(()=>{let ye=a<100,Ne=ye?a+be+13:a-82-13,ie=ye?`M ${te+ve/2-6} ${a+be+3} L ${te+ve/2} ${a+be+13} L ${te+ve/2+6} ${a+be+3}`:`M ${te+ve/2-6} ${a-13} L ${te+ve/2} ${a-3} L ${te+ve/2+6} ${a-13}`,Fe=Ne+22,Me=Ne+40,Re=Ne+55,Mt=Ne+70,V=ye?Ne+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:ye?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:ye?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:ie,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:te+ve/2-120,y:Ne,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:te+ve/2,y:Fe,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:te+ve/2-110,y:Me,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:te+ve/2-70,y:Me,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ut(e.startDate)}),jsx("text",{x:te+ve/2-110,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:te+ve/2-70,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ut(e.endDate)}),jsx("text",{x:te+ve/2+10,y:Me,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:te+ve/2+65,y:Me,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ie()}),jsx("text",{x:te+ve/2+10,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:te+ve/2+65,y:Re,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:te+ve/2-110,y:Mt,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:te+ve/2-50,y:Mt,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(Z=>Z.name).join(", ").substring(0,30),e.assignees.map(Z=>Z.name).join(", ").length>30?"...":""]})]}),!ye&&jsx("text",{x:te+ve/2,y:V,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":Ee?"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 Nd({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:l,showBelow:c}=e,p=82,n=13,m=c?o+l+n:o-p-n,d=c?`M ${r+s/2-6} ${o+l+3} L ${r+s/2} ${o+l+13} L ${r+s/2+6} ${o+l+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=m+22,u=m+40,x=m+55,f=m+70,g=y=>y.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),k=()=>{if(!a.startDate||!a.endDate)return "N/A";let y=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${y} day${y!==1?"s":""}`};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,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:m,width:240,height:p,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?g(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:x,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?g(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:k()}),jsx("text",{x:r+s/2+10,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:x,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(y=>y.name).join(", ").substring(0,30),a.assignees.map(y=>y.name).join(", ").length>30?"...":""]})]})]})})}function an({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:l}){let[c,p]=useState(false),n=a-e,m=r-t,d=e+n/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,u=6,x=Math.atan2(m,n),f=a-u*Math.cos(x-Math.PI/6),g=r-u*Math.sin(x-Math.PI/6),k=a-u*Math.cos(x+Math.PI/6),h=r-u*Math.sin(x+Math.PI/6),b=o.dependency;useEffect(()=>{l&&s&&l(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,l]);let y=!s&&!l;return jsxs("g",{onMouseEnter:()=>!y&&p(true),onMouseLeave:()=>!y&&p(false),style:{pointerEvents:y?"none":"auto"},children:[!y&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&l?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${g} M ${a} ${r} L ${k} ${h}`,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&l?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:b,initial:{scale:0},animate:{scale:c&&l?0:c?1.3:1,opacity:c&&l?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!l&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:D=>{D.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function on({task:e,x:t,y:a,theme:r,onClick:o}){let[s,l]=useState(false),c=16,p=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>l(true),onMouseLeave:()=>l(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:p(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 le={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(m=>{m.dependencies&&r.set(m.id,m.dependencies),m.subtasks&&o(m.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let l=new Set,c=new Set,p=n=>{if(!l.has(n)){l.add(n),c.add(n);let m=r.get(n)||[];for(let d of m){if(!l.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(n),false};return p(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=le.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=le.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=le.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=le.flattenTasks(e),r=[["ID","Name","Start Date","End Date","Progress","Status","Dependencies"].join(",")];return t.forEach(o=>{let s=[o.id,`"${o.name.replace(/"/g,'""')}"`,o.startDate?o.startDate.toISOString().split("T")[0]:"",o.endDate?o.endDate.toISOString().split("T")[0]:"",o.progress.toString(),o.status||"",o.dependencies?.join(";")||""];r.push(s.join(","));}),r.join(`
111
+ - [ ] `,priority:"MEDIUM",labels:["meeting"]}}];function fs({templates:e,onSelectTemplate:t,className:a}){let[r,o]=useState(false),s=useRef(null),l=useRef(null);useEffect(()=>{function n(m){s.current&&!s.current.contains(m.target)&&l.current&&!l.current.contains(m.target)&&o(false);}if(r)return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=n=>{t(n),o(false);},p=e.reduce((n,m)=>{let d=m.category||"Other";return n[d]||(n[d]=[]),n[d].push(m),n},{});return jsxs("div",{className:C("relative inline-block",a),children:[jsxs("button",{ref:l,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:C("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(p).map(([n,m])=>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:m.map(d=>jsxs("button",{onClick:()=>c(d),className:"w-full px-4 py-3 flex items-start gap-3 text-left transition-all active:scale-[0.98]",style:{color:"var(--theme-text-primary)"},onMouseEnter: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:d.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"font-semibold text-sm",style:{color:"var(--theme-text-primary)"},children:d.name}),d.description&&jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--theme-text-tertiary)"},children:d.description})]})]},d.id))})]},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 bs({board:e,isOpen:t,onClose:a,onImport:r,boardElementRef:o,className:s}){let[l,c]=useState("export"),[p,n]=useState("json"),[m,d]=useState(null),i=useRef(null);if(!t)return null;let u=async()=>{let f=o?.current||void 0,g=await Vi(e,p,f);ji(g,p);},x=async f=>{let g=f.target.files?.[0];if(g){try{let k=await qi(g),h=g.name.endsWith(".json")?"json":"csv",b=Yi(k,h);d(b),b.success&&r&&r(b,k);}catch(k){d({success:false,errors:[`Failed to read file: ${k instanceof Error?k.message:"Unknown error"}`]});}i.current&&(i.current.value="");}};return jsxs("div",{className:C("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:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="export"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Export"}),jsx("button",{onClick:()=>c("import"),className:C("flex-1 px-6 py-4 font-semibold transition-colors",l==="import"?"text-white border-b-2 border-blue-500":"text-white/50 hover:text-white/80"),children:"Import"})]}),jsxs("div",{className:"p-6",children:[l==="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:C("p-4 rounded-lg border-2 transition-all text-center",p===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"})]}),l==="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:x,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"})]})]}),m&&jsxs("div",{className:C("p-4 rounded-lg",m.success?"bg-green-500/20 border border-green-500/30":"bg-red-500/20 border border-red-500/30"),children:[jsx("h3",{className:C("font-semibold mb-2",m.success?"text-green-400":"text-red-400"),children:m.success?"\u2713 Import Successful":"\u2717 Import Failed"}),m.success&&jsxs("div",{className:"text-sm text-white/80",children:[jsxs("div",{children:["Cards imported: ",m.cardsImported]}),jsxs("div",{children:["Columns imported: ",m.columnsImported]})]}),m.errors&&m.errors.length>0&&jsx("div",{className:"mt-2 text-sm",children:m.errors.map((f,g)=>jsxs("div",{className:"text-red-300",children:["\u2022 ",f]},g))})]})]})]})]})]})}var Nu=["URGENT","HIGH","MEDIUM","LOW"],Su=[{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"}],Eu=[{value:"none",label:"No Grouping"},{value:"priority",label:"By Priority"},{value:"assignee",label:"By Assignee"},{value:"label",label:"By Label"}];function ys({filters:e,sort:t,onFiltersChange:a,onSortChange:r,onReset:o,onFilterMyTasks:s,onFilterOverdue:l,onFilterHighPriority:c,availableUsers:p=[],availableLabels:n=[],availableColumns:m=[],showQuickFilters:d=true,compact:i=false,groupBy:u="none",onGroupByChange:x}){let[f,g]=useState(true),k=useCallback(N=>{a({search:N.target.value});},[a]),h=useCallback(N=>{a({dateFilter:N.target.value});},[a]),b=useCallback(N=>{r({by:N.target.value});},[r]),y=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:()=>g(!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:N=>{N.currentTarget.style.backgroundColor="var(--theme-bg-tertiary)";},onMouseLeave:N=>{N.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:[d&&jsxs("div",{className:"filter-bar__quick",style:{marginBottom:"12px"},children:[jsx("span",{className:"filter-bar__label",children:"Quick:"}),s&&jsx("button",{onClick:s,className:"filter-bar__quick-btn",title:"Show only my tasks",children:"My Tasks"}),l&&jsx("button",{onClick:l,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:k,className:"filter-bar__search"})}),jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.dateFilter,onChange:h,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:N=>{let A=N.target.value;a({priorities:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Priorities"}),Nu.map(N=>jsx("option",{value:N,children:N},N))]})}),p.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.assignees[0]||"all",onChange:N=>{let A=N.target.value;a({assignees:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Assignees"}),p.map(N=>jsx("option",{value:N.id,children:N.name},N.id))]})}),n.length>0&&jsx("div",{className:"filter-bar__field",children:jsxs("select",{value:e.labels[0]||"all",onChange:N=>{let A=N.target.value;a({labels:A==="all"?[]:[A]});},className:"filter-bar__select",children:[jsx("option",{value:"all",children:"All Labels"}),n.map(N=>jsx("option",{value:N,children:N},N))]})}),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:b,className:"filter-bar__select filter-bar__select--sm",children:Su.map(N=>jsx("option",{value:N.value,children:N.label},N.value))}),t.by!=="none"&&jsx("button",{onClick:y,className:"filter-bar__sort-toggle",title:`Sort ${t.order==="asc"?"descending":"ascending"}`,children:t.order==="asc"?"\u2191":"\u2193"})]}),x&&jsx("div",{className:"filter-bar__field",children:jsx("select",{value:u,onChange:N=>x(N.target.value),className:"filter-bar__select",style:{fontWeight:500,borderWidth:"2px"},children:Eu.map(N=>jsx("option",{value:N.value,children:N.label},N.value))})}),D&&jsx("button",{onClick:o,className:"filter-bar__reset",title:"Clear all filters",children:"Clear"})]})]})]})}function vs({onOpenExport:e,onOpenThemes:t,onOpenShortcuts:a,className:r,viewMode:o="kanban",onExportGanttPDF:s,onExportGanttExcel:l,onExportGanttPNG:c,onExportGanttCSV:p}){let[n,m]=useState(false),d=useRef(null);useEffect(()=>{let u=x=>{d.current&&!d.current.contains(x.target)&&m(false);};return n&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u);}},[n]);let i=u=>{u(),m(false);};return jsxs("div",{className:C("relative",r),ref:d,children:[jsxs("button",{onClick:()=>m(!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 l?.()),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(()=>p?.()),className:"w-full px-4 py-3 text-left text-sm font-medium transition-colors flex items-center gap-3",style:{color:"var(--theme-text-primary)"},onMouseEnter: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 xs={name:"dark",displayName:"Dark (Enhanced)",emoji:"\u{1F319}",colors:{bgPrimary:"#222326",bgSecondary:"#2A2B2F",bgTertiary:"#33343A",bgCard:"#2d2d2d",bgHover:"#353535",bgActive:"#404040",bgInput:"#2a2a2a",textPrimary:"#F4F5F8",textSecondary:"#AEB6C0",textTertiary:"#7A7F8A",textDisabled:"#606060",textInverse:"#1a1a1a",borderPrimary:"rgba(255, 255, 255, 0.1)",borderSecondary:"rgba(255, 255, 255, 0.05)",borderDefault:"#404040",borderHover:"#505050",borderSubtle:"#2a2a2a",accentPrimary:"#5E6AD2",accentHover:"#7780DD",interactivePrimary:"#0ea5e9",interactivePrimaryHover:"#0284c7",interactivePrimaryBorder:"rgba(14, 165, 233, 0.3)",interactivePrimaryBackground:"rgba(14, 165, 233, 0.1)",interactivePrimaryBackgroundHover:"rgba(14, 165, 233, 0.2)",success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6",danger:"#ef4444",dangerBorder:"rgba(239, 68, 68, 0.3)",dangerBackground:"rgba(239, 68, 68, 0.1)",dangerBackgroundHover:"rgba(239, 68, 68, 0.2)"},shadows:{sm:"0 1px 2px rgba(0, 0, 0, 0.3)",md:"0 4px 12px rgba(0, 0, 0, 0.4)",lg:"0 12px 32px rgba(0, 0, 0, 0.5)"},radii:{sm:"6px",md:"8px",lg:"12px",full:"9999px"},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px"}},ks={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"}},ws={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"}},xr={dark:xs,light:ks,neutral:ws},Vo="dark";var jo=createContext(void 0),zu="asakaa-theme";function Jl({children:e,defaultTheme:t=Vo,storageKey:a=zu}){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,p=xr[r];Object.entries(p.colors).forEach(([m,d])=>{d&&c.style.setProperty(`--theme-${$u(m)}`,d);}),Object.entries({bgPrimary:"--asakaa-color-background-primary",bgSecondary:"--asakaa-color-background-secondary",bgTertiary:"--asakaa-color-background-tertiary",bgCard:"--asakaa-color-background-card",bgHover:"--asakaa-color-background-hover",bgActive:"--asakaa-color-background-active",bgInput:"--asakaa-color-background-input",textPrimary:"--asakaa-color-text-primary",textSecondary:"--asakaa-color-text-secondary",textTertiary:"--asakaa-color-text-tertiary",textDisabled:"--asakaa-color-text-disabled",textInverse:"--asakaa-color-text-inverse",borderPrimary:"--asakaa-color-border-primary",borderSecondary:"--asakaa-color-border-secondary",borderDefault:"--asakaa-color-border-default",borderHover:"--asakaa-color-border-hover",borderSubtle:"--asakaa-color-border-subtle",accentPrimary:"--asakaa-color-accent-primary",accentHover:"--asakaa-color-accent-hover",interactivePrimary:"--asakaa-color-interactive-primary",interactivePrimaryHover:"--asakaa-color-interactive-primaryHover",interactivePrimaryBorder:"--asakaa-color-interactive-primaryBorder",interactivePrimaryBackground:"--asakaa-color-interactive-primaryBackground",interactivePrimaryBackgroundHover:"--asakaa-color-interactive-primaryBackgroundHover",success:"--asakaa-color-status-success",warning:"--asakaa-color-status-warning",error:"--asakaa-color-status-error",info:"--asakaa-color-status-info",danger:"--asakaa-color-danger",dangerBorder:"--asakaa-color-danger-border",dangerBackground:"--asakaa-color-danger-background",dangerBackgroundHover:"--asakaa-color-danger-backgroundHover"}).forEach(([m,d])=>{let i=p.colors[m];i&&c.style.setProperty(d,i);}),c.setAttribute("data-theme",r),c.classList.remove("theme-dark","theme-light","theme-neutral"),c.classList.add(`theme-${r}`);},[r]);let l={theme:r,setTheme:s,themes:xr};return jsx(jo.Provider,{value:l,children:e})}function _r(){let e=useContext(jo);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}function $u(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Cs({isOpen:e,onClose:t,className:a}){let{theme:r,setTheme:o}=_r();return e?jsxs("div",{className:C("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(xr).map(([s,l])=>jsxs("button",{onClick:()=>{o(s),t();},className:C("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:l.emoji}),jsxs("div",{className:"text-left flex-1",children:[jsx("div",{className:"font-semibold",style:{color:"var(--theme-text-primary)"},children:l.displayName}),jsxs("div",{className:"text-xs",style:{color:"var(--theme-text-secondary)"},children:[s==="dark"&&"Default dark theme with Linear-inspired colors",s==="light"&&"Clean light theme with high contrast",s==="neutral"&&"Monochrome zen theme"]})]}),r===s&&jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:jsx("path",{d:"M20 6L9 17l-5-5"})})]},s))})]})]}):null}function Zl(e="dark"){if(typeof window>"u"||typeof getComputedStyle>"u")return _e[e]||_e.dark;let t=document.documentElement,a=getComputedStyle(t),r=(s,l)=>a.getPropertyValue(s).trim()||l;return {bgPrimary:r("--theme-bg-primary",_e[e].bgPrimary),bgSecondary:r("--theme-bg-secondary",_e[e].bgSecondary),bgGrid:r("--theme-bg-card",_e[e].bgGrid),bgWeekend:r("--theme-bg-hover",_e[e].bgWeekend),border:r("--theme-border-primary",_e[e].border),borderLight:r("--theme-border-subtle",_e[e].borderLight),textPrimary:r("--theme-text-primary",_e[e].textPrimary),textSecondary:r("--theme-text-secondary",_e[e].textSecondary),textTertiary:r("--theme-text-tertiary",_e[e].textTertiary),accent:r("--theme-accent-primary",_e[e].accent),accentHover:r("--theme-accent-hover",_e[e].accentHover),accentLight:r("--theme-accent-primary",_e[e].accentLight),taskBarPrimary:r("--theme-accent-primary",_e[e].taskBarPrimary),taskBarProgress:r("--theme-accent-hover",_e[e].taskBarProgress),taskBarHandle:r("--theme-text-inverse",_e[e].taskBarHandle||"#FFFFFF"),dependency:r("--theme-border-secondary",_e[e].dependency),dependencyHover:r("--theme-border-secondary",_e[e].dependencyHover),criticalPath:r("--theme-error",_e[e].criticalPath),criticalPathLight:r("--theme-error",_e[e].criticalPathLight),today:e==="light"?r("--theme-accent-primary",_e[e].today):e==="neutral"?r("--theme-text-primary",_e[e].today):r("--theme-error",_e[e].today),todayLight:e==="light"?r("--theme-accent-primary",_e[e].todayLight):e==="neutral"?r("--theme-text-primary",_e[e].todayLight):r("--theme-error",_e[e].todayLight),milestone:r("--theme-warning",_e[e].milestone),milestoneLight:r("--theme-warning",_e[e].milestoneLight),statusTodo:r("--theme-text-tertiary",_e[e].statusTodo),statusInProgress:r("--theme-accent-primary",_e[e].statusInProgress),statusCompleted:r("--theme-success",_e[e].statusCompleted),hoverBg:r("--theme-bg-hover",_e[e].hoverBg),focusRing:r("--theme-accent-primary",_e[e].focusRing)}}var Ko={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"}},Ql={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"}},Ts={en:Ko,es:Ql};function ed(e){return Ts[e]||Ts.en}function Ds(e,t){let a=ed(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 jr=createContext(Ko);function mo(){return useContext(jr)}function ag({theme:e,onExportPNG:t,onExportPDF:a,onExportExcel:r,onExportCSV:o,onExportJSON:s,onExportMSProject:l}){let[c,p]=useState(false),[n,m]=useState(null),d=useRef(null),i=mo();if(useEffect(()=>{let g=k=>{d.current&&!d.current.contains(k.target)&&p(false);};return c&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[c]),!(t||a||r||o||s||l))return null;let x=[{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:l}].filter(g=>g.handler),f=async(g,k)=>{if(k){m(g);try{await k();}catch(h){console.error(`Export ${g} failed:`,h);}finally{m(null),p(false);}}};return jsxs("div",{ref:d,className:"relative",children:[jsxs(motion.button,{onClick:()=>p(!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:x.map((g,k)=>jsxs(motion.button,{onClick:()=>f(g.id,g.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:k<x.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:k*.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===g.id?jsx(motion.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:jsx(Download,{className:"w-4 h-4"})}):g.icon}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium truncate",style:{color:e.textPrimary},children:g.label}),jsx("div",{className:"text-[10px] truncate",style:{color:e.textTertiary},children:g.description})]})]},g.id))})})})]})}function rg({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 l=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:l?r.textPrimary:r.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:l?600:500,zIndex:l?2:1},whileHover:{scale:1.02},whileTap:{scale:.98},children:[l&&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:l?"#FFFFFF":r.textTertiary},children:s.icon}),jsx("span",{className:"relative z-10",style:{color:l?"#FFFFFF":r.textTertiary},children:s.label})]},s.value)})})}function og({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 ng({theme:e,value:t,onChange:a}){let[r,o]=useState(false),s=useRef(null),l=mo();useEffect(()=>{let n=m=>{s.current&&!s.current.contains(m.target)&&o(false);};return r&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[r]);let c=[{value:"compact",label:l.toolbar.compact||"Compact"},{value:"comfortable",label:l.toolbar.normal||"Normal"},{value:"spacious",label:l.toolbar.spacious||"Spacious"}],p=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:`${l.toolbar.density||"Density"}: ${p}`,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,m)=>{let d=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:d?e.accentLight:"transparent",borderBottom:m<c.length-1?`1px solid ${e.borderLight}`:"none"},whileHover:{backgroundColor:d?e.accentLight:e.hoverBg},initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:m*.03},children:[jsx("span",{className:"text-xs",style:{color:d?e.accent:e.textPrimary,fontFamily:"Inter, sans-serif",fontWeight:d?600:500},children:n.label}),d&&jsx(Check,{className:"w-3.5 h-3.5",style:{color:e.accent}})]},n.value)})})})})]})}function Yo({theme:e,timeScale:t,onTimeScaleChange:a,zoom:r,onZoomChange:o,currentTheme:s,onThemeChange:l,rowDensity:c,onRowDensityChange:p,showThemeSelector:n=false,showCreateTaskButton:m=false,createTaskLabel:d,onCreateTask:i,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}){let b=mo(),y=u||x||f||g||k||h,D=[{value:"day",label:b.toolbar.day},{value:"week",label:b.toolbar.week},{value:"month",label:b.toolbar.month}],N=[{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(og,{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(ng,{theme:e,value:c,onChange:p})]}),jsxs("div",{className:"flex items-center gap-3",children:[m&&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:d||b.toolbar.createTask})]}),(y||n)&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),y&&jsxs(Fragment,{children:[jsx(ag,{theme:e,onExportPNG:u,onExportPDF:x,onExportExcel:f,onExportCSV:g,onExportJSON:k,onExportMSProject:h}),n&&jsx("div",{className:"w-px h-6",style:{backgroundColor:e.borderLight}})]}),n&&jsx(rg,{options:N,value:s,onChange:A=>l(A),theme:e})]})]})}function qo({columns:e,onToggleColumn:t,theme:a}){let[r,o]=useState(false),[s,l]=useState({x:0,y:0}),c=useRef(null),p=useRef(null);useEffect(()=>{if(!r)return;let m=d=>{c.current&&!c.current.contains(d.target)&&o(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);let n=e.filter(m=>m.id!=="name");return jsxs(Fragment,{children:[jsx(motion.button,{ref:p,onClick:()=>{if(!r&&p.current){let m=p.current.getBoundingClientRect();l({x:m.left,y:m.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(rt,{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(m=>jsxs("button",{onClick:()=>{t(m.id);},className:"w-full px-3 py-2 text-left flex items-center justify-between transition-colors text-sm",style:{color:a.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=a.hoverBg;},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{children:m.label}),m.visible&&jsx(Check,{className:"w-4 h-4",style:{color:a.accent}})]},m.id))]})})})})]})}function Kr({isOpen:e,x:t,y:a,items:r,onClose:o,theme:s}){let l=useRef(null),[c,p]=useState({x:t,y:a});if(useEffect(()=>{if(!e)return;let m=200,d=r.length*36+8,i=8,u=window.innerWidth,x=window.innerHeight,f=t,g=a;t+m+i>u&&(f=t-m,f<i&&(f=i)),a+d+i>x&&(g=x-d-i,g<i&&(g=i)),p({x:f,y:g});},[e,t,a,r.length]),useEffect(()=>{if(!e)return;let m=i=>{l.current&&!l.current.contains(i.target)&&o();},d=i=>{i.key==="Escape"&&o();};return document.addEventListener("mousedown",m),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",d);}},[e,o]),!e)return null;let n=m=>m.startsWith("#")&&(m.length===7||m.length===4)?m: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:l,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(m=>jsxs("div",{children:[m.separator&&jsx("div",{className:"my-1 h-px",style:{backgroundColor:s.borderLight}}),jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),o());},disabled:m.disabled,className:"w-full px-3 py-2 text-left flex items-center gap-2 transition-colors text-sm",style:{color:m.disabled?s.textTertiary:s.textPrimary,backgroundColor:"transparent",fontFamily:"Inter, sans-serif",cursor:m.disabled?"not-allowed":"pointer",opacity:m.disabled?.5:1},onMouseEnter:d=>{m.disabled||(d.currentTarget.style.backgroundColor=s.hoverBg);},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent";},children:[m.icon&&jsx("span",{style:{color:s.textSecondary},children:m.icon}),jsx("span",{className:"flex-1",children:m.label}),m.submenu&&jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:s.textTertiary}})]})]},m.id))})})})}var Ct={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 ud({tasks:e,selectedTaskIds:t,onTaskSelect:a,onTaskCreate:r,onTaskDelete:o,onTaskDuplicate:s,onTaskMove:l,onTaskIndent:c,onTaskOutdent:p,onTaskRename:n,onTaskToggleExpand:m,onOpenTaskModal:d,enableKeyboard:i=true}){let u=useRef(false),x=useCallback(b=>{u.current=b;},[]),f=useCallback(b=>{let y=[],D=N=>{for(let A of N)y.push(A),A.subtasks&&A.subtasks.length>0&&A.isExpanded&&D(A.subtasks);};return D(b),y},[]),g=useCallback(()=>{let b=f(e);for(let y of b)if(t.has(y.id))return y;return null},[e,t,f]),k=useCallback((b,y)=>{let D=f(e);if(D.length===0)return;let N=g();if(!N){a(D[0].id,false);return}let A=D.findIndex(T=>T.id===N.id);if(A===-1)return;let v=b==="up"?A-1:A+1;if(v<0||v>=D.length)return;let B=D[v];a(B.id,y);},[e,g,f,a]),h=useCallback(b=>{if(!i)return;let y=b.target;if(y.tagName==="INPUT"||y.tagName==="TEXTAREA"||y.isContentEditable||u.current){b.key==="Escape"&&(y.blur(),u.current=false);return}let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?b.metaKey:b.ctrlKey,v=Array.from(t),B=g();if(b.key==="ArrowUp"){b.preventDefault(),k("up",b.shiftKey);return}if(b.key==="ArrowDown"){b.preventDefault(),k("down",b.shiftKey);return}if(B&&(b.key==="ArrowRight"||b.key==="ArrowLeft")){B.subtasks&&B.subtasks.length>0&&(b.preventDefault(),(b.key==="ArrowRight"&&!B.isExpanded||b.key==="ArrowLeft"&&B.isExpanded)&&m(B.id));return}if(b.altKey&&(b.key==="ArrowUp"||b.key==="ArrowDown")){v.length>0&&(b.preventDefault(),l(v,b.key==="ArrowUp"?"up":"down"));return}if(b.key==="Tab"&&!b.shiftKey){v.length>0&&(b.preventDefault(),c(v));return}if(b.key==="Tab"&&b.shiftKey){v.length>0&&(b.preventDefault(),p(v));return}if(b.key==="Enter"&&!b.shiftKey&&!A){B&&(b.preventDefault(),r(B.id,"below"));return}if(b.key==="Enter"&&b.shiftKey&&!A){B&&(b.preventDefault(),r(B.id,"above"));return}if(b.key==="Enter"&&A){B&&(b.preventDefault(),d(B.id));return}if(b.key==="F2"){B&&(b.preventDefault(),n(B.id));return}if(b.key==="Delete"||b.key==="Backspace"&&A){v.length>0&&(b.preventDefault(),o(v));return}if(b.key==="d"&&A&&!b.shiftKey){v.length>0&&(b.preventDefault(),s(v));return}},[i,t,g,k,r,o,s,l,c,p,n,m,d]);return useEffect(()=>{if(i)return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h);}},[i,h]),{setIsEditing:x}}function fd(){let[e,t]=useState(new Set),[a,r]=useState(null),o=useCallback(d=>{t(new Set([d])),r(d);},[]),s=useCallback(d=>{t(i=>{let u=new Set(i);return u.has(d)?u.delete(d):u.add(d),u}),r(d);},[]),l=useCallback((d,i)=>{if(!a){o(d);return}let u=i.indexOf(a),x=i.indexOf(d);if(u===-1||x===-1){o(d);return}let f=Math.min(u,x),g=Math.max(u,x),k=i.slice(f,g+1);t(new Set(k)),r(d);},[a,o]),c=useCallback((d,i,u,x)=>{x?l(d,i):u?s(d):o(d);},[o,s,l]),p=useCallback((d,i)=>{i?t(u=>{let x=new Set(u);return x.add(d),x}):o(d);},[o]),n=useCallback(()=>{t(new Set),r(null);},[]),m=useCallback(d=>e.has(d),[e]);return {selectedTaskIds:e,selectTask:o,toggleTaskSelection:s,selectTaskRange:l,handleTaskClick:c,handleKeyboardSelection:p,clearSelection:n,isTaskSelected:m}}function Yr(e){let t=[],a=(r,o,s=0)=>{for(let l=0;l<r.length;l++){let c={...r[l],parentId:o,level:s,position:l};t.push(c),c.subtasks&&c.subtasks.length>0&&c.isExpanded&&a(c.subtasks,c.id,s+1);}};return a(e),t}function hd(e,t){for(let a of e){if(a.id===t)return a;if(a.subtasks){let r=hd(a.subtasks,t);if(r)return r}}return null}function Es(e,t){for(let a of e)if(a.subtasks){if(a.subtasks.some(o=>o.id===t))return a;let r=Es(a.subtasks,t);if(r)return r}return null}function Ps(e,t){if(t.length===0)return e;let a=Yr(e),r=t[0],o=a.findIndex(d=>d.id===r);if(o<=0)return e;let s=a[o-1],l=(d,i)=>{let u=[];return {tasks:d.filter(f=>{if(i.has(f.id))return u.push(f),false;if(f.subtasks){let g=l(f.subtasks,i);f.subtasks=g.tasks,u.push(...g.removed);}return true}),removed:u}},c=(d,i,u)=>d.map(x=>x.id===i?{...x,subtasks:[...x.subtasks||[],...u],isExpanded:true}:x.subtasks?{...x,subtasks:c(x.subtasks,i,u)}:x),p=new Set(t),{tasks:n,removed:m}=l(e,p);return c(n,s.id,m)}function Ms(e,t){if(t.length===0)return e;let a=[...e];for(let r of t){let o=Es(a,r);if(!o)continue;let s=Es(a,o.id),l=(n,m,d)=>{for(let i=0;i<n.length;i++){let u=n[i];if(u.id===m&&u.subtasks){let x=u.subtasks.findIndex(f=>f.id===d);if(x!==-1){let[f]=u.subtasks.splice(x,1);return f}}if(u.subtasks){let x=l(u.subtasks,m,d);if(x)return x}}return null},c=(n,m,d)=>{let i=n.findIndex(u=>u.id===m);if(i!==-1)return n.splice(i+1,0,d),n;for(let u of n)u.subtasks&&c(u.subtasks,m,d);return n},p=l(a,o.id,r);p&&(s&&s.subtasks?c(s.subtasks,o.id,p):c(a,o.id,p));}return a}function As(e,t,a){if(t.length===0)return e;let r=[...e],o=t[0],s=(l,c,p)=>{let n=l.findIndex(d=>d.id===c);if(n===-1){for(let d of l)if(d.subtasks&&s(d.subtasks,c,p))return true;return false}let m=p==="up"?n-1:n+1;return m<0||m>=l.length?false:([l[n],l[m]]=[l[m],l[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=l=>{let c=l.findIndex(m=>m.id===r);if(c===-1){for(let m of l)if(m.subtasks&&o(m.subtasks))return true;return false}let p=l[c],n={...p,id:`${p.id}-copy-${Date.now()}`,name:`${p.name} (Copy)`,subtasks:p.subtasks?s(p.subtasks):void 0};return l.splice(c+1,0,n),true},s=l=>l.map(c=>({...c,id:`${c.id}-copy-${Date.now()}`,subtasks:c.subtasks?s(c.subtasks):void 0}));o(a);}return a}function bd(e,t,a){let r=[...e],o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l={id:`task-${Date.now()}`,name:"New Task",progress:0,status:"todo",startDate:o,endDate:s,color:"#6366F1"},c=p=>{let n=p.findIndex(d=>d.id===t);if(n===-1){for(let d of p)if(d.subtasks&&c(d.subtasks))return true;return false}let m=a==="above"?n:n+1;return p.splice(m,0,l),true};return c(r),{tasks:r,newTask:l}}function Fs(e,t,a){return e.map(r=>r.id===t?{...r,name:a}:r.subtasks?{...r,subtasks:Fs(r.subtasks,t,a)}:r)}function Bs(e,t){return e.map(a=>a.id===t?{...a,isExpanded:!a.isExpanded}:a.subtasks?{...a,subtasks:Bs(a.subtasks,t)}:a)}function Rs(e,t){let a=m=>{for(let d of m){if(d.id===t)return d;if(d.subtasks){let i=a(d.subtasks);if(i)return i}}return null},r=a(e),o=new Date,s=new Date(o);s.setDate(s.getDate()+7);let l=r?.startDate||o,c=r?.endDate||s,p={id:`task-${Date.now()}`,name:"New Subtask",progress:0,status:"todo",startDate:new Date(l),endDate:new Date(c),color:r?.color||"#3B82F6"},n=m=>m.map(d=>{if(d.id===t){let i=d.subtasks||[];return {...d,subtasks:[...i,p],isExpanded:true}}return d.subtasks?{...d,subtasks:n(d.subtasks)}:d});return {tasks:n(e),newTask:p}}function yd(e,t,a,r){if(t===a)return e;let o=hd(e,t);if(!o)return e;if(a){let c=(p,n)=>{if(!p.subtasks)return false;for(let m of p.subtasks)if(m.id===n||c(m,n))return true;return false};if(c(o,a))return e}let s=c=>c.filter(p=>p.id!==t).map(p=>p.subtasks&&p.subtasks.length>0?{...p,subtasks:s(p.subtasks)}:p),l=s(e);if(a===null){let c=r!==void 0?r:l.length;l.splice(c,0,{...o,parentId:void 0});}else {let c=p=>p.map(n=>{if(n.id===a){let m=n.subtasks||[],d=r!==void 0?r:m.length,i=[...m];return i.splice(d,0,{...o,parentId:a}),{...n,subtasks:i,isExpanded:true}}return n.subtasks&&n.subtasks.length>0?{...n,subtasks:c(n.subtasks)}:n});l=c(l);}return l}function Zo({tasks:e,theme:t,rowHeight:a,availableUsers:r=[],templates:o,onTaskClick:s,onTaskDblClick:l,onTaskContextMenu:c,onTaskToggle:p,scrollTop:n,columns:m,onToggleColumn:d,onColumnResize:i,onTaskUpdate:u,onTaskIndent:x,onTaskOutdent:f,onTaskMove:g,onMultiTaskDelete:k,onTaskDuplicate:h,onTaskCreate:b,onTaskRename:y,onCreateSubtask:D,onOpenTaskModal:N,onDeleteRequest:A,onTaskReparent:v}){let B=useContext(jr),[T,w]=useState(null),[R,P]=useState(null),[H,q]=useState(""),he=useRef(null),[xe,Ae]=useState(null),[Be,$]=useState(0),[F,W]=useState(0),[E,K]=useState({isOpen:false,x:0,y:0,type:"header"}),[X,U]=useState(null),[De,ke]=useState(null),[$e,be]=useState(null),tt=useRef(0),Pe=5,et=useRef(false),[ht,Dt]=useState(null),[dt,O]=useState(false),[re,de]=useState(null),[Ce,Ee]=useState(false),at=useRef(null);useEffect(()=>{function V(Z){at.current&&!at.current.contains(Z.target)&&Ee(false);}if(Ce)return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[Ce]),useEffect(()=>{R&&he.current&&(he.current.focus(),he.current.select());},[R]),useEffect(()=>{if(!xe)return;let V=nt=>{let fe=nt.clientX-Be,Ue=F+fe;i?.(xe,Ue);},Z=()=>{Ae(null),document.body.style.cursor="",document.body.style.userSelect="";};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",Z),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",Z),document.body.style.cursor="",document.body.style.userSelect="";}},[xe,Be,F,i]);let{selectedTaskIds:ut,handleTaskClick:Ie,isTaskSelected:I}=fd(),{setIsEditing:Y}=ud({tasks:e,selectedTaskIds:ut,onTaskSelect:(V,Z)=>{let fe=Yr(e).map(Ue=>Ue.id);Ie(V,fe,Z||false,false);},onTaskCreate:b||(()=>{}),onTaskDelete:k||(()=>{}),onTaskDuplicate:h||(()=>{}),onTaskMove:g||(()=>{}),onTaskIndent:x||(()=>{}),onTaskOutdent:f||(()=>{}),onTaskRename:V=>{let Z=Yr(e).find(nt=>nt.id===V);Z&&te(Z);},onTaskToggleExpand:p||(()=>{}),onOpenTaskModal:V=>{let Z=Yr(e).find(nt=>nt.id===V);Z&&N&&N(Z);},enableKeyboard:true}),He=(V,Z=0)=>{let nt=[];for(let fe of V)nt.push({task:fe,level:Z}),fe.subtasks&&fe.subtasks.length>0&&fe.isExpanded&&nt.push(...He(fe.subtasks,Z+1));return nt},We=He(e),yt=48,Q=V=>!V.startDate||!V.endDate?"-":`${Math.ceil((V.endDate.getTime()-V.startDate.getTime())/(1e3*60*60*24))}d`,te=V=>{P(V.id),q(V.name),Y(true);},ve=V=>{H.trim()&&H!==e.find(Z=>Z.id===V)?.name&&y?.(V,H.trim()),P(null),q(""),Y(false);},Te=()=>{P(null),q(""),Y(false);},oe=(V,Z)=>{Z.stopPropagation(),D?.(V.id);},Se=(V,Z)=>{Z.preventDefault(),tt.current=Z.clientY,U(V),et.current=false,O(false),Dt({x:Z.clientX,y:Z.clientY});},ye=V=>{if(!X||(Math.abs(V.clientY-tt.current)>Pe&&!et.current&&(et.current=true,O(true)),Dt({x:V.clientX,y:V.clientY}),!et.current))return;let nt=document.querySelectorAll("[data-task-row]"),fe=null,Ue=null;nt.forEach(Je=>{let z=Je.getBoundingClientRect(),ne=Je.getAttribute("data-task-row");if(ne&&ne!==X&&V.clientY>=z.top&&V.clientY<=z.bottom){fe=ne;let Ge=V.clientY-z.top,Ke=z.height;Ge<Ke*.25?Ue="above":Ge>Ke*.75?Ue="below":Ue="child";}}),ke(fe),be(Ue);},Ne=()=>{if(et.current&&X&&De&&$e){if($e==="child")v?.(X,De);else if($e==="above"||$e==="below"){let V=(fe,Ue,Je=null)=>{for(let z of fe){if(z.id===Ue)return Je;if(z.subtasks){let ne=V(z.subtasks,Ue,z.id);if(ne!==void 0)return ne}}},Z=V(e,De,null),nt=(fe,Ue)=>{let Je=fe.findIndex(z=>z.id===Ue);return $e==="below"?Je+1:Je};if(Z===null){let fe=nt(e,De);v?.(X,null,fe);}else {let fe=We.find(Ue=>Ue.task.id===Z)?.task;if(fe?.subtasks){let Ue=nt(fe.subtasks,De);v?.(X,Z,Ue);}}}}U(null),ke(null),be(null),Dt(null),et.current=false,O(false);};useEffect(()=>{if(X)return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Ne),document.body.style.cursor="grabbing",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Ne),document.body.style.cursor="",document.body.style.userSelect="";}},[X,De,$e]);let ie=(V,Z,nt)=>{switch(V.id){case "name":let fe=R===Z.id,Ue=T===Z.id;return jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 relative",style:{paddingLeft:`${nt*20}px`},children:[v&&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:Ue?1:.3},onMouseDown:pe=>Se(Z.id,pe),title:"Arrastrar para mover tarea",children:jsx(GripVertical,{className:"w-4 h-4"})}),Z.subtasks&&Z.subtasks.length>0?jsx("button",{onClick:pe=>{pe.stopPropagation(),p?.(Z.id);},className:"p-0.5 hover:bg-opacity-10 rounded transition-colors flex-shrink-0",style:{color:t.textSecondary},children:Z.isExpanded?jsx(ChevronDown,{className:"w-4 h-4"}):jsx(ChevronRight,{className:"w-4 h-4"})}):jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:Z.color||"#3B82F6",opacity:Z.parentId?.6:1,borderColor:Z.isMilestone?t.accent:"transparent",borderWidth:Z.isMilestone?"2px":"0px"},title:Z.isMilestone?"Milestone":Z.parentId?"Subtask":"Task"})}),fe?jsx("input",{ref:he,type:"text",value:H,onChange:pe=>q(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"?ve(Z.id):pe.key==="Escape"&&Te();},onBlur:()=>ve(Z.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:pe=>pe.stopPropagation()}):jsxs(Fragment,{children:[jsx("span",{className:"flex-1",style:{color:Z.parentId?t.textSecondary:t.textPrimary,fontFamily:"Inter, sans-serif",fontSize:Z.parentId?"13px":"14px",fontWeight:Z.isMilestone?600:Z.parentId?400:600,letterSpacing:Z.parentId?"0":"-0.01em"},title:Z.name,children:Z.name}),Ue&&!fe&&jsxs("div",{className:"flex items-center gap-1 ml-2",onClick:pe=>pe.stopPropagation(),children:[jsx("button",{onClick:pe=>oe(Z,pe),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:pe=>{pe.stopPropagation(),te(Z);},className:"p-1 rounded hover:bg-opacity-20 transition-colors",style:{color:t.textTertiary,backgroundColor:"transparent"},title:"Rename (F2)",children:jsx(Edit3,{className:"w-3.5 h-3.5"})})]})]})]});case "startDate":case "endDate":let z=V.id==="startDate"?"startDate":"endDate",ne=Z[z],Ge=re?.taskId===Z.id&&re?.field===z,Ke=pe=>pe?(typeof pe=="string"?new Date(pe):pe).toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}):"-";return jsxs("div",{className:"flex items-center justify-center w-full relative",onClick:pe=>pe.stopPropagation(),children:[jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors hover:bg-white/5",style:{color:t.textSecondary},onClick:pe=>{if(Ge)de(null);else {let Nt=pe.currentTarget.getBoundingClientRect();de({taskId:Z.id,field:z,month:ne?typeof ne=="string"?new Date(ne):ne:new Date,position:{top:Nt.bottom+4,left:Nt.left}});}},children:[jsx(Calendar,{className:"w-3 h-3",style:{color:t.textTertiary}}),jsx("span",{children:Ke(ne)})]}),Ge&&typeof document<"u"&&createPortal(jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>de(null)}),jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"fixed z-[9999] rounded-xl shadow-2xl overflow-visible flex",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,top:re?.position.top,left:re?.position.left},onClick:pe=>pe.stopPropagation(),children:[jsxs("div",{className:"w-36 py-2",style:{borderRight:`1px solid ${t.border}`},children:[(()=>{let pe=new Date,Nt=new Date(pe);Nt.setDate(pe.getDate()+1);let Jt=new Date(pe);Jt.setDate(pe.getDate()+7);let Ar=new Date(pe);return Ar.setDate(pe.getDate()+14),[{label:"Hoy",date:pe},{label:"Ma\xF1ana",date:Nt},{label:"Pr\xF3xima semana",date:Jt},{label:"2 semanas",date:Ar}].map((Lr,Ha)=>jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:t.textPrimary},onMouseEnter:cr=>cr.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:cr=>cr.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(Z.id,{[z]:Lr.date}),de(null);},children:Lr.label},Ha))})(),jsx("div",{style:{borderTop:`1px solid ${t.border}`,margin:"0.25rem 0"}}),jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-xs text-left transition-colors",style:{color:"#EF4444"},onMouseEnter:pe=>pe.currentTarget.style.backgroundColor=t.hoverBg||"rgba(255,255,255,0.05)",onMouseLeave:pe=>pe.currentTarget.style.backgroundColor="transparent",onClick:()=>{u?.(Z.id,{[z]:void 0}),de(null);},children:"Borrar"})]}),jsxs("div",{className:"p-2",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("button",{type:"button",onClick:()=>de(pe=>pe?{...pe,month:new Date(pe.month.getFullYear(),pe.month.getMonth()-1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronLeft,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})}),jsx("span",{className:"text-xs font-medium",style:{color:t.textPrimary},children:re?.month.toLocaleDateString("es-ES",{month:"long",year:"numeric"})}),jsx("button",{type:"button",onClick:()=>de(pe=>pe?{...pe,month:new Date(pe.month.getFullYear(),pe.month.getMonth()+1)}:null),className:"p-1 rounded hover:bg-white/10",children:jsx(ChevronRight,{className:"w-3.5 h-3.5",style:{color:t.textSecondary}})})]}),jsx("div",{className:"grid grid-cols-7 gap-0.5 mb-1",children:["D","L","M","M","J","V","S"].map((pe,Nt)=>jsx("div",{className:"w-6 h-6 flex items-center justify-center text-[10px]",style:{color:t.textTertiary},children:pe},Nt))}),jsx("div",{className:"grid grid-cols-7 gap-0.5",children:(()=>{let pe=re?.month||new Date,Nt=pe.getFullYear(),Jt=pe.getMonth(),Ar=new Date(Nt,Jt,1).getDay(),Ir=new Date(Nt,Jt+1,0).getDate(),Lr=new Date,Ha=[];for(let St=Ar-1;St>=0;St--)Ha.push({day:new Date(Nt,Jt,-St).getDate(),date:new Date(Nt,Jt-1,new Date(Nt,Jt,-St).getDate()),isCurrentMonth:false});for(let St=1;St<=Ir;St++)Ha.push({day:St,date:new Date(Nt,Jt,St),isCurrentMonth:true});let cr=42-Ha.length;for(let St=1;St<=cr;St++)Ha.push({day:St,date:new Date(Nt,Jt+1,St),isCurrentMonth:false});return Ha.map((St,Mn)=>{let An=St.date.toDateString()===Lr.toDateString(),Fr=(ne?typeof ne=="string"?new Date(ne):ne:null)?.toDateString()===St.date.toDateString();return jsx("button",{type:"button",className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] transition-colors",style:{color:St.isCurrentMonth?Fr?"#FFF":t.textPrimary:t.textTertiary,backgroundColor:Fr?"#3B82F6":"transparent",boxShadow:An&&!Fr?"inset 0 0 0 1px #3B82F6":"none"},onClick:()=>{u?.(Z.id,{[z]:St.date}),de(null);},children:St.day},Mn)})})()})]})]})]}),document.body)]});case "duration":return jsx("div",{className:"flex items-center justify-center w-full",children:jsx("span",{className:"text-xs tabular-nums",style:{color:t.textSecondary,fontFamily:"Inter, sans-serif",fontWeight:600},children:Q(Z)})});case "assignees":let aa=r.filter(pe=>Z.assignees?.some(Nt=>Nt.name===pe.name||Nt.initials===pe.initials));return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(fr,{assignedUsers:aa,availableUsers:r,onChange:pe=>{let Nt=pe.map(Jt=>({id:Jt.id,name:Jt.name,initials:Jt.initials,color:Jt.color}));u?.(Z.id,{assignees:Nt.length>0?Nt:void 0});}})});case "status":return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(gl,{status:Z.status||"todo",onChange:pe=>{u?.(Z.id,{status:pe,progress:pe==="completed"?100:Z.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:`${Z.progress}%`,backgroundColor:Z.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:[Z.progress,"%"]})]});case "priority":let dr={low:"LOW",medium:"MEDIUM",high:"HIGH",urgent:"URGENT"},qa={LOW:"low",MEDIUM:"medium",HIGH:"high",URGENT:"urgent"},Ra=dr[Z.priority||"medium"]||"MEDIUM";return jsx("div",{className:"flex items-center justify-center w-full",onClick:pe=>pe.stopPropagation(),children:jsx(ur,{priority:Ra,onChange:pe=>{pe&&u?.(Z.id,{priority:qa[pe]||"medium"});}})});default:return null}},Fe=V=>[{id:"hide",label:"Hide Column",icon:Ct.Hide,onClick:()=>d(V),disabled:V==="name"},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"sortAsc",label:"Sort Ascending",icon:Ct.SortAsc,onClick:()=>{}},{id:"sortDesc",label:"Sort Descending",icon:Ct.SortDesc,onClick:()=>{}}],Me=V=>V.subtasks&&V.subtasks.length>0?[{id:"addSubtask",label:B?.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{D?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"delete",label:B?.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{A?A(V.id,V.name):k?.([V.id]);}}]:[{id:"edit",label:B?.contextMenu?.editTask||"Edit Task",icon:Ct.Pencil,onClick:()=>{l?.(V);}},{id:"addSubtask",label:B?.contextMenu?.addSubtask||"Add Subtask",icon:Ct.Add,onClick:()=>{D?.(V.id);}},{id:"sep1",label:"",onClick:()=>{},separator:true},{id:"markIncomplete",label:B?.contextMenu?.markIncomplete||"Mark Incomplete",icon:Ct.MarkIncomplete,onClick:()=>{u?.(V.id,{status:"todo",progress:0});},disabled:V.status==="todo"},{id:"setInProgress",label:B?.contextMenu?.setInProgress||"Set In Progress",icon:Ct.SetInProgress,onClick:()=>{u?.(V.id,{status:"in-progress"});},disabled:V.status==="in-progress"},{id:"markComplete",label:B?.contextMenu?.markComplete||"Mark Complete",icon:Ct.MarkComplete,onClick:()=>{u?.(V.id,{status:"completed",progress:100});},disabled:V.status==="completed"},{id:"sep2",label:"",onClick:()=>{},separator:true},{id:"split",label:B?.contextMenu?.splitTask||"Split Task",icon:Ct.Split,onClick:()=>{},disabled:true},{id:"sep3",label:"",onClick:()=>{},separator:true},{id:"delete",label:B?.contextMenu?.deleteTask||"Delete Task",icon:Ct.Delete,onClick:()=>{A?A(V.id,V.name):k?.([V.id]);}}],Re=m.filter(V=>V.visible),Mt=Re.reduce((V,Z)=>V+Z.width,0)+60;return jsxs("div",{className:"h-full",style:{backgroundColor:t.bgPrimary,minWidth:Mt},children:[jsxs("div",{className:"sticky top-0 z-10 flex items-center",style:{backgroundColor:t.bgGrid,height:`${yt}px`,paddingLeft:"3px",paddingRight:"60px",borderBottom:`1px solid ${t.border}`,boxSizing:"border-box",position:"relative"},children:[jsxs("div",{className:"flex items-center gap-1 px-2 flex-shrink-0",style:{height:"100%",position:"absolute",right:8,top:0,zIndex:5,backgroundColor:t.bgGrid},children:[jsx(qo,{columns:m,onToggleColumn:d,theme:t}),jsx("button",{onClick:()=>Ee(!Ce),className:"p-1.5 rounded hover:bg-opacity-10 transition-colors",style:{color:t.textTertiary},title:"Keyboard shortcuts",children:jsx(Keyboard,{className:"w-4 h-4"})}),Ce&&jsxs("div",{ref:at,className:"absolute top-full right-0 mt-2 p-4 rounded-lg shadow-2xl z-50 min-w-[400px]",style:{backgroundColor:t.bgPrimary,border:`1px solid ${t.border}`,color:t.textPrimary},onClick:V=>V.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:()=>Ee(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"})]})]})]})]})]})]}),Re.map((V,Z)=>{let nt=Z===Re.length-1,fe=V.id==="name";return jsxs("div",{className:`flex items-center px-4 cursor-pointer hover:bg-opacity-50 transition-colors relative ${fe?"":"justify-center"}`,style:{width:`${V.width}px`,minWidth:`${V.minWidth??(fe?200:60)}px`,maxWidth:`${V.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:nt?"none":`1px solid ${t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},onContextMenu:Ue=>{Ue.preventDefault(),K({isOpen:true,x:Ue.clientX,y:Ue.clientY,type:"header",columnId:V.id});},onMouseEnter:Ue=>{Ue.currentTarget.style.backgroundColor=t.hoverBg;},onMouseLeave:Ue=>{Ue.currentTarget.style.backgroundColor="transparent";},children:[jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:t.textTertiary,fontFamily:"Inter, sans-serif",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,paddingRight:"0"},title:V.label,children:V.label}),V.resizable&&jsx("div",{className:"absolute right-0 top-0 bottom-0 cursor-col-resize transition-colors group",style:{width:"8px",marginRight:"-4px",backgroundColor:xe===V.id?`${t.accent}30`:"transparent",zIndex:5},onMouseDown:Ue=>{Ue.preventDefault(),Ue.stopPropagation(),Ae(V.id),$(Ue.clientX),W(V.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"}})})]},V.id)})]}),jsx("div",{className:"gantt-taskgrid-content",children:We.map(({task:V,level:Z},nt)=>{let fe=I(V.id),Ue=De===V.id,Je=Ue&&$e==="above",z=Ue&&$e==="below",ne=Ue&&$e==="child",Ge={};return ne&&(Ge.backgroundColor=`${t.accent}15`,Ge.boxShadow=`inset 0 0 0 2px ${t.accent}`),jsxs(motion.div,{"data-task-row":V.id,className:`flex items-center cursor-pointer group ${X===V.id?"opacity-50":""}`,style:{position:"relative",height:`${a}px`,borderLeft:fe?`3px solid ${t.accent}`:"3px solid transparent",backgroundColor:fe?t.accentLight:ne?`${t.accent}15`:nt%2===0?t.bgPrimary:t.bgGrid,...Ge},onMouseEnter:()=>w(V.id),onMouseLeave:()=>w(null),onClick:Ke=>{let dr=Yr(e).map(pe=>pe.id),Ra=navigator.platform.toUpperCase().indexOf("MAC")>=0?Ke.metaKey:Ke.ctrlKey;Ie(V.id,dr,Ra,Ke.shiftKey),s?.(V);},onDoubleClick:Ke=>{Ke.stopPropagation(),l?.(V);},onContextMenu:Ke=>{Ke.preventDefault(),K({isOpen:true,x:Ke.clientX,y:Ke.clientY,type:"task",task:V}),c?.(V,Ke);},whileHover:{backgroundColor:fe?t.accentLight:t.hoverBg},children:[Je&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),z&&jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"2px",backgroundColor:t.accent,zIndex:10}}),Re.map((Ke,aa)=>{let dr=aa===Re.length-1,qa=Ke.id==="name";return jsx("div",{className:`px-4 flex items-center ${qa?"justify-start":"justify-center"}`,style:{width:`${Ke.width}px`,minWidth:`${Ke.minWidth??(qa?200:60)}px`,maxWidth:`${Ke.maxWidth??2e3}px`,flexShrink:0,flexGrow:0,borderRight:dr?"none":`1px solid ${T===V.id?t.border:t.borderLight}`,height:"100%",boxSizing:"border-box",overflow:"hidden"},children:ie(Ke,V,qa?Z:0)},`${V.id}-${Ke.id}`)})]},V.id)})}),jsx(Kr,{isOpen:E.isOpen,x:E.x,y:E.y,items:E.type==="header"&&E.columnId?Fe(E.columnId):E.type==="task"&&E.task?Me(E.task):[],onClose:()=>K({...E,isOpen:false}),theme:t}),dt&&ht&&X&&typeof document<"u"&&createPortal(jsx("div",{style:{position:"fixed",left:ht.x+12,top:ht.y-10,zIndex:99999,pointerEvents:"none"},children:(()=>{let V=We.find(Z=>Z.task.id===X)?.task;return V?jsx("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{backgroundColor:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(4px)"},children:jsx("span",{className:"text-xs font-medium",style:{color:t.textSecondary,opacity:.9},children:V.name})}):null})()}),document.body)]})}function Cd(e,t){let[a,r]=useState("none"),[o,s]=useState(0),[l,c]=useState(e),[p,n]=useState(t),[m,d]=useState(null),[i,u]=useState(null),[x,f]=useState(null),[g,k]=useState(null),[h,b]=useState(0),[y,D]=useState(0),[N,A]=useState(null),[v,B]=useState(false);return {dragMode:a,setDragMode:r,dragOffset:o,setDragOffset:s,ghostX:l,setGhostX:c,ghostWidth:p,setGhostWidth:n,connectionLine:m,setConnectionLine:d,hoveredTaskId:i,setHoveredTaskId:u,activeZone:x,setActiveZone:f,draggedSegmentIndex:g,setDraggedSegmentIndex:k,draggedSegmentStartX:h,setDraggedSegmentStartX:b,segmentDragOffsetX:y,setSegmentDragOffsetX:D,hoveredSegmentIndex:N,setHoveredSegmentIndex:A,isHovered:v,setIsHovered:B,isDragging:a!=="none",isResizing:a==="resize-start"||a==="resize-end",isConnecting:a==="connect",resetDragState:(H,q)=>{r("none"),d(null),u(null),c(H),n(q),D(0),k(null),b(0);}}}function Qo({task:e,x:t,y:a,width:r,theme:o,dayWidth:s,startDate:l,templates:c,onClick:p,onDoubleClick:n,onContextMenu:m,onDateChange:d,onDependencyCreate:i,allTaskPositions:u=[],onDragMove:x,onHoverChange:f}){let g=Cd(t,r),k=useRef(null),{dragMode:h,setDragMode:b,dragOffset:y,setDragOffset:D,ghostX:N,setGhostX:A,ghostWidth:v,setGhostWidth:B,connectionLine:T,setConnectionLine:w,hoveredTaskId:R,setHoveredTaskId:P,activeZone:H,setActiveZone:q,draggedSegmentIndex:he,setDraggedSegmentIndex:xe,draggedSegmentStartX:Ae,setDraggedSegmentStartX:Be,segmentDragOffsetX:$,setSegmentDragOffsetX:F,hoveredSegmentIndex:W,setHoveredSegmentIndex:E,isHovered:K,setIsHovered:X,isDragging:U,isResizing:De,isConnecting:ke,resetDragState:$e}=g,be=32,tt=8,Pe=e.endDate&&e.endDate<new Date&&e.progress<100,et=e.isCriticalPath,ht=o.name==="neutral"||o.today==="#1C1917",Dt=e.status==="completed"||e.progress===100,dt={low:"#2ECC71",LOW:"#2ECC71",medium:"#F1C40F",MEDIUM:"#F1C40F",high:"#E67E22",HIGH:"#E67E22",urgent:"#E74C3C",URGENT:"#E74C3C"},re=e.isCriticalPath||Pe?"#DC2626":e.color?e.color:e.priority&&dt[e.priority]?dt[e.priority]:o.taskBarPrimary,Ce=(oe=>oe>=80?20:oe>=60?15:oe>=50?12:10)(r),Ee=r<50,at=r<40;useEffect(()=>{if(f)if(K&&!U&&!e.segments){let oe=a<100;f({task:e,x:t,y:a,width:r,height:be,showBelow:oe});}else f(null);},[K,U,e,t,a,r,be,f]);let ut=oe=>oe.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Ie=()=>{let oe=Math.ceil((e.endDate.getTime()-e.startDate.getTime())/864e5);return `${oe} day${oe!==1?"s":""}`},I=oe=>Math.round(oe/s)*s,Y=oe=>{let Se=Math.round(oe/s),ye=new Date(l);return ye.setDate(ye.getDate()+Se),ye},He=(oe,Se)=>{for(let ye of u){if(ye.id===e.id)continue;let Ne=5;if(oe>=ye.x-Ne&&oe<=ye.x+ye.width+Ne&&Se>=ye.y-Ne&&Se<=ye.y+ye.height+Ne)return ye.id}return null},We=useCallback((oe,Se,ye)=>{oe.preventDefault(),oe.stopPropagation();let Ne=k.current?.ownerSVGElement;if(!Ne)return;let ie=Ne.createSVGPoint();ie.x=oe.clientX,ie.y=oe.clientY;let Fe=ie.matrixTransform(Ne.getScreenCTM()?.inverse()),Me=ye!==void 0?ye:t,Re=Se;if(!Re){let Mt=Fe.x-Me;oe.shiftKey?(Re="connect",w({x:t+r,y:a+be/2})):oe.ctrlKey||oe.metaKey?Re="move":oe.altKey?Re=Mt<r/2?"resize-start":"resize-end":at?Mt<r/2?Re="move":Re="resize-end":Ee?Mt<=Ce/2?Re="resize-start":Mt>=r-Ce/2?Re="resize-end":Re="move":Mt<=Ce?Re="resize-start":Mt>=r-Ce?Re="resize-end":Re="move";}b(Re),X(false),q(null),Re==="move"?D(Fe.x-Me):Re==="connect"?w({x:t+r,y:a+be/2}):D(0),A(Me),B(r);},[t,r,a,be]),yt=useCallback(oe=>{if(h==="none")return;let Se=k.current?.ownerSVGElement;if(!Se)return;let ye=Se.createSVGPoint();ye.x=oe.clientX,ye.y=oe.clientY;let Ne=ye.matrixTransform(Se.getScreenCTM()?.inverse());if(h==="connect"){w({x:Ne.x,y:Ne.y});let ie=He(Ne.x,Ne.y);P(ie);}else if(h==="move"){let ie=Ne.x-y,Fe=I(ie);A(Fe),B(r);let Me=Math.round((Fe-t)/s);if(x?.(e.id,Me,true),e.segments&&e.segments.length>0&&he!==null){let Re=Fe-Ae;F(Re);}}else if(h==="resize-start"){let ie=Ne.x,Fe=I(ie),Me=t+r-Fe;Me>=s&&(A(Fe),B(Me));}else if(h==="resize-end"){let ie=Ne.x,Me=I(ie)-t;Me>=s&&B(Me);}},[h,t,r,s,y,e,I,he,Ae,He,P,w,A,B,F,x]),Q=useCallback(()=>{if(h!=="none"){if(h==="connect")R&&i&&i(e,R),w(null),P(null);else {let oe=e.endDate.getTime()-e.startDate.getTime(),Se,ye,Ne=true;if(h==="move"){if(Se=Y(N),ye=new Date(Se.getTime()+oe),e.segments&&e.segments.length>0&&he!==null){let ie=Math.round($/s),Fe=e.segments.map((V,Z)=>{if(Z===he){let nt=new Date(V.startDate),fe=new Date(V.endDate);return nt.setDate(nt.getDate()+ie),fe.setDate(fe.getDate()+ie),{startDate:nt,endDate:fe}}return V}),Me=Fe.flatMap(V=>[V.startDate,V.endDate]),Re=new Date(Math.min(...Me.map(V=>V.getTime()))),Mt=new Date(Math.max(...Me.map(V=>V.getTime())));d?.({...e,segments:Fe},Re,Mt),$e(t,r);return}}else h==="resize-start"?(Se=Y(N),ye=e.endDate,Se>ye&&(console.warn("Invalid date range: start date must be before or equal to end date"),Ne=false)):h==="resize-end"?(Se=e.startDate,ye=Y(N+v),ye<Se&&(console.warn("Invalid date range: end date must be after or equal to start date"),Ne=false)):Ne=false;Ne&&Se&&ye&&(ye.getTime()<Se.getTime()?console.warn("Invalid date range: end date cannot be before start date"):d?.(e,Se,ye));}x?.(e.id,0,false),$e(t,r);}},[h,N,v,e,d,R,i,t,r,s,Y,$,he,$e,x]);useEffect(()=>{if(h==="none")return;let oe=ye=>{yt(ye);},Se=()=>{Q();};return window.addEventListener("mousemove",oe),window.addEventListener("mouseup",Se),()=>{window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",Se);}},[h,yt,Q]);let te=U&&!ke?N:t,ve=U&&!ke?v:r,Te=c.taskClass(e);return jsxs("g",{ref:k,onMouseEnter:()=>!U&&X(true),onMouseLeave:()=>{U||(X(false),q(null));},onClick:()=>!U&&p?.(e),onDoubleClick:oe=>{U||(oe.stopPropagation(),n?.(e));},onContextMenu:oe=>{oe.preventDefault(),m?.(e,oe);},children:[K&&!U&&!Ee&&!e.segments&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:Ce,height:be,fill:H==="resize-start"?o.accent:"transparent",opacity:H==="resize-start"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-start"),onMouseDown:oe=>We(oe,"resize-start")}),jsx("rect",{x:t+Ce,y:a,width:r-Ce*2,height:be,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.1:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:oe=>We(oe,"move")}),jsx("rect",{x:t+r-Ce,y:a,width:Ce,height:be,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.15:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:oe=>We(oe,"resize-end")})]}),K&&!U&&at&&jsxs(Fragment,{children:[jsx("rect",{x:t,y:a,width:r/2,height:be,fill:H==="move"?o.accent:"transparent",opacity:H==="move"?.2:0,style:{cursor:"grab",pointerEvents:"all"},onMouseEnter:()=>q("move"),onMouseDown:oe=>We(oe,"move")}),jsx("rect",{x:t+r/2,y:a,width:r/2,height:be,fill:H==="resize-end"?o.accent:"transparent",opacity:H==="resize-end"?.2:0,style:{cursor:"ew-resize",pointerEvents:"all"},onMouseEnter:()=>q("resize-end"),onMouseDown:oe=>We(oe,"resize-end")}),K&&jsx(motion.line,{x1:t+r/2,y1:a+4,x2:t+r/2,y2:a+be-4,stroke:o.textTertiary,strokeWidth:1,strokeDasharray:"2 2",opacity:.3,initial:{opacity:0},animate:{opacity:.3},transition:{duration:.2},style:{pointerEvents:"none"}})]}),U&&!ke&&!e.segments&&jsx(motion.rect,{x:N,y:a,width:v,height:be,rx:tt,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:te,y:a,width:ve,height:be,rx:tt,fill:re,"data-task-class":Te,initial:{opacity:0,scale:.95},animate:{opacity:U&&!ke?.15:e.parentId?.6:K?.9:.8,scale:K&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:oe=>We(oe),style:{cursor:U?ke?"crosshair":De?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),!e.segments&&jsx("rect",{x:te,y:a,width:ve*(e.progress/100),height:be,rx:tt,fill:re,opacity:1,style:{pointerEvents:"none"}}),e.segments&&e.segments.map((oe,Se)=>{let ye=(oe.startDate.getTime()-l.getTime())/864e5*s,ie=(oe.endDate.getTime()-l.getTime())/(1e3*60*60*24)*s-ye+s,Fe=U&&h==="move"&&he===Se,Me=W===Se,Re=Fe?ye+$:ye;return jsxs("g",{onMouseEnter:()=>!U&&E(Se),onMouseLeave:()=>!U&&E(null),children:[jsx(motion.rect,{x:Re,y:a,width:ie,height:be,rx:tt,fill:re,initial:{opacity:0,scale:.95},animate:{opacity:Fe||e.parentId?.6:Me?.9:.8,scale:Me&&!U?1.02:1},transition:{duration:.2,ease:[.4,0,.2,1]},onMouseDown:Mt=>{Mt.stopPropagation(),xe(Se),Be(ye),We(Mt,void 0,ye);},style:{cursor:U?ke?"crosshair":De?"ew-resize":"grabbing":"grab",pointerEvents:"all"}}),jsx("rect",{x:Re,y:a,width:ie*(e.progress/100),height:be,rx:tt,fill:re,opacity:1,style:{pointerEvents:"none"}})]},`segment-${Se}`)}),ht&&(Pe||et)&&!e.segments&&jsxs(Fragment,{children:[et&&!Pe&&jsx("rect",{x:te,y:a,width:ve,height:be,rx:tt,fill:"none",stroke:o.border,strokeWidth:2,strokeDasharray:"4 4",opacity:.8,style:{pointerEvents:"none"}}),Pe&&jsx("rect",{x:te,y:a,width:ve,height:be,rx:tt,fill:"url(#diagonal-stripes)",opacity:.3,style:{pointerEvents:"none"}})]}),ve>60&&!e.segments&&(()=>{let oe=c.taskLabel(e),Se=typeof oe=="string"?oe:e.name,ye=Se.length>Math.floor(ve/8)?`${Se.substring(0,Math.floor(ve/8))}...`:Se;return jsx("text",{x:te+12,y:a+be/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:ye})})(),ve>100&&e.progress>0&&e.progress<100&&!U&&!e.segments&&jsxs("text",{x:te+ve-12,y:a+be/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&&!U&&!e.segments&&jsxs("g",{style:{pointerEvents:"none"},children:[e.status==="completed"&&jsx("circle",{cx:te+ve-8,cy:a+8,r:4,fill:o.statusCompleted,stroke:"#FFFFFF",strokeWidth:1.5}),e.status==="in-progress"&&jsx("circle",{cx:te+ve-8,cy:a+8,r:4,fill:o.statusInProgress,stroke:"#FFFFFF",strokeWidth:1.5,opacity:.8})]}),(K||De)&&!ke&&!e.segments&&jsxs(Fragment,{children:[jsxs("g",{style:{pointerEvents:"all"},children:[jsx("rect",{x:Ee?te-15:te-10,y:a-5,width:Ee?25:20,height:be+10,fill:"transparent",onMouseDown:oe=>We(oe,"resize-start"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te-8:te-3,y:a+6,width:Ee?8:6,height:Ee?be-12:be-16,rx:3,fill:h==="resize-start"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="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:te+ve-10,y:a-5,width:Ee?25:20,height:be+10,fill:"transparent",onMouseDown:oe=>We(oe,"resize-end"),style:{cursor:"ew-resize"}}),jsx(motion.rect,{x:Ee?te+ve:te+ve-3,y:a+6,width:Ee?8:6,height:Ee?be-12:be-16,rx:3,fill:h==="resize-end"?o.accent:o.taskBarHandle,stroke:o.taskBarPrimary,strokeWidth:1.5,initial:{opacity:0,scale:0},animate:{opacity:1,scale:h==="resize-end"?1.2:1},transition:{duration:.2,type:"spring",stiffness:400,damping:25},style:{pointerEvents:"none"}})]})]}),jsx(AnimatePresence,{children:K&&!U&&!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+be/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:oe=>{oe.stopPropagation(),We(oe,"connect");},style:{cursor:"crosshair"}}),jsx("text",{x:t+r+20,y:a+be/2,dominantBaseline:"middle",fill:o.textTertiary,fontSize:"10",fontFamily:"Inter, sans-serif",style:{pointerEvents:"none",userSelect:"none"},children:"Link"})]})}),ke&&T&&jsxs("g",{style:{pointerEvents:"none"},children:[jsx(motion.line,{x1:t+r,y1:a+be/2,x2:T.x,y2:T.y,stroke:R?o.statusCompleted:o.accent,strokeWidth:R?3:2,strokeDasharray:"6 4",initial:{opacity:0},animate:{opacity:R?1:.8},transition:{duration:.15}}),jsx(motion.circle,{cx:T.x,cy:T.y,r:R?8:6,fill:R?o.statusCompleted:o.accent,stroke:"#FFFFFF",strokeWidth:2,initial:{scale:0},animate:{scale:1},transition:{duration:.15}}),R&&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"})]}),(K||U)&&!ke&&!e.segments&&jsx(motion.rect,{x:te-2,y:a-2,width:ve+4,height:be+4,rx:tt+2,fill:"none",stroke:U?o.accent:o.taskBarPrimary,strokeWidth:2,opacity:U?.6:.4,initial:{opacity:0},animate:{opacity:U?.6:.4},transition:{duration:.2},style:{pointerEvents:"none"}}),De&&jsxs(Fragment,{children:[jsx("line",{x1:N,y1:0,x2:N,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}}),jsx("line",{x1:N+v,y1:0,x2:N+v,y2:1e3,stroke:o.accent,strokeWidth:1,strokeDasharray:"4 4",opacity:.3,style:{pointerEvents:"none"}})]}),jsx(AnimatePresence,{children:K&&!U&&!e.segments&&!f&&(()=>{let ye=a<100,Ne=ye?a+be+13:a-82-13,ie=ye?`M ${te+ve/2-6} ${a+be+3} L ${te+ve/2} ${a+be+13} L ${te+ve/2+6} ${a+be+3}`:`M ${te+ve/2-6} ${a-13} L ${te+ve/2} ${a-3} L ${te+ve/2+6} ${a-13}`,Fe=Ne+22,Me=Ne+40,Re=Ne+55,Mt=Ne+70,V=ye?Ne+82-5:a-18;return jsxs(motion.g,{initial:{opacity:0,y:ye?-10:10},animate:{opacity:1,y:0},exit:{opacity:0,y:ye?-10:10},transition:{duration:.2},style:{pointerEvents:"none"},children:[jsx("path",{d:ie,fill:o.bgSecondary,stroke:o.border,strokeWidth:1}),jsx("rect",{x:te+ve/2-120,y:Ne,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:te+ve/2,y:Fe,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:te+ve/2-110,y:Me,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Start:"}),jsx("text",{x:te+ve/2-70,y:Me,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ut(e.startDate)}),jsx("text",{x:te+ve/2-110,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:te+ve/2-70,y:Re,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:ut(e.endDate)}),jsx("text",{x:te+ve/2+10,y:Me,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Duration:"}),jsx("text",{x:te+ve/2+65,y:Me,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:Ie()}),jsx("text",{x:te+ve/2+10,y:Re,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:te+ve/2+65,y:Re,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:te+ve/2-110,y:Mt,fill:o.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Assignees:"}),jsxs("text",{x:te+ve/2-50,y:Mt,fill:o.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:[e.assignees.map(Z=>Z.name).join(", ").substring(0,30),e.assignees.map(Z=>Z.name).join(", ").length>30?"...":""]})]}),!ye&&jsx("text",{x:te+ve/2,y:V,textAnchor:"middle",fill:o.textTertiary,fontSize:"9",fontFamily:"Inter, sans-serif",style:{opacity:.7},children:at?"Left: move \u2022 Right: resize":Ee?"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 Nd({tooltipData:e,theme:t}){if(!e)return null;let {task:a,x:r,y:o,width:s,height:l,showBelow:c}=e,p=82,n=13,m=c?o+l+n:o-p-n,d=c?`M ${r+s/2-6} ${o+l+3} L ${r+s/2} ${o+l+13} L ${r+s/2+6} ${o+l+3}`:`M ${r+s/2-6} ${o-13} L ${r+s/2} ${o-3} L ${r+s/2+6} ${o-13}`,i=m+22,u=m+40,x=m+55,f=m+70,g=y=>y.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),k=()=>{if(!a.startDate||!a.endDate)return "N/A";let y=Math.ceil((a.endDate.getTime()-a.startDate.getTime())/(1e3*60*60*24));return `${y} day${y!==1?"s":""}`};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,fill:t.bgSecondary,stroke:t.border,strokeWidth:1}),jsx("rect",{x:r+s/2-120,y:m,width:240,height:p,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?g(a.startDate):"N/A"}),jsx("text",{x:r+s/2-110,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"End:"}),jsx("text",{x:r+s/2-70,y:x,fill:t.textSecondary,fontSize:"11",fontWeight:"500",fontFamily:"Inter, sans-serif",children:a.endDate?g(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:k()}),jsx("text",{x:r+s/2+10,y:x,fill:t.textTertiary,fontSize:"11",fontFamily:"Inter, sans-serif",children:"Progress:"}),jsxs("text",{x:r+s/2+65,y:x,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(y=>y.name).join(", ").substring(0,30),a.assignees.map(y=>y.name).join(", ").length>30?"...":""]})]})]})})}function an({x1:e,y1:t,x2:a,y2:r,theme:o,onDelete:s,onHoverChange:l}){let[c,p]=useState(false),n=a-e,m=r-t,d=e+n/2,i=`M ${e} ${t} C ${d} ${t}, ${d} ${r}, ${a} ${r}`,u=6,x=Math.atan2(m,n),f=a-u*Math.cos(x-Math.PI/6),g=r-u*Math.sin(x-Math.PI/6),k=a-u*Math.cos(x+Math.PI/6),h=r-u*Math.sin(x+Math.PI/6),b=o.dependency;useEffect(()=>{l&&s&&l(c?{x1:e,y1:t,x2:a,y2:r,onDelete:s}:null);},[c,e,t,a,r,s,l]);let y=!s&&!l;return jsxs("g",{onMouseEnter:()=>!y&&p(true),onMouseLeave:()=>!y&&p(false),style:{pointerEvents:y?"none":"auto"},children:[!y&&jsx("path",{d:i,fill:"none",stroke:"transparent",strokeWidth:20,strokeLinecap:"round",style:{cursor:"pointer"}}),jsx(motion.path,{d:i,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{pathLength:0,opacity:0},animate:{pathLength:1,opacity:c&&l?0:c?1:.8,strokeWidth:c?2.5:2},transition:{pathLength:{duration:.5,ease:"easeInOut"},opacity:{duration:.2},strokeWidth:{duration:.2}}}),jsx(motion.path,{d:`M ${a} ${r} L ${f} ${g} M ${a} ${r} L ${k} ${h}`,fill:"none",stroke:b,strokeWidth:2,strokeLinecap:"round",initial:{opacity:0,scale:.8},animate:{opacity:c&&l?0:c?1:.8,scale:c?1.1:1,strokeWidth:c?2.5:2},transition:{duration:.2}}),jsx(motion.circle,{cx:a,cy:r,r:3,fill:b,initial:{scale:0},animate:{scale:c&&l?0:c?1.3:1,opacity:c&&l?0:c?1:.8},transition:{scale:{delay:.3,duration:.15},opacity:{duration:.2}}}),c&&s&&!l&&jsxs(motion.g,{initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.2},onClick:D=>{D.stopPropagation(),s();},style:{cursor:"pointer"},children:[jsx("circle",{cx:d,cy:(t+r)/2,r:10,fill:o.bgSecondary,stroke:o.error||"#ef4444",strokeWidth:2}),jsx("line",{x1:d-4,y1:(t+r)/2-4,x2:d+4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"}),jsx("line",{x1:d+4,y1:(t+r)/2-4,x2:d-4,y2:(t+r)/2+4,stroke:o.error||"#ef4444",strokeWidth:2,strokeLinecap:"round"})]})]})}function on({task:e,x:t,y:a,theme:r,onClick:o}){let[s,l]=useState(false),c=16,p=n=>n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return jsxs("g",{onMouseEnter:()=>l(true),onMouseLeave:()=>l(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:p(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 le={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(m=>{m.dependencies&&r.set(m.id,m.dependencies),m.subtasks&&o(m.subtasks);});};o(e);let s=r.get(a)||[];r.set(a,[...s,t]);let l=new Set,c=new Set,p=n=>{if(!l.has(n)){l.add(n),c.add(n);let m=r.get(n)||[];for(let d of m){if(!l.has(d)&&p(d))return true;if(c.has(d))return true}}return c.delete(n),false};return p(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=le.findTaskById(a.subtasks,t);if(r)return r}}},getParentTasks:(e,t)=>{let a=[],r=le.findTaskById(e,t);if(!r||!r.parentId)return a;let o=r.parentId;for(;o;){let s=le.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=le.flattenTasks(e),r=[["ID","Name","Start Date","End Date","Progress","Status","Dependencies"].join(",")];return t.forEach(o=>{let s=[o.id,`"${o.name.replace(/"/g,'""')}"`,o.startDate?o.startDate.toISOString().split("T")[0]:"",o.endDate?o.endDate.toISOString().split("T")[0]:"",o.progress.toString(),o.status||"",o.dependencies?.join(";")||""];r.push(s.join(","));}),r.join(`
112
112
  `)},formatDate:e=>{let t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return `${t}-${a}-${r}`},parseDate:e=>new Date(e),getTaskDateRange:e=>!e.startDate||!e.endDate?null:{start:e.startDate,end:e.endDate},getEarliestStartDate:e=>{let a=le.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=le.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)=>le.flattenTasks(e).filter(r=>r.dependencies&&r.dependencies.includes(t)),getDependencyTasks:(e,t)=>{let a=le.findTaskById(e,t);return !a||!a.dependencies?[]:le.flattenTasks(e).filter(o=>a.dependencies.includes(o.id))},filterByStatus:(e,t)=>le.flattenTasks(e).filter(a=>a.status===t),filterByDateRange:(e,t,a)=>le.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=le.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=>le.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=le.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 l=[["Task Name","Start Date","End Date","Duration","Progress","Status"]],c=s.map(p=>{let n=p.startDate&&p.endDate?le.calculateDuration(p.startDate,p.endDate):0;return [p.name,p.startDate?le.formatDate(p.startDate):"N/A",p.endDate?le.formatDate(p.endDate):"N/A",n>0?`${n} days`:"N/A",`${p.progress}%`,p.status||"N/A"]});r(o,{head:l,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=le.flattenTasks(e).map(p=>{let n=p.startDate&&p.endDate?le.calculateDuration(p.startDate,p.endDate):0;return {"Task ID":p.id,"Task Name":p.name,"Start Date":p.startDate?le.formatDate(p.startDate):"","End Date":p.endDate?le.formatDate(p.endDate):"","Duration (days)":n>0?n:"","Progress (%)":p.progress,Status:p.status||"",Assignees:p.assignees?.map(m=>m.name).join(", ")||"",Dependencies:p.dependencies?.join(", ")||"","Is Milestone":p.isMilestone?"Yes":"No","Parent ID":p.parentId||"",Level:p.level||0}}),s=a.utils.json_to_sheet(o),l=[{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"]=l;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=le.flattenTasks(e),o=new Map;r.forEach((i,u)=>{o.set(i.id,u+1);});let s=i=>i.toISOString().replace("Z",""),l=le.getEarliestStartDate(e)||new Date,c=le.getLatestEndDate(e)||new Date,p=r.map((i,u)=>{let x=o.get(i.id),f=i.startDate&&i.endDate?le.calculateDuration(i.startDate,i.endDate):0,g=(i.dependencies||[]).filter(k=>o.has(k)).map(k=>`
113
113
  <PredecessorLink>
114
114
  <PredecessorUID>${o.get(k)}</PredecessorUID>